Skip to contentSkip to conversation

drm/amdgpu: Restore partition mode after reset

PATCH In review Lijo Lazar 3 participants 3 messages Sep 8, 2023 – Sep 11, 2023

Subsystems (2)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Restore partition mode after reset

On a full device reset, PSP FW gets unloaded. Hence restore the partition mode by placing a new request.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  5 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c    | 28 ++++++++++++++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h    |  1 +
 drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c |  2 +-
 4 files changed, 28 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
index 5f32e8d4f3d3..5d2b6a7c5f6e 100644
@@ -5115,6 +5115,11 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
 				if (r)
 					return r;
 
+				r = amdgpu_xcp_restore_partition_mode(
+					tmp_adev->xcp_mgr);
+				if (r)
+					goto out;
+
 				r = amdgpu_device_ip_resume_phase2(tmp_adev);
 				if (r)
 					goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +21 -7
index 565a1fa436d4..2b99eed5ba19 100644
@@ -163,16 +163,11 @@ int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode)
 	return 0;
 }
 
-int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode)
+static int __amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr,
+					      int mode)
 {
 	int ret, curr_mode, num_xcps = 0;
 
-	if (!xcp_mgr || mode == AMDGPU_XCP_MODE_NONE)
-		return -EINVAL;
-
-	if (xcp_mgr->mode == mode)
-		return 0;
-
 	if (!xcp_mgr->funcs || !xcp_mgr->funcs->switch_partition_mode)
 		return 0;
 
@@ -201,6 +196,25 @@ int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode)
 	return ret;
 }
 
+int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode)
+{
+	if (!xcp_mgr || mode == AMDGPU_XCP_MODE_NONE)
+		return -EINVAL;
+
+	if (xcp_mgr->mode == mode)
+		return 0;
+
+	return __amdgpu_xcp_switch_partition_mode(xcp_mgr, mode);
+}
+
+int amdgpu_xcp_restore_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr)
+{
+	if (!xcp_mgr || xcp_mgr->mode == AMDGPU_XCP_MODE_NONE)
+		return 0;
+
+	return __amdgpu_xcp_switch_partition_mode(xcp_mgr, xcp_mgr->mode);
+}
+
 int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)
 {
 	int mode;
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h +1 -0
index 9a1036aeec2a..90138bc5f03d 100644
@@ -129,6 +129,7 @@ int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode,
 int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode);
 int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags);
 int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode);
+int amdgpu_xcp_restore_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr);
 int amdgpu_xcp_get_partition(struct amdgpu_xcp_mgr *xcp_mgr,
 			     enum AMDGPU_XCP_IP_BLOCK ip, int instance);
 
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +1 -1
index d0fc62784e82..3f715e7fe1a9 100644
@@ -500,7 +500,7 @@ static int aqua_vanjaram_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr,
 		return -EINVAL;
 	}
 
-	if (adev->kfd.init_complete)
+	if (adev->kfd.init_complete && !amdgpu_in_reset(adev))
 		flags |= AMDGPU_XCP_OPS_KFD;
 
 	if (flags & AMDGPU_XCP_OPS_KFD) {
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Lijo Lazar

On a full device reset, PSP FW gets unloaded. Hence restore the partition mode by placing a new request.

Quoted 100 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  5 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c    | 28 ++++++++++++++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h    |  1 +
 drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c |  2 +-
 4 files changed, 28 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
index 5f32e8d4f3d3..5d2b6a7c5f6e 100644
@@ -5115,6 +5115,11 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
                                if (r)
                                        return r;
 
+                               r = amdgpu_xcp_restore_partition_mode(
+                                       tmp_adev->xcp_mgr);
+                               if (r)
+                                       goto out;
+
                                r = amdgpu_device_ip_resume_phase2(tmp_adev);
                                if (r)
                                        goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +21 -7
index 565a1fa436d4..2b99eed5ba19 100644
@@ -163,16 +163,11 @@ int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode)
        return 0;
 }
 
-int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode)
+static int __amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr,
+                                             int mode)
 {
        int ret, curr_mode, num_xcps = 0;
 
-       if (!xcp_mgr || mode == AMDGPU_XCP_MODE_NONE)
-               return -EINVAL;
-
-       if (xcp_mgr->mode == mode)
-               return 0;
-
        if (!xcp_mgr->funcs || !xcp_mgr->funcs->switch_partition_mode)
                return 0;
 
@@ -201,6 +196,25 @@ int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode)
        return ret;
 }
 
+int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode)
+{
+       if (!xcp_mgr || mode == AMDGPU_XCP_MODE_NONE)
+               return -EINVAL;
+
+       if (xcp_mgr->mode == mode)
+               return 0;
+
+       return __amdgpu_xcp_switch_partition_mode(xcp_mgr, mode);
+}
+
+int amdgpu_xcp_restore_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr)
+{
+       if (!xcp_mgr || xcp_mgr->mode == AMDGPU_XCP_MODE_NONE)
+               return 0;
+
+       return __amdgpu_xcp_switch_partition_mode(xcp_mgr, xcp_mgr->mode);
+}
+
 int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)
 {
        int mode;
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h +1 -0
index 9a1036aeec2a..90138bc5f03d 100644
@@ -129,6 +129,7 @@ int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode,
 int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode);
 int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags);
 int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode);
+int amdgpu_xcp_restore_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr);
 int amdgpu_xcp_get_partition(struct amdgpu_xcp_mgr *xcp_mgr,
                             enum AMDGPU_XCP_IP_BLOCK ip, int instance);
 
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +1 -2
index d0fc62784e82..3f715e7fe1a9 100644
@@ -500,7 +500,7 @@ static int aqua_vanjaram_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr,
                return -EINVAL;
        }
 
-       if (adev->kfd.init_complete)
+       if (adev->kfd.init_complete && !amdgpu_in_reset(adev))
                flags |= AMDGPU_XCP_OPS_KFD;
 
        if (flags & AMDGPU_XCP_OPS_KFD) {
--

2.25.1

Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Lijo Lazar

[AMD Official Use Only - General]

Thanks & Regards
Asad

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, September 8, 2023 4:10 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>
Subject: [PATCH] drm/amdgpu: Restore partition mode after reset

On a full device reset, PSP FW gets unloaded. Hence restore the partition mode by placing a new request.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  5 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c    | 28 ++++++++++++++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h    |  1 +
 drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c |  2 +-
 4 files changed, 28 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
index 5f32e8d4f3d3..5d2b6a7c5f6e 100644
@@ -5115,6 +5115,11 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
                                if (r)
                                        return r;
 
+                               r = amdgpu_xcp_restore_partition_mode(
+                                       tmp_adev->xcp_mgr);
+                               if (r)
+                                       goto out;
+
                                r = amdgpu_device_ip_resume_phase2(tmp_adev);
                                if (r)
                                        goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +18 -7
index 565a1fa436d4..2b99eed5ba19 100644
@@ -163,16 +163,11 @@ int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode)
        return 0;
 }
 
-int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode)
+static int __amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr,
+                                             int mode)
 {
        int ret, curr_mode, num_xcps = 0;
 
-       if (!xcp_mgr || mode == AMDGPU_XCP_MODE_NONE)
-               return -EINVAL;
-
-       if (xcp_mgr->mode == mode)
-               return 0;
-
        if (!xcp_mgr->funcs || !xcp_mgr->funcs->switch_partition_mode)
                return 0;
 
@@ -201,6 +196,25 @@ int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode)
        return ret;
 }
 
+int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr,
+int mode) {
+       if (!xcp_mgr || mode == AMDGPU_XCP_MODE_NONE)
+               return -EINVAL;
+
+       if (xcp_mgr->mode == mode)
+               return 0;
+
+       return __amdgpu_xcp_switch_partition_mode(xcp_mgr, mode); }
+
+int amdgpu_xcp_restore_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr) {
+       if (!xcp_mgr || xcp_mgr->mode == AMDGPU_XCP_MODE_NONE)
+               return 0;
+
+       return __amdgpu_xcp_switch_partition_mode(xcp_mgr, xcp_mgr->mode); }
+
 int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags)  {
        int mode;
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h +1 -0
index 9a1036aeec2a..90138bc5f03d 100644
@@ -129,6 +129,7 @@ int amdgpu_xcp_mgr_init(struct amdgpu_device *adev, int init_mode,  int amdgpu_xcp_init(struct amdgpu_xcp_mgr *xcp_mgr, int num_xcps, int mode);  int amdgpu_xcp_query_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, u32 flags);  int amdgpu_xcp_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr, int mode);
+int amdgpu_xcp_restore_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr);
 int amdgpu_xcp_get_partition(struct amdgpu_xcp_mgr *xcp_mgr,
                             enum AMDGPU_XCP_IP_BLOCK ip, int instance);
 
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c +1 -1
index d0fc62784e82..3f715e7fe1a9 100644
@@ -500,7 +500,7 @@ static int aqua_vanjaram_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr,
                return -EINVAL;
        }
 
-       if (adev->kfd.init_complete)
+       if (adev->kfd.init_complete && !amdgpu_in_reset(adev))
                flags |= AMDGPU_XCP_OPS_KFD;
 
        if (flags & AMDGPU_XCP_OPS_KFD) {

--
2.25.1