Skip to contentSkip to conversation

drm/ssd130x: Use drm_atomic_get_new_plane_state()

PATCH In review Javier Martinez Canillas 3 participants 6 messages Sep 23, 2022 – Sep 27, 2022

Subsystems (3)
lore
Share & tools
lore

Javier Martinez Canillas

author maintainer
#0 lore raw

PATCH 1/1 drm/ssd130x: Use drm_atomic_get_new_plane_state()

The struct drm_plane .state shouldn't be accessed directly but instead the drm_atomic_get_new_plane_state() helper function should be used.

This is based on a similar patch from Thomas Zimmermann for the simpledrm driver. No functional changes.

---

 drivers/gpu/drm/solomon/ssd130x.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/solomon/ssd130x.c +4 -4
index 7fae9480aa11..a537692100d1 100644
@@ -566,10 +566,10 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_m
 }
 
 static void ssd130x_primary_plane_helper_atomic_update(struct drm_plane *plane,
-						       struct drm_atomic_state *old_state)
+						       struct drm_atomic_state *state)
 {
-	struct drm_plane_state *plane_state = plane->state;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(old_state, plane);
+	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
+	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_device *drm = plane->dev;
 	struct drm_rect src_clip, dst_clip;
@@ -591,7 +591,7 @@ static void ssd130x_primary_plane_helper_atomic_update(struct drm_plane *plane,
 }
 
 static void ssd130x_primary_plane_helper_atomic_disable(struct drm_plane *plane,
-							struct drm_atomic_state *old_state)
+							struct drm_atomic_state *state)
 {
 	struct drm_device *drm = plane->dev;
 	struct ssd130x_device *ssd130x = drm_to_ssd130x(drm);
Signature · 1 line
2.37.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Javier Martinez Canillas

The struct drm_plane .state shouldn't be accessed directly but instead the drm_atomic_get_new_plane_state() helper function should be used.

This is based on a similar patch from Thomas Zimmermann for the simpledrm driver. No functional changes.

I wonder how many naked obj->state dereferences are still left in places where they should be using the get_{new,old}() stuff. Might have to write a bit of cocci to find out...

Btw on a somewhat related note, I've been thinking about bringing for_each_crtc_in_state() & co. back (got removed in commit 77ac3b00b131 ("drm/atomic: Remove deprecated accessor macros")) but this time without any object state iterator variable. Now that we're more often just plumbing the full atomic state through I think there are bunch of places that don't need the object state(s) within the loop at all, so having to have those variables around makes the whole thing a bit noisy. Also IIRC we had to add some (void) casts into the current macros to hide some compiler warnings about unused variables. Could get rid of at least some of those extra casts again.

I don't suppose there's anyone interested in doing that so I don't have to? ;)

Quoted 34 lines

---

 drivers/gpu/drm/solomon/ssd130x.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/solomon/ssd130x.c +4 -4
index 7fae9480aa11..a537692100d1 100644
@@ -566,10 +566,10 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_m
 }
 
 static void ssd130x_primary_plane_helper_atomic_update(struct drm_plane *plane,
-						       struct drm_atomic_state *old_state)
+						       struct drm_atomic_state *state)
 {
-	struct drm_plane_state *plane_state = plane->state;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(old_state, plane);
+	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
+	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
 	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
 	struct drm_device *drm = plane->dev;
 	struct drm_rect src_clip, dst_clip;
@@ -591,7 +591,7 @@ static void ssd130x_primary_plane_helper_atomic_update(struct drm_plane *plane,
 }
 
 static void ssd130x_primary_plane_helper_atomic_disable(struct drm_plane *plane,
-							struct drm_atomic_state *old_state)
+							struct drm_atomic_state *state)
 {
 	struct drm_device *drm = plane->dev;
 	struct ssd130x_device *ssd130x = drm_to_ssd130x(drm);
Signature · 1 line
2.37.3
Signature · 2 lines
Ville Syrjälä
Intel
author maintainer
#2 lore raw

Hello Ville,

Quoted 4 lines · Ville Syrjälä
Quoted 3 lines · Javier Martinez Canillas

The struct drm_plane .state shouldn't be accessed directly but instead the drm_atomic_get_new_plane_state() helper function should be used.

Quoted 8 lines
Quoted 5 lines

This is based on a similar patch from Thomas Zimmermann for the simpledrm driver. No functional changes.

Thanks.

Quoted 17 lines

I wonder how many naked obj->state dereferences are still left in places where they should be using the get_{new,old}() stuff. Might have to write a bit of cocci to find out...

Btw on a somewhat related note, I've been thinking about bringing for_each_crtc_in_state() & co. back (got removed in commit 77ac3b00b131 ("drm/atomic: Remove deprecated accessor macros")) but this time without any object state iterator variable. Now that we're more often just plumbing the full atomic state through I think there are bunch of places that don't need the object state(s) within the loop at all, so having to have those variables around makes the whole thing a bit noisy. Also IIRC we had to add some (void) casts into the current macros to hide some compiler warnings about unused variables. Could get rid of at least some of those extra casts again.

Quoted 3 lines

I don't suppose there's anyone interested in doing that so I don't have to? ;)

Maybe you can add an entry in Documentation/gpu/todo.rst, explaining this and putting yourself as a contact?

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#3 lore raw
Quoted 35 lines · Javier Martinez Canillas

Hello Ville,

Quoted 4 lines · Ville Syrjälä
Quoted 3 lines · Javier Martinez Canillas

The struct drm_plane .state shouldn't be accessed directly but instead the drm_atomic_get_new_plane_state() helper function should be used.

Quoted 8 lines
Quoted 5 lines

This is based on a similar patch from Thomas Zimmermann for the simpledrm driver. No functional changes.

Thanks.

Quoted 17 lines

I wonder how many naked obj->state dereferences are still left in places where they should be using the get_{new,old}() stuff. Might have to write a bit of cocci to find out...

Btw on a somewhat related note, I've been thinking about bringing for_each_crtc_in_state() & co. back (got removed in commit 77ac3b00b131 ("drm/atomic: Remove deprecated accessor macros")) but this time without any object state iterator variable. Now that we're more often just plumbing the full atomic state through I think there are bunch of places that don't need the object state(s) within the loop at all, so having to have those variables around makes the whole thing a bit noisy. Also IIRC we had to add some (void) casts into the current macros to hide some compiler warnings about unused variables. Could get rid of at least some of those extra casts again.

Quoted 6 lines
Quoted 3 lines

I don't suppose there's anyone interested in doing that so I don't have to? ;)

Maybe you can add an entry in Documentation/gpu/todo.rst, explaining this and putting yourself as a contact?

Seems about as much work as just doing it.

Signature · 2 lines
Ville Syrjälä
Intel
maintainer Reviewed-by on v1 1/1
#4 lore raw
In reply to Javier Martinez Canillas

Am 23.09.22 um 10:34 schrieb Javier Martinez Canillas:

Quoted 8 lines

The struct drm_plane .state shouldn't be accessed directly but instead the drm_atomic_get_new_plane_state() helper function should be used.

This is based on a similar patch from Thomas Zimmermann for the simpledrm driver. No functional changes.

Quoted 32 lines

---

  drivers/gpu/drm/solomon/ssd130x.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/solomon/ssd130x.c +4 -4
index 7fae9480aa11..a537692100d1 100644
@@ -566,10 +566,10 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_m
  }
 
  static void ssd130x_primary_plane_helper_atomic_update(struct drm_plane *plane,
-						       struct drm_atomic_state *old_state)
+						       struct drm_atomic_state *state)
  {
-	struct drm_plane_state *plane_state = plane->state;
-	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(old_state, plane);
+	struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
+	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
  	struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
  	struct drm_device *drm = plane->dev;
  	struct drm_rect src_clip, dst_clip;
@@ -591,7 +591,7 @@ static void ssd130x_primary_plane_helper_atomic_update(struct drm_plane *plane,
  }
 
  static void ssd130x_primary_plane_helper_atomic_disable(struct drm_plane *plane,
-							struct drm_atomic_state *old_state)
+							struct drm_atomic_state *state)
  {
  	struct drm_device *drm = plane->dev;
  	struct ssd130x_device *ssd130x = drm_to_ssd130x(drm);
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
author maintainer Applied
#5 lore raw
Quoted 6 lines · Thomas Zimmermann

Am 23.09.22 um 10:34 schrieb Javier Martinez Canillas:

Quoted 3 lines

The struct drm_plane .state shouldn't be accessed directly but instead the drm_atomic_get_new_plane_state() helper function should be used.

Quoted 8 lines
Quoted 5 lines

This is based on a similar patch from Thomas Zimmermann for the simpledrm driver. No functional changes.

Pushed to drm-misc (drm-misc-next). Thanks!

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat