Skip to contentSkip to conversation

drm/amdgpu: Fix SDMA UTC_L1 handling during start/stop sequences

PATCH In review Jesse Zhang 3 participants 5 messages Jun 16, 2025

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

PATCH v2 1/1 drm/amdgpu: Fix SDMA UTC_L1 handling during start/stop sequences

This commit makes two key fixes to SDMA v4.4.2 handling:

1. disable UTC_L1 in sdma_cntl register when stopping SDMA engines by reading the current value before modifying UTC_L1_ENABLE bit.

2. Ensure UTC_L1_ENABLE is consistently managed by:
- Adding the missing register write when enabling UTC_L1 during start
- Keeping UTC_L1 enabled by default as per hardware requirements

Fixes the commit 7f03b1d14d51 ("drm/amdgpu:
Remove sdma halt/unhalt during frontdoor load") by maintaining proper SDMA controller state during initialization sequences.

v2: Correct SDMA_CNTL setting (Philip)

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +5 -1
index e6af50c947a1..52157acab55a 100644
@@ -492,7 +492,7 @@ static void sdma_v4_4_2_inst_gfx_stop(struct amdgpu_device *adev,
 {
 	struct amdgpu_ring *sdma[AMDGPU_MAX_SDMA_INSTANCES];
 	u32 doorbell_offset, doorbell;
-	u32 rb_cntl, ib_cntl;
+	u32 rb_cntl, ib_cntl, sdma_cntl;
 	int i;
 
 	for_each_inst(i, inst_mask) {
@@ -504,6 +504,9 @@ static void sdma_v4_4_2_inst_gfx_stop(struct amdgpu_device *adev,
 		ib_cntl = RREG32_SDMA(i, regSDMA_GFX_IB_CNTL);
 		ib_cntl = REG_SET_FIELD(ib_cntl, SDMA_GFX_IB_CNTL, IB_ENABLE, 0);
 		WREG32_SDMA(i, regSDMA_GFX_IB_CNTL, ib_cntl);
+		sdma_cntl = RREG32_SDMA(i, SDMA_CNTL);
+		sdma_cntl = REG_SET_FIELD(sdma_cntl, SDMA_CNTL, UTC_L1_ENABLE, 0);
+		WREG32_SDMA(i, regSDMA_CNTL, sdma_cntl);
 
 		if (sdma[i]->use_doorbell) {
 			doorbell = RREG32_SDMA(i, regSDMA_GFX_DOORBELL);
@@ -997,6 +1000,7 @@ static int sdma_v4_4_2_inst_start(struct amdgpu_device *adev,
 		/* set utc l1 enable flag always to 1 */
 		temp = RREG32_SDMA(i, regSDMA_CNTL);
 		temp = REG_SET_FIELD(temp, SDMA_CNTL, UTC_L1_ENABLE, 1);
+		WREG32_SDMA(i, regSDMA_CNTL, temp);
 
 		if (amdgpu_ip_version(adev, SDMA0_HWIP, 0) < IP_VERSION(4, 4, 5)) {
 			/* enable context empty interrupt during initialization */
Signature · 1 line
2.34.1
Acked-by on v2 1/1
#1 lore raw
Quoted 6 lines · Jesse Zhang

This commit makes two key fixes to SDMA v4.4.2 handling:

1. disable UTC_L1 in sdma_cntl register when stopping SDMA engines by reading the current value before modifying UTC_L1_ENABLE bit.

Quoted 7 lines

2. Ensure UTC_L1_ENABLE is consistently managed by:
- Adding the missing register write when enabling UTC_L1 during start
- Keeping UTC_L1 enabled by default as per hardware requirements

Fixes the commit 7f03b1d14d51 ("drm/amdgpu:
Remove sdma halt/unhalt during frontdoor load") by maintaining proper SDMA controller state during initialization sequences.

Proper fixes tag formatting:

Fixes 7f03b1d14d51 ("drm/amdgpu: Remove sdma halt/unhalt during

frontdoor load")

Quoted 5 lines

v2: Correct SDMA_CNTL setting (Philip)

Quoted 38 lines
---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +5 -2
index e6af50c947a1..52157acab55a 100644
@@ -492,7 +492,7 @@ static void sdma_v4_4_2_inst_gfx_stop(struct amdgpu_device *adev,
 {
        struct amdgpu_ring *sdma[AMDGPU_MAX_SDMA_INSTANCES];
        u32 doorbell_offset, doorbell;
-       u32 rb_cntl, ib_cntl;
+       u32 rb_cntl, ib_cntl, sdma_cntl;
        int i;
 
        for_each_inst(i, inst_mask) {
@@ -504,6 +504,9 @@ static void sdma_v4_4_2_inst_gfx_stop(struct amdgpu_device *adev,
                ib_cntl = RREG32_SDMA(i, regSDMA_GFX_IB_CNTL);
                ib_cntl = REG_SET_FIELD(ib_cntl, SDMA_GFX_IB_CNTL, IB_ENABLE, 0);
                WREG32_SDMA(i, regSDMA_GFX_IB_CNTL, ib_cntl);
+               sdma_cntl = RREG32_SDMA(i, SDMA_CNTL);
+               sdma_cntl = REG_SET_FIELD(sdma_cntl, SDMA_CNTL, UTC_L1_ENABLE, 0);
+               WREG32_SDMA(i, regSDMA_CNTL, sdma_cntl);
 
                if (sdma[i]->use_doorbell) {
                        doorbell = RREG32_SDMA(i, regSDMA_GFX_DOORBELL);
@@ -997,6 +1000,7 @@ static int sdma_v4_4_2_inst_start(struct amdgpu_device *adev,
                /* set utc l1 enable flag always to 1 */
                temp = RREG32_SDMA(i, regSDMA_CNTL);
                temp = REG_SET_FIELD(temp, SDMA_CNTL, UTC_L1_ENABLE, 1);
+               WREG32_SDMA(i, regSDMA_CNTL, temp);
 
                if (amdgpu_ip_version(adev, SDMA0_HWIP, 0) < IP_VERSION(4, 4, 5)) {
                        /* enable context empty interrupt during initialization */
--

2.34.1

#2 lore raw
Quoted 11 lines · Alex Deucher
Quoted 10 lines · Jesse Zhang

This commit makes two key fixes to SDMA v4.4.2 handling:

1. disable UTC_L1 in sdma_cntl register when stopping SDMA engines by reading the current value before modifying UTC_L1_ENABLE bit.

2. Ensure UTC_L1_ENABLE is consistently managed by:
- Adding the missing register write when enabling UTC_L1 during start
- Keeping UTC_L1 enabled by default as per hardware requirements

Quoted 9 lines
Quoted 3 lines

Fixes the commit 7f03b1d14d51 ("drm/amdgpu:
Remove sdma halt/unhalt during frontdoor load") by maintaining proper SDMA controller state during initialization sequences.

Proper fixes tag formatting:

Fixes 7f03b1d14d51 ("drm/amdgpu: Remove sdma halt/unhalt during

frontdoor load")

The default reset value of that field is 1. Keeping SDMA unhalted but rings disabled shouldn't ideally be a problem - should be similar to the case when it's loaded also.

Thanks,
Lijo

Quoted 46 lines
Quoted 5 lines

v2: Correct SDMA_CNTL setting (Philip)

Quoted 38 lines
---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +5 -2
index e6af50c947a1..52157acab55a 100644
@@ -492,7 +492,7 @@ static void sdma_v4_4_2_inst_gfx_stop(struct amdgpu_device *adev,
 {
        struct amdgpu_ring *sdma[AMDGPU_MAX_SDMA_INSTANCES];
        u32 doorbell_offset, doorbell;
-       u32 rb_cntl, ib_cntl;
+       u32 rb_cntl, ib_cntl, sdma_cntl;
        int i;
 
        for_each_inst(i, inst_mask) {
@@ -504,6 +504,9 @@ static void sdma_v4_4_2_inst_gfx_stop(struct amdgpu_device *adev,
                ib_cntl = RREG32_SDMA(i, regSDMA_GFX_IB_CNTL);
                ib_cntl = REG_SET_FIELD(ib_cntl, SDMA_GFX_IB_CNTL, IB_ENABLE, 0);
                WREG32_SDMA(i, regSDMA_GFX_IB_CNTL, ib_cntl);
+               sdma_cntl = RREG32_SDMA(i, SDMA_CNTL);
+               sdma_cntl = REG_SET_FIELD(sdma_cntl, SDMA_CNTL, UTC_L1_ENABLE, 0);
+               WREG32_SDMA(i, regSDMA_CNTL, sdma_cntl);
 
                if (sdma[i]->use_doorbell) {
                        doorbell = RREG32_SDMA(i, regSDMA_GFX_DOORBELL);
@@ -997,6 +1000,7 @@ static int sdma_v4_4_2_inst_start(struct amdgpu_device *adev,
                /* set utc l1 enable flag always to 1 */
                temp = RREG32_SDMA(i, regSDMA_CNTL);
                temp = REG_SET_FIELD(temp, SDMA_CNTL, UTC_L1_ENABLE, 1);
+               WREG32_SDMA(i, regSDMA_CNTL, temp);
 
                if (amdgpu_ip_version(adev, SDMA0_HWIP, 0) < IP_VERSION(4, 4, 5)) {
                        /* enable context empty interrupt during initialization */
--

2.34.1

#3 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, June 16, 2025 11:05 PM
To: Alex Deucher <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Kim, Jonathan <[email protected]>
Subject: Re: [PATCH V2] drm/amdgpu: Fix SDMA UTC_L1 handling during start/stop sequences

Quoted 11 lines · Alex Deucher
Quoted 10 lines · Jesse Zhang

This commit makes two key fixes to SDMA v4.4.2 handling:

1. disable UTC_L1 in sdma_cntl register when stopping SDMA engines by reading the current value before modifying UTC_L1_ENABLE bit.

2. Ensure UTC_L1_ENABLE is consistently managed by:
- Adding the missing register write when enabling UTC_L1 during start
- Keeping UTC_L1 enabled by default as per hardware requirements

Quoted 9 lines
Quoted 3 lines

Fixes the commit 7f03b1d14d51 ("drm/amdgpu:
Remove sdma halt/unhalt during frontdoor load") by maintaining proper SDMA controller state during initialization sequences.

Proper fixes tag formatting:

Fixes 7f03b1d14d51 ("drm/amdgpu: Remove sdma halt/unhalt during

frontdoor load")

The default reset value of that field is 1. Keeping SDMA unhalted but rings disabled shouldn't ideally be a problem - should be similar to the case when it's loaded also.

Yes, Lijo, I will remove the related description when submitting. This is our problem. We need a workaround to enable SDMA_CNTL::UTC_L1. Because when we call smu queue reset interface, it disables UTC_L1.

Regards
Jesse
Thanks,
Lijo

Quoted 49 lines
Quoted 5 lines

v2: Correct SDMA_CNTL setting (Philip)

Quoted 41 lines
---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +1 -1
index e6af50c947a1..52157acab55a 100644
@@ -492,7 +492,7 @@ static void sdma_v4_4_2_inst_gfx_stop(struct
 amdgpu_device *adev,  {
        struct amdgpu_ring *sdma[AMDGPU_MAX_SDMA_INSTANCES];
        u32 doorbell_offset, doorbell;
-       u32 rb_cntl, ib_cntl;
+       u32 rb_cntl, ib_cntl, sdma_cntl;
        int i;
 
        for_each_inst(i, inst_mask) { @@ -504,6 +504,9 @@ static void

sdma_v4_4_2_inst_gfx_stop(struct amdgpu_device *adev,

                ib_cntl = RREG32_SDMA(i, regSDMA_GFX_IB_CNTL);
                ib_cntl = REG_SET_FIELD(ib_cntl, SDMA_GFX_IB_CNTL, IB_ENABLE, 0);
                WREG32_SDMA(i, regSDMA_GFX_IB_CNTL, ib_cntl);
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +3 -0
+               sdma_cntl = RREG32_SDMA(i, SDMA_CNTL);
+               sdma_cntl = REG_SET_FIELD(sdma_cntl, SDMA_CNTL, UTC_L1_ENABLE, 0);
+               WREG32_SDMA(i, regSDMA_CNTL, sdma_cntl);
 
                if (sdma[i]->use_doorbell) {
                        doorbell = RREG32_SDMA(i,

regSDMA_GFX_DOORBELL); @@ -997,6 +1000,7 @@ static int sdma_v4_4_2_inst_start(struct amdgpu_device *adev,

                /* set utc l1 enable flag always to 1 */
                temp = RREG32_SDMA(i, regSDMA_CNTL);
                temp = REG_SET_FIELD(temp, SDMA_CNTL, UTC_L1_ENABLE,

1);
+ WREG32_SDMA(i, regSDMA_CNTL, temp);

                if (amdgpu_ip_version(adev, SDMA0_HWIP, 0) < IP_VERSION(4, 4, 5)) {
                        /* enable context empty interrupt during

initialization */
--
2.34.1

#4 lore raw
Quoted 29 lines · Jesse(Jie)

[AMD Official Use Only - AMD Internal Distribution Only]

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, June 16, 2025 11:05 PM
To: Alex Deucher <[email protected]>; Zhang, Jesse(Jie) <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Kim, Jonathan <[email protected]>
Subject: Re: [PATCH V2] drm/amdgpu: Fix SDMA UTC_L1 handling during start/stop sequences

Quoted 17 lines · Alex Deucher
Quoted 6 lines · Jesse Zhang

This commit makes two key fixes to SDMA v4.4.2 handling:

1. disable UTC_L1 in sdma_cntl register when stopping SDMA engines by reading the current value before modifying UTC_L1_ENABLE bit.

Quoted 7 lines

2. Ensure UTC_L1_ENABLE is consistently managed by:
- Adding the missing register write when enabling UTC_L1 during start
- Keeping UTC_L1 enabled by default as per hardware requirements

Fixes the commit 7f03b1d14d51 ("drm/amdgpu:
Remove sdma halt/unhalt during frontdoor load") by maintaining proper SDMA controller state during initialization sequences.

Proper fixes tag formatting:

Quoted 9 lines
Quoted 3 lines
Fixes 7f03b1d14d51 ("drm/amdgpu: Remove sdma halt/unhalt during

frontdoor load")

The default reset value of that field is 1. Keeping SDMA unhalted but rings disabled shouldn't ideally be a problem - should be similar to the case when it's loaded also.

Yes, Lijo, I will remove the related description when submitting. This is our problem. We need a workaround to enable SDMA_CNTL::UTC_L1. Because when we call smu queue reset interface, it disables UTC_L1.

Thanks for clarifying. While submitting, please update the description to indicate that this is related to stop/restart of engines for an engine reset.

Thanks,
Lijo

Quoted 55 lines

Regards
Jesse
Thanks,
Lijo

Quoted 49 lines
Quoted 5 lines

v2: Correct SDMA_CNTL setting (Philip)

Quoted 41 lines
---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +1 -1
index e6af50c947a1..52157acab55a 100644
@@ -492,7 +492,7 @@ static void sdma_v4_4_2_inst_gfx_stop(struct
 amdgpu_device *adev,  {
        struct amdgpu_ring *sdma[AMDGPU_MAX_SDMA_INSTANCES];
        u32 doorbell_offset, doorbell;
-       u32 rb_cntl, ib_cntl;
+       u32 rb_cntl, ib_cntl, sdma_cntl;
        int i;
 
        for_each_inst(i, inst_mask) { @@ -504,6 +504,9 @@ static void

sdma_v4_4_2_inst_gfx_stop(struct amdgpu_device *adev,

                ib_cntl = RREG32_SDMA(i, regSDMA_GFX_IB_CNTL);
                ib_cntl = REG_SET_FIELD(ib_cntl, SDMA_GFX_IB_CNTL, IB_ENABLE, 0);
                WREG32_SDMA(i, regSDMA_GFX_IB_CNTL, ib_cntl);
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +3 -0
+               sdma_cntl = RREG32_SDMA(i, SDMA_CNTL);
+               sdma_cntl = REG_SET_FIELD(sdma_cntl, SDMA_CNTL, UTC_L1_ENABLE, 0);
+               WREG32_SDMA(i, regSDMA_CNTL, sdma_cntl);
 
                if (sdma[i]->use_doorbell) {
                        doorbell = RREG32_SDMA(i,

regSDMA_GFX_DOORBELL); @@ -997,6 +1000,7 @@ static int sdma_v4_4_2_inst_start(struct amdgpu_device *adev,

                /* set utc l1 enable flag always to 1 */
                temp = RREG32_SDMA(i, regSDMA_CNTL);
                temp = REG_SET_FIELD(temp, SDMA_CNTL, UTC_L1_ENABLE,

1);
+ WREG32_SDMA(i, regSDMA_CNTL, temp);

                if (amdgpu_ip_version(adev, SDMA0_HWIP, 0) < IP_VERSION(4, 4, 5)) {
                        /* enable context empty interrupt during

initialization */
--
2.34.1