Skip to content

Commit 8207d4a

Browse files
cdleonardtorvalds
authored andcommitted
scripts/gdb: add lx-genpd-summary command
This is like /sys/kernel/debug/pm/pm_genpd_summary except it's accessible through a debugger. This can be useful if the target crashes or hangs because power domains were not properly enabled. Link: http://lkml.kernel.org/r/f9ee627a0d4f94b894aa202fee8a98444049bed8.1561492937.git.leonard.crestez@nxp.com Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com> Reviewed-by: Stephen Boyd <sboyd@kernel.org> Cc: Kieran Bingham <kbingham@kernel.org> Cc: Jan Kiszka <jan.kiszka@siemens.com> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5515e9a commit 8207d4a

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

‎scripts/gdb/linux/genpd.py‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# Copyright (c) NXP 2019
4+
5+
import gdb
6+
import sys
7+
8+
from linux.utils import CachedType
9+
from linux.lists import list_for_each_entry
10+
11+
generic_pm_domain_type = CachedType('struct generic_pm_domain')
12+
pm_domain_data_type = CachedType('struct pm_domain_data')
13+
device_link_type = CachedType('struct device_link')
14+
15+
16+
def kobject_get_path(kobj):
17+
path = kobj['name'].string()
18+
parent = kobj['parent']
19+
if parent:
20+
path = kobject_get_path(parent) + '/' + path
21+
return path
22+
23+
24+
def rtpm_status_str(dev):
25+
if dev['power']['runtime_error']:
26+
return 'error'
27+
if dev['power']['disable_depth']:
28+
return 'unsupported'
29+
_RPM_STATUS_LOOKUP = [
30+
"active",
31+
"resuming",
32+
"suspended",
33+
"suspending"
34+
]
35+
return _RPM_STATUS_LOOKUP[dev['power']['runtime_status']]
36+
37+
38+
class LxGenPDSummary(gdb.Command):
39+
'''Print genpd summary
40+
41+
Output is similar to /sys/kernel/debug/pm_genpd/pm_genpd_summary'''
42+
43+
def __init__(self):
44+
super(LxGenPDSummary, self).__init__('lx-genpd-summary', gdb.COMMAND_DATA)
45+
46+
def summary_one(self, genpd):
47+
if genpd['status'] == 0:
48+
status_string = 'on'
49+
else:
50+
status_string = 'off-{}'.format(genpd['state_idx'])
51+
52+
slave_names = []
53+
for link in list_for_each_entry(
54+
genpd['master_links'],
55+
device_link_type.get_type().pointer(),
56+
'master_node'):
57+
slave_names.apend(link['slave']['name'])
58+
59+
gdb.write('%-30s %-15s %s\n' % (
60+
genpd['name'].string(),
61+
status_string,
62+
', '.join(slave_names)))
63+
64+
# Print devices in domain
65+
for pm_data in list_for_each_entry(genpd['dev_list'],
66+
pm_domain_data_type.get_type().pointer(),
67+
'list_node'):
68+
dev = pm_data['dev']
69+
kobj_path = kobject_get_path(dev['kobj'])
70+
gdb.write(' %-50s %s\n' % (kobj_path, rtpm_status_str(dev)))
71+
72+
def invoke(self, arg, from_tty):
73+
gdb.write('domain status slaves\n');
74+
gdb.write(' /device runtime status\n');
75+
gdb.write('----------------------------------------------------------------------\n');
76+
for genpd in list_for_each_entry(
77+
gdb.parse_and_eval('&gpd_list'),
78+
generic_pm_domain_type.get_type().pointer(),
79+
'gpd_list_node'):
80+
self.summary_one(genpd)
81+
82+
83+
LxGenPDSummary()

‎scripts/gdb/vmlinux-gdb.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@
3535
import linux.constants
3636
import linux.timerlist
3737
import linux.clk
38+
import linux.genpd

0 commit comments

Comments
 (0)