From patchwork Thu Nov 10 13:55:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13038824 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18FC8C4332F for ; Thu, 10 Nov 2022 13:55:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 890F510E7D7; Thu, 10 Nov 2022 13:55:55 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 376BE10E7D0 for ; Thu, 10 Nov 2022 13:55:24 +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 smtp-out1.suse.de (Postfix) with ESMTPS id 9D66622AA3; Thu, 10 Nov 2022 13:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1668088521; 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=uS1ubEDgZOCboLhD8v1qzuxTMKvLMpSWRMmbHtl2y1A=; b=mHu8/HF/OjQvcPBWx60VgUca6FilbFM+ew9K/x8jpOZIdnKmYmOywgYKlGtTrFbR1fsdMy FkOzrdvXxzhsRYtLabAHxvCKQhs9n5YTJq4xLLqzDdldNrAI7whQGJxbJE37/v3RCgU4LK rnnSTN58aJ9mLkMzcpvO0FosehkLiho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1668088521; 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=uS1ubEDgZOCboLhD8v1qzuxTMKvLMpSWRMmbHtl2y1A=; b=fd9CGlAxKkAyXxg3LeTGWQct3ZXORpIzrL/515TEegza+TLzdYPK6gJGKwN0mXS+hZFoOA irvz5zzoEFlWBUAA== 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 79FF11332F; Thu, 10 Nov 2022 13:55:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mNIJHckCbWP/DAAAMHmgww (envelope-from ); Thu, 10 Nov 2022 13:55:21 +0000 From: Thomas Zimmermann To: daniel@ffwll.ch, airlied@gmail.com, javierm@redhat.com, mripard@kernel.org, maarten.lankhorst@linux.intel.com Subject: [PATCH 1/5] drm/fb-helper: Set damage-clip area in helper Date: Thu, 10 Nov 2022 14:55:15 +0100 Message-Id: <20221110135519.30029-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221110135519.30029-1-tzimmermann@suse.de> References: <20221110135519.30029-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Set the damage area in the new helper drm_fb_helper_add_damage_clip(). It can now be updated without scheduling the damage worker. This change will help to remove the damage worker entirely. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index e0384f967c0b3..178615565760e 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -576,8 +576,8 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) } EXPORT_SYMBOL(drm_fb_helper_fini); -static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y, - u32 width, u32 height) +static void drm_fb_helper_add_damage_clip(struct drm_fb_helper *helper, u32 x, u32 y, + u32 width, u32 height) { struct drm_clip_rect *clip = &helper->damage_clip; unsigned long flags; @@ -588,6 +588,12 @@ static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y, clip->x2 = max_t(u32, clip->x2, x + width); clip->y2 = max_t(u32, clip->y2, y + height); spin_unlock_irqrestore(&helper->damage_lock, flags); +} + +static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y, + u32 width, u32 height) +{ + drm_fb_helper_add_damage_clip(helper, x, y, width, height); schedule_work(&helper->damage_work); } From patchwork Thu Nov 10 13:55:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13038820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18226C4332F for ; Thu, 10 Nov 2022 13:55:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F65910E7BF; Thu, 10 Nov 2022 13:55:28 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 51CC810E7BF for ; Thu, 10 Nov 2022 13:55:23 +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 smtp-out2.suse.de (Postfix) with ESMTPS id C278D1FBB2; Thu, 10 Nov 2022 13:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1668088521; 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=WfcCt3uUmutntHKtAOPku8UlFaCXtqKw+vqc9Zvyvbk=; b=mKeTMgE0s9siHQNiDTgZ31yaC6n9HBZxIBFH0Glqcsu/6AZYiOgc5MeNIBxjHfB5n0sZ7T KkwPvb+8y4FQiQjx3Y3khpP7E2XxtdHEmFS6hWFUqp574P843TGdnBfaJbjAAetf/a3kLL s6E3g8Q/XBUjTq0OTMZW70lgaici1/s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1668088521; 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=WfcCt3uUmutntHKtAOPku8UlFaCXtqKw+vqc9Zvyvbk=; b=mnj8Tvz1jcxJWoLR6C8FnGUGhCS4ikRzDCohQcdrNVZS7NdXG26vsE1Nn2ijW6+NH9gNHi VNUNVgAhLolhfTAA== 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 A099813B60; Thu, 10 Nov 2022 13:55:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qNpqJskCbWP/DAAAMHmgww (envelope-from ); Thu, 10 Nov 2022 13:55:21 +0000 From: Thomas Zimmermann To: daniel@ffwll.ch, airlied@gmail.com, javierm@redhat.com, mripard@kernel.org, maarten.lankhorst@linux.intel.com Subject: [PATCH 2/5] drm/fb-helper: Move dirty-fb update into helper function Date: Thu, 10 Nov 2022 14:55:16 +0100 Message-Id: <20221110135519.30029-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221110135519.30029-1-tzimmermann@suse.de> References: <20221110135519.30029-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move the dirty-fb update from the damage-worker callback into the new helper drm_fb_helper_fb_dirty(), so that it can run outside the damage worker. This change will help to remove the damage worker entirely. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 178615565760e..be8ecb5e50b56 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -367,9 +367,8 @@ static void drm_fb_helper_resume_worker(struct work_struct *work) console_unlock(); } -static void drm_fb_helper_damage_work(struct work_struct *work) +static void drm_fb_helper_fb_dirty(struct drm_fb_helper *helper) { - struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper, damage_work); struct drm_device *dev = helper->dev; struct drm_clip_rect *clip = &helper->damage_clip; struct drm_clip_rect clip_copy; @@ -404,6 +403,13 @@ static void drm_fb_helper_damage_work(struct work_struct *work) spin_unlock_irqrestore(&helper->damage_lock, flags); } +static void drm_fb_helper_damage_work(struct work_struct *work) +{ + struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper, damage_work); + + drm_fb_helper_fb_dirty(helper); +} + /** * drm_fb_helper_prepare - setup a drm_fb_helper structure * @dev: DRM device From patchwork Thu Nov 10 13:55:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13038822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F05D6C433FE for ; Thu, 10 Nov 2022 13:55:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D8A9910E7CF; Thu, 10 Nov 2022 13:55:29 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7EC7810E7CB for ; Thu, 10 Nov 2022 13:55:23 +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 smtp-out1.suse.de (Postfix) with ESMTPS id EAD5D22AA4; Thu, 10 Nov 2022 13:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1668088521; 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=QiGBU8Iw2c+74FQin++OWEXwxST0lQeVqXIo0F4T6Gk=; b=IErZL59Qj1ECPIKIP77L6jwDxtxpWq2tWrx8CNQsA49ABN1gEfu9bEfrIS0bBJCn9qV+FE +7IKxpTb+VA1utZCDgIbFUTdhGqhLKM6xjznWmB2bsVbsHrC7/3h/JpqXIVHBk/J1SSkIz +0A+P0EPM49wZyCTtXCCalZxUjp9xSU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1668088521; 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=QiGBU8Iw2c+74FQin++OWEXwxST0lQeVqXIo0F4T6Gk=; b=qISkHRP8xXBY6/wHoTN6SZ6JZTVFq7LVohbExXRT3R77te9RjfVk5W1h6UWIbNFQck8Vjp 2jZl1dvDlAOxkUDg== 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 C73111332F; Thu, 10 Nov 2022 13:55:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kMl2L8kCbWP/DAAAMHmgww (envelope-from ); Thu, 10 Nov 2022 13:55:21 +0000 From: Thomas Zimmermann To: daniel@ffwll.ch, airlied@gmail.com, javierm@redhat.com, mripard@kernel.org, maarten.lankhorst@linux.intel.com Subject: [PATCH 3/5] drm/fb-helper: Perform damage handling in deferred-I/O helper Date: Thu, 10 Nov 2022 14:55:17 +0100 Message-Id: <20221110135519.30029-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221110135519.30029-1-tzimmermann@suse.de> References: <20221110135519.30029-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Call fb_dirty directly from drm_fb_helper_deferred_io() to avoid the latency of running the damage worker. The deferred-I/O helper drm_fb_helper_deferred_io() runs in a worker thread at regular intervals as part of writing to mmaped framebuffer memory. It used to schedule the fbdev damage worker to flush the framebuffer. Changing this to flushing the framebuffer directly avoids the latency introduced by the damage worker. Signed-off-by: Thomas Zimmermann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index be8ecb5e50b56..ebc44ed1bf4a2 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -644,10 +644,14 @@ static void drm_fb_helper_memory_range_to_clip(struct fb_info *info, off_t off, void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagereflist) { struct drm_fb_helper *helper = info->par; + struct drm_device *dev = helper->dev; unsigned long start, end, min_off, max_off; struct fb_deferred_io_pageref *pageref; struct drm_rect damage_area; + if (drm_WARN_ON(dev, !helper->funcs->fb_dirty)) + return; + min_off = ULONG_MAX; max_off = 0; list_for_each_entry(pageref, pagereflist, list) { @@ -656,22 +660,26 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli min_off = min(min_off, start); max_off = max(max_off, end); } - if (min_off >= max_off) - return; - 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 = min(max_off, info->screen_size); + /* + * 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 = min(max_off, info->screen_size); + if (min_off < max_off) { drm_fb_helper_memory_range_to_clip(info, min_off, max_off - min_off, &damage_area); - drm_fb_helper_damage(helper, damage_area.x1, damage_area.y1, - drm_rect_width(&damage_area), - drm_rect_height(&damage_area)); + drm_fb_helper_add_damage_clip(helper, damage_area.x1, damage_area.y1, + drm_rect_width(&damage_area), + drm_rect_height(&damage_area)); } + + /* + * Flushes all dirty pages from mmap's pageref list and the + * areas that have been written by struct fb_ops callbacks. + */ + drm_fb_helper_fb_dirty(helper); } EXPORT_SYMBOL(drm_fb_helper_deferred_io); From patchwork Thu Nov 10 13:55:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13038825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91F42C4332F for ; Thu, 10 Nov 2022 13:56:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11E4E10E7CB; Thu, 10 Nov 2022 13:56:11 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by gabe.freedesktop.org (Postfix) with ESMTPS id D924A10E7CA for ; Thu, 10 Nov 2022 13:55:23 +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 smtp-out2.suse.de (Postfix) with ESMTPS id 1E5621FCD6; Thu, 10 Nov 2022 13:55:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1668088522; 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=+WHnyWTBEvWeDqGjzK5N/5CNzzjTdf5KrYFwZJbjJp4=; b=NHv2KU4B2ddu4sXgcb5xs9Hi2IfY0vE3eVKu94KmkjSrSg2DLXy0JsKJSUosGQFiY5tJGZ 72SS5ZnWs/NPzM+ZMJYFVKu6wLGnVlWmaHB1UC1Kp0A5cKjhlbHPo0CToIpPiuUlcGVDIt SV7nbgxnxGISB7zISA1GMi7XKQjIUgY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1668088522; 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=+WHnyWTBEvWeDqGjzK5N/5CNzzjTdf5KrYFwZJbjJp4=; b=mHdSnf+o7C9+djHi9xRTWWTctGo5lzOxJAMpUxtXMLpbb5KuKXo6OvhhJlUd0bfmKU7hm1 InZLeVXriS7hFjDQ== 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 EE11313B60; Thu, 10 Nov 2022 13:55:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OKZlOckCbWP/DAAAMHmgww (envelope-from ); Thu, 10 Nov 2022 13:55:21 +0000 From: Thomas Zimmermann To: daniel@ffwll.ch, airlied@gmail.com, javierm@redhat.com, mripard@kernel.org, maarten.lankhorst@linux.intel.com Subject: [PATCH 4/5] drm/fb-helper: Schedule deferred-I/O worker after writing to framebuffer Date: Thu, 10 Nov 2022 14:55:18 +0100 Message-Id: <20221110135519.30029-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221110135519.30029-1-tzimmermann@suse.de> References: <20221110135519.30029-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Schedule the deferred-I/O worker instead of the damage worker after writing to the fbdev framebuffer. The deferred-I/O worker then performs the dirty-fb update. The fbdev emulation will initialize deferred I/O for all drivers that require damage updates. It is therefore a valid assumption that the deferred-I/O worker is present. It would be possible to perform the damage handling directly from within the write operation. But doing this could increase the overhead of the write or interfere with a concurrently scheduled deferred-I/O worker. Instead, scheduling the deferred-I/O worker with its regular delay of 50 ms removes load off the write operation and allows the deferred-I/O worker to handle multiple write operations that arrived during the delay time window. Signed-off-by: Thomas Zimmermann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 81 ++++++++++++++++++++--------- drivers/video/fbdev/core/fb_defio.c | 16 ++++++ include/linux/fb.h | 1 + 3 files changed, 72 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index ebc44ed1bf4a2..8cb644e4ecf90 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -596,14 +596,6 @@ static void drm_fb_helper_add_damage_clip(struct drm_fb_helper *helper, u32 x, u spin_unlock_irqrestore(&helper->damage_lock, flags); } -static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y, - u32 width, u32 height) -{ - drm_fb_helper_add_damage_clip(helper, x, y, width, height); - - schedule_work(&helper->damage_work); -} - /* * Convert memory region into area of scanlines and pixels per * scanline. The parameters off and len must not reach beyond @@ -683,6 +675,23 @@ void drm_fb_helper_deferred_io(struct fb_info *info, struct list_head *pagerefli } EXPORT_SYMBOL(drm_fb_helper_deferred_io); +static void drm_fb_helper_flush(struct drm_fb_helper *helper) +{ + struct drm_device *dev = helper->dev; + struct fb_info *info = helper->info; + + /* + * For now, we assume that deferred I/O has been enabled as damage + * updates require deferred I/O for a working mmap. The current + * fbdev emulation does not flush buffers if no damage update is + * necessary. So it's safe to assume fbdefio to be set. + */ + if (drm_WARN_ON_ONCE(dev, !info->fbdefio)) + return; + + fb_deferred_io_flush(info); +} + typedef ssize_t (*drm_fb_helper_read_screen)(struct fb_info *info, char __user *buf, size_t count, loff_t pos); @@ -824,9 +833,10 @@ ssize_t drm_fb_helper_sys_write(struct fb_info *info, const char __user *buf, 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)); + drm_fb_helper_add_damage_clip(helper, damage_area.x1, damage_area.y1, + drm_rect_width(&damage_area), + drm_rect_height(&damage_area)); + drm_fb_helper_flush(helper); } return ret; @@ -847,8 +857,11 @@ void drm_fb_helper_sys_fillrect(struct fb_info *info, sys_fillrect(info, rect); - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height); + if (helper->funcs->fb_dirty) { + drm_fb_helper_add_damage_clip(helper, rect->dx, rect->dy, + rect->width, rect->height); + drm_fb_helper_flush(helper); + } } EXPORT_SYMBOL(drm_fb_helper_sys_fillrect); @@ -866,8 +879,11 @@ void drm_fb_helper_sys_copyarea(struct fb_info *info, sys_copyarea(info, area); - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height); + if (helper->funcs->fb_dirty) { + drm_fb_helper_add_damage_clip(helper, area->dx, area->dy, + area->width, area->height); + drm_fb_helper_flush(helper); + } } EXPORT_SYMBOL(drm_fb_helper_sys_copyarea); @@ -885,8 +901,11 @@ void drm_fb_helper_sys_imageblit(struct fb_info *info, sys_imageblit(info, image); - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height); + if (helper->funcs->fb_dirty) { + drm_fb_helper_add_damage_clip(helper, image->dx, image->dy, + image->width, image->height); + drm_fb_helper_flush(helper); + } } EXPORT_SYMBOL(drm_fb_helper_sys_imageblit); @@ -997,9 +1016,10 @@ ssize_t drm_fb_helper_cfb_write(struct fb_info *info, const char __user *buf, 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)); + drm_fb_helper_add_damage_clip(helper, damage_area.x1, damage_area.y1, + drm_rect_width(&damage_area), + drm_rect_height(&damage_area)); + drm_fb_helper_flush(helper); } return ret; @@ -1020,8 +1040,11 @@ void drm_fb_helper_cfb_fillrect(struct fb_info *info, cfb_fillrect(info, rect); - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, rect->dx, rect->dy, rect->width, rect->height); + if (helper->funcs->fb_dirty) { + drm_fb_helper_add_damage_clip(helper, rect->dx, rect->dy, + rect->width, rect->height); + drm_fb_helper_flush(helper); + } } EXPORT_SYMBOL(drm_fb_helper_cfb_fillrect); @@ -1039,8 +1062,11 @@ void drm_fb_helper_cfb_copyarea(struct fb_info *info, cfb_copyarea(info, area); - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, area->dx, area->dy, area->width, area->height); + if (helper->funcs->fb_dirty) { + drm_fb_helper_add_damage_clip(helper, area->dx, area->dy, + area->width, area->height); + drm_fb_helper_flush(helper); + } } EXPORT_SYMBOL(drm_fb_helper_cfb_copyarea); @@ -1058,8 +1084,11 @@ void drm_fb_helper_cfb_imageblit(struct fb_info *info, cfb_imageblit(info, image); - if (helper->funcs->fb_dirty) - drm_fb_helper_damage(helper, image->dx, image->dy, image->width, image->height); + if (helper->funcs->fb_dirty) { + drm_fb_helper_add_damage_clip(helper, image->dx, image->dy, + image->width, image->height); + drm_fb_helper_flush(helper); + } } EXPORT_SYMBOL(drm_fb_helper_cfb_imageblit); diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c index c730253ab85ce..325d12c3a4d61 100644 --- a/drivers/video/fbdev/core/fb_defio.c +++ b/drivers/video/fbdev/core/fb_defio.c @@ -332,3 +332,19 @@ void fb_deferred_io_cleanup(struct fb_info *info) mutex_destroy(&fbdefio->lock); } EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup); + +void fb_deferred_io_flush(struct fb_info *info) +{ + struct fb_deferred_io *fbdefio = info->fbdefio; + + if (WARN_ON_ONCE(!fbdefio)) + return; /* bug in driver logic */ + + /* + * There's no requirement to perform the flush immediately. So + * schedule the worker with a delay and let a few more writes + * pile up. + */ + schedule_delayed_work(&info->deferred_work, fbdefio->delay); +} +EXPORT_SYMBOL_GPL(fb_deferred_io_flush); diff --git a/include/linux/fb.h b/include/linux/fb.h index bcb8658f5b64d..54b3b3e13522f 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -663,6 +663,7 @@ extern void fb_deferred_io_open(struct fb_info *info, struct inode *inode, struct file *file); extern void fb_deferred_io_cleanup(struct fb_info *info); +extern void fb_deferred_io_flush(struct fb_info *info); extern int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasync); From patchwork Thu Nov 10 13:55:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13038823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFA46C4332F for ; Thu, 10 Nov 2022 13:55:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 204EA10E7D1; Thu, 10 Nov 2022 13:55:53 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 221A510E7CF for ; Thu, 10 Nov 2022 13:55:24 +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 smtp-out1.suse.de (Postfix) with ESMTPS id 4406722AA7; Thu, 10 Nov 2022 13:55:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1668088522; 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=i9eBXxN7mXkEdLsNGtlvbjv7IIOoP5uxEM08fIfHnIQ=; b=uoeBzXHC3WayvfkNFjrJxvmkNe8WTjyYbN8fBMjUl7f0CEhlKDKGb7wK71XKrqdT2h9hG7 xBXMdauaI/wIAtQ9CEulhIzOurKrwBT4ZgtymZrB6wstaiwHw+aw1uj2wKmQUSV+B28m5Q cFEsO4t2Dzs70weAzy7jbAXfZFW/or4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1668088522; 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=i9eBXxN7mXkEdLsNGtlvbjv7IIOoP5uxEM08fIfHnIQ=; b=0ro/S61W9UWwHuoGZKmzlA4inrbQSsCQShoOxiK3akjWH4kZcljgy1Tsbz13/3TbFtUiCb Q546BCFSocHsyyAg== 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 219C01332F; Thu, 10 Nov 2022 13:55:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8H12B8oCbWP/DAAAMHmgww (envelope-from ); Thu, 10 Nov 2022 13:55:22 +0000 From: Thomas Zimmermann To: daniel@ffwll.ch, airlied@gmail.com, javierm@redhat.com, mripard@kernel.org, maarten.lankhorst@linux.intel.com Subject: [PATCH 5/5] drm/fb-helper: Remove damage worker Date: Thu, 10 Nov 2022 14:55:19 +0100 Message-Id: <20221110135519.30029-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221110135519.30029-1-tzimmermann@suse.de> References: <20221110135519.30029-1-tzimmermann@suse.de> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The fbdev damage worker is unused, so remove it. Signed-off-by: Thomas Zimmermann Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 9 --------- include/drm/drm_fb_helper.h | 2 -- 2 files changed, 11 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 8cb644e4ecf90..47b8ef03a1f89 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -403,13 +403,6 @@ static void drm_fb_helper_fb_dirty(struct drm_fb_helper *helper) spin_unlock_irqrestore(&helper->damage_lock, flags); } -static void drm_fb_helper_damage_work(struct work_struct *work) -{ - struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper, damage_work); - - drm_fb_helper_fb_dirty(helper); -} - /** * drm_fb_helper_prepare - setup a drm_fb_helper structure * @dev: DRM device @@ -425,7 +418,6 @@ void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, INIT_LIST_HEAD(&helper->kernel_fb_list); spin_lock_init(&helper->damage_lock); INIT_WORK(&helper->resume_work, drm_fb_helper_resume_worker); - INIT_WORK(&helper->damage_work, drm_fb_helper_damage_work); helper->damage_clip.x1 = helper->damage_clip.y1 = ~0; mutex_init(&helper->lock); helper->funcs = funcs; @@ -557,7 +549,6 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) return; cancel_work_sync(&fb_helper->resume_work); - cancel_work_sync(&fb_helper->damage_work); info = fb_helper->info; if (info) { diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index ecfcd2c56d95a..f37bb2832ba41 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -116,7 +116,6 @@ struct drm_fb_helper_funcs { * @damage_clip: clip rectangle used with deferred_io to accumulate damage to * the screen buffer * @damage_lock: spinlock protecting @damage_clip - * @damage_work: worker used to flush the framebuffer * @resume_work: worker used during resume if the console lock is already taken * * This is the main structure used by the fbdev helpers. Drivers supporting @@ -146,7 +145,6 @@ struct drm_fb_helper { u32 pseudo_palette[17]; struct drm_clip_rect damage_clip; spinlock_t damage_lock; - struct work_struct damage_work; struct work_struct resume_work; /**