diff mbox series

drm/ssd130x: Synchronize access to dma-buf imported GEM BOs

Message ID 20220927095249.1919385-1-javierm@redhat.com (mailing list archive)
State Accepted
Headers show
Series drm/ssd130x: Synchronize access to dma-buf imported GEM BOs | expand

Commit Message

Javier Martinez Canillas Sept. 27, 2022, 9:52 a.m. UTC
Synchronize CPU access to GEM BOs with other drivers when updating the
screen buffer. Imported DMA buffers might otherwise contain stale data.

Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 drivers/gpu/drm/solomon/ssd130x.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Thomas Zimmermann Sept. 27, 2022, 11:18 a.m. UTC | #1
Hi

Am 27.09.22 um 11:52 schrieb Javier Martinez Canillas:
> Synchronize CPU access to GEM BOs with other drivers when updating the
> screen buffer. Imported DMA buffers might otherwise contain stale data.
> 
> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
> 
>   drivers/gpu/drm/solomon/ssd130x.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
> index a537692100d1..bc41a5ae810a 100644
> --- a/drivers/gpu/drm/solomon/ssd130x.c
> +++ b/drivers/gpu/drm/solomon/ssd130x.c
> @@ -555,11 +555,18 @@ static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_m
>   	if (!buf)
>   		return -ENOMEM;
>   
> +	ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE);
> +	if (ret)
> +		goto out_free;
> +
>   	iosys_map_set_vaddr(&dst, buf);
>   	drm_fb_xrgb8888_to_mono(&dst, &dst_pitch, vmap, fb, rect);
>   
> +	drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
> +
>   	ssd130x_update_rect(ssd130x, buf, rect);
>   
> +out_free:
>   	kfree(buf);
>   
>   	return ret;
Javier Martinez Canillas Sept. 27, 2022, 11:36 a.m. UTC | #2
On 9/27/22 13:18, Thomas Zimmermann wrote:
> Hi
> 
> Am 27.09.22 um 11:52 schrieb Javier Martinez Canillas:
>> Synchronize CPU access to GEM BOs with other drivers when updating the
>> screen buffer. Imported DMA buffers might otherwise contain stale data.
>>
>> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> 

Pushed to drm-misc (drm-misc-next). Thanks!
diff mbox series

Patch

diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c
index a537692100d1..bc41a5ae810a 100644
--- a/drivers/gpu/drm/solomon/ssd130x.c
+++ b/drivers/gpu/drm/solomon/ssd130x.c
@@ -555,11 +555,18 @@  static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb, const struct iosys_m
 	if (!buf)
 		return -ENOMEM;
 
+	ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE);
+	if (ret)
+		goto out_free;
+
 	iosys_map_set_vaddr(&dst, buf);
 	drm_fb_xrgb8888_to_mono(&dst, &dst_pitch, vmap, fb, rect);
 
+	drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
+
 	ssd130x_update_rect(ssd130x, buf, rect);
 
+out_free:
 	kfree(buf);
 
 	return ret;