radeon: Test for PCI root bus before assuming bus->self
Subsystems (2)
PATCH 1/1 radeon: Test for PCI root bus before assuming bus->self
If we assign a Radeon device to a virtual machine, we can no longer assume a fixed hardware topology, like the GPU having a parent device. This patch simply adds a few pci_is_root_bus() tests to avoid passing a NULL pointer to PCI access functions, allowing the radeon driver to work in a QEMU 440FX machine with an assigned HD8570 on the emulated PCI root bus.
---
drivers/gpu/drm/radeon/cik.c | 6 +++++- drivers/gpu/drm/radeon/si.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/cik.c +5 -1
@@ -9555,6 +9555,9 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)int ret, i;u16 tmp16; +if (pci_is_root_bus (rdev->pdev->bus)) +return ; +if (radeon_pcie_gen2 ==0 )return ;
@@ -9781,7 +9784,8 @@ static void cik_program_aspm(struct radeon_device *rdev)if (orig != data)WREG32_PCIE_PORT (PCIE_LC_LINK_WIDTH_CNTL , data); -if (!disable_clkreq) { +if (!disable_clkreq && + !pci_is_root_bus (rdev->pdev->bus)) {struct pci_dev *root = rdev->pdev->bus->self;u32 lnkcap;
drivers/gpu/drm/radeon/si.c +5 -1
@@ -7177,6 +7177,9 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev)int ret, i;u16 tmp16; +if (pci_is_root_bus (rdev->pdev->bus)) +return ; +if (radeon_pcie_gen2 ==0 )return ;
@@ -7454,7 +7457,8 @@ static void si_program_aspm(struct radeon_device *rdev)if (orig != data)WREG32_PIF_PHY1 (PB1_PIF_CNTL , data); -if (!disable_clkreq) { +if (!disable_clkreq && + !pci_is_root_bus (rdev->pdev->bus)) {struct pci_dev *root = rdev->pdev->bus->self;u32 lnkcap;
Quoted 8 lines · Alex Williamson
If we assign a Radeon device to a virtual machine, we can no longer assume a fixed hardware topology, like the GPU having a parent device. This patch simply adds a few
pci_is_root_bus()tests to avoid passing a NULL pointer to PCI access functions, allowing the radeon driver to work in a QEMU 440FX machine with an assigned HD8570 on the emulated PCI root bus.Signed-off-by Alex Williamson <[email protected]>
Added to my -fixes queue. thanks!
Alex
Quoted 59 lines
---
drivers/gpu/drm/radeon/cik.c | 6 +++++- drivers/gpu/drm/radeon/si.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/cik.c +5
-1@@ -9555,6 +9555,9 @@ static void cik_pcie_gen3_enable(struct radeon_device *rdev)int ret, i;u16 tmp16; +if (pci_is_root_bus (rdev->pdev->bus)) +return ; +if (radeon_pcie_gen2 ==0 )return ;@@ -9781,7 +9784,8 @@ static void cik_program_aspm(struct radeon_device *rdev)if (orig != data)WREG32_PCIE_PORT (PCIE_LC_LINK_WIDTH_CNTL , data); -if (!disable_clkreq) { +if (!disable_clkreq && + !pci_is_root_bus (rdev->pdev->bus)) {struct pci_dev *root = rdev->pdev->bus->self;u32 lnkcap;drivers/gpu/drm/radeon/si.c +5
-1@@ -7177,6 +7177,9 @@ static void si_pcie_gen3_enable(struct radeon_device *rdev)int ret, i;u16 tmp16; +if (pci_is_root_bus (rdev->pdev->bus)) +return ; +if (radeon_pcie_gen2 ==0 )return ;@@ -7454,7 +7457,8 @@ static void si_program_aspm(struct radeon_device *rdev)if (orig != data)WREG32_PIF_PHY1 (PB1_PIF_CNTL , data); -if (!disable_clkreq) { +if (!disable_clkreq && + !pci_is_root_bus (rdev->pdev->bus)) {struct pci_dev *root = rdev->pdev->bus->self;u32 lnkcap;_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerQuoted 11 lines
Quoted 8 lines · Alex Williamson
If we assign a Radeon device to a virtual machine, we can no longer assume a fixed hardware topology, like the GPU having a parent device. This patch simply adds a few
pci_is_root_bus()tests to avoid passing a NULL pointer to PCI access functions, allowing the radeon driver to work in a QEMU 440FX machine with an assigned HD8570 on the emulated PCI root bus.Signed-off-by Alex Williamson <[email protected]>
Does this mean inside a VM we can't enable pcie 2 speeds?
This could lead to a quite disappointing speed decrease for DMA transfers.
Dave.
Quoted 9 lines · Dave Airlie
Quoted 9 lines
Quoted 7 lines · Alex Williamson
If we assign a Radeon device to a virtual machine, we can no longer assume a fixed hardware topology, like the GPU having a parent device. This patch simply adds a few
pci_is_root_bus()tests to avoid passing a NULL pointer to PCI access functions, allowing the radeon driver to work in a QEMU 440FX machine with an assigned HD8570 on the emulated PCI root bus.
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Alex Williamson <[email protected]>Does this mean inside a VM we can't enable pcie 2 speeds?
Shouldn't the device already be set to something reasonable before it's assigned?
Quoted 1 line
This could lead to a quite disappointing speed decrease for DMA transfers.
We couldn't do it before anyway, there's no decrease. Even with a Q35 QEMU chipset the best we were doing was tweaking dummy registers on the upstream port. Should VFIO be doing bus tuning prior to exposing the device? I suppose our other option would be to let the link control bits of the emulated downstream port pass through to the host. In any case, I don't see that this patch limits performance any more than it already is for a VM. Thanks,
Alex
Quoted 9 lines · Dave Airlie
Quoted 9 lines
Quoted 7 lines · Alex Williamson
If we assign a Radeon device to a virtual machine, we can no longer assume a fixed hardware topology, like the GPU having a parent device. This patch simply adds a few
pci_is_root_bus()tests to avoid passing a NULL pointer to PCI access functions, allowing the radeon driver to work in a QEMU 440FX machine with an assigned HD8570 on the emulated PCI root bus.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Alex Williamson <[email protected]>Does this mean inside a VM we can't enable pcie 2 speeds?
This could lead to a quite disappointing speed decrease for DMA transfers.
It depends on the sbios, but most boards negotiate the highest speed at boot.
Alex