Skip to contentSkip to conversation

drm/amd/amdgpu: Add pcie indirect support to amdgpu_mm_wreg_mmio_rlc()

PATCH In review Tom St Denis 4 participants 6 messages Jan 7, 2022 – Jan 10, 2022

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

PATCH 1/1 drm/amd/amdgpu: Add pcie indirect support to amdgpu_mm_wreg_mmio_rlc()

The function amdgpu_mm_wreg_mmio_rlc() is used by debugfs to write to MMIO registers. It didn't support registers beyond the BAR mapped MMIO space. This adds pcie indirect write support.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
index c38e0e87090b..53a04095a6db 100644
@@ -552,7 +552,7 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,
 }
 
 /**
- * amdgpu_mm_wreg_mmio_rlc -  write register either with mmio or with RLC path if in range
+ * amdgpu_mm_wreg_mmio_rlc -  write register either with direct/indirect mmio or with RLC path if in range
  *
  * this function is invoked only the debugfs register access
  */
@@ -567,6 +567,8 @@ void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
 	    adev->gfx.rlc.funcs->is_rlcg_access_range) {
 		if (adev->gfx.rlc.funcs->is_rlcg_access_range(adev, reg))
 			return adev->gfx.rlc.funcs->sriov_wreg(adev, reg, v, 0, 0);
+	} else if ((reg * 4) >= adev->rmmio_size) {
+		adev->pcie_wreg(adev, reg * 4, v);
 	} else {
 		writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
 	}
Signature · 1 line
2.32.0
maintainer Acked-by on v1 1/1
#1 lore raw

[AMD Official Use Only]

________________________________
From: amd-gfx <[email protected]> on behalf of Tom St Denis <[email protected]>
Sent: Friday, January 7, 2022 7:07 AM
To: [email protected] <[email protected]>
Cc: StDenis, Tom <[email protected]>
Subject: [PATCH] drm/amd/amdgpu: Add pcie indirect support to amdgpu_mm_wreg_mmio_rlc()

The function amdgpu_mm_wreg_mmio_rlc() is used by debugfs to write to MMIO registers. It didn't support registers beyond the BAR mapped MMIO space. This adds pcie indirect write support.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
index c38e0e87090b..53a04095a6db 100644
@@ -552,7 +552,7 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,
 }
 
 /**
- * amdgpu_mm_wreg_mmio_rlc -  write register either with mmio or with RLC path if in range
+ * amdgpu_mm_wreg_mmio_rlc -  write register either with direct/indirect mmio or with RLC path if in range
  *
  * this function is invoked only the debugfs register access
  */
@@ -567,6 +567,8 @@ void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
             adev->gfx.rlc.funcs->is_rlcg_access_range) {
                 if (adev->gfx.rlc.funcs->is_rlcg_access_range(adev, reg))
                         return adev->gfx.rlc.funcs->sriov_wreg(adev, reg, v, 0, 0);
+       } else if ((reg * 4) >= adev->rmmio_size) {
+               adev->pcie_wreg(adev, reg * 4, v);
         } else {
                 writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
         }

--
2.32.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Tom St Denis

[AMD Official Use Only]

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tom St Denis
Sent: Friday, January 7, 2022 20:08
To: [email protected]
Cc: StDenis, Tom <[email protected]>
Subject: [PATCH] drm/amd/amdgpu: Add pcie indirect support to amdgpu_mm_wreg_mmio_rlc()

The function amdgpu_mm_wreg_mmio_rlc() is used by debugfs to write to MMIO registers. It didn't support registers beyond the BAR mapped MMIO space. This adds pcie indirect write support.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
index c38e0e87090b..53a04095a6db 100644
@@ -552,7 +552,7 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,  }
 
 /**
- * amdgpu_mm_wreg_mmio_rlc -  write register either with mmio or with RLC path if in range
+ * amdgpu_mm_wreg_mmio_rlc -  write register either with 
+ direct/indirect mmio or with RLC path if in range
  *
  * this function is invoked only the debugfs register access
  */
@@ -567,6 +567,8 @@ void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
 	    adev->gfx.rlc.funcs->is_rlcg_access_range) {
 		if (adev->gfx.rlc.funcs->is_rlcg_access_range(adev, reg))
 			return adev->gfx.rlc.funcs->sriov_wreg(adev, reg, v, 0, 0);
+	} else if ((reg * 4) >= adev->rmmio_size) {
+		adev->pcie_wreg(adev, reg * 4, v);
 	} else {
 		writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
 	}

--
2.32.0

#3 lore raw
In reply to Tom St Denis
Quoted 24 lines · Tom St Denis

The function amdgpu_mm_wreg_mmio_rlc() is used by debugfs to write to MMIO registers. It didn't support registers beyond the BAR mapped MMIO space. This adds pcie indirect write support.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
index c38e0e87090b..53a04095a6db 100644
@@ -552,7 +552,7 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,
 }
 
 /**
- * amdgpu_mm_wreg_mmio_rlc -  write register either with mmio or with RLC path if in range
+ * amdgpu_mm_wreg_mmio_rlc -  write register either with direct/indirect mmio or with RLC path if in range
  *
  * this function is invoked only the debugfs register access
  */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev, · line 571

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -567,6 +567,8 @@ void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
            adev->gfx.rlc.funcs->is_rlcg_access_range) {
                if (adev->gfx.rlc.funcs->is_rlcg_access_range(adev, reg))
                        return adev->gfx.rlc.funcs->sriov_wreg(adev, reg, v, 0, 0);
+       } else if ((reg * 4) >= adev->rmmio_size) {
+               adev->pcie_wreg(adev, reg * 4, v);

Actually, for older asics, we shouldn't we be using mmINDEX/mmDATA rather than the pcie indirect registers? Or is that handled already somehow?

Alex

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
        } else {
                writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
        }
--

2.32.0

#4 lore raw

[AMD Official Use Only]

RE - Actually, for older asics, we shouldn't we be using mmINDEX/mmDATA rather than the pcie indirect registers? Or is that handled already somehow?

I remember we checked this with hw team before (might two years ago when make the change in amdgpu_device_rreg/wreg helper). The answer was it is safe to retire mmINDEX/DATA approach for SI and onwards. PCIE_INDEX/DATA should be good enough for indirect access in amdgpu driver. For radeon driver, mmINDEX/mmDATA shall still be kept.

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Sunday, January 9, 2022 05:13
To: StDenis, Tom <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH] drm/amd/amdgpu: Add pcie indirect support to amdgpu_mm_wreg_mmio_rlc()

Quoted 27 lines · Tom St Denis

The function amdgpu_mm_wreg_mmio_rlc() is used by debugfs to write to MMIO registers. It didn't support registers beyond the BAR mapped MMIO space. This adds pcie indirect write support.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
index c38e0e87090b..53a04095a6db 100644
@@ -552,7 +552,7 @@ void amdgpu_device_wreg(struct amdgpu_device 
 *adev,  }
 
 /**
- * amdgpu_mm_wreg_mmio_rlc -  write register either with mmio or with 

RLC path if in range
+ * amdgpu_mm_wreg_mmio_rlc - write register either with
+ direct/indirect mmio or with RLC path if in range *
* this function is invoked only the debugfs register access */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev, · line 572

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -567,6 +567,8 @@ void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
            adev->gfx.rlc.funcs->is_rlcg_access_range) {
                if (adev->gfx.rlc.funcs->is_rlcg_access_range(adev, reg))
                        return adev->gfx.rlc.funcs->sriov_wreg(adev, 
 reg, v, 0, 0);
+       } else if ((reg * 4) >= adev->rmmio_size) {
+               adev->pcie_wreg(adev, reg * 4, v);

Actually, for older asics, we shouldn't we be using mmINDEX/mmDATA rather than the pcie indirect registers? Or is that handled already somehow?

Alex

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
        } else {
                writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
        }

--
2.32.0

#5 lore raw
Quoted 7 lines · Hawking

[AMD Official Use Only]

RE - Actually, for older asics, we shouldn't we be using mmINDEX/mmDATA rather than the pcie indirect registers? Or is that handled already somehow?

I remember we checked this with hw team before (might two years ago when make the change in amdgpu_device_rreg/wreg helper). The answer was it is safe to retire mmINDEX/DATA approach for SI and onwards. PCIE_INDEX/DATA should be good enough for indirect access in amdgpu driver. For radeon driver, mmINDEX/mmDATA shall still be kept.

Thanks for the confirmation.

Alex

Quoted 54 lines

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Sunday, January 9, 2022 05:13
To: StDenis, Tom <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH] drm/amd/amdgpu: Add pcie indirect support to amdgpu_mm_wreg_mmio_rlc()

Quoted 27 lines · Tom St Denis

The function amdgpu_mm_wreg_mmio_rlc() is used by debugfs to write to MMIO registers. It didn't support registers beyond the BAR mapped MMIO space. This adds pcie indirect write support.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
index c38e0e87090b..53a04095a6db 100644
@@ -552,7 +552,7 @@ void amdgpu_device_wreg(struct amdgpu_device
 *adev,  }
 
 /**
- * amdgpu_mm_wreg_mmio_rlc -  write register either with mmio or with

RLC path if in range
+ * amdgpu_mm_wreg_mmio_rlc - write register either with
+ direct/indirect mmio or with RLC path if in range *
* this function is invoked only the debugfs register access */

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev, · line 572

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -567,6 +567,8 @@ void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
            adev->gfx.rlc.funcs->is_rlcg_access_range) {
                if (adev->gfx.rlc.funcs->is_rlcg_access_range(adev, reg))
                        return adev->gfx.rlc.funcs->sriov_wreg(adev,
 reg, v, 0, 0);
+       } else if ((reg * 4) >= adev->rmmio_size) {
+               adev->pcie_wreg(adev, reg * 4, v);

Actually, for older asics, we shouldn't we be using mmINDEX/mmDATA rather than the pcie indirect registers? Or is that handled already somehow?

Alex

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
        } else {
                writel(v, ((void __iomem *)adev->rmmio) + (reg * 4));
        }

--
2.32.0