forked from Ricks-Lab/gpu-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamdgpu-pciid
executable file
·118 lines (99 loc) · 4.63 KB
/
amdgpu-pciid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env python3
"""amdgpu-pciid - Manages the local pci id lookup table
WARNING: this utility is under development and should not be used
This utility will display the version of the current pci.ids data extract
in use. With the *--download* option, the latest pci.ids file from
https://pci-ids.ucw.cz/ will be downloaded. With the *--install* option,
the latest pci.ids will be downloaded and filtered for AMD specific data
and written to the file used by amdgpu-utils to decode device names from the
driver provided device id. The *--force* option can be used to update this
file even if there is no change in version. If your GPU model is missing
from the pci.ids file, you can use the device id of your card found with
amdgpu-ls and make a request for the addition on the pci.ids website.
Copyright (C) 2019 RueiKe
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = "RueiKe"
__copyright__ = "Copyright (C) 2019 RueiKe"
__credits__ = [""]
__license__ = "GNU General Public License"
__program_name__ = "amdgpu-pciid"
__version__ = "v2.5.0"
__maintainer__ = "RueiKe"
__status__ = "Stable Release"
import argparse
import re
import subprocess
import os
import platform
import sys
import time
from GPUmodules import PCImodule as PCI
from GPUmodules import env
from datetime import datetime
from uuid import uuid4
import glob
import shutil
from pathlib import Path
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--about", help="README", action="store_true", default=False)
parser.add_argument("--download", help="download pci decode table from https://pci-ids.ucw.cz/v2.2/pci.ids",
action="store_true", default=False)
parser.add_argument("--install", help="download, parse amd entries, and install a new decode file",
action="store_true", default=False)
parser.add_argument("--force", help="force install of new pci.ids data even if revision is unchanged",
action="store_true", default=False)
parser.add_argument("-d", "--debug", help="Debug output", action="store_true", default=False)
args = parser.parse_args()
# About me
if args.about == True :
print(__doc__ )
print("Author: ", __author__ )
print("Copyright: ", __copyright__)
print("Credits: ", __credits__)
print("License: ", __license__)
print("Version: ", __version__)
print("Maintainer: ", __maintainer__)
print("Status: ", __status__)
sys.exit(0)
env.gut_const.PATH = os.path.dirname(str(Path(__file__).resolve()))
env.gut_const.DEBUG = args.debug
if env.gut_const.check_env() < 0:
print("Error in environment. Exiting...")
sys.exit(-1)
pciid = PCI.PCI_ID()
# display info about pci.ids
if args.download == False and args.install == False:
original_amd_file = os.path.join(env.gut_const.PATH, "GPUmodules", pciid.amdgpu_utils_file)
original_file_version = pciid.get_pciid_version()
print("Current pci.ids version %s : %s" % (original_file_version, original_amd_file))
sys.exit(0)
if args.download == True or args.install == True:
pciid_filename_new = pciid.download_pciid()
print("Download complete: %s" % pciid_filename_new)
new_file_version = pciid.get_pciid_version(pciid_filename_new)
print(" Download %s : %s" % (new_file_version, pciid_filename_new))
if args.install == True:
original_amd_file = os.path.join(env.gut_const.PATH, "GPUmodules", pciid.amdgpu_utils_file)
original_file_version = pciid.get_pciid_version()
print(" Original %s : %s" % (original_file_version, original_amd_file))
if original_file_version == new_file_version and args.force != True:
print("No updates, skipping install")
else:
pciid.update_pci_id(pciid_filename_new)
print("Completed update to %s" % new_file_version)
# remove downloaded file
os.remove(pciid_filename_new)
sys.exit(0)
if __name__ == "__main__":
main()