From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@redhat.com, sean@poorly.run, daniel@ffwll.ch,
kraxel@redhat.com, emil.velikov@collabora.com, sam@ravnborg.org,
noralf@tronnes.org
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 1/5] drm/udl: Unmap buffer object after damage update
Date: Thu, 14 Nov 2019 15:10:21 +0100 [thread overview]
Message-ID: <20191114141025.32198-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20191114141025.32198-1-tzimmermann@suse.de>
Udl keeps a BO mapped for its entire lifetime if it has been used in a
damage update at least once. The BO's free callback release the mapping
before it frees the BO.
Change this behaviour to unmap immediately after the damage update, so
SHMEM's implementation of free can be used.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/udl/udl_fb.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index 8fe4d8cf3212..a9e6ec360b16 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -73,6 +73,7 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
struct urb *urb;
int aligned_x;
int log_bpp;
+ void *vaddr;
BUG_ON(!is_power_of_2(fb->base.format->cpp[0]));
log_bpp = __ffs(fb->base.format->cpp[0]);
@@ -80,14 +81,10 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
if (!fb->active_16)
return 0;
- if (!fb->shmem->vaddr) {
- void *vaddr;
-
- vaddr = drm_gem_shmem_vmap(&fb->shmem->base);
- if (IS_ERR(vaddr)) {
- DRM_ERROR("failed to vmap fb\n");
- return 0;
- }
+ vaddr = drm_gem_shmem_vmap(&fb->shmem->base);
+ if (IS_ERR(vaddr)) {
+ DRM_ERROR("failed to vmap fb\n");
+ return 0;
}
aligned_x = DL_ALIGN_DOWN(x, sizeof(unsigned long));
@@ -96,22 +93,23 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
if ((width <= 0) ||
(x + width > fb->base.width) ||
- (y + height > fb->base.height))
- return -EINVAL;
+ (y + height > fb->base.height)) {
+ ret = -EINVAL;
+ goto err_drm_gem_shmem_vunmap;
+ }
start_cycles = get_cycles();
urb = udl_get_urb(dev);
if (!urb)
- return 0;
+ goto out;
cmd = urb->transfer_buffer;
for (i = y; i < y + height ; i++) {
const int line_offset = fb->base.pitches[0] * i;
const int byte_offset = line_offset + (x << log_bpp);
const int dev_byte_offset = (fb->base.width * i + x) << log_bpp;
- if (udl_render_hline(dev, log_bpp, &urb,
- (char *) fb->shmem->vaddr,
+ if (udl_render_hline(dev, log_bpp, &urb, (char *)vaddr,
&cmd, byte_offset, dev_byte_offset,
width << log_bpp,
&bytes_identical, &bytes_sent))
@@ -138,7 +136,14 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
>> 10)), /* Kcycles */
&udl->cpu_kcycles_used);
+out:
+ drm_gem_shmem_vunmap(&fb->shmem->base, vaddr);
+
return 0;
+
+err_drm_gem_shmem_vunmap:
+ drm_gem_shmem_vunmap(&fb->shmem->base, vaddr);
+ return ret;
}
static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
--
2.23.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-11-14 14:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-14 14:10 [PATCH 0/5] drm/udl: Convert to GEM framebuffer helpers Thomas Zimmermann
2019-11-14 14:10 ` Thomas Zimmermann [this message]
2019-11-14 14:10 ` [PATCH 2/5] drm/udl: Remove udl implementation of GEM's free_object() Thomas Zimmermann
2019-11-14 14:10 ` [PATCH 3/5] drm/udl: Store active framebuffer in device structure Thomas Zimmermann
2019-11-14 14:10 ` [PATCH 4/5] drm/udl: Call udl_handle_damage() with DRM framebuffer Thomas Zimmermann
2019-11-14 14:10 ` [PATCH 5/5] drm/udl: Replace struct udl_framebuffer with generic implementation Thomas Zimmermann
2019-11-25 18:39 ` [PATCH 0/5] drm/udl: Convert to GEM framebuffer helpers Sam Ravnborg
2019-11-26 8:49 ` Thomas Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191114141025.32198-2-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.velikov@collabora.com \
--cc=kraxel@redhat.com \
--cc=noralf@tronnes.org \
--cc=sam@ravnborg.org \
--cc=sean@poorly.run \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox