diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 6 | ||||
-rw-r--r-- | scripts/gdb/linux/device.py | 182 | ||||
-rw-r--r-- | scripts/gdb/linux/genpd.py | 83 | ||||
-rw-r--r-- | scripts/gdb/vmlinux-gdb.py | 2 | ||||
-rwxr-xr-x | scripts/get_maintainer.pl | 14 |
5 files changed, 283 insertions, 4 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index a6d436809bf5..93a7edfe0f05 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -6639,6 +6639,12 @@ sub process { | |||
6639 | "unknown module license " . $extracted_string . "\n" . $herecurr); | 6639 | "unknown module license " . $extracted_string . "\n" . $herecurr); |
6640 | } | 6640 | } |
6641 | } | 6641 | } |
6642 | |||
6643 | # check for sysctl duplicate constants | ||
6644 | if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max)\b/) { | ||
6645 | WARN("DUPLICATED_SYSCTL_CONST", | ||
6646 | "duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h\n" . $herecurr); | ||
6647 | } | ||
6642 | } | 6648 | } |
6643 | 6649 | ||
6644 | # If we have no input at all, then there is nothing to report on | 6650 | # If we have no input at all, then there is nothing to report on |
diff --git a/scripts/gdb/linux/device.py b/scripts/gdb/linux/device.py new file mode 100644 index 000000000000..16376c5cfec6 --- /dev/null +++ b/scripts/gdb/linux/device.py | |||
@@ -0,0 +1,182 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
2 | # | ||
3 | # Copyright (c) NXP 2019 | ||
4 | |||
5 | import gdb | ||
6 | |||
7 | from linux.utils import CachedType | ||
8 | from linux.utils import container_of | ||
9 | from linux.lists import list_for_each_entry | ||
10 | |||
11 | |||
12 | device_private_type = CachedType('struct device_private') | ||
13 | device_type = CachedType('struct device') | ||
14 | |||
15 | subsys_private_type = CachedType('struct subsys_private') | ||
16 | kobject_type = CachedType('struct kobject') | ||
17 | kset_type = CachedType('struct kset') | ||
18 | |||
19 | bus_type = CachedType('struct bus_type') | ||
20 | class_type = CachedType('struct class') | ||
21 | |||
22 | |||
23 | def dev_name(dev): | ||
24 | dev_init_name = dev['init_name'] | ||
25 | if dev_init_name: | ||
26 | return dev_init_name.string() | ||
27 | return dev['kobj']['name'].string() | ||
28 | |||
29 | |||
30 | def kset_for_each_object(kset): | ||
31 | return list_for_each_entry(kset['list'], | ||
32 | kobject_type.get_type().pointer(), "entry") | ||
33 | |||
34 | |||
35 | def for_each_bus(): | ||
36 | for kobj in kset_for_each_object(gdb.parse_and_eval('bus_kset')): | ||
37 | subsys = container_of(kobj, kset_type.get_type().pointer(), 'kobj') | ||
38 | subsys_priv = container_of(subsys, subsys_private_type.get_type().pointer(), 'subsys') | ||
39 | yield subsys_priv['bus'] | ||
40 | |||
41 | |||
42 | def for_each_class(): | ||
43 | for kobj in kset_for_each_object(gdb.parse_and_eval('class_kset')): | ||
44 | subsys = container_of(kobj, kset_type.get_type().pointer(), 'kobj') | ||
45 | subsys_priv = container_of(subsys, subsys_private_type.get_type().pointer(), 'subsys') | ||
46 | yield subsys_priv['class'] | ||
47 | |||
48 | |||
49 | def get_bus_by_name(name): | ||
50 | for item in for_each_bus(): | ||
51 | if item['name'].string() == name: | ||
52 | return item | ||
53 | raise gdb.GdbError("Can't find bus type {!r}".format(name)) | ||
54 | |||
55 | |||
56 | def get_class_by_name(name): | ||
57 | for item in for_each_class(): | ||
58 | if item['name'].string() == name: | ||
59 | return item | ||
60 | raise gdb.GdbError("Can't find device class {!r}".format(name)) | ||
61 | |||
62 | |||
63 | klist_type = CachedType('struct klist') | ||
64 | klist_node_type = CachedType('struct klist_node') | ||
65 | |||
66 | |||
67 | def klist_for_each(klist): | ||
68 | return list_for_each_entry(klist['k_list'], | ||
69 | klist_node_type.get_type().pointer(), 'n_node') | ||
70 | |||
71 | |||
72 | def bus_for_each_device(bus): | ||
73 | for kn in klist_for_each(bus['p']['klist_devices']): | ||
74 | dp = container_of(kn, device_private_type.get_type().pointer(), 'knode_bus') | ||
75 | yield dp['device'] | ||
76 | |||
77 | |||
78 | def class_for_each_device(cls): | ||
79 | for kn in klist_for_each(cls['p']['klist_devices']): | ||
80 | dp = container_of(kn, device_private_type.get_type().pointer(), 'knode_class') | ||
81 | yield dp['device'] | ||
82 | |||
83 | |||
84 | def device_for_each_child(dev): | ||
85 | for kn in klist_for_each(dev['p']['klist_children']): | ||
86 | dp = container_of(kn, device_private_type.get_type().pointer(), 'knode_parent') | ||
87 | yield dp['device'] | ||
88 | |||
89 | |||
90 | def _show_device(dev, level=0, recursive=False): | ||
91 | gdb.write('{}dev {}:\t{}\n'.format('\t' * level, dev_name(dev), dev)) | ||
92 | if recursive: | ||
93 | for child in device_for_each_child(dev): | ||
94 | _show_device(child, level + 1, recursive) | ||
95 | |||
96 | |||
97 | class LxDeviceListBus(gdb.Command): | ||
98 | '''Print devices on a bus (or all buses if not specified)''' | ||
99 | |||
100 | def __init__(self): | ||
101 | super(LxDeviceListBus, self).__init__('lx-device-list-bus', gdb.COMMAND_DATA) | ||
102 | |||
103 | def invoke(self, arg, from_tty): | ||
104 | if not arg: | ||
105 | for bus in for_each_bus(): | ||
106 | gdb.write('bus {}:\t{}\n'.format(bus['name'].string(), bus)) | ||
107 | for dev in bus_for_each_device(bus): | ||
108 | _show_device(dev, level=1) | ||
109 | else: | ||
110 | bus = get_bus_by_name(arg) | ||
111 | if not bus: | ||
112 | raise gdb.GdbError("Can't find bus {!r}".format(arg)) | ||
113 | for dev in bus_for_each_device(bus): | ||
114 | _show_device(dev) | ||
115 | |||
116 | |||
117 | class LxDeviceListClass(gdb.Command): | ||
118 | '''Print devices in a class (or all classes if not specified)''' | ||
119 | |||
120 | def __init__(self): | ||
121 | super(LxDeviceListClass, self).__init__('lx-device-list-class', gdb.COMMAND_DATA) | ||
122 | |||
123 | def invoke(self, arg, from_tty): | ||
124 | if not arg: | ||
125 | for cls in for_each_class(): | ||
126 | gdb.write("class {}:\t{}\n".format(cls['name'].string(), cls)) | ||
127 | for dev in class_for_each_device(cls): | ||
128 | _show_device(dev, level=1) | ||
129 | else: | ||
130 | cls = get_class_by_name(arg) | ||
131 | for dev in class_for_each_device(cls): | ||
132 | _show_device(dev) | ||
133 | |||
134 | |||
135 | class LxDeviceListTree(gdb.Command): | ||
136 | '''Print a device and its children recursively''' | ||
137 | |||
138 | def __init__(self): | ||
139 | super(LxDeviceListTree, self).__init__('lx-device-list-tree', gdb.COMMAND_DATA) | ||
140 | |||
141 | def invoke(self, arg, from_tty): | ||
142 | if not arg: | ||
143 | raise gdb.GdbError('Please provide pointer to struct device') | ||
144 | dev = gdb.parse_and_eval(arg) | ||
145 | if dev.type != device_type.get_type().pointer(): | ||
146 | raise gdb.GdbError('Please provide pointer to struct device') | ||
147 | _show_device(dev, level=0, recursive=True) | ||
148 | |||
149 | |||
150 | class LxDeviceFindByBusName(gdb.Function): | ||
151 | '''Find struct device by bus and name (both strings)''' | ||
152 | |||
153 | def __init__(self): | ||
154 | super(LxDeviceFindByBusName, self).__init__('lx_device_find_by_bus_name') | ||
155 | |||
156 | def invoke(self, bus, name): | ||
157 | name = name.string() | ||
158 | bus = get_bus_by_name(bus.string()) | ||
159 | for dev in bus_for_each_device(bus): | ||
160 | if dev_name(dev) == name: | ||
161 | return dev | ||
162 | |||
163 | |||
164 | class LxDeviceFindByClassName(gdb.Function): | ||
165 | '''Find struct device by class and name (both strings)''' | ||
166 | |||
167 | def __init__(self): | ||
168 | super(LxDeviceFindByClassName, self).__init__('lx_device_find_by_class_name') | ||
169 | |||
170 | def invoke(self, cls, name): | ||
171 | name = name.string() | ||
172 | cls = get_class_by_name(cls.string()) | ||
173 | for dev in class_for_each_device(cls): | ||
174 | if dev_name(dev) == name: | ||
175 | return dev | ||
176 | |||
177 | |||
178 | LxDeviceListBus() | ||
179 | LxDeviceListClass() | ||
180 | LxDeviceListTree() | ||
181 | LxDeviceFindByBusName() | ||
182 | LxDeviceFindByClassName() | ||
diff --git a/scripts/gdb/linux/genpd.py b/scripts/gdb/linux/genpd.py new file mode 100644 index 000000000000..6ca93bd2949e --- /dev/null +++ b/scripts/gdb/linux/genpd.py | |||
@@ -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() | ||
diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py index eff5a48ac026..4136dc2c59df 100644 --- a/scripts/gdb/vmlinux-gdb.py +++ b/scripts/gdb/vmlinux-gdb.py | |||
@@ -35,3 +35,5 @@ else: | |||
35 | import linux.constants | 35 | import linux.constants |
36 | import linux.timerlist | 36 | import linux.timerlist |
37 | import linux.clk | 37 | import linux.clk |
38 | import linux.genpd | ||
39 | import linux.device | ||
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index c1c088ef1420..5ef59214c555 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl | |||
@@ -27,6 +27,7 @@ my $email_usename = 1; | |||
27 | my $email_maintainer = 1; | 27 | my $email_maintainer = 1; |
28 | my $email_reviewer = 1; | 28 | my $email_reviewer = 1; |
29 | my $email_list = 1; | 29 | my $email_list = 1; |
30 | my $email_moderated_list = 1; | ||
30 | my $email_subscriber_list = 0; | 31 | my $email_subscriber_list = 0; |
31 | my $email_git_penguin_chiefs = 0; | 32 | my $email_git_penguin_chiefs = 0; |
32 | my $email_git = 0; | 33 | my $email_git = 0; |
@@ -248,6 +249,7 @@ if (!GetOptions( | |||
248 | 'r!' => \$email_reviewer, | 249 | 'r!' => \$email_reviewer, |
249 | 'n!' => \$email_usename, | 250 | 'n!' => \$email_usename, |
250 | 'l!' => \$email_list, | 251 | 'l!' => \$email_list, |
252 | 'moderated!' => \$email_moderated_list, | ||
251 | 's!' => \$email_subscriber_list, | 253 | 's!' => \$email_subscriber_list, |
252 | 'multiline!' => \$output_multiline, | 254 | 'multiline!' => \$output_multiline, |
253 | 'roles!' => \$output_roles, | 255 | 'roles!' => \$output_roles, |
@@ -1023,7 +1025,8 @@ MAINTAINER field selection options: | |||
1023 | --r => include reviewer(s) if any | 1025 | --r => include reviewer(s) if any |
1024 | --n => include name 'Full Name <addr\@domain.tld>' | 1026 | --n => include name 'Full Name <addr\@domain.tld>' |
1025 | --l => include list(s) if any | 1027 | --l => include list(s) if any |
1026 | --s => include subscriber only list(s) if any | 1028 | --moderated => include moderated lists(s) if any (default: true) |
1029 | --s => include subscriber only list(s) if any (default: false) | ||
1027 | --remove-duplicates => minimize duplicate email names/addresses | 1030 | --remove-duplicates => minimize duplicate email names/addresses |
1028 | --roles => show roles (status:subsystem, git-signer, list, etc...) | 1031 | --roles => show roles (status:subsystem, git-signer, list, etc...) |
1029 | --rolestats => show roles and statistics (commits/total_commits, %) | 1032 | --rolestats => show roles and statistics (commits/total_commits, %) |
@@ -1313,11 +1316,14 @@ sub add_categories { | |||
1313 | } else { | 1316 | } else { |
1314 | if ($email_list) { | 1317 | if ($email_list) { |
1315 | if (!$hash_list_to{lc($list_address)}) { | 1318 | if (!$hash_list_to{lc($list_address)}) { |
1316 | $hash_list_to{lc($list_address)} = 1; | ||
1317 | if ($list_additional =~ m/moderated/) { | 1319 | if ($list_additional =~ m/moderated/) { |
1318 | push(@list_to, [$list_address, | 1320 | if ($email_moderated_list) { |
1319 | "moderated list${list_role}"]); | 1321 | $hash_list_to{lc($list_address)} = 1; |
1322 | push(@list_to, [$list_address, | ||
1323 | "moderated list${list_role}"]); | ||
1324 | } | ||
1320 | } else { | 1325 | } else { |
1326 | $hash_list_to{lc($list_address)} = 1; | ||
1321 | push(@list_to, [$list_address, | 1327 | push(@list_to, [$list_address, |
1322 | "open list${list_role}"]); | 1328 | "open list${list_role}"]); |
1323 | } | 1329 | } |