Commit 6c49103 1 parent 22c7523 commit 6c49103 Copy full SHA for 6c49103
File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,26 @@ GPUS::GPUS(overlay_params* params) : params(params) {
72
72
find_active_gpu ();
73
73
}
74
74
75
+ std::string GPU::is_i915_or_xe () {
76
+ std::string path = " /sys/bus/pci/devices/" ;
77
+ path += pci_dev + " /driver" ;
78
+
79
+ if (!fs::exists (path)) {
80
+ SPDLOG_ERROR (" {} doesn't exist" , path);
81
+ return " " ;
82
+ }
83
+
84
+ if (!fs::is_symlink (path)) {
85
+ SPDLOG_ERROR (" {} is not a symlink (it should be)" , path);
86
+ return " " ;
87
+ }
88
+
89
+ std::string driver = fs::read_symlink (path);
90
+ driver = driver.substr (driver.rfind (" /" ) + 1 );
91
+
92
+ return driver;
93
+ }
94
+
75
95
std::string GPUS::get_pci_device_address (const std::string& drm_card_path) {
76
96
// Resolve the symbolic link to get the actual device path
77
97
fs::path device_path = fs::canonical (fs::path (drm_card_path) / " device" );
Original file line number Diff line number Diff line change 17
17
#include " gpu_fdinfo.h"
18
18
19
19
class GPU {
20
+ private:
21
+ std::string is_i915_or_xe ();
22
+
20
23
public:
21
24
gpu_metrics metrics;
22
25
std::string name;
@@ -38,7 +41,7 @@ class GPU {
38
41
// For now we're only accepting one of these modules at once
39
42
// Might be possible that multiple can exist on a system in the future?
40
43
if (vendor_id == 0x8086 )
41
- fdinfo = std::make_unique<GPU_fdinfo>(" i915 " , pci_dev);
44
+ fdinfo = std::make_unique<GPU_fdinfo>(is_i915_or_xe () , pci_dev);
42
45
43
46
if (vendor_id == 0x5143 )
44
47
fdinfo = std::make_unique<GPU_fdinfo>(" msm" , pci_dev);
You can’t perform that action at this time.
0 commit comments