Skip to content

Commit

Permalink
Fix drm node file descriptor opening logic
Browse files Browse the repository at this point in the history
Fixes #157
  • Loading branch information
Syllo committed Aug 22, 2022
1 parent 8afaee4 commit cf613fb
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/extract_gpuinfo_amdgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,15 @@ static bool gpuinfo_amdgpu_get_device_handles(

int fd = -1;

for (unsigned int j = DRM_NODE_MAX - 1;; j--) {
if (!(1 << j & devs[i]->available_nodes))
continue;

if ((fd = open(devs[i]->nodes[j], O_RDWR)) < 0)
continue;

break;
// Try render node first
if (1 << DRM_NODE_RENDER & devs[i]->available_nodes) {
fd = open(devs[i]->nodes[DRM_NODE_RENDER], O_RDWR);
}
if (fd < 0) {
// Fallback to primary node (control nodes are unused according to the DRM documentation)
if (1 << DRM_NODE_PRIMARY & devs[i]->available_nodes) {
fd = open(devs[i]->nodes[DRM_NODE_PRIMARY], O_RDWR);
}
}

if (fd < 0)
Expand Down

0 comments on commit cf613fb

Please sign in to comment.