amd-debug-tools 0.2.15__tar.gz → 0.2.16__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.15/src/amd_debug_tools.egg-info → amd_debug_tools-0.2.16}/PKG-INFO +1 -1
  2. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/battery.py +23 -11
  3. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/failures.py +4 -3
  4. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/prerequisites.py +6 -5
  5. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/s2idle-hook +5 -1
  6. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/sleep_report.py +2 -1
  7. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/templates/html +193 -110
  8. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/validator.py +2 -4
  9. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16/src/amd_debug_tools.egg-info}/PKG-INFO +1 -1
  10. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_batteries.py +66 -7
  11. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_prerequisites.py +4 -4
  12. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_sleep_report.py +19 -0
  13. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_validator.py +0 -2
  14. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/.github/workflows/ci.yml +0 -0
  15. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/.github/workflows/mirror.yml +0 -0
  16. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/.gitignore +0 -0
  17. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/.pre-commit-config.yaml +0 -0
  18. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/.vscode/settings.json +0 -0
  19. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/LICENSE +0 -0
  20. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/Makefile +0 -0
  21. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/README.md +0 -0
  22. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/amd_bios.py +0 -0
  23. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/amd_pstate.py +0 -0
  24. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/amd_s2idle.py +0 -0
  25. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/amd_ttm.py +0 -0
  26. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/docs/amd-bios.md +0 -0
  27. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/docs/amd-pstate.md +0 -0
  28. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/docs/amd-s2idle.md +0 -0
  29. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/docs/amd-ttm.md +0 -0
  30. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/docs/in-tree.md +0 -0
  31. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/install_deps.py +0 -0
  32. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/psr.py +0 -0
  33. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/pyproject.toml +0 -0
  34. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/setup.cfg +0 -0
  35. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/__init__.py +0 -0
  36. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/acpi.py +0 -0
  37. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/bash/amd-s2idle +0 -0
  38. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/bios.py +0 -0
  39. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/common.py +0 -0
  40. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/database.py +0 -0
  41. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/display.py +0 -0
  42. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/installer.py +0 -0
  43. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/kernel.py +0 -0
  44. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/pstate.py +0 -0
  45. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/s2idle.py +0 -0
  46. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/templates/md +0 -0
  47. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/templates/stdout +0 -0
  48. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/templates/txt +0 -0
  49. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/ttm.py +0 -0
  50. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug/wake.py +0 -0
  51. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug_tools.egg-info/SOURCES.txt +0 -0
  52. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug_tools.egg-info/dependency_links.txt +0 -0
  53. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug_tools.egg-info/entry_points.txt +0 -0
  54. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug_tools.egg-info/requires.txt +0 -0
  55. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/amd_debug_tools.egg-info/top_level.txt +0 -0
  56. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/launcher.py +0 -0
  57. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_acpi.py +0 -0
  58. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_bios.py +0 -0
  59. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_common.py +0 -0
  60. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_database.py +0 -0
  61. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_display.py +0 -0
  62. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_failures.py +0 -0
  63. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_installer.py +0 -0
  64. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_kernel.py +0 -0
  65. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_launcher.py +0 -0
  66. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_pstate.py +0 -0
  67. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_s2idle.py +0 -0
  68. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/src/test_ttm.py +0 -0
  69. {amd_debug_tools-0.2.15 → amd_debug_tools-0.2.16}/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.15
3
+ Version: 0.2.16
4
4
  Summary: debug tools for AMD systems
5
5
  Author-email: Mario Limonciello <superm1@kernel.org>
6
6
  License-Expression: MIT
@@ -38,15 +38,24 @@ class Batteries:
38
38
  names.append(_get_property(dev.properties, "POWER_SUPPLY_NAME", "Unknown"))
39
39
  return names
40
40
 
41
- def get_energy_unit(self, name) -> str:
42
- """Get the energy unit for the given battery name"""
43
- dev = self._get_battery(name)
44
- if not dev:
41
+ def _get_design_voltage(self, dev) -> str:
42
+ """Get the design voltage in µV for the given battery"""
43
+ for key in [
44
+ "POWER_SUPPLY_VOLTAGE_MAX_DESIGN",
45
+ "POWER_SUPPLY_VOLTAGE_MIN_DESIGN",
46
+ "POWER_SUPPLY_VOLTAGE_NOW",
47
+ ]:
48
+ voltage = _get_property(dev.properties, key)
49
+ if voltage:
50
+ return voltage
51
+ return ""
52
+
53
+ def _charge_to_energy(self, dev, charge):
54
+ """Convert battery charge in µAh to energy in µWh"""
55
+ voltage = self._get_design_voltage(dev)
56
+ if not charge or not voltage:
45
57
  return ""
46
- energy = _get_property(dev.properties, "POWER_SUPPLY_ENERGY_NOW")
47
- if energy:
48
- return "µWh"
49
- return "µAh"
58
+ return str(round(int(charge) * int(voltage) / 1000000))
50
59
 
51
60
  def get_energy(self, name) -> int:
52
61
  """Get the current energy for the given battery name"""
@@ -55,7 +64,8 @@ class Batteries:
55
64
  return ""
56
65
  energy = _get_property(dev.properties, "POWER_SUPPLY_ENERGY_NOW")
57
66
  if not energy:
58
- energy = _get_property(dev.properties, "POWER_SUPPLY_CHARGE_NOW")
67
+ charge = _get_property(dev.properties, "POWER_SUPPLY_CHARGE_NOW")
68
+ energy = self._charge_to_energy(dev, charge)
59
69
  return energy
60
70
 
61
71
  def get_energy_full(self, name) -> int:
@@ -65,7 +75,8 @@ class Batteries:
65
75
  return ""
66
76
  energy = _get_property(dev.properties, "POWER_SUPPLY_ENERGY_FULL")
67
77
  if not energy:
68
- energy = _get_property(dev.properties, "POWER_SUPPLY_CHARGE_FULL")
78
+ charge = _get_property(dev.properties, "POWER_SUPPLY_CHARGE_FULL")
79
+ energy = self._charge_to_energy(dev, charge)
69
80
  return energy
70
81
 
71
82
  def get_description_string(self, name) -> str:
@@ -78,9 +89,10 @@ class Batteries:
78
89
  full = self.get_energy_full(name)
79
90
  full_design = _get_property(dev.properties, "POWER_SUPPLY_ENERGY_FULL_DESIGN")
80
91
  if not full_design:
81
- full_design = _get_property(
92
+ charge_full_design = _get_property(
82
93
  dev.properties, "POWER_SUPPLY_CHARGE_FULL_DESIGN"
83
94
  )
95
+ full_design = self._charge_to_energy(dev, charge_full_design)
84
96
 
85
97
  percent = float(full) / int(full_design)
86
98
  return f"Battery {name} ({man} {model}) is operating at {percent:.2%} of design"
@@ -632,9 +632,10 @@ class MissingAmdCaptureModule(S0i3Failure):
632
632
  super().__init__()
633
633
  self.description = "AMD Capture module is missing"
634
634
  self.explanation = (
635
- "The amd_capture module is required for the camera interface included "
636
- "with the SOC to enter the proper power states. "
637
- "Be sure that the amd_capture module is loaded."
635
+ "The amd_capture/amd_isp4_capture module is required for the "
636
+ "camera interface included with the SOC to enter the proper "
637
+ "power states. Be sure that the amd_capture or amd_isp4_capture "
638
+ "modules are loaded."
638
639
  ""
639
640
  "If the module is not available, disable the camera in the BIOS to prevent issues."
640
641
  )
@@ -1028,15 +1028,16 @@ class PrerequisiteValidator(AmdTool):
1028
1028
  self.db.record_prereq(
1029
1029
  f"ISP4 platform camera driver 'amd-isp4' bound to {dev.sys_name}", "✅"
1030
1030
  )
1031
- # check if `amd_capture` module is loaded
1032
- p = os.path.join("/", "sys", "module", "amd_capture")
1033
- if not os.path.exists(p):
1031
+ # check if `amd_capture` or `amd_isp4_capture` modules are loaded
1032
+ p1 = os.path.join("/", "sys", "module", "amd_capture")
1033
+ p2 = os.path.join("/", "sys", "module", "amd_isp4_capture")
1034
+ if not os.path.exists(p1) and not os.path.exists(p2):
1034
1035
  self.db.record_prereq(
1035
- "Camera driver module 'amd_capture' not loaded", "❌"
1036
+ "Camera driver module 'amd_capture'/'amd_isp4_capture' not loaded", "❌"
1036
1037
  )
1037
1038
  self.failures += [MissingAmdCaptureModule()]
1038
1039
  return False
1039
- self.db.record_prereq("Camera driver module 'amd_capture' loaded", "✅")
1040
+ self.db.record_prereq("Camera driver module 'amd_capture'/'amd_isp4_capture' loaded", "✅")
1040
1041
  return True
1041
1042
 
1042
1043
  def map_acpi_path(self):
@@ -3,6 +3,7 @@
3
3
 
4
4
  import argparse
5
5
  import logging
6
+ import os
6
7
  import sys
7
8
 
8
9
 
@@ -59,7 +60,10 @@ def parse_args():
59
60
  if __name__ == "__main__":
60
61
  args = parse_args()
61
62
 
62
- if args.mode != "suspend":
63
+ if (
64
+ args.mode != "suspend"
65
+ and not os.getenv("SYSTEMD_SLEEP_ACTION", "").startswith("suspend")
66
+ ):
63
67
  sys.exit(0)
64
68
 
65
69
  if args.path:
@@ -163,7 +163,8 @@ class SleepReport(AmdTool):
163
163
  (self.df["b1"] - self.df["b0"]) / self.df["full"] * 100
164
164
  )
165
165
  self.df["Battery Ave Rate"] = (
166
- (self.df["b1"] - self.df["b0"]) / self.df["Duration"] / 360
166
+ (self.df["b1"] - self.df["b0"]) / 1000000
167
+ / (self.df["Duration"] / 3600)
167
168
  )
168
169
 
169
170
  # Wake sources
@@ -35,21 +35,49 @@
35
35
  letter-spacing: 0.02em;
36
36
  background-color: #ffffff;
37
37
  color: #000000;
38
- margin: 0em 5.5em 0em 5.5em;
38
+ margin: 2em auto;
39
+ max-width: 1200px;
40
+ padding: 0 2em;
39
41
 
40
42
  }
41
43
 
42
44
  table,
43
45
  th,
44
46
  td {
45
- border-width: 1;
47
+ border: 1px solid #ddd;
46
48
  border-collapse: collapse;
47
49
  table-layout: fixed;
48
50
  font-family: sans-serif;
49
51
  letter-spacing: 0.02em;
50
52
  color: #000000;
51
53
  text-align: left;
52
- padding: 3px;
54
+ padding: 8px;
55
+ }
56
+
57
+ th {
58
+ background-color: #f8f9fa;
59
+ position: sticky;
60
+ top: 0;
61
+ z-index: 10;
62
+ }
63
+
64
+ tr:not(.row-low):not(.row-neutral):not(.row-high):nth-child(even) {
65
+ background-color: #f9f9f9;
66
+ }
67
+
68
+ tr:hover {
69
+ background-color: #f2f2f2 !important;
70
+ }
71
+
72
+ #prereqdebugdata > tbody > tr:hover,
73
+ #cycledata > tbody > tr:hover,
74
+ #failuredata > tbody > tr:hover,
75
+ #debugdata > tbody > tr:hover,
76
+ #prereqdebugdata > tr:hover,
77
+ #cycledata > tr:hover,
78
+ #failuredata > tr:hover,
79
+ #debugdata > tr:hover {
80
+ background-color: transparent !important;
53
81
  }
54
82
 
55
83
  .○ {
@@ -74,9 +102,20 @@
74
102
 
75
103
  .hidden-by-default {
76
104
  display: none;
77
- border: 0px;
78
- border-spacing: 0px;
79
- border-collapse: collapse;
105
+ opacity: 0;
106
+ transition: opacity 0.3s ease;
107
+ }
108
+
109
+ .collapsible-wrapper {
110
+ overflow: hidden;
111
+ max-height: 0;
112
+ opacity: 0;
113
+ transition: max-height 0.4s ease-out, opacity 0.3s ease;
114
+ }
115
+
116
+ .collapsible-wrapper.expanded {
117
+ max-height: 2000px; /* Large enough to hold table */
118
+ opacity: 1;
80
119
  }
81
120
 
82
121
  .hide-borders {
@@ -86,47 +125,69 @@
86
125
 
87
126
  .row-disabled {
88
127
  display: none;
89
- border: 0px;
90
- border-collapse: collapse;
128
+ opacity: 0;
91
129
  }
92
130
 
93
- .arrow::before {
94
- content: "\23f5";
95
- }
96
-
97
- .arrow-expanded::before {
98
- content: "\23F7";
99
-
100
- }
101
-
102
- .row-low {
103
- background-color: #ace3ac;
104
- text-align: center;
131
+ @keyframes fadeIn {
132
+ from { opacity: 0; }
133
+ to { opacity: 1; }
105
134
  }
106
135
 
107
- .row-low:hover {
108
- background-color: #caedca;
109
- text-align: center;
136
+ .row-active {
137
+ display: table-row !important;
138
+ animation: fadeIn 0.5s ease forwards;
110
139
  }
111
140
 
112
- .row-neutral {
113
- background-color: #e0e0e0;
114
- text-align: center;
141
+ .arrow {
142
+ cursor: pointer;
143
+ display: inline-block;
115
144
  }
116
145
 
117
- .row-neutral:hover {
118
- background-color: #f0f0f0;
119
- text-align: center;
146
+ .arrow::before {
147
+ content: "\23f5";
148
+ margin-right: 5px;
120
149
  }
121
150
 
122
- .row-high {
123
- background-color: #ffb2aa;
124
- text-align: center;
151
+ .arrow-expanded::before {
152
+ content: "\23F7";
125
153
  }
126
154
 
127
- .row-high:hover {
128
- background-color: #ffd5d1;
129
- text-align: center;
155
+ @media (prefers-color-scheme: dark) {
156
+ body {
157
+ background-color: #121212;
158
+ color: #e0e0e0;
159
+ }
160
+ table, th, td {
161
+ border-color: #333;
162
+ color: #e0e0e0;
163
+ }
164
+ th {
165
+ background-color: #1e1e1e;
166
+ }
167
+ tr:not(.row-low):not(.row-neutral):not(.row-high):nth-child(even) {
168
+ background-color: #1a1a1a;
169
+ }
170
+ tr:hover {
171
+ background-color: #2a2a2a !important;
172
+ }
173
+ .row-low { background-color: #1b4d1b; }
174
+ .row-low:hover { background-color: #266b26; }
175
+ .row-neutral { background-color: #333; }
176
+ .row-neutral:hover { background-color: #444; }
177
+ .row-high { background-color: #611a14; }
178
+ .row-high:hover { background-color: #8a251d; }
179
+ .○ { color: #e0e0e0; }
180
+ .🦟 { color: #aaa; }
181
+ #prereqdebugdata > tbody > tr:hover,
182
+ #cycledata > tbody > tr:hover,
183
+ #failuredata > tbody > tr:hover,
184
+ #debugdata > tbody > tr:hover,
185
+ #prereqdebugdata > tr:hover,
186
+ #cycledata > tr:hover,
187
+ #failuredata > tr:hover,
188
+ #debugdata > tr:hover {
189
+ background-color: transparent !important;
190
+ }
130
191
  }
131
192
  </style>
132
193
  </head>
@@ -135,13 +196,15 @@
135
196
  <script>
136
197
  function select_changed(selector, row) {
137
198
  var x = document.getElementById(selector).value;
138
- var y;
139
199
  var rows = document.querySelectorAll(row + " tr.row-disabled");
140
200
  for (var i = 0; i < rows.length; i++) {
141
- rows[i].style.display = "none";
201
+ rows[i].classList.remove("row-active");
142
202
  }
143
203
  if (x != "0") {
144
- document.querySelector(row + x).style.display = "table-row";
204
+ var target = document.querySelector(row + x);
205
+ if (target) {
206
+ target.classList.add("row-active");
207
+ }
145
208
  if (row == row + x)
146
209
  document.getElementById(selector).value = 0;
147
210
  }
@@ -156,22 +219,25 @@
156
219
 
157
220
  function debug_data_changed() {
158
221
  select_changed("debug", "#debugdata")
222
+ var label = document.getElementById("debug_label");
159
223
  if (document.getElementById("debug").value != "0") {
160
- document.getElementById("debug_label").style.display = "";
224
+ label.style.display = "block";
225
+ setTimeout(() => label.style.opacity = "1", 10);
161
226
  } else {
162
- document.getElementById("debug_label").style.display = "none";
227
+ label.style.opacity = "0";
228
+ setTimeout(() => label.style.display = "none", 300);
163
229
  }
164
230
  }
165
231
 
166
232
  function prereq_debug_data_changed() {
167
- var table = document.getElementById("prereqdebugdata");
168
- var arrow = document.getElementById("prereqdata-arrow")
169
- if (table.classList.contains("hidden-by-default")) {
170
- table.className = "hide-borders";
171
- arrow.className = "arrow-expanded";
233
+ var wrapper = document.getElementById("prereqdebugdata-wrapper");
234
+ var arrow = document.getElementById("prereqdata-arrow");
235
+ if (wrapper.classList.contains("expanded")) {
236
+ wrapper.classList.remove("expanded");
237
+ arrow.classList.remove("arrow-expanded");
172
238
  } else {
173
- table.className = "hidden-by-default";
174
- arrow.className = "arrow"
239
+ wrapper.classList.add("expanded");
240
+ arrow.classList.add("arrow-expanded");
175
241
  }
176
242
  }
177
243
 
@@ -199,19 +265,15 @@
199
265
  {% endif %}
200
266
  }
201
267
 
202
- function summary_data_changed() {
268
+ function summary_data_changed(ev) {
203
269
  var table = document.getElementById("summary");
204
270
  const start_select = document.getElementById('start_select');
205
271
  const end_select = document.getElementById('end_select');
272
+
273
+ if (!start_select || !end_select) return;
274
+
206
275
  var start = parseInt(start_select.value);
207
276
  var end = parseInt(end_select.value);
208
- var min_duration = 0;
209
-
210
- // if duration filter activated, hide rows that don't match
211
- if (document.getElementById('med_duration').checked)
212
- min_duration = document.getElementById("med_duration").value;
213
- else if (document.getElementById('min_duration').checked)
214
- min_duration = document.getElementById("min_duration").value;
215
277
 
216
278
  // reset end if start was picked bigger than end
217
279
  if (start > end) {
@@ -219,11 +281,22 @@
219
281
  end = start;
220
282
  }
221
283
 
284
+ var min_duration = 0;
285
+ if (document.getElementById('med_duration').checked)
286
+ min_duration = document.getElementById("med_duration").value;
287
+ else if (document.getElementById('min_duration').checked)
288
+ min_duration = document.getElementById("min_duration").value;
289
+
222
290
  // show all rows between start and end
223
- for (var i = 1; i < table.rows.length; i++) {
224
- var row = table.rows[i];
225
- var index = parseInt(row.cells[0].textContent);
226
- var row_duration = parseTimeToSeconds(row.cells[2].textContent);
291
+ var rows = table.tBodies[0].rows;
292
+ for (var i = 0; i < rows.length; i++) {
293
+ var row = rows[i];
294
+ var index_cell = row.cells[0];
295
+ if (!index_cell) continue;
296
+
297
+ var index = parseInt(index_cell.textContent);
298
+ var duration_cell = row.cells[2];
299
+ var row_duration = duration_cell ? parseTimeToSeconds(duration_cell.textContent) : 0;
227
300
 
228
301
  if (row_duration >= min_duration &&
229
302
  index >= start && index <= end) {
@@ -235,74 +308,83 @@
235
308
 
236
309
  // reset other tables if we now show more than one cycle
237
310
  if (end - start > 0) {
238
- // reset cycle data selector
239
- document.getElementById("cycles").selectedIndex = 0;
240
- cycle_data_changed();
311
+ var cycles_select = document.getElementById("cycles");
312
+ if (cycles_select) {
313
+ cycles_select.selectedIndex = 0;
314
+ cycle_data_changed();
315
+ }
241
316
  {% if failures %}
242
- //reset failure data selector
243
- document.getElementById("failures").value = 0;
244
- failure_data_changed();
317
+ var failures_select = document.getElementById("failures");
318
+ if (failures_select) {
319
+ failures_select.value = 0;
320
+ failure_data_changed();
321
+ }
245
322
  {% endif %}
246
323
  {% if debug_data %}
247
- //reset debug data selector
248
- document.getElementById("debug").selectedIndex = 0;
249
- debug_data_changed();
324
+ var debug_select = document.getElementById("debug");
325
+ if (debug_select) {
326
+ debug_select.selectedIndex = 0;
327
+ debug_data_changed();
328
+ }
250
329
  {% endif %}
251
- } else if (start = end)
252
- pick_data_for_cycle(start)
330
+ } else if (start == end) {
331
+ pick_data_for_cycle(start);
332
+ }
253
333
  }
254
334
 
255
335
  function populate_summary_selectors() {
256
336
  const table = document.getElementById('summary');
257
337
  const start_select = document.getElementById('start_select');
258
338
  const end_select = document.getElementById('end_select');
339
+
340
+ if (!start_select || !end_select || !table || !table.tBodies || !table.tBodies[0]) return;
259
341
 
260
- for (let i = 0; i < table.rows.length; i++) {
342
+ var rows = table.tBodies[0].rows;
343
+ for (let i = 0; i < rows.length; i++) {
261
344
  const start_option = document.createElement('option');
262
345
  const end_option = document.createElement('option');
263
- var columns = table.rows[i].getElementsByTagName("td");
346
+ var columns = rows[i].getElementsByTagName("td");
264
347
 
265
348
  //Populate all start/end selector values
266
- if (i != table.rows.length - 1) {
267
- start_option.text = `Cycle ${i}`;
268
- start_option.value = i
269
- end_option.text = `Cycle ${i}`;
270
- end_option.value = i
271
- start_select.add(start_option);
272
- end_select.add(end_option);
273
- }
274
-
275
- //apply coloring to hardware sleep
276
- if (i != 0) {
349
+ start_option.text = `Cycle ${i}`;
350
+ start_option.value = i;
351
+ end_option.text = `Cycle ${i}`;
352
+ end_option.value = i;
353
+ start_select.add(start_option);
354
+ end_select.add(end_option);
355
+
356
+ if (columns.length > 2) {
357
+ //apply coloring to hardware sleep
277
358
  if (parseFloat(columns[2].innerHTML) < 85)
278
- table.rows[i].className = "row-high";
359
+ rows[i].className = "row-high";
279
360
  }
280
361
  }
281
362
 
282
363
  // Pick the end selector for last column
283
- end_select.selectedIndex = table.rows.length - 2;
364
+ end_select.selectedIndex = rows.length - 1;
284
365
 
285
- // if we only have one selector then pick it
286
- if (start_select.selectedIndex == end_select.selectedIndex) {
287
- pick_summary_cycle(start_select.selectedIndex)
366
+ summary_data_changed(event);
367
+
368
+ // if we only have one cycle then pick it
369
+ if (rows.length == 1) {
370
+ pick_summary_cycle(0)
288
371
  }
289
372
  }
290
373
 
291
374
  function pick_summary_cycle(num) {
292
- //narrow down filter to just the selected cycle
293
375
  document.getElementById('start_select').selectedIndex = num;
294
376
  document.getElementById('end_select').selectedIndex = num;
295
- summary_data_changed();
377
+ summary_data_changed(event);
296
378
  pick_data_for_cycle(num);
297
379
  }
298
380
 
299
381
  function reset_clicked() {
300
382
  const table = document.getElementById('summary');
383
+ var rows = table.tBodies[0].rows;
301
384
  document.getElementById('start_select').selectedIndex = 0;
302
- console.log(table.rows.length);
303
- document.getElementById('end_select').selectedIndex = table.rows.length - 2;
385
+ document.getElementById('end_select').selectedIndex = rows.length - 1;
304
386
  document.getElementById('all_time').checked = true;
305
- summary_data_changed();
387
+ summary_data_changed(event);
306
388
  }
307
389
 
308
390
  window.addEventListener('load', populate_summary_selectors);
@@ -321,18 +403,19 @@
321
403
  {% endif %}
322
404
  {% if prereq_debug_data %}
323
405
  <h3>
324
- <label id="prereqdata-arrow" for="prereqdebugdata" onclick="prereq_debug_data_changed()"
325
- class="arrow">Prerequisites</label>
406
+ <span id="prereqdata-arrow" onclick="prereq_debug_data_changed()" class="arrow">Prerequisites</span>
326
407
  </h3>
327
- <table id="prereqdebugdata" class="hidden-by-default">
328
- {% for obj in prereq_debug_data %}
329
- <TR>
330
- <TD>
331
- <pre>{{obj.data}}</pre>
332
- </TD>
333
- </TR>
334
- {% endfor %}
335
- </table>
408
+ <div id="prereqdebugdata-wrapper" class="collapsible-wrapper">
409
+ <table id="prereqdebugdata" class="hide-borders">
410
+ {% for obj in prereq_debug_data %}
411
+ <TR>
412
+ <TD>
413
+ <pre>{{obj.data}}</pre>
414
+ </TD>
415
+ </TR>
416
+ {% endfor %}
417
+ </table>
418
+ </div>
336
419
  {% endif %}
337
420
  <h2>Summary</h2>
338
421
  {% if battery_svg %}
@@ -348,16 +431,16 @@
348
431
  <p>Choose a single cycle to see messages and data for that cycle.</p>
349
432
  <button type="button" onclick="reset_clicked()">Reset</button>
350
433
  <h4>Filter cycle range</h4>
351
- <select id="start_select" onchange="summary_data_changed()"></select>
434
+ <select id="start_select" onchange="summary_data_changed(event)"></select>
352
435
  and
353
- <select id="end_select" onchange="summary_data_changed()"></select>
436
+ <select id="end_select" onchange="summary_data_changed(event)"></select>
354
437
  <h4>Filter minimum session length</h4>
355
- <input type="radio" name="session1" id="all_time" value="all_time" onchange="js:summary_data_changed()"
438
+ <input type="radio" name="session1" id="all_time" value="all_time" onchange="summary_data_changed(event)"
356
439
  checked="" />
357
440
  <label>All</label>
358
- <input type="radio" name="session1" id="med_duration" value="600" onchange="js:summary_data_changed()" />
441
+ <input type="radio" name="session1" id="med_duration" value="600" onchange="summary_data_changed(event)" />
359
442
  <label>&gt;10 min</label>
360
- <input type="radio" name="session1" id="min_duration" value="60" onchange="js:summary_data_changed()" />
443
+ <input type="radio" name="session1" id="min_duration" value="60" onchange="summary_data_changed(event)" />
361
444
  <label>&gt;1 min</label>
362
445
  {% else %}
363
446
  <select id="start_select" class="hidden-by-default"></select>
@@ -403,7 +486,7 @@
403
486
  </table>
404
487
  {% endif %}
405
488
  {% if debug_data %}
406
- <h3 id="debug_label" style="display:none;">Debugging 🦟</h3>
489
+ <h3 id="debug_label" style="display:none; transition: opacity 0.3s ease; opacity: 0;">Debugging 🦟</h3>
407
490
  <p><label for="debug" class="hidden-by-default">Choose a cycle:</label>
408
491
  <select id="debug" onchange="debug_data_changed()" class="hidden-by-default">
409
492
  <option value="0">Disabled</option>
@@ -160,12 +160,10 @@ class SleepValidator(AmdTool):
160
160
  def capture_battery(self):
161
161
  """Capture battery energy levels"""
162
162
  for name in self.batteries.get_batteries():
163
- unit = self.batteries.get_energy_unit(name)
164
163
  energy = self.batteries.get_energy(name)
165
164
  full = self.batteries.get_energy_full(name)
166
- self.db.record_debug(f"{name} energy level is {energy} {unit}")
167
- report_unit = "W" if unit == "µWh" else "A"
168
- self.db.record_battery_energy(name, energy, full, report_unit)
165
+ self.db.record_debug(f"{name} energy level is {energy} µWh")
166
+ self.db.record_battery_energy(name, energy, full, "W")
169
167
 
170
168
  def check_rtc_cmos(self):
171
169
  """Check if the RTC is configured to use ACPI alarm"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amd-debug-tools
3
- Version: 0.2.15
3
+ Version: 0.2.16
4
4
  Summary: debug tools for AMD systems
5
5
  Author-email: Mario Limonciello <superm1@kernel.org>
6
6
  License-Expression: MIT
@@ -35,8 +35,8 @@ class TestBatteries(unittest.TestCase):
35
35
  result = self.batteries.get_batteries()
36
36
  self.assertEqual(result, ["BAT0"])
37
37
 
38
- def test_get_energy_unit(self):
39
- """Test getting energy unit for a battery"""
38
+ def test_get_energy(self):
39
+ """Test getting current energy for a battery"""
40
40
  mock_device = MagicMock()
41
41
  mock_device.device_path = "/devices/LNXSYSTM:00/device:00/PNP0C0A:00"
42
42
  mock_device.properties = {
@@ -44,20 +44,44 @@ class TestBatteries(unittest.TestCase):
44
44
  "POWER_SUPPLY_ENERGY_NOW": "50000",
45
45
  }
46
46
  self.mock_context.list_devices.return_value = [mock_device]
47
- result = self.batteries.get_energy_unit("BAT0")
48
- self.assertEqual(result, "µWh")
47
+ result = self.batteries.get_energy("BAT0")
48
+ self.assertEqual(result, "50000")
49
49
 
50
- def test_get_energy(self):
51
- """Test getting current energy for a battery"""
50
+ def test_get_energy_no_attrs(self):
51
+ """Test graceful failure for a battery with no energy information"""
52
52
  mock_device = MagicMock()
53
53
  mock_device.device_path = "/devices/LNXSYSTM:00/device:00/PNP0C0A:00"
54
54
  mock_device.properties = {
55
55
  "POWER_SUPPLY_NAME": "BAT0",
56
- "POWER_SUPPLY_ENERGY_NOW": "50000",
57
56
  }
58
57
  self.mock_context.list_devices.return_value = [mock_device]
59
58
  result = self.batteries.get_energy("BAT0")
59
+ self.assertEqual(result, "")
60
+
61
+ def test_get_energy_from_charge(self):
62
+ """Test getting current energy for a battery that only reports charge"""
63
+ mock_device = MagicMock()
64
+ mock_device.device_path = "/devices/LNXSYSTM:00/device:00/PNP0C0A:00"
65
+ mock_device.properties = {
66
+ "POWER_SUPPLY_NAME": "BAT0",
67
+ "POWER_SUPPLY_CHARGE_NOW": "3230",
68
+ }
69
+ self.mock_context.list_devices.return_value = [mock_device]
70
+
71
+ # Confirm graceful handling when no design voltage available
72
+ result = self.batteries.get_energy("BAT0")
73
+ self.assertEqual(result, "")
74
+
75
+ # Confirm precedence among possible battery voltage attributes
76
+ mock_device.properties["POWER_SUPPLY_VOLTAGE_NOW"] = "15480000"
77
+ result = self.batteries.get_energy("BAT0")
60
78
  self.assertEqual(result, "50000")
79
+ mock_device.properties["POWER_SUPPLY_VOLTAGE_MIN_DESIGN"] = "15000000"
80
+ result = self.batteries.get_energy("BAT0")
81
+ self.assertEqual(result, "48450")
82
+ mock_device.properties["POWER_SUPPLY_VOLTAGE_MAX_DESIGN"] = "16000000"
83
+ result = self.batteries.get_energy("BAT0")
84
+ self.assertEqual(result, "51680")
61
85
 
62
86
  def test_get_energy_full(self):
63
87
  """Test getting full energy for a battery"""
@@ -72,6 +96,21 @@ class TestBatteries(unittest.TestCase):
72
96
  result = self.batteries.get_energy_full("BAT0")
73
97
  self.assertEqual(result, "60000")
74
98
 
99
+ def test_get_energy_full_from_charge(self):
100
+ """Test getting full energy for a battery that only reports charge"""
101
+ """Test getting full energy for a battery"""
102
+ mock_device = MagicMock()
103
+ mock_device.device_path = "/devices/LNXSYSTM:00/device:00/PNP0C0A:00"
104
+ mock_device.properties = {
105
+ "POWER_SUPPLY_NAME": "BAT0",
106
+ "POWER_SUPPLY_CHARGE_FULL": "3876",
107
+ "POWER_SUPPLY_VOLTAGE_MIN_DESIGN": "15480000",
108
+ }
109
+ self.mock_context.list_devices.return_value = [mock_device]
110
+
111
+ result = self.batteries.get_energy_full("BAT0")
112
+ self.assertEqual(result, "60000")
113
+
75
114
  def test_get_description_string(self):
76
115
  """Test getting description string for a battery"""
77
116
  mock_device = MagicMock()
@@ -90,3 +129,23 @@ class TestBatteries(unittest.TestCase):
90
129
  result,
91
130
  "Battery BAT0 (ACME SuperBattery) is operating at 75.00% of design",
92
131
  )
132
+
133
+ def test_get_description_string_from_charge(self):
134
+ """Test getting description string for a battery that only reports charge"""
135
+ mock_device = MagicMock()
136
+ mock_device.device_path = "/devices/LNXSYSTM:00/device:00/PNP0C0A:00"
137
+ mock_device.properties = {
138
+ "POWER_SUPPLY_NAME": "BAT0",
139
+ "POWER_SUPPLY_MANUFACTURER": "ACME",
140
+ "POWER_SUPPLY_MODEL_NAME": "SuperBattery",
141
+ "POWER_SUPPLY_CHARGE_FULL": "60000",
142
+ "POWER_SUPPLY_CHARGE_FULL_DESIGN": "80000",
143
+ "POWER_SUPPLY_VOLTAGE_MIN_DESIGN": "15480000",
144
+ }
145
+ self.mock_context.list_devices.return_value = [mock_device]
146
+
147
+ result = self.batteries.get_description_string("BAT0")
148
+ self.assertEqual(
149
+ result,
150
+ "Battery BAT0 (ACME SuperBattery) is operating at 75.00% of design",
151
+ )
@@ -2504,12 +2504,12 @@ class TestPrerequisiteValidator(unittest.TestCase):
2504
2504
  def test_check_isp4_driver_bound_but_module_not_loaded(
2505
2505
  self, _mock_readlink, mock_path_exists
2506
2506
  ):
2507
- """Test check_isp4 when driver is bound but amd_capture module is not loaded"""
2507
+ """Test check_isp4 when driver is bound but amd_capture or amd_isp4_capture modules are not loaded"""
2508
2508
 
2509
2509
  def exists_side_effect(path):
2510
2510
  if "path" in path or "driver" in path:
2511
2511
  return True
2512
- if "amd_capture" in path:
2512
+ if "amd_capture" in path or "amd_isp4_capture" in path:
2513
2513
  return False
2514
2514
  return True
2515
2515
 
@@ -2523,7 +2523,7 @@ class TestPrerequisiteValidator(unittest.TestCase):
2523
2523
  "ISP4 platform camera driver 'amd-isp4' bound to OMNI5C10:00", "✅"
2524
2524
  )
2525
2525
  self.mock_db.record_prereq.assert_any_call(
2526
- "Camera driver module 'amd_capture' not loaded", "❌"
2526
+ "Camera driver module 'amd_capture'/'amd_isp4_capture' not loaded", "❌"
2527
2527
  )
2528
2528
  self.assertTrue(
2529
2529
  any(isinstance(f, MissingAmdCaptureModule) for f in self.validator.failures)
@@ -2546,7 +2546,7 @@ class TestPrerequisiteValidator(unittest.TestCase):
2546
2546
  "ISP4 platform camera driver 'amd-isp4' bound to OMNI5C10:00", "✅"
2547
2547
  )
2548
2548
  self.mock_db.record_prereq.assert_any_call(
2549
- "Camera driver module 'amd_capture' loaded", "✅"
2549
+ "Camera driver module 'amd_capture'/'amd_isp4_capture' loaded", "✅"
2550
2550
  )
2551
2551
 
2552
2552
  @patch("amd_debug.prerequisites.os.path.exists")
@@ -194,3 +194,22 @@ class TestSleepReport(unittest.TestCase):
194
194
  self.assertTrue(
195
195
  math.isnan(self.report.df["Hardware Sleep"].iloc[0])
196
196
  ) # Hardware Sleep should be NaN
197
+
198
+ def test_battery_ave_rate(self):
199
+ """Test the pre_process_dataframe Battery Ave Rate calculation."""
200
+ self.report.df = pd.DataFrame(
201
+ {
202
+ "t0": [datetime(2023, 10, 10, 12, 0, 0).strftime("%Y%m%d%H%M%S")],
203
+ "t1": [datetime(2023, 10, 10, 13, 0, 0).strftime("%Y%m%d%H%M%S")],
204
+ "hw": [50],
205
+ "requested": [1],
206
+ "gpio": ["1, 2"],
207
+ "wake_irq": ["1"],
208
+ "b0": [90000000],
209
+ "b1": [85000000],
210
+ "full": [100000000],
211
+ }
212
+ )
213
+ self.report.pre_process_dataframe()
214
+ batt_ave_rate = self.report.df["Battery Ave Rate"].iloc[0]
215
+ self.assertAlmostEqual(batt_ave_rate, -5, places=3)
@@ -105,8 +105,6 @@ class TestValidator(unittest.TestCase):
105
105
  """Test capture_battery method"""
106
106
  with patch.object(
107
107
  self.validator.batteries, "get_batteries", return_value=["BAT0"]
108
- ), patch.object(
109
- self.validator.batteries, "get_energy_unit", return_value="µWh"
110
108
  ), patch.object(
111
109
  self.validator.batteries, "get_energy", return_value=50000
112
110
  ), patch.object(