Skip to contentSkip to conversation

drm/simpledrm: Various improvements

PATCH In review Thomas Zimmermann 3 participants 18 messages Sep 22, 2022 – Sep 23, 2022

Subsystems (2)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover drm/simpledrm: Various improvements

This patchset contains various improvements to simpledrm that have piled up over time.

Thomas Zimmermann (5):
drm/simpledrm: Compute linestride with drm_format_info_min_pitch() drm/simpledrm: Use drm_atomic_get_new_plane_state() drm/simpledrm: Remove !fb check from atomic_update drm/simpledrm: Iterate over damage clips
drm/simpledrm: Synchronize access to GEM BOs

 drivers/gpu/drm/tiny/simpledrm.c | 48 +++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 20 deletions(-)

base-commit: a7d5d07d5ac5ac58ec81932b3f732e3127d17af9

Signature · 1 line
2.37.3
author maintainer
#1 lore raw

PATCH 1/5 drm/simpledrm: Compute linestride with drm_format_info_min_pitch()

If not given, compute the stride with drm_format_info_min_pitch(). It's the standard helper for this purpose.

Fixes fd9e3169e42b ("drm/simpledrm: Compute framebuffer stride if not set")
Cc Javier Martinez Canillas <[email protected]>
---
 drivers/gpu/drm/tiny/simpledrm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +5 -2
index ea5b3239a659..51d01e34d5eb 100644
@@ -687,8 +687,11 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
 		drm_err(dev, "no simplefb configuration found\n");
 		return ERR_PTR(-ENODEV);
 	}
-	if (!stride)
-		stride = DIV_ROUND_UP(drm_format_info_bpp(format, 0) * width, 8);
+	if (!stride) {
+		stride = drm_format_info_min_pitch(format, 0, width);
+		if (drm_WARN_ON(dev, !stride))
+			return ERR_PTR(-EINVAL);
+	}
 
 	sdev->mode = simpledrm_mode(width, height);
 	sdev->format = format;
Signature · 1 line
2.37.3
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] drm/simpledrm: Compute linestride with drm_format_info_min_pitch()

Hello Thomas,

Quoted 12 lines · Thomas Zimmermann

If not given, compute the stride with drm_format_info_min_pitch(). It's the standard helper for this purpose.

Fixes fd9e3169e42b ("drm/simpledrm: Compute framebuffer stride if not set")
Cc Javier Martinez Canillas <[email protected]>
---
 drivers/gpu/drm/tiny/simpledrm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#3 lore raw

PATCH 2/5 drm/simpledrm: Use drm_atomic_get_new_plane_state()

In reply to Thomas Zimmermann

Lookup the plane's state in atomic_update with the helper drm_atomic_get_new_plane_state(). Also rename the helpers' state arguments. No functional changes.

---
 drivers/gpu/drm/tiny/simpledrm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +4 -4
index 51d01e34d5eb..14782a50f816 100644
@@ -470,10 +470,10 @@ static const uint64_t simpledrm_primary_plane_format_modifiers[] = {
 };
 
 static void simpledrm_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_framebuffer *fb = plane_state->fb;
 	struct drm_device *dev = plane->dev;
@@ -503,7 +503,7 @@ static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane
 }
 
 static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *plane,
-							  struct drm_atomic_state *old_state)
+							  struct drm_atomic_state *state)
 {
 	struct drm_device *dev = plane->dev;
 	struct simpledrm_device *sdev = simpledrm_device_of_dev(dev);
Signature · 1 line
2.37.3
#4 lore raw

RE: [PATCH 2/5] drm/simpledrm: Use drm_atomic_get_new_plane_state()

Quoted 35 lines

-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Thomas Zimmermann
Sent: Thursday, September 22, 2022 9:10 AM
To: [email protected]; [email protected]; [email protected]
Cc: Thomas Zimmermann <[email protected]>; dri- [email protected]
Subject: [PATCH 2/5] drm/simpledrm: Use drm_atomic_get_new_plane_state()

Lookup the plane's state in atomic_update with the helper drm_atomic_get_new_plane_state(). Also rename the helpers' state arguments. No functional changes.

---
drivers/gpu/drm/tiny/simpledrm.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +0 -0
index 51d01e34d5eb..14782a50f816 100644
@@ -470,10 +470,10 @@ static const uint64_t
 simpledrm_primary_plane_format_modifiers[] = {
 };
 

static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane,

drivers/gpu/drm/tiny/simpledrm.c +0 -1
-							 struct

drm_atomic_state *old_state)

drivers/gpu/drm/tiny/simpledrm.c +1 -0
+							 struct

drm_atomic_state *state)
{

drivers/gpu/drm/tiny/simpledrm.c static const uint64_t simpledrm_primary_plane_format_modifiers[] = { · line 475

Quoted 3 lines
drivers/gpu/drm/tiny/simpledrm.c +1 -2
-	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);

Going from plane->state to drm_atomic_get_new_plane_state seems like a slight function change.

If this is the equivalent and the "right" way to do this, should the ->state part of the data structure be pruned?

The comment for drm_atomic_get_new_plane_state also says that it can return NULL.

would plane->state be NULL in this case?

Thanks,

M

Quoted 19 lines
drivers/gpu/drm/tiny/simpledrm.c +1 -0
+	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_framebuffer *fb = plane_state->fb;
	struct drm_device *dev = plane->dev;
drivers/gpu/drm/tiny/simpledrm.c +0 -0
@@ -503,7 +503,7 @@ static void

simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane }

static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *plane,

drivers/gpu/drm/tiny/simpledrm.c +0 -1
-							  struct

drm_atomic_state *old_state)

drivers/gpu/drm/tiny/simpledrm.c +1 -0
+							  struct

drm_atomic_state *state)

{
	struct drm_device *dev = plane->dev;
	struct simpledrm_device *sdev = simpledrm_device_of_dev(dev);

--
2.37.3

author maintainer
#5 lore raw

Re: [PATCH 2/5] drm/simpledrm: Use drm_atomic_get_new_plane_state()

Hi

Am 22.09.22 um 18:12 schrieb Ruhl, Michael J:

Quoted 41 lines
Quoted 35 lines

-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Thomas Zimmermann
Sent: Thursday, September 22, 2022 9:10 AM
To: [email protected]; [email protected]; [email protected]
Cc: Thomas Zimmermann <[email protected]>; dri- [email protected]
Subject: [PATCH 2/5] drm/simpledrm: Use drm_atomic_get_new_plane_state()

Lookup the plane's state in atomic_update with the helper drm_atomic_get_new_plane_state(). Also rename the helpers' state arguments. No functional changes.

---
drivers/gpu/drm/tiny/simpledrm.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +0 -0
index 51d01e34d5eb..14782a50f816 100644
@@ -470,10 +470,10 @@ static const uint64_t
 simpledrm_primary_plane_format_modifiers[] = {
 };
 

static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane,

drivers/gpu/drm/tiny/simpledrm.c +0 -1
-							 struct

drm_atomic_state *old_state)

drivers/gpu/drm/tiny/simpledrm.c +1 -0
+							 struct

drm_atomic_state *state)
{

drivers/gpu/drm/tiny/simpledrm.c static const uint64_t simpledrm_primary_plane_format_modifiers[] = { · line 475

Quoted 3 lines
drivers/gpu/drm/tiny/simpledrm.c +1 -2
-	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);

Going from plane->state to drm_atomic_get_new_plane_state seems like a slight function change.

Quoted 2 lines

If this is the equivalent and the "right" way to do this, should the ->state part of the data structure be pruned?

The plane->state field is still relevant. I recently learned that the state-lookup helpers are supposed to be used in all atomic_check/commit functions. Ville gave a description here:

https://lore.kernel.org/dri-devel/[email protected]/

Quoted 4 lines

The comment for drm_atomic_get_new_plane_state also says that it can return NULL.

would plane->state be NULL in this case?

I don't think so. In atomic_update, we know that we're supposed to change the plane. That requires the state. Maybe it's different in the plane's atomic_disable helper, we don't access the state there.

Best regards
Thomas

Quoted 25 lines

Thanks,

M

Quoted 19 lines
drivers/gpu/drm/tiny/simpledrm.c +1 -0
+	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_framebuffer *fb = plane_state->fb;
	struct drm_device *dev = plane->dev;
drivers/gpu/drm/tiny/simpledrm.c +0 -0
@@ -503,7 +503,7 @@ static void

simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane }

static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *plane,

drivers/gpu/drm/tiny/simpledrm.c +0 -1
-							  struct

drm_atomic_state *old_state)

drivers/gpu/drm/tiny/simpledrm.c +1 -0
+							  struct

drm_atomic_state *state)

{
	struct drm_device *dev = plane->dev;
	struct simpledrm_device *sdev = simpledrm_device_of_dev(dev);

--
2.37.3

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
Reviewed-by
#6 lore raw

RE: [PATCH 2/5] drm/simpledrm: Use drm_atomic_get_new_plane_state()

Quoted 67 lines

-----Original Message-----
From: Thomas Zimmermann <[email protected]>
Sent: Friday, September 23, 2022 3:53 AM
To: Ruhl, Michael J <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]
Subject: Re: [PATCH 2/5] drm/simpledrm: Use drm_atomic_get_new_plane_state()

Hi

Am 22.09.22 um 18:12 schrieb Ruhl, Michael J:

Quoted 28 lines
Quoted 28 lines

-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Thomas Zimmermann
Sent: Thursday, September 22, 2022 9:10 AM
To: [email protected]; [email protected]; [email protected]
Cc: Thomas Zimmermann <[email protected]>; dri- [email protected]
Subject: [PATCH 2/5] drm/simpledrm: Use drm_atomic_get_new_plane_state()

Lookup the plane's state in atomic_update with the helper drm_atomic_get_new_plane_state(). Also rename the helpers' state arguments. No functional changes.

---
drivers/gpu/drm/tiny/simpledrm.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +0 -0
index 51d01e34d5eb..14782a50f816 100644
@@ -470,10 +470,10 @@ static const uint64_t
 simpledrm_primary_plane_format_modifiers[] = {
 };
 
Quoted 9 lines

drivers/gpu/drm/tiny/simpledrm.c

Quoted 9 lines

static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane,

drivers/gpu/drm/tiny/simpledrm.c +0 -1
-							 struct

drm_atomic_state *old_state)

drivers/gpu/drm/tiny/simpledrm.c +1 -0
+							 struct

drm_atomic_state *state)
{

drivers/gpu/drm/tiny/simpledrm.c +0 -2
-	struct drm_plane_state *plane_state = plane->state;
-	struct drm_plane_state *old_plane_state =

drm_atomic_get_old_plane_state(old_state, plane);

Quoted 1 line

drivers/gpu/drm/tiny/simpledrm.c

Quoted 1 line
drivers/gpu/drm/tiny/simpledrm.c +1 -0
+	struct drm_plane_state *plane_state =

drm_atomic_get_new_plane_state(state, plane);

Quoted 2 lines

Going from plane->state to drm_atomic_get_new_plane_state seems like a

slight function change.

Quoted 2 lines

If this is the equivalent and the "right" way to do this, should the ->state

part of the data

Quoted 1 line

structure be pruned?

The plane->state field is still relevant. I recently learned that the state-lookup helpers are supposed to be used in all atomic_check/commit functions. Ville gave a description here:

https://lore.kernel.org/dri-devel/[email protected]/

Quoted 1 line
Quoted 8 lines
Quoted 1 line

The comment for drm_atomic_get_new_plane_state also says that it can

return NULL.

Quoted 2 lines

would plane->state be NULL in this case?

I don't think so. In atomic_update, we know that we're supposed to change the plane. That requires the state. Maybe it's different in the plane's atomic_disable helper, we don't access the state there.

Ok, that makes sense.

If you need it:

M

Quoted 39 lines

Best regards
Thomas

Quoted 6 lines

Thanks,

M

drivers/gpu/drm/tiny/simpledrm.c

Quoted 1 line
drivers/gpu/drm/tiny/simpledrm.c +1 -0
+	struct drm_plane_state *old_plane_state =

drm_atomic_get_old_plane_state(state, plane);

Quoted 1 line
Quoted 1 line

struct drm_shadow_plane_state *shadow_plane_state =

to_drm_shadow_plane_state(plane_state);

Quoted 4 lines
Quoted 4 lines
	struct drm_framebuffer *fb = plane_state->fb;
	struct drm_device *dev = plane->dev;
drivers/gpu/drm/tiny/simpledrm.c +0 -0
@@ -503,7 +503,7 @@ static void

simpledrm_primary_plane_helper_atomic_update(struct drm_plane

*plane

Quoted 14 lines
Quoted 8 lines

}

static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *plane,

drivers/gpu/drm/tiny/simpledrm.c +0 -1
-							  struct

drm_atomic_state *old_state)

drivers/gpu/drm/tiny/simpledrm.c +1 -0
+							  struct

drm_atomic_state *state)

Quoted 5 lines
{
	struct drm_device *dev = plane->dev;
	struct simpledrm_device *sdev = simpledrm_device_of_dev(dev);

--
2.37.3

--
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

Reviewed-by on v1 2/5
#7 lore raw

Re: [PATCH 2/5] drm/simpledrm: Use drm_atomic_get_new_plane_state()

In reply to Thomas Zimmermann
Quoted 4 lines · Thomas Zimmermann

Lookup the plane's state in atomic_update with the helper drm_atomic_get_new_plane_state(). Also rename the helpers' state arguments. No functional changes.

I think this was Suggested-by: Ville Syrjälä <[email protected]> ?

Quoted 2 lines

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#8 lore raw

Re: [PATCH 2/5] drm/simpledrm: Use drm_atomic_get_new_plane_state()

Hi

Am 23.09.22 um 09:47 schrieb Javier Martinez Canillas:

Quoted 7 lines · Thomas Zimmermann
Quoted 4 lines

Lookup the plane's state in atomic_update with the helper drm_atomic_get_new_plane_state(). Also rename the helpers' state arguments. No functional changes.

I think this was Suggested-by: Ville Syrjälä <[email protected]> ?

Not directly, but it seems fair to give him credit.

Quoted 6 lines
Quoted 3 lines

---

Thanks for the r-bs.

Best regards
Thomas

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
#9 lore raw

PATCH 3/5 drm/simpledrm: Remove !fb check from atomic_update

In reply to Thomas Zimmermann

The primary plane implements atomic_disable, so atomic_update will not be called without a framebuffer set. Remove the test for !fb.

---
 drivers/gpu/drm/tiny/simpledrm.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +0 -3
index 14782a50f816..8fab22a26e26 100644
@@ -482,9 +482,6 @@ static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane
 	struct drm_rect src_clip, dst_clip;
 	int idx;
 
-	if (!fb)
-		return;
-
 	if (!drm_atomic_helper_damage_merged(old_plane_state, plane_state, &src_clip))
 		return;
 
Signature · 1 line
2.37.3
Reviewed-by on v1 3/5
#10 lore raw

Re: [PATCH 3/5] drm/simpledrm: Remove !fb check from atomic_update

Quoted 8 lines · Thomas Zimmermann

The primary plane implements atomic_disable, so atomic_update will not be called without a framebuffer set. Remove the test for !fb.

---
 drivers/gpu/drm/tiny/simpledrm.c | 3 ---
 1 file changed, 3 deletions(-)
Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#11 lore raw

PATCH 4/5 drm/simpledrm: Iterate over damage clips

In reply to Thomas Zimmermann

Iterate over all damage clips and updated them one by one. Replaces the merging of damage areas, which can result in significant overhead if damage areas are not close to each other.

---
 drivers/gpu/drm/tiny/simpledrm.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +13 -11
index 8fab22a26e26..5f242558891e 100644
@@ -478,23 +478,25 @@ static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane
 	struct drm_framebuffer *fb = plane_state->fb;
 	struct drm_device *dev = plane->dev;
 	struct simpledrm_device *sdev = simpledrm_device_of_dev(dev);
-	struct iosys_map dst = IOSYS_MAP_INIT_VADDR(sdev->screen_base);
-	struct drm_rect src_clip, dst_clip;
+	struct drm_atomic_helper_damage_iter iter;
+	struct drm_rect damage;
 	int idx;
 
-	if (!drm_atomic_helper_damage_merged(old_plane_state, plane_state, &src_clip))
+	if (!drm_dev_enter(dev, &idx))
 		return;
 
-	dst_clip = plane_state->dst;
-	if (!drm_rect_intersect(&dst_clip, &src_clip))
-		return;
+	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+	drm_atomic_for_each_plane_damage(&iter, &damage) {
+		struct iosys_map dst = IOSYS_MAP_INIT_VADDR(sdev->screen_base);
+		struct drm_rect dst_clip = plane_state->dst;
 
-	if (!drm_dev_enter(dev, &idx))
-		return;
+		if (!drm_rect_intersect(&dst_clip, &damage))
+			continue;
 
-	iosys_map_incr(&dst, drm_fb_clip_offset(sdev->pitch, sdev->format, &dst_clip));
-	drm_fb_blit(&dst, &sdev->pitch, sdev->format->format, shadow_plane_state->data, fb,
-		    &src_clip);
+		iosys_map_incr(&dst, drm_fb_clip_offset(sdev->pitch, sdev->format, &dst_clip));
+		drm_fb_blit(&dst, &sdev->pitch, sdev->format->format, shadow_plane_state->data, fb,
+			    &damage);
+	}
 
 	drm_dev_exit(idx);
 }
Signature · 1 line
2.37.3
Reviewed-by on v1 4/5
#12 lore raw

Re: [PATCH 4/5] drm/simpledrm: Iterate over damage clips

Quoted 6 lines · Thomas Zimmermann

Iterate over all damage clips and updated them one by one. Replaces the merging of damage areas, which can result in significant overhead if damage areas are not close to each other.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#13 lore raw

PATCH 5/5 drm/simpledrm: Synchronize access to GEM BOs

In reply to Thomas Zimmermann

Synchronize CPU access to GEM BOs with other drivers when updating the screen buffer. Imported buffers might otherwise contain stale data.

---
 drivers/gpu/drm/tiny/simpledrm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +8 -2
index 5f242558891e..18489779fb8a 100644
@@ -480,11 +480,15 @@ static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane
 	struct simpledrm_device *sdev = simpledrm_device_of_dev(dev);
 	struct drm_atomic_helper_damage_iter iter;
 	struct drm_rect damage;
-	int idx;
+	int ret, idx;
 
-	if (!drm_dev_enter(dev, &idx))
+	ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE);
+	if (ret)
 		return;
 
+	if (!drm_dev_enter(dev, &idx))
+		goto out_drm_gem_fb_end_cpu_access;
+
 	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
 	drm_atomic_for_each_plane_damage(&iter, &damage) {
 		struct iosys_map dst = IOSYS_MAP_INIT_VADDR(sdev->screen_base);
@@ -499,6 +503,8 @@ static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane
 	}
 
 	drm_dev_exit(idx);
+out_drm_gem_fb_end_cpu_access:
+	drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
 }
 
 static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *plane,
Signature · 1 line
2.37.3
Reviewed-by on v1 5/5
#14 lore raw

Re: [PATCH 5/5] drm/simpledrm: Synchronize access to GEM BOs

Quoted 3 lines · Thomas Zimmermann

Synchronize CPU access to GEM BOs with other drivers when updating the screen buffer. Imported buffers might otherwise contain stale data.

Can you please elaborate what the problem is? The framebuffers memory is setup by the firmware and would never come from an imported dma-buf, so could the GEM BOs even be shared with other drivers?

Or is this done just for the sake of correctness ?

Quoted 2 lines

---

The change looks good to me though if is for the latter.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#15 lore raw

Re: [PATCH 5/5] drm/simpledrm: Synchronize access to GEM BOs

Hi

Am 23.09.22 um 10:06 schrieb Javier Martinez Canillas:

Quoted 10 lines · Thomas Zimmermann
Quoted 3 lines

Synchronize CPU access to GEM BOs with other drivers when updating the screen buffer. Imported buffers might otherwise contain stale data.

Can you please elaborate what the problem is? The framebuffers memory is setup by the firmware and would never come from an imported dma-buf, so could the GEM BOs even be shared with other drivers?

Or is this done just for the sake of correctness ?

This isn't about the scanout buffer that we get from the firmware. This is about synchronizing access to the GEM BO memory buffers. Our BOs' memory buffer are allocated from SHMEM or could be imported via dma-buf. In the latter case, another driver or hardware might modify their content concurrently. We need to synchronize before reading the memory from our CPU. The pattern is

1) sync BO memory content via begin_cpu_access()
2) blit from BO mem to scanout buffer
3) release BO memory via end_cpu_access()

Best regards
Thomas

Quoted 8 lines
Quoted 3 lines

---

The change looks good to me though if is for the latter.

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
#16 lore raw

Re: [PATCH 5/5] drm/simpledrm: Synchronize access to GEM BOs

Quoted 21 lines · Thomas Zimmermann

Hi

Am 23.09.22 um 10:06 schrieb Javier Martinez Canillas:

Quoted 10 lines · Thomas Zimmermann
Quoted 3 lines

Synchronize CPU access to GEM BOs with other drivers when updating the screen buffer. Imported buffers might otherwise contain stale data.

Can you please elaborate what the problem is? The framebuffers memory is setup by the firmware and would never come from an imported dma-buf, so could the GEM BOs even be shared with other drivers?

Or is this done just for the sake of correctness ?

This isn't about the scanout buffer that we get from the firmware. This is about synchronizing access to the GEM BO memory buffers. Our BOs' memory buffer are allocated from SHMEM or could be imported via dma-buf. In the latter case, another driver or hardware might modify their content concurrently. We need to synchronize before reading the memory from our CPU. The pattern is

Quoted 4 lines

1) sync BO memory content via begin_cpu_access()
2) blit from BO mem to scanout buffer
3) release BO memory via end_cpu_access()

Yeah, I got that part. What I was asking is if importing from dma-buf is a real use case for simpledrm or if this patch was more about making the driver correct and aligned with what other DRM drivers do?

In any case I agree with the change, it's just the rationale for it that wasn't clear to me.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
author maintainer
#17 lore raw

Re: [PATCH 5/5] drm/simpledrm: Synchronize access to GEM BOs

Hi

Am 23.09.22 um 12:58 schrieb Javier Martinez Canillas:

Quoted 22 lines · Thomas Zimmermann
Quoted 21 lines

Hi

Am 23.09.22 um 10:06 schrieb Javier Martinez Canillas:

Quoted 10 lines · Thomas Zimmermann
Quoted 3 lines

Synchronize CPU access to GEM BOs with other drivers when updating the screen buffer. Imported buffers might otherwise contain stale data.

Can you please elaborate what the problem is? The framebuffers memory is setup by the firmware and would never come from an imported dma-buf, so could the GEM BOs even be shared with other drivers?

Or is this done just for the sake of correctness ?

This isn't about the scanout buffer that we get from the firmware. This is about synchronizing access to the GEM BO memory buffers. Our BOs' memory buffer are allocated from SHMEM or could be imported via dma-buf. In the latter case, another driver or hardware might modify their content concurrently. We need to synchronize before reading the memory from our CPU. The pattern is

Quoted 8 lines
Quoted 4 lines

1) sync BO memory content via begin_cpu_access()
2) blit from BO mem to scanout buffer
3) release BO memory via end_cpu_access()

Yeah, I got that part. What I was asking is if importing from dma-buf is a real use case for simpledrm or if this patch was more about making the driver correct and aligned with what other DRM drivers do?

In a multi-GPU scenario, it could happen that one display uses simpledrm. If the other GPU has a native driver that exports the BO for screen mirroring, the synchronization might be needed. Admittedly it's not a likely scenario. But still...

Best regards
Thomas

Quoted 3 lines

In any case I agree with the change, it's just the rationale for it that wasn't clear to me.

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