Skip to content

Commit

Permalink
Version 0.2 with experimental RDNA3 support
Browse files Browse the repository at this point in the history
 * Bump version to 0.2.0
 * Experimental support for Navi 3x a.k.a RDNA3
 * Support importing the PP table from MorePowerTool saves
 * Regenerate all atom_gen structures from kernel 6.8 sources
 * Remove atom.py and some workarounds from atom_gen
 * Added regression test for RX 7900 XTX
 * Minor style fixes
 * Minor doc updates
  • Loading branch information
sibradzic committed Mar 25, 2024
1 parent a6a93c6 commit 81eca14
Show file tree
Hide file tree
Showing 18 changed files with 5,719 additions and 7,313 deletions.
26 changes: 23 additions & 3 deletions README.md
Expand Up @@ -12,13 +12,18 @@ allow PowerPlay tables to be dynamically modified on runtime, which may be
known as "soft" PowerPlay table. On Linux, the PowerPlay table is by default
found at: `/sys/class/drm/card0/device/pp_table`.

This tool does very minimal interpretation of actual PowerPlay table values.
By design, it is mostly up to the user to do such thing.

Alternatively, one can use this tool to get PowerPlay data by:

* Extracting PowerPlay table from Video ROM image (see extract command)
* Importing "Soft PowerPlay" table from Windows registry, directly from
offline Windows/System32/config/SYSTEM file on disk, so it would work
from Linux distro that has access to mounted Windows partition
(path to SYSTEM registry file is specified with `--from-registry` option)
* Importing "Soft PowerPlay" table from "More Powe Tool" MPT file
(path to MPT file is specified with `--from-mpt option`)

This tool currently supports parsing and modifying PowerPlay tables found
on the following AMD GPU families:
Expand All @@ -32,6 +37,7 @@ on the following AMD GPU families:
* Navi 21 (Sienna Cichlid)
* Navi 22 (Navy Flounder)
* Navi 23 (Dimgrey Cavefish)
* Navi 3x *experimental support

Note: iGPUs found in many recent AMD APUs are using completely different
PowerPlay control methods, this tool does not support them.
Expand All @@ -46,10 +52,21 @@ https://github.com/sibradzic/upp

### Requirements

Python 3.6+, click library. Optionally, for reading "soft" PowerPlay table
Python 3.7+, click library. Optionally, for reading "soft" PowerPlay table
from Windows registry: python-registry. Should work on Windows as well
(testers wanted).

### Installation

Either get it with pip:

pip install upp

or use it as is directly from the source tree:

cd src
python3 -m upp.upp --help

### Usage

At its current form this is a CLI only tool. Getting help:
Expand Down Expand Up @@ -78,10 +95,13 @@ So, an usage pattern would be like this:
Some generic options applicable to all commands may be used, but please note
that they have to be specified *before* an actual command:

-p, --pp-file <filename> Input/output PP table file.
-p, --pp-file <filename> Input/output PP table binary file.
-f, --from-registry <filename> Import PP_PhmSoftPowerPlayTable from Windows
registry (overrides -p / --pp-file option).
-m, --from-mpt <filename> Import PowerPlay Table from More Power Tool
(overrides --pp-file and --from-registry optios).
-d, --debug / --no-debug Debug mode.
-h, --help Show help.
-h, --help Show this message and exit.

#### Dumping all data:

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='upp',
version='0.1.8',
version='0.2.0',
author='Samir Ibradžić',
description='Uplift Power Play',
long_description=long_description,
Expand All @@ -15,15 +15,15 @@
packages=['upp', 'upp/atom_gen'],
classifiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Operating System :: OS Independent',
],
python_requires='>=3.6, <4',
python_requires='>=3.7, <4',
install_requires=[
'click',
'setuptools'
Expand Down
51 changes: 23 additions & 28 deletions src/upp/atom_gen/README.md
Expand Up @@ -3,23 +3,17 @@

## Reguirements

sudo apt install clang-6.0
sudo apt install clang
pip3 install --user ctypeslib2 clang


## Get latest Linux kernel

git clone --depth=1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

Generated against 36a21d517 (5.14-rc5) (Sun Aug 8 13:49:31 2021 -0700)


## atom.py

sed -i 's|\tstruct mutex mutex;|//\0|' linux/drivers/gpu/drm/amd/amdgpu/atom.h
clang2py -k 'm' --clang-args="\
-Ilinux/include -Ilinux/drivers/gpu/drm/amd/include" \
linux/drivers/gpu/drm/amd/amdgpu/atom.h > atom.py
pushd linux && git checkout drivers/gpu/drm/amd/amdgpu/atom.h && popd
Generated against e8f897f4a (v6.8) (Sun Mar 10 13:38:09 2024 -0700)
clang version 17.0.6
clang2py version 2.3.4


## atombios.py
Expand All @@ -28,6 +22,8 @@ Generated against 36a21d517 (5.14-rc5) (Sun Aug 8 13:49:31 2021 -0700)
--include stdint.h \
--include linux/drivers/gpu/drm/amd/include/atom-types.h \
" \
-s struct__ATOM_COMMON_TABLE_HEADER -s struct__ATOM_MASTER_DATA_TABLE \
-s struct__ATOM_ROM_HEADER -s struct__ATOM_ROM_HEADER_V2_1 \
linux/drivers/gpu/drm/amd/include/atombios.h > atombios.py


Expand All @@ -46,7 +42,7 @@ Generated against 36a21d517 (5.14-rc5) (Sun Aug 8 13:49:31 2021 -0700)

## vega10_pptable.py (Vega10 aka Vega 56/64)

clang2py -k 'mst' \
clang2py -k 'mste' \
--clang-args="--include stdint.h \
--include linux/drivers/gpu/drm/amd/include/atom-types.h \
--include linux/drivers/gpu/drm/amd/include/atomfirmware.h \
Expand All @@ -56,41 +52,40 @@ Generated against 36a21d517 (5.14-rc5) (Sun Aug 8 13:49:31 2021 -0700)

## vega20_pptable.py (Vega20 aka Radeon7)

clang2py -k 'mst' \
clang2py -k 'mste' \
--clang-args="--include stdint.h \
--include linux/drivers/gpu/drm/amd/include/atom-types.h \
--include linux/drivers/gpu/drm/amd/include/atomfirmware.h \
--include linux/drivers/gpu/drm/amd/pm/inc/smu11_driver_if.h " \
--include linux/drivers/gpu/drm/amd/pm/powerplay/inc/smu11_driver_if.h " \
linux/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_pptable.h > vega20_pptable.py


## smu_v11_0_navi10.py (Navi10/14)

clang2py -k 'mst' \
clang2py -k 'mste' \
--clang-args="--include stdint.h \
--include linux/drivers/gpu/drm/amd/include/atom-types.h \
--include linux/drivers/gpu/drm/amd/include/atomfirmware.h \
--include linux/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_navi10.h " \
linux/drivers/gpu/drm/amd/pm/inc/smu_v11_0_pptable.h > smu_v11_0_navi10.py
--include linux/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_navi10.h " \
linux/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0_pptable.h > smu_v11_0_navi10.py


## smu_v11_0_navi20.py (Navi21/22/23)

### An ugly workadound for Navi 23
clang2py -k 'mste' \
--clang-args="--include stdint.h \
--include linux/drivers/gpu/drm/amd/include/atom-types.h \
--include linux/drivers/gpu/drm/amd/include/atomfirmware.h \
--include linux/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h " \
linux/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v11_0_7_pptable.h > smu_v11_0_7_navi20.py

Something is totally weird with Navi 23 (RX6600) PP table, data at the end of
the table seems to be totally messed up. Since VBIOSes of various RX6600 card
manufacturers contains very similar "garbage" there, it might be possible that
PP table definition at smu11_driver_if_sienna_cichlid.h is wrong?

sed -i 's| int8_t Mem1Offset;| uint8_t Mem1Offset;|' linux/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h
## smu_v13_0 (Navi 3x)

clang2py -k 'mst' \
clang2py -k 'mste' \
--clang-args="--include stdint.h \
--include linux/drivers/gpu/drm/amd/include/atom-types.h \
--include linux/drivers/gpu/drm/amd/include/atomfirmware.h \
--include linux/drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h " \
linux/drivers/gpu/drm/amd/pm/inc/smu_v11_0_7_pptable.h > smu_v11_0_7_navi20.py

pushd linux && git checkout drivers/gpu/drm/amd/pm/inc/smu11_driver_if_sienna_cichlid.h && popd
--include linux/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h " \
linux/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0_7_pptable.h > smu_v13_0_7_navi30.py

110 changes: 0 additions & 110 deletions src/upp/atom_gen/atom.py

This file was deleted.

0 comments on commit 81eca14

Please sign in to comment.