amd-debug-tools 0.2.13__tar.gz → 0.2.15__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. {amd_debug_tools-0.2.13/src/amd_debug_tools.egg-info → amd_debug_tools-0.2.15}/PKG-INFO +1 -1
  2. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/common.py +13 -1
  3. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/kernel.py +22 -0
  4. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/prerequisites.py +22 -0
  5. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/s2idle.py +12 -6
  6. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/wake.py +25 -7
  7. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15/src/amd_debug_tools.egg-info}/PKG-INFO +1 -1
  8. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_prerequisites.py +68 -1
  9. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_s2idle.py +7 -4
  10. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/.github/workflows/ci.yml +0 -0
  11. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/.github/workflows/mirror.yml +0 -0
  12. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/.gitignore +0 -0
  13. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/.pre-commit-config.yaml +0 -0
  14. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/.vscode/settings.json +0 -0
  15. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/LICENSE +0 -0
  16. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/Makefile +0 -0
  17. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/README.md +0 -0
  18. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/amd_bios.py +0 -0
  19. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/amd_pstate.py +0 -0
  20. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/amd_s2idle.py +0 -0
  21. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/amd_ttm.py +0 -0
  22. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/docs/amd-bios.md +0 -0
  23. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/docs/amd-pstate.md +0 -0
  24. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/docs/amd-s2idle.md +0 -0
  25. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/docs/amd-ttm.md +0 -0
  26. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/docs/in-tree.md +0 -0
  27. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/install_deps.py +0 -0
  28. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/psr.py +0 -0
  29. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/pyproject.toml +0 -0
  30. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/setup.cfg +0 -0
  31. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/__init__.py +0 -0
  32. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/acpi.py +0 -0
  33. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/bash/amd-s2idle +0 -0
  34. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/battery.py +0 -0
  35. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/bios.py +0 -0
  36. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/database.py +0 -0
  37. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/display.py +0 -0
  38. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/failures.py +0 -0
  39. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/installer.py +0 -0
  40. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/pstate.py +0 -0
  41. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/s2idle-hook +0 -0
  42. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/sleep_report.py +0 -0
  43. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/templates/html +0 -0
  44. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/templates/md +0 -0
  45. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/templates/stdout +0 -0
  46. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/templates/txt +0 -0
  47. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/ttm.py +0 -0
  48. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug/validator.py +0 -0
  49. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug_tools.egg-info/SOURCES.txt +0 -0
  50. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug_tools.egg-info/dependency_links.txt +0 -0
  51. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug_tools.egg-info/entry_points.txt +0 -0
  52. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug_tools.egg-info/requires.txt +0 -0
  53. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/amd_debug_tools.egg-info/top_level.txt +0 -0
  54. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/launcher.py +0 -0
  55. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_acpi.py +0 -0
  56. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_batteries.py +0 -0
  57. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_bios.py +0 -0
  58. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_common.py +0 -0
  59. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_database.py +0 -0
  60. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_display.py +0 -0
  61. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_failures.py +0 -0
  62. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_installer.py +0 -0
  63. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_kernel.py +0 -0
  64. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_launcher.py +0 -0
  65. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_pstate.py +0 -0
  66. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_sleep_report.py +0 -0
  67. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_ttm.py +0 -0
  68. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_validator.py +0 -0
  69. {amd_debug_tools-0.2.13 → amd_debug_tools-0.2.15}/src/test_wake.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amd-debug-tools
3
- Version: 0.2.13
3
+ Version: 0.2.15
4
4
  Summary: debug tools for AMD systems
5
5
  Author-email: Mario Limonciello <superm1@kernel.org>
6
6
  License-Expression: MIT
@@ -382,7 +382,19 @@ def relaunch_sudo() -> None:
382
382
  """Relaunch the script with sudo if not already running as root"""
383
383
  if not is_root():
384
384
  logging.debug("Relaunching with sudo")
385
- os.execvp("sudo", ["sudo", "-E"] + sys.argv)
385
+ env_vars = []
386
+ for var in ["DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "XDG_RUNTIME_DIR",
387
+ "DBUS_SESSION_BUS_ADDRESS", "XDG_SESSION_TYPE"]:
388
+ value = os.environ.get(var)
389
+ if value:
390
+ env_vars.append(f"{var}={value}")
391
+
392
+ if env_vars:
393
+ sudo_cmd = ["sudo"] + [f"--preserve-env={var.split('=')[0]}" for var in env_vars] + sys.argv
394
+ else:
395
+ sudo_cmd = ["sudo"] + sys.argv
396
+
397
+ os.execvp("sudo", sudo_cmd)
386
398
 
387
399
 
388
400
  def running_ssh():
@@ -168,6 +168,10 @@ class KernelLogger:
168
168
  """Find lines that match a pattern"""
169
169
  return ""
170
170
 
171
+ def get_full_log(self) -> str:
172
+ """Get the full log as a string"""
173
+ return ""
174
+
171
175
 
172
176
  class InputFile(KernelLogger):
173
177
  """Class for input file parsing"""
@@ -183,6 +187,10 @@ class InputFile(KernelLogger):
183
187
  for entry in self.buffer.split("\n"):
184
188
  callback(entry, priority)
185
189
 
190
+ def get_full_log(self):
191
+ """Get the full log as a string"""
192
+ return self.buffer
193
+
186
194
 
187
195
  class DmesgLogger(KernelLogger):
188
196
  """Class for dmesg logging"""
@@ -256,6 +264,10 @@ class DmesgLogger(KernelLogger):
256
264
  """Capture the header of the log"""
257
265
  return self.buffer.split("\n")[0]
258
266
 
267
+ def get_full_log(self):
268
+ """Get the full log as a string"""
269
+ return self.buffer
270
+
259
271
 
260
272
  class CySystemdLogger(KernelLogger):
261
273
  """Class for logging using systemd journal using cython"""
@@ -319,6 +331,11 @@ class CySystemdLogger(KernelLogger):
319
331
  return entry["MESSAGE"]
320
332
  return None
321
333
 
334
+ def get_full_log(self):
335
+ """Get the full log as a string"""
336
+ self.seek()
337
+ return "\n".join([entry["MESSAGE"] for entry in self.journal])
338
+
322
339
 
323
340
  class SystemdLogger(KernelLogger):
324
341
  """Class for logging using systemd journal"""
@@ -363,6 +380,11 @@ class SystemdLogger(KernelLogger):
363
380
  return entry["MESSAGE"]
364
381
  return ""
365
382
 
383
+ def get_full_log(self):
384
+ """Get the full log as a string"""
385
+ self.seek()
386
+ return "\n".join([entry["MESSAGE"] for entry in self.journal])
387
+
366
388
 
367
389
  def get_kernel_log(input_file=None) -> KernelLogger:
368
390
  """Get the kernel log provider"""
@@ -340,6 +340,26 @@ class PrerequisiteValidator(AmdTool):
340
340
  and (valid_ahci or not has_sata)
341
341
  )
342
342
 
343
+ def check_amd_xdna(self):
344
+ """Check for AMD XDNA driver"""
345
+ for device in self.pyudev.list_devices(subsystem="pci", PCI_CLASS="118000"):
346
+ slot = device.properties["PCI_SLOT_NAME"]
347
+ driver = device.properties.get("DRIVER")
348
+ pci_id = device.properties.get("PCI_ID")
349
+ if not pci_id.startswith("1022"):
350
+ continue
351
+ if not driver:
352
+ self.db.record_prereq(f"NPU device in {slot} missing driver", "🚦")
353
+ self.failures += [MissingDriver(slot)]
354
+ return False
355
+ p = os.path.join(device.sys_path, "fw_version")
356
+ if os.path.exists(p):
357
+ xdna_fw_version = read_file(p)
358
+ self.db.record_prereq(
359
+ f"NPU loaded with firmware {xdna_fw_version}", "✅"
360
+ )
361
+ return True
362
+
343
363
  def check_amd_hsmp(self):
344
364
  """Check for AMD HSMP driver"""
345
365
  # not needed to check in newer kernels
@@ -1356,6 +1376,7 @@ class PrerequisiteValidator(AmdTool):
1356
1376
  self.check_i2c_hid,
1357
1377
  self.check_pinctrl_amd,
1358
1378
  self.check_amd_hsmp,
1379
+ self.check_amd_xdna,
1359
1380
  self.check_amd_pmc,
1360
1381
  self.check_amd_cpu_hpet_wa,
1361
1382
  self.check_port_pm_override,
@@ -1397,6 +1418,7 @@ class PrerequisiteValidator(AmdTool):
1397
1418
  result = False
1398
1419
  if not result:
1399
1420
  self.db.record_prereq(Headers.BrokenPrerequisites, "🚫")
1421
+ self.db.record_debug(self.kernel_log.get_full_log())
1400
1422
  self.db.sync()
1401
1423
  clear_temporary_message(len(msg))
1402
1424
  return result
@@ -60,14 +60,20 @@ def display_report_file(fname, fmt) -> None:
60
60
  return
61
61
  user = os.environ.get("SUDO_USER")
62
62
  if user:
63
- # ensure that xdg tools will know how to display the file
64
- # (user may need to call tool with sudo -E)
65
- if os.environ.get("XDG_SESSION_TYPE"):
66
- subprocess.call(["sudo", "-E", "-u", user, "xdg-open", fname])
63
+ env_vars = []
64
+ for var in ["DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "XDG_RUNTIME_DIR",
65
+ "DBUS_SESSION_BUS_ADDRESS", "XDG_SESSION_TYPE"]:
66
+ value = os.environ.get(var)
67
+ if value:
68
+ env_vars.append(f"{var}={value}")
69
+
70
+ if env_vars:
71
+ cmd = ["sudo", "-u", user] + [f"env"] + env_vars + ["xdg-open", fname]
72
+ subprocess.call(cmd)
67
73
  else:
68
74
  print(
69
- "To display report automatically in browser launch tool "
70
- f"with '-E' argument (Example: sudo -E {sys.argv[0]})"
75
+ "Unable to detect graphical session environment. "
76
+ "Report saved to: " + fname
71
77
  )
72
78
 
73
79
 
@@ -25,16 +25,28 @@ class WakeIRQ:
25
25
  def __init__(self, num, context=Context()):
26
26
  self.num = num
27
27
  p = os.path.join("/", "sys", "kernel", "irq", str(num))
28
- self.chip_name = read_file(os.path.join(p, "chip_name"))
29
- self.actions = read_file(os.path.join(p, "actions"))
28
+ try:
29
+ self.chip_name = read_file(os.path.join(p, "chip_name"))
30
+ except (PermissionError, FileNotFoundError):
31
+ self.chip_name = ""
32
+ try:
33
+ self.actions = read_file(os.path.join(p, "actions"))
34
+ except (PermissionError, FileNotFoundError):
35
+ self.actions = ""
30
36
  self.driver = ""
31
37
  self.name = ""
32
- wakeup = read_file(os.path.join(p, "wakeup"))
38
+ try:
39
+ wakeup = read_file(os.path.join(p, "wakeup"))
40
+ except (PermissionError, FileNotFoundError):
41
+ wakeup = ""
33
42
 
34
43
  # This is an IRQ tied to _AEI
35
44
  if self.chip_name == "amd_gpio":
36
- hw_gpio = read_file(os.path.join(p, "hwirq"))
37
- self.name = f"GPIO {hw_gpio}"
45
+ try:
46
+ hw_gpio = read_file(os.path.join(p, "hwirq"))
47
+ self.name = f"GPIO {hw_gpio}"
48
+ except (PermissionError, FileNotFoundError):
49
+ self.name = "GPIO (unknown)"
38
50
  # legacy IRQs
39
51
  elif "IR-IO-APIC" in self.chip_name:
40
52
  if self.actions == "acpi":
@@ -73,10 +85,16 @@ class WakeIRQ:
73
85
  os.path.join(p, directory), followlinks=True
74
86
  ):
75
87
  if "name" in files:
76
- self.name = read_file(os.path.join(root, "name"))
88
+ try:
89
+ self.name = read_file(os.path.join(root, "name"))
90
+ except (PermissionError, FileNotFoundError):
91
+ pass
77
92
  t = os.path.join(root, "driver")
78
93
  if os.path.exists(t):
79
- self.driver = os.path.basename(os.readlink(t))
94
+ try:
95
+ self.driver = os.path.basename(os.readlink(t))
96
+ except (PermissionError, FileNotFoundError, OSError):
97
+ pass
80
98
  break
81
99
  if self.name:
82
100
  break
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amd-debug-tools
3
- Version: 0.2.13
3
+ Version: 0.2.15
4
4
  Summary: debug tools for AMD systems
5
5
  Author-email: Mario Limonciello <superm1@kernel.org>
6
6
  License-Expression: MIT
@@ -1991,11 +1991,78 @@ class TestPrerequisiteValidator(unittest.TestCase):
1991
1991
  "USB4 routers found, no need to check DMCUB version"
1992
1992
  )
1993
1993
 
1994
+ @patch("amd_debug.prerequisites.clear_temporary_message")
1995
+ def test_run_failure_records_kernel_log(self, _mock_clear):
1996
+ """Test that the whole kernel log is recorded when prerequisites fail"""
1997
+ # Mock all check and info methods to avoid system access
1998
+ check_methods = [
1999
+ "check_aspm",
2000
+ "check_i2c_hid",
2001
+ "check_pinctrl_amd",
2002
+ "check_amd_hsmp",
2003
+ "check_amd_xdna",
2004
+ "check_amd_pmc",
2005
+ "check_amd_cpu_hpet_wa",
2006
+ "check_port_pm_override",
2007
+ "check_usb3",
2008
+ "check_usb4",
2009
+ "check_sleep_mode",
2010
+ "check_storage",
2011
+ "check_wcn6855_bug",
2012
+ "check_amdgpu",
2013
+ "check_amdgpu_parameters",
2014
+ "check_cpu",
2015
+ "check_msr",
2016
+ "check_smt",
2017
+ "check_iommu",
2018
+ "check_asus_rog_ally",
2019
+ "check_dpia_pg_dmcub",
2020
+ "check_isp4",
2021
+ "check_fadt",
2022
+ "check_logger",
2023
+ "check_lps0",
2024
+ "check_permissions",
2025
+ "check_wlan",
2026
+ "check_taint",
2027
+ "capture_acpi",
2028
+ "map_acpi_path",
2029
+ "check_device_firmware",
2030
+ "check_network",
2031
+ "capture_disabled_pins",
2032
+ ]
2033
+ for method in check_methods:
2034
+ setattr(self.validator, method, MagicMock(return_value=True))
2035
+
2036
+ # Mock one check to fail
2037
+ self.validator.check_permissions.return_value = False
2038
+
2039
+ # Mock get_cpu_vendor
2040
+ self.validator.get_cpu_vendor = MagicMock(return_value="AuthenticAMD")
2041
+
2042
+ # Set a mock kernel log
2043
+ mock_log_content = "Mocked full kernel log content"
2044
+ self.mock_kernel_log.get_full_log.return_value = mock_log_content
2045
+
2046
+ # Run the validator
2047
+ with patch(
2048
+ "amd_debug.prerequisites.print_temporary_message", return_value="msg"
2049
+ ):
2050
+ result = self.validator.run()
2051
+
2052
+ self.assertFalse(result)
2053
+ # Verify Headers.BrokenPrerequisites was recorded
2054
+ from amd_debug.prerequisites import Headers
2055
+
2056
+ self.mock_db.record_prereq.assert_any_call(Headers.BrokenPrerequisites, "🚫")
2057
+ # Verify the whole kernel log was recorded to debug
2058
+ self.mock_db.record_debug.assert_called_with(mock_log_content)
2059
+
1994
2060
  @patch("amd_debug.prerequisites.find_ip_version", return_value=True)
1995
2061
  @patch("amd_debug.prerequisites.os.path.exists", return_value=True)
1996
2062
  @patch("amd_debug.prerequisites.read_file", return_value="0x90001B01")
2063
+ @patch("amd_debug.prerequisites.version.parse")
1997
2064
  def test_check_dpia_pg_dmcub_dmcub_fw_version_new_enough(
1998
- self, mock_read_file, mock_path_exists, mock_find_ip_version
2065
+ self, mock_version_parse, mock_read_file, mock_path_exists, mock_find_ip_version
1999
2066
  ):
2000
2067
  """Test check_dpia_pg_dmcub when DMCUB firmware version is new enough"""
2001
2068
  self.mock_pyudev.list_devices.side_effect = [
@@ -614,10 +614,13 @@ class TestDisplayReportFile(unittest.TestCase):
614
614
  display_report_file("report.html", "html")
615
615
  mock_is_root.assert_called_once()
616
616
  mock_env_get.assert_any_call("SUDO_USER")
617
- mock_env_get.assert_any_call("XDG_SESSION_TYPE")
618
- mock_subprocess_call.assert_called_once_with(
619
- ["sudo", "-E", "-u", "testuser", "xdg-open", "report.html"]
620
- )
617
+ call_args = mock_subprocess_call.call_args[0][0]
618
+ assert call_args[0] == "sudo"
619
+ assert call_args[1] == "-u"
620
+ assert call_args[2] == "testuser"
621
+ assert call_args[3] == "env"
622
+ assert "xdg-open" in call_args
623
+ assert "report.html" in call_args
621
624
 
622
625
  @patch("amd_debug.s2idle.is_root", return_value=True)
623
626
  @patch("os.environ.get", side_effect=lambda key: None)