The BAR0 fallback read path was introduced as a workaround for SR-IOV VFs
where the VRAM aperture is not available during early init. Restrict this
workaround to only SR-IOV VFs where it's needed.

Cc: [email protected]
Reported-by: [email protected]
Fixes: ea8ac194077d ("drm/amdgpu: reduce early full GPU access during SR-IOV 
init")
Signed-off-by: Mario Limonciello <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 3603f7109703c..251c4aea013fc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -765,6 +765,9 @@ static int amdgpu_device_read_fb_via_bar0(struct 
amdgpu_device *adev,
        if (!buf || !size)
                return -EINVAL;
 
+       if (!amdgpu_sriov_vf(adev))
+               return -EINVAL;
+
        flags = pci_resource_flags(adev->pdev, 0);
        if ((flags & IORESOURCE_UNSET) || !(flags & IORESOURCE_MEM))
                return -EINVAL;
-- 
2.43.0

Reply via email to