amd-debug-tools 0.2.0__py3-none-any.whl
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.
Potentially problematic release.
This version of amd-debug-tools might be problematic. Click here for more details.
- amd_debug/__init__.py +45 -0
- amd_debug/acpi.py +107 -0
- amd_debug/bash/amd-s2idle +89 -0
- amd_debug/battery.py +87 -0
- amd_debug/bios.py +138 -0
- amd_debug/common.py +324 -0
- amd_debug/database.py +331 -0
- amd_debug/failures.py +588 -0
- amd_debug/installer.py +404 -0
- amd_debug/kernel.py +389 -0
- amd_debug/prerequisites.py +1215 -0
- amd_debug/pstate.py +314 -0
- amd_debug/s2idle-hook +72 -0
- amd_debug/s2idle.py +406 -0
- amd_debug/sleep_report.py +453 -0
- amd_debug/templates/html +427 -0
- amd_debug/templates/md +39 -0
- amd_debug/templates/stdout +13 -0
- amd_debug/templates/txt +23 -0
- amd_debug/validator.py +863 -0
- amd_debug/wake.py +111 -0
- amd_debug_tools-0.2.0.dist-info/METADATA +180 -0
- amd_debug_tools-0.2.0.dist-info/RECORD +27 -0
- amd_debug_tools-0.2.0.dist-info/WHEEL +5 -0
- amd_debug_tools-0.2.0.dist-info/entry_points.txt +4 -0
- amd_debug_tools-0.2.0.dist-info/licenses/LICENSE +19 -0
- amd_debug_tools-0.2.0.dist-info/top_level.txt +1 -0
amd_debug/wake.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
from pyudev import Context
|
|
6
|
+
|
|
7
|
+
from amd_debug.common import read_file
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class WakeGPIO:
|
|
11
|
+
"""Class for wake GPIOs"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, num):
|
|
14
|
+
self.num = int(num)
|
|
15
|
+
self.name = ""
|
|
16
|
+
|
|
17
|
+
def __str__(self):
|
|
18
|
+
if self.name:
|
|
19
|
+
return f"{self.num} ({self.name})"
|
|
20
|
+
return f"{self.num}"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class WakeIRQ:
|
|
24
|
+
"""Class for wake IRQs"""
|
|
25
|
+
|
|
26
|
+
def __init__(self, num, context=Context()):
|
|
27
|
+
self.num = num
|
|
28
|
+
p = os.path.join("/", "sys", "kernel", "irq", str(num))
|
|
29
|
+
self.chip_name = read_file(os.path.join(p, "chip_name"))
|
|
30
|
+
self.actions = read_file(os.path.join(p, "actions"))
|
|
31
|
+
self.driver = ""
|
|
32
|
+
self.name = ""
|
|
33
|
+
wakeup = read_file(os.path.join(p, "wakeup"))
|
|
34
|
+
|
|
35
|
+
# This is an IRQ tied to _AEI
|
|
36
|
+
if self.chip_name == "amd_gpio":
|
|
37
|
+
hw_gpio = read_file(os.path.join(p, "hwirq"))
|
|
38
|
+
self.name = f"GPIO {hw_gpio}"
|
|
39
|
+
# legacy IRQs
|
|
40
|
+
elif "IR-IO-APIC" in self.chip_name:
|
|
41
|
+
if self.actions == "acpi":
|
|
42
|
+
self.name = "ACPI SCI"
|
|
43
|
+
elif self.actions == "i8042":
|
|
44
|
+
self.name = "PS/2 controller"
|
|
45
|
+
elif self.actions == "pinctrl_amd":
|
|
46
|
+
self.name = "GPIO Controller"
|
|
47
|
+
elif self.actions == "rtc0":
|
|
48
|
+
self.name = "RTC"
|
|
49
|
+
elif self.actions == "timer":
|
|
50
|
+
self.name = "Timer"
|
|
51
|
+
self.actions = ""
|
|
52
|
+
elif "PCI-MSI" in self.chip_name:
|
|
53
|
+
bdf = self.chip_name.split("-")[-1]
|
|
54
|
+
for dev in context.list_devices(subsystem="pci"):
|
|
55
|
+
if dev.device_path.endswith(bdf):
|
|
56
|
+
vendor = dev.properties.get("ID_VENDOR_FROM_DATABASE")
|
|
57
|
+
desc = dev.properties.get("ID_PCI_CLASS_FROM_DATABASE")
|
|
58
|
+
if not desc:
|
|
59
|
+
desc = dev.properties.get("ID_PCI_INTERFACE_FROM_DATABASE")
|
|
60
|
+
name = dev.properties.get("PCI_SLOT_NAME")
|
|
61
|
+
self.driver = dev.properties.get("DRIVER")
|
|
62
|
+
self.name = f"{vendor} {desc} ({name})"
|
|
63
|
+
break
|
|
64
|
+
|
|
65
|
+
# "might" look like an ACPI device, try to follow it
|
|
66
|
+
if not self.name and self.actions:
|
|
67
|
+
p = os.path.join("/", "sys", "bus", "acpi", "devices", self.actions)
|
|
68
|
+
if os.path.exists(p):
|
|
69
|
+
for directory in os.listdir(p):
|
|
70
|
+
if "physical_node" not in directory:
|
|
71
|
+
continue
|
|
72
|
+
|
|
73
|
+
for root, _dirs, files in os.walk(
|
|
74
|
+
os.path.join(p, directory), followlinks=True
|
|
75
|
+
):
|
|
76
|
+
if "name" in files:
|
|
77
|
+
self.name = read_file(os.path.join(root, "name"))
|
|
78
|
+
t = os.path.join(root, "driver")
|
|
79
|
+
if os.path.exists(t):
|
|
80
|
+
self.driver = os.path.basename(os.readlink(t))
|
|
81
|
+
break
|
|
82
|
+
if self.name:
|
|
83
|
+
break
|
|
84
|
+
|
|
85
|
+
# If the name isn't descriptive try to guess further
|
|
86
|
+
if self.driver and self.actions == self.name:
|
|
87
|
+
if self.driver == "i2c_hid_acpi":
|
|
88
|
+
self.name = f"{self.name} I2C HID device"
|
|
89
|
+
|
|
90
|
+
# check if it's disabled
|
|
91
|
+
if not self.name and wakeup == "disabled":
|
|
92
|
+
self.name = "Disabled interrupt"
|
|
93
|
+
|
|
94
|
+
def __str__(self):
|
|
95
|
+
actions = f" ({self.actions})" if self.actions else ""
|
|
96
|
+
return f"{self.name}{actions}"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if __name__ == "__main__":
|
|
100
|
+
from tabulate import tabulate
|
|
101
|
+
|
|
102
|
+
pyudev = Context()
|
|
103
|
+
|
|
104
|
+
p = os.path.join("/sys", "kernel", "irq")
|
|
105
|
+
irqs = []
|
|
106
|
+
for d in os.listdir(p):
|
|
107
|
+
if os.path.isdir(os.path.join(p, d)):
|
|
108
|
+
w = WakeIRQ(d, pyudev)
|
|
109
|
+
irqs.append([int(d), str(WakeIRQ(d, pyudev))])
|
|
110
|
+
irqs.sort()
|
|
111
|
+
print(tabulate(irqs, tablefmt="fancy_grid"))
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amd-debug-tools
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: debug tools for AMD systems
|
|
5
|
+
Author-email: Mario Limonciello <superm1@kernel.org>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://web.git.kernel.org/pub/scm/linux/kernel/git/superm1/amd-debug-tools.git/
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: pyudev
|
|
14
|
+
Requires-Dist: packaging
|
|
15
|
+
Requires-Dist: pandas
|
|
16
|
+
Requires-Dist: jinja2
|
|
17
|
+
Requires-Dist: tabulate
|
|
18
|
+
Requires-Dist: seaborn
|
|
19
|
+
Requires-Dist: cysystemd
|
|
20
|
+
Requires-Dist: Jinja2
|
|
21
|
+
Requires-Dist: matplotlib
|
|
22
|
+
Requires-Dist: seaborn
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# Helpful tools for debugging AMD Zen systems
|
|
26
|
+
[](https://codecov.io/github/superm1/amd-debug-tools)
|
|
27
|
+
[](https://pypi.org/project/amd-debug-tools/)
|
|
28
|
+
|
|
29
|
+
This repository hosts open tools that are useful for debugging issues on AMD systems.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
It is suggested to install tools in a virtual environment either using
|
|
33
|
+
`pipx` or `python3 -m venv`.
|
|
34
|
+
|
|
35
|
+
### From PyPI
|
|
36
|
+
`amd-debug-tools` is distributed as a python wheel, which is a
|
|
37
|
+
binary package format for Python. To install from PyPI, run the following
|
|
38
|
+
command:
|
|
39
|
+
|
|
40
|
+
pipx install amd-debug-tools
|
|
41
|
+
|
|
42
|
+
### From source
|
|
43
|
+
To build the package from source, you will need to the `python3-build`
|
|
44
|
+
package natively installed by your distribution package manager. Then you
|
|
45
|
+
can generate and install a wheel by running the following commands:
|
|
46
|
+
|
|
47
|
+
python3 -m build
|
|
48
|
+
pipx install dist/amd-debug-tools-*.whl
|
|
49
|
+
|
|
50
|
+
### Ensuring path
|
|
51
|
+
If you have not used a `pipx` environment before, you may need to run the following command
|
|
52
|
+
to set up the environment:
|
|
53
|
+
|
|
54
|
+
pipx ensurepath
|
|
55
|
+
|
|
56
|
+
This will add the `pipx` environment to your path.
|
|
57
|
+
|
|
58
|
+
### Running in tree
|
|
59
|
+
If you want to run the tools in tree, you need to make sure that distro dependencies
|
|
60
|
+
that would normally install into a venv are installed. This can be done by running:
|
|
61
|
+
|
|
62
|
+
./install_deps.py
|
|
63
|
+
|
|
64
|
+
After dependencies are installed, you can run the tools by running:
|
|
65
|
+
|
|
66
|
+
./amd_s2idle.py
|
|
67
|
+
./amd_bios.py
|
|
68
|
+
./amd_pstate.py
|
|
69
|
+
|
|
70
|
+
## amd-s2idle
|
|
71
|
+
`amd-s2idle` is a tool used for analyzing the entry and exit of the s2idle
|
|
72
|
+
state of a Linux system.
|
|
73
|
+
|
|
74
|
+
It is intended to use with Linux kernel 6.1 or later and works by hooking
|
|
75
|
+
into dynamic debugging messages and events that are generated by the kernel.
|
|
76
|
+
|
|
77
|
+
For analysis of power consumption issues it can be hooked into `systemd` to
|
|
78
|
+
run a command to capture data right before and after the system enters and
|
|
79
|
+
exits the s2idle state.
|
|
80
|
+
|
|
81
|
+
4 high level commands are supported.
|
|
82
|
+
|
|
83
|
+
### `amd-s2idle install`
|
|
84
|
+
This will install the systemd hook so that data will be captured before and
|
|
85
|
+
after the system enters and exits the s2idle state.
|
|
86
|
+
|
|
87
|
+
This will also install a bash completion script that can be used for other
|
|
88
|
+
commands.
|
|
89
|
+
|
|
90
|
+
**NOTE:** This command is only supported when run from a venv.
|
|
91
|
+
|
|
92
|
+
### `amd-s2idle uninstall`
|
|
93
|
+
This will uninstall the systemd hook and remove the bash completion script.
|
|
94
|
+
|
|
95
|
+
**NOTE:** This command is only supported when run from a venv.
|
|
96
|
+
|
|
97
|
+
### `amd-s2idle test`
|
|
98
|
+
This will run a suspend cycle with a timer based wakeup and capture relevant
|
|
99
|
+
data into a database and produce a report. This can also be used to run multiple cycles.
|
|
100
|
+
|
|
101
|
+
The following optional arguments are supported for this command:
|
|
102
|
+
|
|
103
|
+
--count COUNT Number of cycles to run
|
|
104
|
+
--duration DURATION Duration of the cycle in seconds
|
|
105
|
+
--wait WAIT Time to wait before starting the cycle in seconds
|
|
106
|
+
--format FORMAT Format of the report to produce (html, txt or md)
|
|
107
|
+
--report-file File to write the report to
|
|
108
|
+
--force Run a test cycle even if the system fails to pass prerequisite checks
|
|
109
|
+
--random Run sleep cycles for random durations and waits, using the --duration and --wait arguments as an upper bound
|
|
110
|
+
--logind Use logind to suspend the system
|
|
111
|
+
--tool-debug Enable debug logging
|
|
112
|
+
--bios-debug Enable BIOS debug logging instead of notify logging
|
|
113
|
+
|
|
114
|
+
If the tool is launched with an environment that can call `xdg-open`, the report
|
|
115
|
+
will be opened in a browser.
|
|
116
|
+
|
|
117
|
+
### `amd-s2idle report`
|
|
118
|
+
This will produce a report from the data captured by the `test` command
|
|
119
|
+
and/or from the systemd hook. The report will default to 60 days of data.
|
|
120
|
+
|
|
121
|
+
The following optional arguments are supported for this command:
|
|
122
|
+
|
|
123
|
+
--since SINCE Date to start the report from
|
|
124
|
+
--until UNTIL Date to end the report at
|
|
125
|
+
--format FORMAT Format of the report to produce (html, txt or md)
|
|
126
|
+
--report-file File to write the report to
|
|
127
|
+
--tool-debug Enable tool debug logging
|
|
128
|
+
--report-debug Include debug messages in the report
|
|
129
|
+
|
|
130
|
+
If the tool is launched with an environment that can call `xdg-open`, the report
|
|
131
|
+
will be opened in a browser.
|
|
132
|
+
|
|
133
|
+
### `amd-s2idle version`
|
|
134
|
+
This will print the version of the tool and exit.
|
|
135
|
+
|
|
136
|
+
### Debug output
|
|
137
|
+
All commands support the `--tool-debug` argument which will enable extra debug output. This is often needed for debugging issues with a particular cycle.
|
|
138
|
+
|
|
139
|
+
**NOTE:** enabling debug output significantly increases the size of the report.
|
|
140
|
+
It's suggested that you use `--since` and `--until` to focus on the cycles that you are interested in.
|
|
141
|
+
|
|
142
|
+
## amd-bios
|
|
143
|
+
`amd-bios` is a a tool that can be used to enable or disable BIOS AML debug logging
|
|
144
|
+
-and to parse a kernel log that contains BIOS logs.
|
|
145
|
+
|
|
146
|
+
### `amd-bios trace`
|
|
147
|
+
Modify BIOS AML trace debug logging.
|
|
148
|
+
|
|
149
|
+
One of the following arguments must be set for this command:
|
|
150
|
+
|
|
151
|
+
--enable Enable BIOS AML tracing
|
|
152
|
+
--disable Disable BIOS AML tracing
|
|
153
|
+
|
|
154
|
+
The following optional arguments are supported for this command:
|
|
155
|
+
|
|
156
|
+
--tool-debug Enable tool debug logging
|
|
157
|
+
|
|
158
|
+
### `amd-bios parse`
|
|
159
|
+
Parses a kernel log that contains BIOS AML debug logging and produces a report.
|
|
160
|
+
|
|
161
|
+
The following optional arguments are supported for this command:
|
|
162
|
+
|
|
163
|
+
--input INPUT Optional input file to parse
|
|
164
|
+
--tool-debug Enable tool debug logging
|
|
165
|
+
|
|
166
|
+
### `amd-bios version`
|
|
167
|
+
This will print the version of the tool and exit.
|
|
168
|
+
|
|
169
|
+
## amd-pstate
|
|
170
|
+
`amd-pstate` is a tool used for identification of issues with amd-pstate.
|
|
171
|
+
It will capture some state from the system as well as from the machine specific registers that
|
|
172
|
+
amd-pstate uses.
|
|
173
|
+
|
|
174
|
+
## Compatibility scripts
|
|
175
|
+
|
|
176
|
+
Compatibility scripts are provided for the previous names the tools went by:
|
|
177
|
+
`amd_s2idle.py`, `amd_bios.py` and `amd_pstate.py`.
|
|
178
|
+
These allow cloning the repository and running the scripts without installing
|
|
179
|
+
the package.
|
|
180
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
amd_debug/__init__.py,sha256=aOtpIEKGLUStrh0e4qgilHW7HgF4Od-r9pOoZ87NwAM,1105
|
|
2
|
+
amd_debug/acpi.py,sha256=fkD3Sov8cRT5ryPlakRlT7Z9jiCLT9x_MPWxt3xU_tc,3161
|
|
3
|
+
amd_debug/battery.py,sha256=WN-6ys9PHCZIwg7PdwyBOa62GjBp8WKG0v1YZt5_W5s,3122
|
|
4
|
+
amd_debug/bios.py,sha256=wmPKDsTZeQqsHjWpv-YHdgRNlCtFdzHQ6jJf0H3hjN8,3971
|
|
5
|
+
amd_debug/common.py,sha256=Xi47CAutEAE6mPz3IkdUnU0ayGEkJo30OXr9DIHhu_0,8822
|
|
6
|
+
amd_debug/database.py,sha256=GkRg3cmaNceyQ2_hy0MBAlMbnTDPHo2co2o4ObWpnQg,10621
|
|
7
|
+
amd_debug/failures.py,sha256=QV3wxl9NYxUV5e0VmMy-pNLg4PoLeCVy0RvBux1pnZM,22536
|
|
8
|
+
amd_debug/installer.py,sha256=fSUGLGElpVdUyYJjD4LWntVSmcF_faU6hRCM9t4kNAU,12154
|
|
9
|
+
amd_debug/kernel.py,sha256=xzAy-sDY5-sd4jxyU7EaBokS7YsvEjoWRuexaTJNRBc,11851
|
|
10
|
+
amd_debug/prerequisites.py,sha256=Tu6tDMXTptSSlkDtY_39SGLiJn8MDhUKUE2GLDtmRNI,46731
|
|
11
|
+
amd_debug/pstate.py,sha256=akGdJkIxBp0bx3AeGv6ictNxwv8m0j9vQ2IZB0Jx3dM,9518
|
|
12
|
+
amd_debug/s2idle-hook,sha256=LLiaqPtGd0qetu9n6EYxKHZaIdHpVQDONdOuSc0pfFg,1695
|
|
13
|
+
amd_debug/s2idle.py,sha256=S6IAf87K16-G2xGIXCR6oym7GHGi1TZjxlFiz3s7bU4,12461
|
|
14
|
+
amd_debug/sleep_report.py,sha256=dRoE21nkPMFoa5L9i5XrzPug4KesLfAf1RpPFB7Xpt0,15555
|
|
15
|
+
amd_debug/validator.py,sha256=VomxJOp6ZYBp3oYEaNsD-rvio_b346VSRz7-hyhCS_c,33234
|
|
16
|
+
amd_debug/wake.py,sha256=xT8WrFrN6voCmXWo5dsn4mQ7iR2QJxHrrYBd3EREG-Q,3936
|
|
17
|
+
amd_debug/bash/amd-s2idle,sha256=g_cle1ElCJpwE4wcLezL6y-BdasDKTnNMhrtzKLE9ks,1142
|
|
18
|
+
amd_debug/templates/html,sha256=tnpqHDZF5FfhC6YNRUfOG6Vn9ZtISFr10kEXSB476Mw,14518
|
|
19
|
+
amd_debug/templates/md,sha256=F0xt7m-lOsSz1VeucHA6a-1gsOH7rrik15biXnDgd54,904
|
|
20
|
+
amd_debug/templates/stdout,sha256=hyoOJ96K2dJfnWRWhyCuariLKbEHXvs9mstV_g5aMdI,469
|
|
21
|
+
amd_debug/templates/txt,sha256=nNdsvbPFOhGdL7VA-_4k5aN3nB-6ouGQt6AsWst7T3w,649
|
|
22
|
+
amd_debug_tools-0.2.0.dist-info/licenses/LICENSE,sha256=RBlZI6r3MRGzymI2VDX2iW__D2APDbMhu_Xg5t6BWeo,1066
|
|
23
|
+
amd_debug_tools-0.2.0.dist-info/METADATA,sha256=iyX-wpq8WWdx619aSLbeUd8knAdfm_UCcamPu5mLQVE,6783
|
|
24
|
+
amd_debug_tools-0.2.0.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
25
|
+
amd_debug_tools-0.2.0.dist-info/entry_points.txt,sha256=HC11T2up0pPfroAn6Pg5M2jOZXhkWIipToJ1YPTKqu8,116
|
|
26
|
+
amd_debug_tools-0.2.0.dist-info/top_level.txt,sha256=7yUDU3ZY79gqXz0vl4TJzoTfngMPfQhrYFRU8PR2CB4,10
|
|
27
|
+
amd_debug_tools-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2025 Advanced Micro Devices
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
amd_debug
|