Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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