From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69A44455166 for ; Wed, 29 Jul 2026 15:37:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785339477; cv=none; b=FVrkJjUKq4thvrwASEOwv1PBl4nW1v4ZwSgqXL3oldJoRn5Qfp5zel5riU4/AQ9uluYAZeN9PUlACLmb7ersUeNE61XaxN+JTh3Pg9mUDAUllkYDiWgelOe7gt+RXprh1asxwWyG0LyNLpiCn2pgXlOszFI10iP5gP3/V1oZYBY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785339477; c=relaxed/simple; bh=PZPODkEpy+q+TJ/0FPW8tohFartRAtGP2sHvtej8Bzo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hqJoh8bFjZUmrovmlcaiiLvF76bm/kYTSYprQvlrRtxpa3wIxjiqvpwXznuwE/52zeWRR+pbgPp+jLl6Jn15zG/MzKlmmHktpxzGVum2aT8L5qqtEZYiQHxF5GONjnFIZaTEy7nBTFLVO5FEl7t/ZALL30mpaKJLVRbE9sQPqR0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TKCkTYrs; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=pzDv2Zix; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TKCkTYrs"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="pzDv2Zix" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785339475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vf6pfIfaVLMFzvLPsE8ryO6B6y5q/a5WhsnlX5GEQB4=; b=TKCkTYrs0sL7WlhP64Un2hHvXVwriBadJn8Yn/lpI/4lbf2IMc6jnKtu+YF9I+jZnLj+qk cj3HGTWL8h6cc7mZluRGxa77dXIoRJKfREdSv6o6BxHpNSVYPE+cqR41Nv2EQiKIrMIpwZ RT9yjGf3uemVFOomawF0BnsJ32AXf/M= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-mLvGtZ8MM_OL0GX7KMrQSg-1; Wed, 29 Jul 2026 11:37:54 -0400 X-MC-Unique: mLvGtZ8MM_OL0GX7KMrQSg-1 X-Mimecast-MFC-AGG-ID: mLvGtZ8MM_OL0GX7KMrQSg_1785339473 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-490a767c7dcso9244825e9.2 for ; Wed, 29 Jul 2026 08:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1785339473; x=1785944273; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Vf6pfIfaVLMFzvLPsE8ryO6B6y5q/a5WhsnlX5GEQB4=; b=pzDv2ZixKZP+tPRoW9OSN2trhbBZxJ+OOVXxneKmVALiCswOKWEpqh8HDjPguk4V9g hz4sAxfMuByBTFoSKiPvIKGXTs6tZaK+lKmosZoowWGtmeF4r2NeZBjZ/MCUH6+WnryD 1LoL5U4eybkplsRQtZfWS7BioFSbRVnRm6rxO4RPMA5Cq7txkuvSe0xHayeqfCRfHGoN 0XvpSXHQu9+KUHIkHWd1eK1yab3RpGdOXYTeDn4gcHGZJbj9I93QY4K7TNL0CvoPjRjg k7kHmJaiZe+Vj1dQhzZF05dKrV+xUU8EMUkQnAPxecAjBL4U+Qd3CRqX/7oAeWzy1fBa X+QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785339473; x=1785944273; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Vf6pfIfaVLMFzvLPsE8ryO6B6y5q/a5WhsnlX5GEQB4=; b=Bb2RypXwzhGTzZpr+50QVXLT8RRcCzIJz+xEJRWe1eM73hRdmgREYlnRAEDr2ke8tl YHsa52TxUdCBCzTh7CAjyvcUPKI9dRWqPzLyiQBygLA+U3wMNvru/x26eTDrelKYtW4r uxpFJdJLVYFZHSRH1jY/IYUEv39fXfOzgftIlWxQObpQOB6LIrkgPGT2jMvgyZUWQK+p l1yrlwWJpY35izJDQ1jqcjEAELoTV9Kj71p8ubM/MwfOugVXqNg9hkvhhAykLwbckgIo C5OTf0o02bQ9I03/g0BtQ3znV3HFBA7k8qbctWGKKBnY2tGyOPyiTdWKR+VCh+Z9srDp p0gg== X-Forwarded-Encrypted: i=1; AHgh+Rp0oGDr25IWUsPK56gP+bAwlzu8/tHnacvAUmG28W2+MVedyFLMh6/drApCrIQGRlcC+qlkratrJ9Lv9zM=@vger.kernel.org X-Gm-Message-State: AOJu0YyD/wiKKwFh2B00P3i5h5pgzmyT89QP1prWR0Bb0pVgtDcKWNwJ OOC6dS+yTG352kWAJ2vjCbEryf6D+3hpsLg8uutWfB28qC9wPD8dWJdRq9jkALMdgfgwJMlUZEd weQTuysbIhlJyPUUndWJ4BWYqeWy6zV0hmdDcqV0pfKqfm4peeRN9wwMi0TcG+4LqIg== X-Gm-Gg: AR+sD12YMoCiYN5snuP3diGd0BiE9uyRPiunYxhOAnUH8WO6CdvMh5RtXLX2TliwNaS T1LVDDsvei7mFGRLdxHPG3OaCHJcfDFeNcHD2IS04laAh/jN0i4Jl0aqrilSS5zoiBfGLvk5mxx 3whFTOfvWNmcckHV4s5LNlDruhlZt0EiMQDzqvkUJno3VIaF6DHlcbQm9OO3514KVym1Diz60rn uPdgKcoBx7hPzUoOH7U21aw8vxcF2gXMUSNSYlvblny3Hw2PyHc2L07kJ4F3+kLuqoWTYXCZ3LI pP1/rAVUIsqgl15nOduz8GnyErxIZAnEeN4R8PBRIXpoi+Q1R7FffjhtiESJ0f/0UKOVnO151kW NQAbaZp1MZqgYfFAB2KqoAdB/mzZN8qdXk3iHphrKFn1pyA== X-Received: by 2002:a05:600c:4583:b0:495:44f3:4576 with SMTP id 5b1f17b1804b1-496c64130a6mr75389535e9.7.1785339472784; Wed, 29 Jul 2026 08:37:52 -0700 (PDT) X-Received: by 2002:a05:600c:4583:b0:495:44f3:4576 with SMTP id 5b1f17b1804b1-496c64130a6mr75389125e9.7.1785339472257; Wed, 29 Jul 2026 08:37:52 -0700 (PDT) Received: from ?IPV6:2a01:e0a:9b4:d000:c3c5:df83:3a33:2c51? ([2a01:e0a:9b4:d000:c3c5:df83:3a33:2c51]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496c4615f5fsm156433295e9.9.2026.07.29.08.37.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jul 2026 08:37:51 -0700 (PDT) Message-ID: Date: Wed, 29 Jul 2026 17:37:48 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/4] drm/log: Batch vmap/vunmap and flush for record drawing To: oushixiong1025@163.com Cc: Javier Martinez Canillas , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Shixiong Ou References: <20260729084823.693723-1-oushixiong1025@163.com> Content-Language: en-US, fr From: Jocelyn Falempe In-Reply-To: <20260729084823.693723-1-oushixiong1025@163.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 29/07/2026 10:48, oushixiong1025@163.com wrote: > From: Shixiong Ou > > 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 > --- > 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); > } > > /*