Skip to contentSkip to conversation

drm/amd: Fix amdgpu_device_find_parent()

PATCH In review Mario Limonciello 2 participants 2 messages May 30 – Jun 1

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: Fix amdgpu_device_find_parent()

commit e4300be450453 ("drm/amd: Add dedicated helper for amdgpu_device_find_parent()") created a dedicated helper to find the parent device outside of the dGPU but it had a logic error that caused it to walk all the way up the topology and return the wrong device.

Break out of the loop when the device is found.

Fixes e4300be450453 ("drm/amd: Add dedicated helper for amdgpu_device_find_parent()")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index 5ff224163bab5..b82c6ef589557 100644
@@ -1921,6 +1921,7 @@ static struct pci_dev *amdgpu_device_find_parent(struct amdgpu_device *adev)
 	while ((parent = pci_upstream_bridge(parent))) {
 		if (parent->vendor == PCI_VENDOR_ID_ATI)
 			continue;
+		break;
 	}
 
 	return parent;
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Mario Limonciello

commit e4300be450453 ("drm/amd: Add dedicated helper for amdgpu_device_find_parent()") created a dedicated helper to find the parent device outside of the dGPU but it had a logic error that caused it to walk all the way up the topology and return the wrong device.

Break out of the loop when the device is found.

Fixes e4300be450453 ("drm/amd: Add dedicated helper for amdgpu_device_find_parent()")
Quoted 19 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index 5ff224163bab5..b82c6ef589557 100644
@@ -1921,6 +1921,7 @@ static struct pci_dev *amdgpu_device_find_parent(struct amdgpu_device *adev)
        while ((parent = pci_upstream_bridge(parent))) {
                if (parent->vendor == PCI_VENDOR_ID_ATI)
                        continue;
+               break;
        }
 
        return parent;
--

2.43.0