[PATCH 3/8] drm/simpledrm: Store xfrm buffer in device instance
Thomas Zimmermann
tzimmermann at suse.de
Wed Sep 20 11:10:15 UTC 2023
Store and instance of struct drm_xfrm_buf in struct simpledrm_device
and keep the allocated memory allocated across display updates. Avoid
possibly reallocating temporary memory on each display update. Unloading
the DRM device also releases the xfrm buffer.
Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
drivers/gpu/drm/tiny/simpledrm.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
index 8aceb7d378dea..31fc32a00d0a5 100644
--- a/drivers/gpu/drm/tiny/simpledrm.c
+++ b/drivers/gpu/drm/tiny/simpledrm.c
@@ -232,6 +232,7 @@ struct simpledrm_device {
struct drm_display_mode mode;
const struct drm_format_info *format;
unsigned int pitch;
+ struct drm_xfrm_buf xfrm;
/* memory management */
struct iosys_map screen_base;
@@ -486,7 +487,6 @@ 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 drm_xfrm_buf xfrm = DRM_XFRM_BUF_INIT;
struct drm_atomic_helper_damage_iter iter;
struct drm_rect damage;
int ret, idx;
@@ -508,13 +508,12 @@ static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane
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, &xfrm);
+ fb, &damage, &sdev->xfrm);
}
drm_dev_exit(idx);
out_drm_gem_fb_end_cpu_access:
drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
- drm_xfrm_buf_release(&xfrm);
}
static void simpledrm_primary_plane_helper_atomic_disable(struct drm_plane *plane,
@@ -714,6 +713,10 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
sdev->format = format;
sdev->pitch = stride;
+ ret = drmm_xfrm_buf_init(dev, &sdev->xfrm);
+ if (ret)
+ return ERR_PTR(ret);
+
drm_dbg(dev, "display mode={" DRM_MODE_FMT "}\n", DRM_MODE_ARG(&sdev->mode));
drm_dbg(dev, "framebuffer format=%p4cc, size=%dx%d, stride=%d byte\n",
&format->format, width, height, stride);
--
2.42.0
More information about the dri-devel
mailing list