Skip to contentSkip to conversation

drm/loongson: Fix framebuffer selection in async cursor updates

PATCH Applied Evanshenf 4 participants 5 messages Oct 3 – Oct 31

Subsystems (4)
lore
Share & tools
lore

Evanshenf

author
#0 lore raw

PATCH 1/1 drm/loongson: Fix framebuffer selection in async cursor updates

An asynchronous cursor update swaps the new framebuffer into the live plane state. However, the driver reads both old_fb and new_fb from the live state before this swap. When an enabled cursor changes buffers, the address-update condition is therefore false and the hardware continues scanning the previous buffer.

Read new_fb from the new plane state before swapping the framebuffer references. This updates the hardware address when the framebuffer changes while retaining the existing behavior for cursor movement.

Verified on a Loongson 3A5000 with LS7A2000 using 32x32 and 64x64 legacy cursor updates. Callback counters and read-only register observations confirmed the asynchronous path, the stale address before the change, and the new address afterward. Same-framebuffer movement and cursor disable/re-enable also passed, with the primary framebuffer and mode unchanged.

AI assistance was used to investigate the existing report, prepare the fix and test tools, run the build and hardware comparison, and draft this message.

Fixes f39db26c5428 ("drm: Add kms driver for loongson display controller")
Assisted-by LLM
---
 drivers/gpu/drm/loongson/lsdc_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/loongson/lsdc_plane.c +1 -1
index bcc0ffa..7b9c65c 100644
@@ -230,7 +230,7 @@ static void lsdc_cursor_plane_atomic_async_update(struct drm_plane *plane,
 
 	new_state = drm_atomic_get_new_plane_state(state, plane);
 
-	new_fb = plane->state->fb;
+	new_fb = new_state->fb;
 
 	plane->state->crtc_x = new_state->crtc_x;
 	plane->state->crtc_y = new_state->crtc_y;

base-commit: bca45af5998a05f34b13a2ef11e639bac9c62643

Signature · 1 line
2.43.0
reviewer
#1 lore raw

(Cc'ing drm-misc maintainers)

Quoted 48 lines · 在 2026-10-03六的 09:00 +0000,Evanshenf写道:

An asynchronous cursor update swaps the new framebuffer into the live plane state. However, the driver reads both old_fb and new_fb from the
live state before this swap. When an enabled cursor changes buffers, the
address-update condition is therefore false and the hardware continues
scanning the previous buffer.

Read new_fb from the new plane state before swapping the framebuffer references. This updates the hardware address when the framebuffer changes while retaining the existing behavior for cursor movement.

Verified on a Loongson 3A5000 with LS7A2000 using 32x32 and 64x64 legacy
cursor updates. Callback counters and read-only register observations confirmed the asynchronous path, the stale address before the change, and the new address afterward. Same-framebuffer movement and cursor disable/re-enable also passed, with the primary framebuffer and mode unchanged.

AI assistance was used to investigate the existing report, prepare the
fix and test tools, run the build and hardware comparison, and draft this message.

Closes:
https://lore.kernel.org/r/[email protected]/

Fixes f39db26c5428 ("drm: Add kms driver for loongson display

controller")

Assisted-by LLM

---
 drivers/gpu/drm/loongson/lsdc_plane.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/loongson/lsdc_plane.c +0 -0
index bcc0ffa..7b9c65c 100644
@@ -230,7 +230,7 @@ static void
 lsdc_cursor_plane_atomic_async_update(struct drm_plane *plane,


  new_state = drm_atomic_get_new_plane_state(state, plane);

drivers/gpu/drm/loongson/lsdc_plane.c static void lsdc_cursor_plane_atomic_async_update(struct drm_plane *plane, · line 233

Quoted 2 lines
drivers/gpu/drm/loongson/lsdc_plane.c +1 -1
-	new_fb = plane->state->fb;
+	new_fb = new_state->fb;

This change looks okay, although I don't know whether the atomic_async_update() hook should be implemented at all now.

```
Reviewed-by: Icenowy Zheng <[email protected]>
```

However, please wait for further clarification of the function itself from drm-misc maintainers.

Thanks,
Icenowy

Quoted 5 lines


  plane->state->crtc_x = new_state->crtc_x;
  plane->state->crtc_y = new_state->crtc_y;

base-commit: bca45af5998a05f34b13a2ef11e639bac9c62643

maintainer Reviewed-by
#2 lore raw

The fix is correct.

Thanks,

Qianhai Wu

Quoted 72 lines · Icenowy Zheng

(Cc'ing drm-misc maintainers)

Quoted 44 lines · 在 2026-10-03六的 09:00 +0000,Evanshenf写道:

An asynchronous cursor update swaps the new framebuffer into the live plane state. However, the driver reads both old_fb and new_fb from the
live state before this swap. When an enabled cursor changes buffers, the
address-update condition is therefore false and the hardware continues
scanning the previous buffer.

Read new_fb from the new plane state before swapping the framebuffer references. This updates the hardware address when the framebuffer changes while retaining the existing behavior for cursor movement.

Verified on a Loongson 3A5000 with LS7A2000 using 32x32 and 64x64 legacy
cursor updates. Callback counters and read-only register observations confirmed the asynchronous path, the stale address before the change, and the new address afterward. Same-framebuffer movement and cursor disable/re-enable also passed, with the primary framebuffer and mode unchanged.

AI assistance was used to investigate the existing report, prepare the
fix and test tools, run the build and hardware comparison, and draft this message.

Closes:
https://lore.kernel.org/r/[email protected]/

Fixes f39db26c5428 ("drm: Add kms driver for loongson display

controller")

Assisted-by LLM
---
  drivers/gpu/drm/loongson/lsdc_plane.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/loongson/lsdc_plane.c +0 -0
index bcc0ffa..7b9c65c 100644

drivers/gpu/drm/loongson/lsdc_plane.c static void · line 234

Quoted 6 lines
drivers/gpu/drm/loongson/lsdc_plane.c +1 -1
@@ -230,7 +230,7 @@ static void
 lsdc_cursor_plane_atomic_async_update(struct drm_plane *plane,
 
  	new_state = drm_atomic_get_new_plane_state(state, plane);
 
-	new_fb = plane->state->fb;
+	new_fb = new_state->fb;

This change looks okay, although I don't know whether the atomic_async_update() hook should be implemented at all now.

```
Reviewed-by: Icenowy Zheng <[email protected]>
```

However, please wait for further clarification of the function itself from drm-misc maintainers.

Thanks,
Icenowy

Quoted 5 lines
drivers/gpu/drm/loongson/lsdc_plane.c +0 -0
  	plane->state->crtc_x = new_state->crtc_x;
  	plane->state->crtc_y = new_state->crtc_y;

base-commit: bca45af5998a05f34b13a2ef11e639bac9c62643

reviewer Reviewed-by on v1 1/1
#3 lore raw
In reply to Evanshenf
Quoted 22 lines · Evanshenf

An asynchronous cursor update swaps the new framebuffer into the live plane state. However, the driver reads both old_fb and new_fb from the live state before this swap. When an enabled cursor changes buffers, the address-update condition is therefore false and the hardware continues scanning the previous buffer.

Read new_fb from the new plane state before swapping the framebuffer references. This updates the hardware address when the framebuffer changes while retaining the existing behavior for cursor movement.

Verified on a Loongson 3A5000 with LS7A2000 using 32x32 and 64x64 legacy cursor updates. Callback counters and read-only register observations confirmed the asynchronous path, the stale address before the change, and the new address afterward. Same-framebuffer movement and cursor disable/re-enable also passed, with the primary framebuffer and mode unchanged.

AI assistance was used to investigate the existing report, prepare the fix and test tools, run the build and hardware comparison, and draft this message.

Quoted 5 lines
Fixes f39db26c5428 ("drm: Add kms driver for loongson display controller")
Assisted-by LLM
Quoted 23 lines
---
 drivers/gpu/drm/loongson/lsdc_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/loongson/lsdc_plane.c +1 -1
index bcc0ffa..7b9c65c 100644
@@ -230,7 +230,7 @@ static void lsdc_cursor_plane_atomic_async_update(struct drm_plane *plane,
 
        new_state = drm_atomic_get_new_plane_state(state, plane);
 
-       new_fb = plane->state->fb;
+       new_fb = new_state->fb;
 
        plane->state->crtc_x = new_state->crtc_x;
        plane->state->crtc_y = new_state->crtc_y;

base-commit: bca45af5998a05f34b13a2ef11e639bac9c62643 --
2.43.0

reviewer Applied
#4 lore raw
In reply to Evanshenf
Quoted 26 lines · 在 2026-10-03六的 09:00 +0000,Evanshenf写道:

An asynchronous cursor update swaps the new framebuffer into the live plane state. However, the driver reads both old_fb and new_fb from the
live state before this swap. When an enabled cursor changes buffers, the
address-update condition is therefore false and the hardware continues
scanning the previous buffer.

Read new_fb from the new plane state before swapping the framebuffer references. This updates the hardware address when the framebuffer changes while retaining the existing behavior for cursor movement.

Verified on a Loongson 3A5000 with LS7A2000 using 32x32 and 64x64 legacy
cursor updates. Callback counters and read-only register observations confirmed the asynchronous path, the stale address before the change, and the new address afterward. Same-framebuffer movement and cursor disable/re-enable also passed, with the primary framebuffer and mode unchanged.

AI assistance was used to investigate the existing report, prepare the
fix and test tools, run the build and hardware comparison, and draft this message.

Quoted 9 lines

Closes:
https://lore.kernel.org/r/[email protected]/

Fixes f39db26c5428 ("drm: Add kms driver for loongson display

controller")

Assisted-by LLM

Applied to drm-misc-fixes, Thanks for your contribution!

Icenowy

Quoted 21 lines

---
 drivers/gpu/drm/loongson/lsdc_plane.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/loongson/lsdc_plane.c +0 -0
index bcc0ffa..7b9c65c 100644
@@ -230,7 +230,7 @@ static void
 lsdc_cursor_plane_atomic_async_update(struct drm_plane *plane,


  new_state = drm_atomic_get_new_plane_state(state, plane);

drivers/gpu/drm/loongson/lsdc_plane.c +1 -1
-	new_fb = plane->state->fb;
+	new_fb = new_state->fb;


  plane->state->crtc_x = new_state->crtc_x;
  plane->state->crtc_y = new_state->crtc_y;

base-commit: bca45af5998a05f34b13a2ef11e639bac9c62643