Skip to contentSkip to conversation

drm/amdgpu: Workaround RCC_DEV0_EPF0_STRAP0 access issue for SRIOV

PATCH In review Rohit Khaire 2 participants 3 messages Sep 11, 2020 – Sep 21, 2020

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

PATCH 1/1 drm/amdgpu: Workaround RCC_DEV0_EPF0_STRAP0 access issue for SRIOV

---
 drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +13 -1
index 7429f30398b9..fdfa075e6d5a 100644
@@ -51,8 +51,20 @@ static void nbio_v2_3_remap_hdp_registers(struct amdgpu_device *adev)
 
 static u32 nbio_v2_3_get_rev_id(struct amdgpu_device *adev)
 {
-	u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
+	u32 tmp;
 
+	/*
+	 * On SRIOV VF RCC_DEV0_EPF0_STRAP is blocked.
+	 * So we read rev_id from PCI config space.
+	 */
+	if (amdgpu_sriov_vf(adev)) {
+		pci_read_config_dword(adev->pdev, PCI_REVISION_ID, &tmp);
+		/* Revision ID is the least significant 8 bits */
+		tmp &= 0xFF;
+		return tmp;
+	}
+
+	tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
 	tmp &= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0_MASK;
 	tmp >>= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0__SHIFT;
 
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw
Quoted 13 lines · Rohit Khaire
---
 drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0 -0
index 7429f30398b9..fdfa075e6d5a 100644
@@ -51,8 +51,20 @@ static void nbio_v2_3_remap_hdp_registers(struct amdgpu_device *adev)
 
 static u32 nbio_v2_3_get_rev_id(struct amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c static void nbio_v2_3_remap_hdp_registers(struct amdgpu_device *adev) · line 61

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +7 -1
 {
-       u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
+       u32 tmp;
 
+       /*
+        * On SRIOV VF RCC_DEV0_EPF0_STRAP is blocked.
+        * So we read rev_id from PCI config space.
+        */
+       if (amdgpu_sriov_vf(adev)) {
+               pci_read_config_dword(adev->pdev, PCI_REVISION_ID, &tmp);

This is not going to do what you want. The pci revision id is not the same as the ati rev id. If you actually want the pci revision id, we already have it in adev->pdev->revision, no need to fetch it directly.

Alex

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +6 -1
+               /* Revision ID is the least significant 8 bits */
+               tmp &= 0xFF;
+               return tmp;
+       }
+
+       tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
        tmp &= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0_MASK;
        tmp >>= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0__SHIFT;
 
--

2.17.1

Quoted 4 lines

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

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

#2 lore raw

[AMD Public Use]

Hi Alex,

I discussed this with my team, we are fine with PCI_REVISION_ID for SRIOV.

I am resending my patch with the change you suggested.

Thanks
Rohit

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: September 14, 2020 1:16 AM
To: Khaire, Rohit <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Workaround RCC_DEV0_EPF0_STRAP0 access issue for SRIOV

Quoted 14 lines · Rohit Khaire
---
 drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +0 -0
index 7429f30398b9..fdfa075e6d5a 100644
@@ -51,8 +51,20 @@ static void nbio_v2_3_remap_hdp_registers(struct 
 amdgpu_device *adev)
 

drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c static void nbio_v2_3_remap_hdp_registers(struct · line 61

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +7 -1
 static u32 nbio_v2_3_get_rev_id(struct amdgpu_device *adev)  {
-       u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
+       u32 tmp;
 
+       /*
+        * On SRIOV VF RCC_DEV0_EPF0_STRAP is blocked.
+        * So we read rev_id from PCI config space.
+        */
+       if (amdgpu_sriov_vf(adev)) {
+               pci_read_config_dword(adev->pdev, PCI_REVISION_ID, &tmp);

This is not going to do what you want. The pci revision id is not the same as the ati rev id. If you actually want the pci revision id, we already have it in adev->pdev->revision, no need to fetch it directly.

Alex

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +6 -1
+               /* Revision ID is the least significant 8 bits */
+               tmp &= 0xFF;
+               return tmp;
+       }
+
+       tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
        tmp &= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0_MASK;
        tmp >>= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0__SHIFT;
 
--

2.17.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Crohit.khaire%40amd.com%7C3f71c48028984d067a0208d8586d4528%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637356573621338868&amp;sdata=4Z0WFnTuSqp4NaCtUc%2B0iJcH5y%2FbRT9yTz6sP8vm8Vg%3D&amp;reserved=0

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