lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <70b98a91dd823b235fbabba58c23c56a6e9f7f41.camel@intel.com>
Date:   Tue, 23 May 2023 22:01:57 +0000
From:   "Pandruvada, Srinivas" <srinivas.pandruvada@...el.com>
To:     "Zhang, Rui" <rui.zhang@...el.com>,
        "rafael@...nel.org" <rafael@...nel.org>,
        "daniel.lezcano@...aro.org" <daniel.lezcano@...aro.org>,
        "todd.e.brandt@...ux.intel.com" <todd.e.brandt@...ux.intel.com>
CC:     "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Brandt, Todd E" <todd.e.brandt@...el.com>
Subject: Re: [PATCH 2/2] simple python script for testing PSVT table


Sent by mistake please ignore.

Thanks,
Srinivas

On Tue, 2023-05-23 at 15:01 -0700, Srinivas Pandruvada wrote:
> From: Todd Brandt <todd.e.brandt@...ux.intel.com>
> 
> Added a simple python script for testing the thermal tables.
> 
>   ACPI Thermal Table Test
>   Usage: therm-table-test.py <options>
>   Description:
>     Python script for quick testing of thermal table availablity
>   Options:
>     -h      Print this help text
>     -art    Test the ART table
>     -trt    Test the TRT table
>     -psvt   Test the PSVT table
>     (none)  Test all tables
> 
> Signed-off-by: Todd Brandt <todd.e.brandt@...ux.intel.com>
> ---
>  scripts/acpi-thermal-rel-test.py | 148
> +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 148 insertions(+)
>  create mode 100644 scripts/acpi-thermal-rel-test.py
> 
> diff --git a/scripts/acpi-thermal-rel-test.py b/scripts/acpi-thermal-
> rel-test.py
> new file mode 100644
> index 0000000..9a82777
> --- /dev/null
> +++ b/scripts/acpi-thermal-rel-test.py
> @@ -0,0 +1,148 @@
> +#!/usr/bin/python
> +
> +import sys
> +import os
> +from fcntl import ioctl
> +import array
> +import struct
> +
> +def i(x):
> +    return x - 2**32
> +
> +ACPI_THERMAL_GET_TRT_LEN    = i(0x80087301)
> +ACPI_THERMAL_GET_ART_LEN    = i(0x80087302)
> +ACPI_THERMAL_GET_TRT_COUNT  = i(0x80087303)
> +ACPI_THERMAL_GET_ART_COUNT  = i(0x80087304)
> +ACPI_THERMAL_GET_TRT        = i(0x80087305)
> +ACPI_THERMAL_GET_ART        = i(0x80087306)
> +ACPI_THERMAL_GET_PSVT_REV   = i(0x80087307)
> +ACPI_THERMAL_GET_PSVT_LEN   = i(0x80087308)
> +ACPI_THERMAL_GET_PSVT_COUNT = i(0x80087309)
> +ACPI_THERMAL_GET_PSVT       = i(0x8008730a)
> +
> +def toInt(buf):
> +       return struct.unpack('Q', buf)[0]
> +
> +def toStr(buf):
> +       return buf.tostring()
> +
> +def testART():
> +       f = os.open('/dev/acpi_thermal_rel', os.O_RDWR)
> +       buf = array.array('h', [0])
> +       ioctl(f, ACPI_THERMAL_GET_ART_COUNT, buf)
> +       count = buf[0]
> +       print('ACPI_THERMAL_GET_ART_COUNT = %d' % count)
> +       buf = array.array('h', [0])
> +       ioctl(f, ACPI_THERMAL_GET_ART_LEN, buf)
> +       length = buf[0]
> +       print('ACPI_THERMAL_GET_ART_LEN = %d' % length)
> +       buf = array.array('c', '\0'*length)
> +       ioctl(f, ACPI_THERMAL_GET_ART, buf)
> +       print('ACPI_THERMAL_GET_ART')
> +       plen = length/count
> +       for i in range(count):
> +               package = buf[(i*plen):((i+1)*plen)]
> +               print('  package %d' % i)
> +               print('    source: %s' % toStr(package[0:8]))
> +               print('    target: %s' % toStr(package[8:16]))
> +               print('    weight: %d' % toInt(package[16:24]))
> +
> +def testTRT():
> +       f = os.open('/dev/acpi_thermal_rel', os.O_RDWR)
> +       buf = array.array('h', [0])
> +       ioctl(f, ACPI_THERMAL_GET_TRT_COUNT, buf)
> +       count = buf[0]
> +       print('ACPI_THERMAL_GET_TRT_COUNT = %d' % count)
> +       buf = array.array('h', [0])
> +       ioctl(f, ACPI_THERMAL_GET_TRT_LEN, buf)
> +       length = buf[0]
> +       print('ACPI_THERMAL_GET_TRT_LEN = %d' % length)
> +       buf = array.array('c', '\0'*length)
> +       ioctl(f, ACPI_THERMAL_GET_TRT, buf)
> +       print('ACPI_THERMAL_GET_TRT')
> +       plen = length/count
> +       for i in range(count):
> +               package = buf[(i*plen):((i+1)*plen)]
> +               print('  package %d' % i)
> +               print('    source: %s' % toStr(package[0:8]))
> +               print('    target: %s' % toStr(package[8:16]))
> +               print('    influence: %d' % toInt(package[16:24]))
> +               print('    sample_period: %d' %
> toInt(package[24:32]))
> +
> +def testPSVT():
> +       f = os.open('/dev/acpi_thermal_rel', os.O_RDWR)
> +       buf = array.array('h', [0])
> +       ioctl(f, ACPI_THERMAL_GET_PSVT_REV, buf)
> +       rev = buf[0]
> +       print('ACPI_THERMAL_GET_PSVT_REV = %d' % rev)
> +       buf = array.array('h', [0])
> +       ioctl(f, ACPI_THERMAL_GET_PSVT_COUNT, buf)
> +       count = buf[0]
> +       print('ACPI_THERMAL_GET_PSVT_COUNT = %d' % count)
> +       buf = array.array('h', [0])
> +       ioctl(f, ACPI_THERMAL_GET_PSVT_LEN, buf)
> +       length = buf[0]
> +       print('ACPI_THERMAL_GET_PSVT_LEN = %d' % length)
> +       buf = array.array('c', '\0'*length)
> +       ioctl(f, ACPI_THERMAL_GET_PSVT, buf)
> +       print('ACPI_THERMAL_GET_PSVT')
> +       plen = length/count
> +       for i in range(count):
> +               package = buf[(i*plen):((i+1)*plen)]
> +               knobtype = toInt(package[88:96])
> +               print('  package %d' % i)
> +               print('    source: %s' % toStr(package[0:8]))
> +               print('    target: %s' % toStr(package[8:16]))
> +               print('    priority: %d' % toInt(package[16:24]))
> +               print('    sample_period: %d' %
> toInt(package[24:32]))
> +               print('    target_domain: %d' %
> toInt(package[32:40]))
> +               print('    passive_temp: %d' % toInt(package[40:48]))
> +               print('    source_domain: %d' %
> toInt(package[48:56]))
> +               if(knobtype == 2):
> +                       print('    control_knob: %s' %
> toStr(package[56:64]))
> +               else:
> +                       print('    control_knob: %d' %
> toInt(package[56:64]))
> +               print('    limit: %d' % toInt(package[64:72]))
> +               print('    limit_step_size: %d' %
> toInt(package[72:80]))
> +               print('    unlimit_step_size: %d' %
> toInt(package[80:88]))
> +
> +def printHelp():
> +       print('ACPI Thermal Table Test')
> +       print('Usage: therm-table-test.py <options>')
> +       print('Description:')
> +       print('  Python script for quick testing of thermal table
> availablity')
> +       print('Options:')
> +       print('  -h      Print this help text')
> +       print('  -art    Test the ART table')
> +       print('  -trt    Test the TRT table')
> +       print('  -psvt   Test the PSVT table')
> +       print('  (none)  Test all tables')
> +
> +if __name__ == '__main__':
> +       tests = {'art':False, 'trt':False, 'psvt':False}
> +       args = iter(sys.argv[1:])
> +       for arg in args:
> +               if(arg == '-h'):
> +                       printHelp()
> +                       sys.exit()
> +               elif(arg == '-art'):
> +                       tests['art'] = True
> +               elif(arg == '-trt'):
> +                       tests['trt'] = True
> +               elif(arg == '-psvt'):
> +                       tests['psvt'] = True
> +               else:
> +                       printHelp()
> +                       print('Invalid argument: %s' % arg)
> +                       sys.exit()
> +
> +       if not tests['art'] and not tests['trt'] and not
> tests['psvt']:
> +               for i in tests:
> +                       tests[i] = True
> +
> +       if tests['art']:
> +               testART()
> +       if tests['trt']:
> +               testTRT()
> +       if tests['psvt']:
> +               testPSVT()

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ