drm/amdgpu: Use correct VIEWPORT_DIMENSION for DCN2
Subsystems (2)
PATCH 1/1 drm/amdgpu: Use correct VIEWPORT_DIMENSION for DCN2
For some reason this file isn't using the appropriate register headers for DCN headers, which means that on DCN2 we're getting the VIEWPORT_DIMENSION offset wrong.
This means that we're not correctly carving out the framebuffer memory correctly for a framebuffer allocated by EFI and therefore see corruption when loading amdgpu before the display driver takes over control of the framebuffer scanout.
Fix this by checking the DCE_HWIP and picking the correct offset accordingly.
Long-term we should expose this info from DC as GMC shouldn't need to know about DCN registers.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +11 -1
@@ -72,6 +72,9 @@#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0 0x049d#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0_BASE_IDX 2 +#define DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION 0x05ea +#define DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_BASE_IDX 2 +static const char *gfxhub_client_ids[] = {"CB" ,
@@ -1142,7 +1145,6 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)switch (adev->ip_versions[DCE_HWIP ][0 ]) {case IP_VERSION (1 ,0 ,0 ):case IP_VERSION (1 ,0 ,1 ): -case IP_VERSION (2 ,1 ,0 ): viewport =RREG32_SOC15 (DCE ,0 , mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); size = (REG_GET_FIELD(viewport, HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_HEIGHT) *
@@ -1150,6 +1152,14 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev) HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_WIDTH) * 4);break ; +case IP_VERSION (2 ,1 ,0 ): + viewport =RREG32_SOC15 (DCE ,0 , DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); + size = (REG_GET_FIELD (viewport, +HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_HEIGHT ) * +REG_GET_FIELD (viewport, +HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_WIDTH ) * +4 ); +break ;default : viewport =RREG32_SOC15 (DCE ,0 , mmSCL0_VIEWPORT_SIZE); size = (REG_GET_FIELD(viewport, SCL0_VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
Signature · 1 line
2.34.1
Quoted 9 lines · Harry Wentland
For some reason this file isn't using the appropriate register headers for DCN headers, which means that on DCN2 we're getting the
VIEWPORT_DIMENSIONoffset wrong.This means that we're not correctly carving out the framebuffer memory correctly for a framebuffer allocated by EFI and therefore see corruption when loading amdgpu before the display driver takes over control of the framebuffer scanout.
Quoted 7 lines
Fix this by checking the
DCE_HWIPand picking the correct offset accordingly.Long-term we should expose this info from DC as GMC shouldn't need to know about DCN registers.
Signed-off-by Harry Wentland <[email protected]>
Look good for me, this patch needs to backport it to stable kernel (CC stable mailing list).
Quoted 44 lines
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +11
-1@@ -72,6 +72,9 @@#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0 0x049d#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0_BASE_IDX 2 +#define DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION 0x05ea +#define DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_BASE_IDX 2 +static const char *gfxhub_client_ids[] = {"CB" ,@@ -1142,7 +1145,6 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)switch (adev->ip_versions[DCE_HWIP ][0 ]) {case IP_VERSION (1 ,0 ,0 ):case IP_VERSION (1 ,0 ,1 ): -case IP_VERSION (2 ,1 ,0 ): viewport =RREG32_SOC15 (DCE ,0 , mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); size = (REG_GET_FIELD(viewport, HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_HEIGHT) *@@ -1150,6 +1152,14 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev) HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_WIDTH) * 4);break ; +case IP_VERSION (2 ,1 ,0 ): + viewport =RREG32_SOC15 (DCE ,0 , DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); + size = (REG_GET_FIELD (viewport, +HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_HEIGHT ) * +REG_GET_FIELD (viewport, +HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_WIDTH ) * +4 ); +break ;default : viewport =RREG32_SOC15 (DCE ,0 , mmSCL0_VIEWPORT_SIZE); size = (REG_GET_FIELD(viewport, SCL0_VIEWPORT_SIZE, VIEWPORT_HEIGHT) *Signature · 1 line
2.34.1
Christian König
maintainerAm 05.01.22 um 21:39 schrieb Harry Wentland:
Quoted 9 lines
For some reason this file isn't using the appropriate register headers for DCN headers, which means that on DCN2 we're getting the
VIEWPORT_DIMENSIONoffset wrong.This means that we're not correctly carving out the framebuffer memory correctly for a framebuffer allocated by EFI and therefore see corruption when loading amdgpu before the display driver takes over control of the framebuffer scanout.
Quoted 7 lines
Fix this by checking the
DCE_HWIPand picking the correct offset accordingly.Long-term we should expose this info from DC as GMC shouldn't need to know about DCN registers.
Signed-off-by Harry Wentland <[email protected]>
Please add a TODO comment that in the long run that code should be moved into DC.
With that done the patch is Acked-by: Christian König <[email protected]>.
Thanks,
Christian.
Quoted 41 lines
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +11
-1@@ -72,6 +72,9 @@#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0 0x049d#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0_BASE_IDX 2 +#define DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION 0x05ea +#define DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_BASE_IDX 2 +static const char *gfxhub_client_ids[] = {"CB" ,@@ -1142,7 +1145,6 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)switch (adev->ip_versions[DCE_HWIP ][0 ]) {case IP_VERSION (1 ,0 ,0 ):case IP_VERSION (1 ,0 ,1 ): -case IP_VERSION (2 ,1 ,0 ): viewport =RREG32_SOC15 (DCE ,0 , mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); size = (REG_GET_FIELD(viewport, HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_HEIGHT) *@@ -1150,6 +1152,14 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev) HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_WIDTH) * 4);break ; +case IP_VERSION (2 ,1 ,0 ): + viewport =RREG32_SOC15 (DCE ,0 , DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION); + size = (REG_GET_FIELD (viewport, +HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_HEIGHT ) * +REG_GET_FIELD (viewport, +HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION ,PRI_VIEWPORT_WIDTH ) * +4 ); +break ;default : viewport =RREG32_SOC15 (DCE ,0 , mmSCL0_VIEWPORT_SIZE); size = (REG_GET_FIELD(viewport, SCL0_VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
[Public]
Quoted 41 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Harry Wentland
Sent: Wednesday, January 5, 2022 3:39 PM
To: [email protected]; Koenig, Christian <[email protected]>; Lee, Becle <[email protected]>; Huang, Rex <[email protected]>; Huang, Ray <[email protected]>
Cc: Wentland, Harry <[email protected]>
Subject: [PATCH] drm/amdgpu: Use correctVIEWPORT_DIMENSIONfor DCN2For some reason this file isn't using the appropriate register headers for DCN headers, which means that on DCN2 we're getting the
VIEWPORT_DIMENSIONoffset wrong.This means that we're not correctly carving out the framebuffer memory correctly for a framebuffer allocated by EFI and therefore see corruption when loading amdgpu before the display driver takes over control of the framebuffer scanout.
Fix this by checking the
DCE_HWIPand picking the correct offset accordingly.Long-term we should expose this info from DC as GMC shouldn't need to know about DCN registers.
Signed-off-by Harry Wentland <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0@@ -72,6 +72,9 @@#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0
0x049d
#definemmDCHUBBUB_SDPIF_MMIO_CNTRL_0_BASE_IDX
2
Quoted 6 lines
+#define
DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION0x05ea
+#defineDCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_BASE_IDX2
+
We normally append the _DCN2 to the end in these cases of the macro. With that fixed,
Quoted 38 lines
static const char *gfxhub_client_ids[] = {
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-1"CB",@@ -1142,7 +1145,6 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev) switch (adev->ip_versions[DCE_HWIP][0]) {case IP_VERSION (1 ,0 ,0 ):case IP_VERSION (1 ,0 ,1 ): -case IP_VERSION (2 ,1 ,0 ): viewport =RREG32_SOC15 (DCE ,0 , mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION);size = (REG_GET_FIELD(viewport,
HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION,PRI_VIEWPORT_HEIGHT) *drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0@@ -1150,6 +1152,14 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)
HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION,PRI_VIEWPORT_WIDTH) *drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-04);break ; +case IP_VERSION (2 ,1 ,0 ): + viewport = RREG32_SOC15(DCE, 0,
DCN2_mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION);drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0+ size = (REG_GET_FIELD(viewport, +
HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION,PRI_VIEWPORT_HEIGHT) *drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0+ REG_GET_FIELD(viewport, +
HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION,PRI_VIEWPORT_WIDTH) *drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2
-0+ 4); +break ;default : viewport = RREG32_SOC15(DCE, 0,
mmSCL0_VIEWPORT_SIZE);
size = (REG_GET_FIELD(viewport,SCL0_VIEWPORT_SIZE,VIEWPORT_HEIGHT) *
--
2.34.1