[PATCH] drm/amd/amdgpu: Test for PCI root bus before assuming bus->self

Yang Xiao YangX92 at hotmail.com
Tue Nov 27 03:33:35 UTC 2018


From: Young_X <YangX92 at hotmail.com>

    If we assign an amd device to a virtual mechine, we can no longer
    assume a fixed hardware topology, like the GPU having a parent device.
    This patch simply adds pci_is_root_bus() tests to avoid passing a
    NULL pointer to PCI access functions.

    See commit e79d5c0870ee ("drm/amdgpu: check before checking pci bridge
    registers") and commit 0bd252de78d4 ("radeon: Test for PCI root bus
    before assuming bus->self") for details.

Signed-off-by: Young_X <YangX92 at hotmail.com>
---
 drivers/gpu/drm/amd/amdgpu/cik.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c
index f41f5f5..8b51fa8 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik.c
@@ -1622,7 +1622,8 @@ static void cik_program_aspm(struct amdgpu_device *adev)
 			if (orig != data)
 				WREG32_PCIE(ixPCIE_LC_LINK_WIDTH_CNTL, data);
 
-			if (!disable_clkreq) {
+			if (!disable_clkreq &&
+			    !pci_is_root_bus(adev->pdev->bus)) {
 				struct pci_dev *root = adev->pdev->bus->self;
 				u32 lnkcap;
 
-- 
2.7.4



More information about the amd-gfx mailing list