Skip to contentSkip to conversation

drm amdgpu: Skip tmr load for SRIOV

PATCH In review Liu ChengZhe 3 participants 3 messages Jul 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm amdgpu: Skip tmr load for SRIOV

From: root <[email protected]>

1. For Navi12, CHIP_SIENNA_CICHLID, skip tmr load operation;
2. Check pointer before release firmware.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 40 +++++++++++++++++++++----
 1 file changed, 34 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +34 -6
index a053b7af0680..a9481e112cb3 100644
@@ -193,12 +193,18 @@ static int psp_sw_fini(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	psp_memory_training_fini(&adev->psp);
-	release_firmware(adev->psp.sos_fw);
-	adev->psp.sos_fw = NULL;
-	release_firmware(adev->psp.asd_fw);
-	adev->psp.asd_fw = NULL;
-	release_firmware(adev->psp.ta_fw);
-	adev->psp.ta_fw = NULL;
+	if (adev->psp.sos_fw) {
+		release_firmware(adev->psp.sos_fw);
+		adev->psp.sos_fw = NULL;
+	}
+	if (adev->psp.asd_fw) {
+		release_firmware(adev->psp.asd_fw);
+		adev->psp.asd_fw = NULL;
+	}
+	if (adev->psp.ta_fw) {
+		release_firmware(adev->psp.ta_fw);
+		adev->psp.ta_fw = NULL;
+	}
 
 	if (adev->asic_type == CHIP_NAVI10)
 		psp_sysfs_fini(adev);
@@ -409,11 +415,33 @@ static int psp_clear_vf_fw(struct psp_context *psp)
 	return ret;
 }
 
+static bool psp_skip_tmr(struct psp_context *psp)
+{
+	bool ret = false;
+
+	switch (psp->adev->asic_type) {
+	case CHIP_NAVI12:
+	case CHIP_SIENNA_CICHLID:
+		ret = true;
+		break;
+	default:
+		return false;
+	}
+
+	return ret;
+}
+
 static int psp_tmr_load(struct psp_context *psp)
 {
 	int ret;
 	struct psp_gfx_cmd_resp *cmd;
 
+	/* for Navi12 and CHIP_SIENNA_CICHLID SRIOV, do not setup TMR
+	 * (already setup by host driver)
+	 */
+	if (amdgpu_sriov_vf(psp->adev) && psp_skip_tmr(psp))
+		return 0;
+
 	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 	if (!cmd)
 		return -ENOMEM;
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

[AMD Official Use Only - Internal Distribution Only]

Please fix your git setup to use your name rather than "root" as the author.

Alex

________________________________
From: Liu ChengZhe <[email protected]>
Sent: Monday, July 27, 2020 6:57 AM
To: [email protected] <[email protected]>
Cc: Tuikov, Luben <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>; Xiao, Jack <[email protected]>; Zhang, Hawking <[email protected]>; Xu, Feifei <[email protected]>; Wang, Kevin(Yang) <[email protected]>; Yuan, Xiaojie <[email protected]>; Liu, Cheng Zhe <[email protected]>
Subject: [PATCH 1/2] drm amdgpu: Skip tmr load for SRIOV

From: root <[email protected]>

1. For Navi12, CHIP_SIENNA_CICHLID, skip tmr load operation;
2. Check pointer before release firmware.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 40 +++++++++++++++++++++----
 1 file changed, 34 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +34 -6
index a053b7af0680..a9481e112cb3 100644
@@ -193,12 +193,18 @@ static int psp_sw_fini(void *handle)
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
         psp_memory_training_fini(&adev->psp);
-       release_firmware(adev->psp.sos_fw);
-       adev->psp.sos_fw = NULL;
-       release_firmware(adev->psp.asd_fw);
-       adev->psp.asd_fw = NULL;
-       release_firmware(adev->psp.ta_fw);
-       adev->psp.ta_fw = NULL;
+       if (adev->psp.sos_fw) {
+               release_firmware(adev->psp.sos_fw);
+               adev->psp.sos_fw = NULL;
+       }
+       if (adev->psp.asd_fw) {
+               release_firmware(adev->psp.asd_fw);
+               adev->psp.asd_fw = NULL;
+       }
+       if (adev->psp.ta_fw) {
+               release_firmware(adev->psp.ta_fw);
+               adev->psp.ta_fw = NULL;
+       }
 
         if (adev->asic_type == CHIP_NAVI10)
                 psp_sysfs_fini(adev);
@@ -409,11 +415,33 @@ static int psp_clear_vf_fw(struct psp_context *psp)
         return ret;
 }
 
+static bool psp_skip_tmr(struct psp_context *psp)
+{
+       bool ret = false;
+
+       switch (psp->adev->asic_type) {
+       case CHIP_NAVI12:
+       case CHIP_SIENNA_CICHLID:
+               ret = true;
+               break;
+       default:
+               return false;
+       }
+
+       return ret;
+}
+
 static int psp_tmr_load(struct psp_context *psp)
 {
         int ret;
         struct psp_gfx_cmd_resp *cmd;
 
+       /* for Navi12 and CHIP_SIENNA_CICHLID SRIOV, do not setup TMR
+        * (already setup by host driver)
+        */
+       if (amdgpu_sriov_vf(psp->adev) && psp_skip_tmr(psp))
+               return 0;
+
         cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
         if (!cmd)
                 return -ENOMEM;

--
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw
In reply to Liu ChengZhe
Quoted 48 lines · Liu ChengZhe

From: root <[email protected]>

1. For Navi12, CHIP_SIENNA_CICHLID, skip tmr load operation;
2. Check pointer before release firmware.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 40 +++++++++++++++++++++----
 1 file changed, 34 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +17 -6
index a053b7af0680..a9481e112cb3 100644
@@ -193,12 +193,18 @@ static int psp_sw_fini(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	psp_memory_training_fini(&adev->psp);
-	release_firmware(adev->psp.sos_fw);
-	adev->psp.sos_fw = NULL;
-	release_firmware(adev->psp.asd_fw);
-	adev->psp.asd_fw = NULL;
-	release_firmware(adev->psp.ta_fw);
-	adev->psp.ta_fw = NULL;
+	if (adev->psp.sos_fw) {
+		release_firmware(adev->psp.sos_fw);
+		adev->psp.sos_fw = NULL;
+	}
+	if (adev->psp.asd_fw) {
+		release_firmware(adev->psp.asd_fw);
+		adev->psp.asd_fw = NULL;
+	}
+	if (adev->psp.ta_fw) {
+		release_firmware(adev->psp.ta_fw);
+		adev->psp.ta_fw = NULL;
+	}
 
 	if (adev->asic_type == CHIP_NAVI10)
 		psp_sysfs_fini(adev);
@@ -409,11 +415,33 @@ static int psp_clear_vf_fw(struct psp_context *psp)
 	return ret;
 }
 
+static bool psp_skip_tmr(struct psp_context *psp)
+{
+	bool ret = false;
+
+	switch (psp->adev->asic_type) {

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_clear_vf_fw(struct psp_context *psp) · line 432

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +10 -0
+	case CHIP_NAVI12:
+	case CHIP_SIENNA_CICHLID:
+		ret = true;
+		break;
+	default:
+		return false;
+	}
+
+	return ret;
+}

There's no need for the local "bool ret". Remove it. See in the "default:" case you already do "return false;". Do "return true;" in the NAVI12 and SIENNA CICHLID case.

Regards,
Luben

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -0
+
 static int psp_tmr_load(struct psp_context *psp)
 {
 	int ret;
 	struct psp_gfx_cmd_resp *cmd;

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_clear_vf_fw(struct psp_context *psp) · line 447

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -0
 
+	/* for Navi12 and CHIP_SIENNA_CICHLID SRIOV, do not setup TMR
+	 * (already setup by host driver)
+	 */
+	if (amdgpu_sriov_vf(psp->adev) && psp_skip_tmr(psp))
+		return 0;
+
 	cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 	if (!cmd)
 		return -ENOMEM;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx