_PR3 detection was changed in commit 134b8c5d8674e ("drm/amd: Fix
detection of _PR3 on the PCIe root port") to look at the root port
of the topology containing the GPU.  This however was too far because
it ignored whether or not all the intermediary bridges could power
off the device.  The original design in commit b10c1c5b3a4e3 ("drm/amdgpu:
add check for ACPI power resources") was too narrow because it matched
the switches internal to the GPU.

Use the goldilocks approach and look for the first bridge outside of the
GPU and check for _PR3 on that device.

Fixes: 134b8c5d8674e ("drm/amd: Fix detection of _PR3 on the PCIe root port")
Signed-off-by: Mario Limonciello <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b6a24faaf78dd..7319467b11a94 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1939,7 +1939,6 @@ static struct pci_dev *amdgpu_device_find_parent(struct 
amdgpu_device *adev)
 static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)
 {
        struct amdgpu_ip_block *ip_block;
-       struct pci_dev *parent;
        bool total, skip_bios;
        uint32_t bios_flags;
        int i, r;
@@ -2026,10 +2025,8 @@ static int amdgpu_device_ip_early_init(struct 
amdgpu_device *adev)
            !dev_is_removable(&adev->pdev->dev))
                adev->flags |= AMD_IS_PX;
 
-       if (!(adev->flags & AMD_IS_APU)) {
-               parent = pcie_find_root_port(adev->pdev);
-               adev->has_pr3 = parent ? pci_pr3_present(parent) : false;
-       }
+       if (!(adev->flags & AMD_IS_APU))
+               adev->has_pr3 = 
pci_pr3_present(amdgpu_device_find_parent(adev));
 
        adev->pm.pp_feature = amdgpu_pp_feature_mask;
        if (amdgpu_sriov_vf(adev) || sched_policy == KFD_SCHED_POLICY_NO_HWS)
-- 
2.43.0

Reply via email to