The critical region v2 patches clear the fw_reserve.p_pf2vf variable after
pf2vf data is read the first time. have_atomics_support relies on that
variable to check for PCIe atomic ops support.

Move have_atomics_support check for SRIOV VFs to be when pf2vf data is
read.

Signed-off-by: Victor Lu <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++++++++------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c   |  3 ++
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 44091ac12fa9..42704dd8d790 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4012,24 +4012,21 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        }
 
        /* enable PCIE atomic ops */
-       if (amdgpu_sriov_vf(adev)) {
-               if (adev->virt.fw_reserve.p_pf2vf)
-                       adev->have_atomics_support = ((struct 
amd_sriov_msg_pf2vf_info *)
-                                                     
adev->virt.fw_reserve.p_pf2vf)->pcie_atomic_ops_support_flags ==
-                               (PCI_EXP_DEVCAP2_ATOMIC_COMP32 | 
PCI_EXP_DEVCAP2_ATOMIC_COMP64);
-       /* APUs w/ gfx9 onwards doesn't reply on PCIe atomics, rather it is a
-        * internal path natively support atomics, set have_atomics_support to 
true.
-        */
-       } else if ((adev->flags & AMD_IS_APU &&
-                  amdgpu_ip_version(adev, GC_HWIP, 0) > IP_VERSION(9, 0, 0)) ||
-                  (adev->gmc.xgmi.connected_to_cpu &&
-                  amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(12, 1, 
0))) {
-               adev->have_atomics_support = true;
-       } else {
-               adev->have_atomics_support =
-                       !pci_enable_atomic_ops_to_root(adev->pdev,
-                                         PCI_EXP_DEVCAP2_ATOMIC_COMP32 |
-                                         PCI_EXP_DEVCAP2_ATOMIC_COMP64);
+       if (!amdgpu_sriov_vf(adev)) {
+               /* APUs w/ gfx9 onwards doesn't reply on PCIe atomics, rather 
it is a
+                * internal path natively support atomics, set 
have_atomics_support to true.
+                */
+               if ((adev->flags & AMD_IS_APU &&
+                          amdgpu_ip_version(adev, GC_HWIP, 0) > IP_VERSION(9, 
0, 0)) ||
+                          (adev->gmc.xgmi.connected_to_cpu &&
+                          amdgpu_ip_version(adev, GC_HWIP, 0) >= 
IP_VERSION(12, 1, 0))) {
+                       adev->have_atomics_support = true;
+               } else {
+                       adev->have_atomics_support =
+                               !pci_enable_atomic_ops_to_root(adev->pdev,
+                                                 PCI_EXP_DEVCAP2_ATOMIC_COMP32 
|
+                                                 
PCI_EXP_DEVCAP2_ATOMIC_COMP64);
+               }
        }
 
        if (!adev->have_atomics_support)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 73169cb775f9..a454c6f12d38 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -652,6 +652,9 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device 
*adev)
                adev->virt.ras_en_caps.all = 
pf2vf->pf2vf_ras_caps.ras_en_caps.all;
                adev->virt.ras_telemetry_en_caps.all =
                        pf2vf->pf2vf_ras_caps.ras_telemetry_en_caps.all;
+
+               adev->have_atomics_support = 
pf2vf->pcie_atomic_ops_support_flags ==
+                       (PCI_EXP_DEVCAP2_ATOMIC_COMP32 | 
PCI_EXP_DEVCAP2_ATOMIC_COMP64);
                break;
        default:
                dev_err(adev->dev, "invalid pf2vf version: 0x%x\n", 
pf2vf_info->version);
-- 
2.34.1

Reply via email to