From nobody Tue Feb 10 03:44:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1667488536; cv=none; d=zohomail.com; s=zohoarc; b=QO0EIe8jSUU7Y3f4gT63x5A8LYNKlGG+4TzHaJg05j+/4EKow/eGSg/ro7ySXch5nzH9TDQczYNykDP/5Lw2ANNeNcxBeMjP4P69At7XMWo7KO4HhdSLUyBGw+WW8Ocj1I926l26QGZiirkfiV7wV6PhMW4dcMZamDHUMOAGIBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667488536; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6vZDLOJd6MhABJ+xWbcToVn7E+N8T6jjqOm5hhU1vcE=; b=m+myWgaWWlja563RMJfPkmO/CPRJHYikE6C/bYXcDzS3rNMay9gqsC2Qu9yL3wFb/rF9YphkgY4cB/gFly5hYKKci/Sok3GrrsNLep5EO82E45Rhm/eY20R8Pcz1KmzyW+YB+VF9zNOabsFKkF3v6AI2U0lrpAiYV0Bz3Y+isSM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1667488536320449.574167414248; Thu, 3 Nov 2022 08:15:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.436648.690906 (Exim 4.92) (envelope-from ) id 1oqbw4-0007YA-Ky; Thu, 03 Nov 2022 15:15:16 +0000 Received: by outflank-mailman (output) from mailman id 436648.690906; Thu, 03 Nov 2022 15:15:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqbw4-0007Pn-21; Thu, 03 Nov 2022 15:15:16 +0000 Received: by outflank-mailman (input) for mailman id 436648; Thu, 03 Nov 2022 15:15:14 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqbvr-0001nI-3q for xen-devel@lists.xenproject.org; Thu, 03 Nov 2022 15:15:03 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 46e9d797-5b8a-11ed-8fd0-01056ac49cbb; Thu, 03 Nov 2022 16:14:57 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 53B241F8EF; Thu, 3 Nov 2022 15:14:59 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C126013AAF; Thu, 3 Nov 2022 15:14:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uGieLPLaY2PBGgAAMHmgww (envelope-from ); Thu, 03 Nov 2022 15:14:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 46e9d797-5b8a-11ed-8fd0-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1667488499; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6vZDLOJd6MhABJ+xWbcToVn7E+N8T6jjqOm5hhU1vcE=; b=yti9r2qWk9MpHeMKTVrTMsnHKmzs8r+WSILqoCaZXPgCYKo3JnU+BAsP+TuN/aPI5uwdMK HvGlepxAFJWH/SUvWHhKbVoa/ldyIVEi8Xs3FEzrkEjof9lErKuo1XrDINe4NXuwjSekIW jVZSiu0fEpk7WQwyTdPfVeWnQY832A4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1667488499; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6vZDLOJd6MhABJ+xWbcToVn7E+N8T6jjqOm5hhU1vcE=; b=2ajT4ujFWhdm3DtOFuj2efRbCkmjwPhuuTSrUUsdxA2jpJJ/72DvyMCD42cLpJ0XRfHVR3 MgsQNmAGVakNH3Bw== From: Thomas Zimmermann To: daniel@ffwll.ch, airlied@gmail.com, sam@ravnborg.org, javierm@redhat.com, mripard@kernel.org, maarten.lankhorst@linux.intel.com Cc: "linux-hyperv@vger.kernel.orglinux-hyperv"@vger.kernel.org, linux-aspeed@lists.ozlabs.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-stm32@st-md-mailman.stormreply.com, linux-samsung-soc@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-rockchip@lists.infradead.org, xen-devel@lists.xenproject.org, linux-sunxi@lists.linux.dev, linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, etnaviv@lists.freedesktop.org, linux-mediatek@lists.infradead.org, spice-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-renesas-soc@vger.kernel.org, freedreno@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v3 18/23] drm/fb_helper: Minimize damage-helper overhead Date: Thu, 3 Nov 2022 16:14:41 +0100 Message-Id: <20221103151446.2638-19-tzimmermann@suse.de> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221103151446.2638-1-tzimmermann@suse.de> References: <20221103151446.2638-1-tzimmermann@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1667488538440100001 Content-Type: text/plain; charset="utf-8" Pull the test for fb_dirty into the caller to avoid extra work if no callback has been set. In this case no damage handling is required and no damage area needs to be computed. Print a warning if the damage worker runs without getting an fb_dirty callback. Signed-off-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/drm_fb_helper.c | 90 ++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helpe= r.c index c7c0c0a8532b4..3dfda1e3830b3 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -449,12 +449,13 @@ static int drm_fb_helper_damage_blit(struct drm_fb_he= lper *fb_helper, static void drm_fb_helper_damage_work(struct work_struct *work) { struct drm_fb_helper *helper =3D container_of(work, struct drm_fb_helper,= damage_work); + struct drm_device *dev =3D helper->dev; struct drm_clip_rect *clip =3D &helper->damage_clip; struct drm_clip_rect clip_copy; unsigned long flags; int ret; =20 - if (!helper->funcs->fb_dirty) + if (drm_WARN_ON_ONCE(dev, !helper->funcs->fb_dirty)) return; =20 spin_lock_irqsave(&helper->damage_lock, flags); @@ -659,16 +660,12 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_help= er) } EXPORT_SYMBOL(drm_fb_helper_fini); =20 -static void drm_fb_helper_damage(struct fb_info *info, u32 x, u32 y, +static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 = y, u32 width, u32 height) { - struct drm_fb_helper *helper =3D info->par; struct drm_clip_rect *clip =3D &helper->damage_clip; unsigned long flags; =20 - if (!helper->funcs->fb_dirty) - return; - spin_lock_irqsave(&helper->damage_lock, flags); clip->x1 =3D min_t(u32, clip->x1, x); clip->y1 =3D min_t(u32, clip->y1, y); @@ -718,6 +715,7 @@ static void drm_fb_helper_memory_range_to_clip(struct f= b_info *info, off_t off, */ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pag= ereflist) { + struct drm_fb_helper *helper =3D info->par; unsigned long start, end, min_off, max_off; struct fb_deferred_io_pageref *pageref; struct drm_rect damage_area; @@ -733,17 +731,19 @@ void drm_fb_helper_deferred_io(struct fb_info *info, = struct list_head *pagerefli if (min_off >=3D max_off) return; =20 - /* - * As we can only track pages, we might reach beyond the end - * of the screen and account for non-existing scanlines. Hence, - * keep the covered memory area within the screen buffer. - */ - max_off =3D min(max_off, info->screen_size); + if (helper->funcs->fb_dirty) { + /* + * As we can only track pages, we might reach beyond the end + * of the screen and account for non-existing scanlines. Hence, + * keep the covered memory area within the screen buffer. + */ + max_off =3D min(max_off, info->screen_size); =20 - drm_fb_helper_memory_range_to_clip(info, min_off, max_off - min_off, &dam= age_area); - drm_fb_helper_damage(info, damage_area.x1, damage_area.y1, - drm_rect_width(&damage_area), - drm_rect_height(&damage_area)); + drm_fb_helper_memory_range_to_clip(info, min_off, max_off - min_off, &da= mage_area); + drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, + drm_rect_width(&damage_area), + drm_rect_height(&damage_area)); + } } EXPORT_SYMBOL(drm_fb_helper_deferred_io); =20 @@ -877,6 +877,7 @@ static ssize_t drm_fb_helper_write_screen_buffer(struct= fb_info *info, const cha ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *b= uf, size_t count, loff_t *ppos) { + struct drm_fb_helper *helper =3D info->par; loff_t pos =3D *ppos; ssize_t ret; struct drm_rect damage_area; @@ -885,10 +886,12 @@ ssize_t drm_fb_helper_sys_write(struct fb_info *info,= const char __user *buf, if (ret <=3D 0) return ret; =20 - drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area); - drm_fb_helper_damage(info, damage_area.x1, damage_area.y1, - drm_rect_width(&damage_area), - drm_rect_height(&damage_area)); + if (helper->funcs->fb_dirty) { + drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area); + drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, + drm_rect_width(&damage_area), + drm_rect_height(&damage_area)); + } =20 return ret; } @@ -904,8 +907,12 @@ EXPORT_SYMBOL(drm_fb_helper_sys_write); void drm_fb_helper_sys_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { + struct drm_fb_helper *helper =3D info->par; + sys_fillrect(info, rect); - drm_fb_helper_damage(info, rect->dx, rect->dy, rect->width, rect->height); + + if (helper->funcs->fb_dirty) + drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->heig= ht); } EXPORT_SYMBOL(drm_fb_helper_sys_fillrect); =20 @@ -919,8 +926,12 @@ EXPORT_SYMBOL(drm_fb_helper_sys_fillrect); void drm_fb_helper_sys_copyarea(struct fb_info *info, const struct fb_copyarea *area) { + struct drm_fb_helper *helper =3D info->par; + sys_copyarea(info, area); - drm_fb_helper_damage(info, area->dx, area->dy, area->width, area->height); + + if (helper->funcs->fb_dirty) + drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->heig= ht); } EXPORT_SYMBOL(drm_fb_helper_sys_copyarea); =20 @@ -934,8 +945,12 @@ EXPORT_SYMBOL(drm_fb_helper_sys_copyarea); void drm_fb_helper_sys_imageblit(struct fb_info *info, const struct fb_image *image) { + struct drm_fb_helper *helper =3D info->par; + sys_imageblit(info, image); - drm_fb_helper_damage(info, image->dx, image->dy, image->width, image->hei= ght); + + if (helper->funcs->fb_dirty) + drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->= height); } EXPORT_SYMBOL(drm_fb_helper_sys_imageblit); =20 @@ -1035,6 +1050,7 @@ static ssize_t fb_write_screen_base(struct fb_info *i= nfo, const char __user *buf ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *b= uf, size_t count, loff_t *ppos) { + struct drm_fb_helper *helper =3D info->par; loff_t pos =3D *ppos; ssize_t ret; struct drm_rect damage_area; @@ -1043,10 +1059,12 @@ ssize_t drm_fb_helper_cfb_write(struct fb_info *inf= o, const char __user *buf, if (ret <=3D 0) return ret; =20 - drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area); - drm_fb_helper_damage(info, damage_area.x1, damage_area.y1, - drm_rect_width(&damage_area), - drm_rect_height(&damage_area)); + if (helper->funcs->fb_dirty) { + drm_fb_helper_memory_range_to_clip(info, pos, ret, &damage_area); + drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, + drm_rect_width(&damage_area), + drm_rect_height(&damage_area)); + } =20 return ret; } @@ -1062,8 +1080,12 @@ EXPORT_SYMBOL(drm_fb_helper_cfb_write); void drm_fb_helper_cfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { + struct drm_fb_helper *helper =3D info->par; + cfb_fillrect(info, rect); - drm_fb_helper_damage(info, rect->dx, rect->dy, rect->width, rect->height); + + if (helper->funcs->fb_dirty) + drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->heig= ht); } EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect); =20 @@ -1077,8 +1099,12 @@ EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect); void drm_fb_helper_cfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) { + struct drm_fb_helper *helper =3D info->par; + cfb_copyarea(info, area); - drm_fb_helper_damage(info, area->dx, area->dy, area->width, area->height); + + if (helper->funcs->fb_dirty) + drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->heig= ht); } EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea); =20 @@ -1092,8 +1118,12 @@ EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea); void drm_fb_helper_cfb_imageblit(struct fb_info *info, const struct fb_image *image) { + struct drm_fb_helper *helper =3D info->par; + cfb_imageblit(info, image); - drm_fb_helper_damage(info, image->dx, image->dy, image->width, image->hei= ght); + + if (helper->funcs->fb_dirty) + drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->= height); } EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit); =20 --=20 2.38.0