Use wrapper functions to set/indicate dpc status.

Signed-off-by: Lijo Lazar <lijo.la...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 17 ++++++++---------
 drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h  | 11 +++++++++++
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f4f80cb2f706..ea66322c279b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -5707,7 +5707,7 @@ int amdgpu_device_link_reset(struct amdgpu_device *adev)
 
        dev_info(adev->dev, "GPU link reset\n");
 
-       if (!adev->pcie_reset_ctx.occurs_dpc)
+       if (!amdgpu_reset_in_dpc(adev))
                ret = amdgpu_dpm_link_reset(adev);
 
        if (ret)
@@ -6158,7 +6158,7 @@ static void amdgpu_device_recovery_prepare(struct 
amdgpu_device *adev,
                        list_add_tail(&tmp_adev->reset_list, device_list);
                        if (adev->shutdown)
                                tmp_adev->shutdown = true;
-                       if (adev->pcie_reset_ctx.occurs_dpc)
+                       if (amdgpu_reset_in_dpc(adev))
                                tmp_adev->pcie_reset_ctx.in_link_reset = true;
                }
                if (!list_is_first(&adev->reset_list, device_list))
@@ -6234,9 +6234,8 @@ static void amdgpu_device_halt_activities(struct 
amdgpu_device *adev,
                drm_client_dev_suspend(adev_to_drm(tmp_adev), false);
 
                /* disable ras on ALL IPs */
-               if (!need_emergency_restart &&
-                     (!adev->pcie_reset_ctx.occurs_dpc) &&
-                     amdgpu_device_ip_need_full_reset(tmp_adev))
+               if (!need_emergency_restart && !amdgpu_reset_in_dpc(adev) &&
+                   amdgpu_device_ip_need_full_reset(tmp_adev))
                        amdgpu_ras_suspend(tmp_adev);
 
                for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
@@ -6264,10 +6263,10 @@ static int amdgpu_device_asic_reset(struct 
amdgpu_device *adev,
 
 retry: /* Rest of adevs pre asic reset from XGMI hive. */
        list_for_each_entry(tmp_adev, device_list, reset_list) {
-               if (adev->pcie_reset_ctx.occurs_dpc)
+               if (amdgpu_reset_in_dpc(adev))
                        tmp_adev->no_hw_access = true;
                r = amdgpu_device_pre_asic_reset(tmp_adev, reset_context);
-               if (adev->pcie_reset_ctx.occurs_dpc)
+               if (amdgpu_reset_in_dpc(adev))
                        tmp_adev->no_hw_access = false;
                /*TODO Should we stop ?*/
                if (r) {
@@ -6900,7 +6899,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev 
*pdev, pci_channel_sta
 
                if (hive)
                        mutex_lock(&hive->hive_lock);
-               adev->pcie_reset_ctx.occurs_dpc = true;
+               amdgpu_reset_set_dpc_status(adev, true);
                memset(&reset_context, 0, sizeof(reset_context));
                INIT_LIST_HEAD(&device_list);
 
@@ -7063,7 +7062,7 @@ void amdgpu_pci_resume(struct pci_dev *pdev)
        amdgpu_device_sched_resume(&device_list, NULL, NULL);
        amdgpu_device_gpu_resume(adev, &device_list, false);
        amdgpu_device_recovery_put_reset_lock(adev, &device_list);
-       adev->pcie_reset_ctx.occurs_dpc = false;
+       amdgpu_reset_set_dpc_status(adev, false);
 
        if (hive) {
                mutex_unlock(&hive->hive_lock);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h
index 4d9b9701139b..3a806953338f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h
@@ -160,4 +160,15 @@ int amdgpu_reset_do_xgmi_reset_on_init(
 
 bool amdgpu_reset_in_recovery(struct amdgpu_device *adev);
 
+static inline void amdgpu_reset_set_dpc_status(struct amdgpu_device *adev,
+                                              bool status)
+{
+       adev->pcie_reset_ctx.occurs_dpc = status;
+}
+
+static inline bool amdgpu_reset_in_dpc(struct amdgpu_device *adev)
+{
+       return adev->pcie_reset_ctx.occurs_dpc;
+}
+
 #endif
-- 
2.49.0

Reply via email to