Skip to contentSkip to conversation

drm/amdgpu: Use correct VIEWPORT_DIMENSION for DCN2

PATCH In review Mario Limonciello 2 participants 5 messages Jan 25, 2022 – Jan 27, 2022

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

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.

(cherry picked from commit dc5d4aff2e99c312df8abbe1ee9a731d2913bc1b)

---
This is backported from 5.17-rc1, but doesn't backport cleanly because v5.16 changed to IP version harvesting for ASIC detection. 5.15.y doesn't have this.

 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +13 -1
index 5551359d5dfd..a4adbbf3acab 100644
@@ -72,6 +72,9 @@
 #define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0                                                                  0x049d
 #define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0_BASE_IDX                                                         2
 
+#define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_DCN2                                                          0x05ea
+#define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_DCN2_BASE_IDX                                                 2
+
 
 static const char *gfxhub_client_ids[] = {
 	"CB",
@@ -1103,6 +1106,8 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)
 	u32 d1vga_control = RREG32_SOC15(DCE, 0, mmD1VGA_CONTROL);
 	unsigned size;
 
+	/* TODO move to DC so GMC doesn't need to hard-code DCN registers */
+
 	if (REG_GET_FIELD(d1vga_control, D1VGA_CONTROL, D1VGA_MODE_ENABLE)) {
 		size = AMDGPU_VBIOS_VGA_ALLOCATION;
 	} else {
@@ -1110,7 +1115,6 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct amdgpu_device *adev)
 
 		switch (adev->asic_type) {
 		case CHIP_RAVEN:
-		case CHIP_RENOIR:
 			viewport = RREG32_SOC15(DCE, 0, mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION);
 			size = (REG_GET_FIELD(viewport,
 					      HUBP0_DCSURF_PRI_VIEWPORT_DIMENSION, PRI_VIEWPORT_HEIGHT) *
@@ -1118,6 +1122,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 CHIP_RENOIR:
+			viewport = RREG32_SOC15(DCE, 0, mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_DCN2);
+			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;
 		case CHIP_VEGA10:
 		case CHIP_VEGA12:
 		case CHIP_VEGA20:
Signature · 1 line
2.25.1
#1 lore raw

[Public]

Quoted 24 lines

-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Tuesday, January 25, 2022 09:21
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH] 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.

Quoted 8 lines
(cherry picked from commit dc5d4aff2e99c312df8abbe1ee9a731d2913bc1b)

---
This is backported from 5.17-rc1, but doesn't backport cleanly because v5.16 changed to IP version harvesting for ASIC detection. 5.15.y doesn't have this.

 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

One more comment - dc5d4aff2e99c3 backports cleanly to 5.16.y. So it should just be a straightforward cherry-pick in 5.16.y, this special modification only for 5.15.y.

Quoted 65 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -0
index 5551359d5dfd..a4adbbf3acab 100644
@@ -72,6 +72,9 @@
 #define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0

0x049d
#define mmDCHUBBUB_SDPIF_MMIO_CNTRL_0_BASE_IDX
2

+#define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_DCN2 0x05ea
+#define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_DCN2_BASE_IDX 2

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -0
+
 
 static const char *gfxhub_client_ids[] = {
 	"CB",
@@ -1103,6 +1106,8 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct
 amdgpu_device *adev)
 	u32 d1vga_control = RREG32_SOC15(DCE, 0, mmD1VGA_CONTROL);
 	unsigned size;
 
+	/* TODO move to DC so GMC doesn't need to hard-code DCN registers
 */
+
 	if (REG_GET_FIELD(d1vga_control, D1VGA_CONTROL,

D1VGA_MODE_ENABLE)) {

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0 -1
 		size = AMDGPU_VBIOS_VGA_ALLOCATION;
 	} else {
@@ -1110,7 +1115,6 @@ static unsigned gmc_v9_0_get_vbios_fb_size(struct
 amdgpu_device *adev)
 
 		switch (adev->asic_type) {
 		case CHIP_RAVEN:
-		case CHIP_RENOIR:
 			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
@@ -1118,6 +1122,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 -0
 				4);
 			break;
+		case CHIP_RENOIR:
+			viewport = RREG32_SOC15(DCE, 0,

mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_DCN2);

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 -1
+				4);
+			break;
 		case CHIP_VEGA10:
 		case CHIP_VEGA12:
 		case CHIP_VEGA20:
--

2.25.1

maintainer
#2 lore raw
In reply to Mario Limonciello
Quoted 15 lines · Mario Limonciello

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.

Quoted 8 lines
(cherry picked from commit dc5d4aff2e99c312df8abbe1ee9a731d2913bc1b)

---
This is backported from 5.17-rc1, but doesn't backport cleanly because v5.16 changed to IP version harvesting for ASIC detection. 5.15.y doesn't have this.

 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

What stable tree(s) do you want this applied to?

And what happened to the original signed-off-by's on the original commit?

thanks,

greg k-h

#3 lore raw

[Public]

Quoted 35 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: Tuesday, January 25, 2022 09:50
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Use correct VIEWPORT_DIMENSION for DCN2

Quoted 15 lines · Mario Limonciello

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.

Quoted 8 lines
(cherry picked from commit dc5d4aff2e99c312df8abbe1ee9a731d2913bc1b)

---
This is backported from 5.17-rc1, but doesn't backport cleanly because v5.16 changed to IP version harvesting for ASIC detection. 5.15.y doesn't have this.

 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
Quoted 2 lines

What stable tree(s) do you want this applied to?

The original commit it was cherry-picked from was CC to @stable and it should have applied to 5.16 from that.

This fixed commit should go into 5.15.y.

Quoted 2 lines

And what happened to the original signed-off-by's on the original commit?

I dropped them because I had to change code to do the backport, it didn't seem reasonable to me to keep all of their ACK's/signed-off-by's on the code still.

If that's incorrect, please let me know and I can re-send with the exact same commit message.

Quoted 4 lines

thanks,

greg k-h

maintainer
#4 lore raw
Quoted 37 lines · Mario

[Public]

Quoted 35 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: Tuesday, January 25, 2022 09:50
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Use correct VIEWPORT_DIMENSION for DCN2

Quoted 23 lines · Mario Limonciello

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.

(cherry picked from commit dc5d4aff2e99c312df8abbe1ee9a731d2913bc1b)

---
This is backported from 5.17-rc1, but doesn't backport cleanly because v5.16 changed to IP version harvesting for ASIC detection. 5.15.y doesn't have this.

 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
Quoted 7 lines
Quoted 2 lines

What stable tree(s) do you want this applied to?

The original commit it was cherry-picked from was CC to @stable and it should have applied to 5.16 from that.

This fixed commit should go into 5.15.y.

Thanks, now queued up.

Quoted 7 lines
Quoted 2 lines

And what happened to the original signed-off-by's on the original commit?

I dropped them because I had to change code to do the backport, it didn't seem reasonable to me to keep all of their ACK's/signed-off-by's on the code still.

If that's incorrect, please let me know and I can re-send with the exact same commit message.

Please keep them. I've fixed this up for now, so no need for a resend.

thanks,

greg k-h