From: Jocelyn Falempe <jfalempe@redhat.com>
To: oushixiong1025@163.com
Cc: Javier Martinez Canillas <javierm@redhat.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Shixiong Ou <oushixiong@kylinos.cn>
Subject: Re: [PATCH 4/4] drm/log: Batch vmap/vunmap and flush for record drawing
Date: Wed, 29 Jul 2026 17:37:48 +0200 [thread overview]
Message-ID: <bfb7df7d-8d50-49e5-b6b5-a8d06aec7e1a@redhat.com> (raw)
In-Reply-To: <20260729084823.693723-1-oushixiong1025@163.com>
On 29/07/2026 10:48, oushixiong1025@163.com wrote:
> From: Shixiong Ou <oushixiong@kylinos.cn>
>
> drm_log_draw_new_line() calls drm_log_clear_line() and
> drm_log_draw_line(), which independently call
> drm_client_buffer_vmap_local(), drm_client_buffer_vunmap_local(),
> and drm_client_buffer_flush(). For each call to
> drm_log_draw_new_line(), this results in 2 vmap/vunmap pairs and
> 2 flush calls, even though vmap_local maps the entire framebuffer
> each time.
>
> Refactor drm_log_clear_line() and drm_log_draw_line() to accept a
> pre-mapped iosys_map by value, removing the per-line vmap/vunmap/flush
> calls. Move the single vmap/vunmap pair and flush up to
> drm_log_draw_new_line(), which now maps once before clearing and
> drawing, then issues a single flush after unmapping.
Thanks, it looks good to me.
I think you just need to remove the drm_rect in drm_log_clear_line() and
drm_log_draw_line(), as they are not used anymore.
Best regards,
--
Jocelyn
>
> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
> ---
> drivers/gpu/drm/clients/drm_log.c | 52 ++++++++++++++++++++-----------
> 1 file changed, 33 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/clients/drm_log.c
> index 63577aeb705c..4896b3e00710 100644
> --- a/drivers/gpu/drm/clients/drm_log.c
> +++ b/drivers/gpu/drm/clients/drm_log.c
> @@ -109,25 +109,21 @@ static void drm_log_blit(struct iosys_map *dst, unsigned int dst_pitch,
> }
> }
>
> -static void drm_log_clear_line(struct drm_log_scanout *scanout, u32 line)
> +static void drm_log_clear_line(struct drm_log_scanout *scanout, u32 line,
> + struct iosys_map map)
> {
> struct drm_framebuffer *fb = scanout->buffer->fb;
> unsigned long height = scanout->scaled_font_h;
> - struct iosys_map map;
> struct drm_rect r = DRM_RECT_INIT(0, line * height, fb->width, height);
only r.y1 is used, so you can remove this rectangle declaration
>
> - if (drm_client_buffer_vmap_local(scanout->buffer, &map))
> - return;
> iosys_map_memset(&map, r.y1 * fb->pitches[0], 0, height * fb->pitches[0]);
> - drm_client_buffer_vunmap_local(scanout->buffer);
> - drm_client_buffer_flush(scanout->buffer, &r);
> }
>
> static void drm_log_draw_line(struct drm_log_scanout *scanout, const char *s,
> - unsigned int len, unsigned int prefix_len)
> + unsigned int len, unsigned int prefix_len,
> + struct iosys_map map)
> {
> struct drm_framebuffer *fb = scanout->buffer->fb;
> - struct iosys_map map;
> const struct font_desc *font = scanout->font;
> size_t font_pitch = DIV_ROUND_UP(font->width, 8);
> const u8 *src;
> @@ -136,10 +132,9 @@ static void drm_log_draw_line(struct drm_log_scanout *scanout, const char *s,
> fb->width, (scanout->line + 1) * scanout->scaled_font_h);
> u32 i;
same here, the drm_rect r, can be removed.>
> - if (drm_client_buffer_vmap_local(scanout->buffer, &map))
> - return;
>
> iosys_map_incr(&map, r.y1 * fb->pitches[0]);
> +
> for (i = 0; i < len && i < scanout->columns; i++) {
> u32 color = (i < prefix_len) ? scanout->prefix_color : scanout->front_color;
> src = font_data_glyph_buf(font->data, font->width, font->height,
> @@ -154,21 +149,40 @@ static void drm_log_draw_line(struct drm_log_scanout *scanout, const char *s,
> scanout->line++;
> if (scanout->line >= scanout->rows)
> scanout->line = 0;
> - drm_client_buffer_vunmap_local(scanout->buffer);
> - drm_client_buffer_flush(scanout->buffer, &r);
> }
>
> static void drm_log_draw_new_line(struct drm_log_scanout *scanout,
> - const char *s, unsigned int len, unsigned int prefix_len)
> + const char *s, unsigned int len,
> + unsigned int prefix_len)
> {
> + struct iosys_map map;
> + struct drm_framebuffer *fb = scanout->buffer->fb;
> + u32 height = scanout->scaled_font_h;
> + u32 line = scanout->line;
> + u32 y2;
> + struct drm_rect dirty;
> +
> + if (drm_client_buffer_vmap_local(scanout->buffer, &map))
> + return;
> +
> if (scanout->line == 0) {
> - drm_log_clear_line(scanout, 0);
> - drm_log_clear_line(scanout, 1);
> - drm_log_clear_line(scanout, 2);
> - } else if (scanout->line + 2 < scanout->rows)
> - drm_log_clear_line(scanout, scanout->line + 2);
> + drm_log_clear_line(scanout, 0, map);
> + drm_log_clear_line(scanout, 1, map);
> + drm_log_clear_line(scanout, 2, map);
> + y2 = min(3, scanout->rows) * height;
> + } else if (scanout->line + 2 < scanout->rows) {
> + drm_log_clear_line(scanout, scanout->line + 2, map);
> + y2 = (line + 3) * height;
> + } else {
> + y2 = (line + 1) * height;
> + }
> +
> + drm_log_draw_line(scanout, s, len, prefix_len, map);
> +
> + drm_client_buffer_vunmap_local(scanout->buffer);
>
> - drm_log_draw_line(scanout, s, len, prefix_len);
> + dirty = DRM_RECT_INIT(0, line * height, fb->width, y2 - line * height);
> + drm_client_buffer_flush(scanout->buffer, &dirty);
> }
>
> /*
prev parent reply other threads:[~2026-07-29 15:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 8:48 oushixiong1025
2026-07-29 15:37 ` Jocelyn Falempe [this message]
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=bfb7df7d-8d50-49e5-b6b5-a8d06aec7e1a@redhat.com \
--to=jfalempe@redhat.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=oushixiong1025@163.com \
--cc=oushixiong@kylinos.cn \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®