Skip to content

Commit

Permalink
Merge branch 'fix_amdgpu_device_handle_segfault'
Browse files Browse the repository at this point in the history
  • Loading branch information
Syllo committed Aug 23, 2022
2 parents 8afaee4 + cf613fb commit 7c7059a
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 7c7059a

Please sign in to comment.