From patchwork Thu Jul 6 15:08:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303910 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70C5CC001DD for ; Thu, 6 Jul 2023 15:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231972AbjGFPOh (ORCPT ); Thu, 6 Jul 2023 11:14:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbjGFPOh (ORCPT ); Thu, 6 Jul 2023 11:14:37 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 235B7FC for ; Thu, 6 Jul 2023 08:14:36 -0700 (PDT) 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 CC7E91FD65; Thu, 6 Jul 2023 15:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656474; 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=0LAe03vb9IhXaEKz5mFi8+dV6xovZ5LeTsmRknDA0M4=; b=ds+VtJ776NQqFdrtbOU4lPKg2Qra8vwur88Yg7N2uGzHgW3dIXK+sRfKHluJnRa2A1pz8A KUWHlSLRrtptF2Brajo6ob54qX+FVuUnD6KuHy2+VAiGsbwSLT2tFygerGwwsGuFf6wAfh M5qL4Xjy/55edevHHcWQ3Uv85u3zbyA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656474; 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=0LAe03vb9IhXaEKz5mFi8+dV6xovZ5LeTsmRknDA0M4=; b=jxn2l9cLay5aCsU230g+pUua3qH3ZQGr0N21TSHmrKmK1BX1ifGeTEyLWbolFcWbGwyV9V 3CqgJz1ERQtaLSCA== 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 A6D6B138FC; Thu, 6 Jul 2023 15:14:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ODvOJ1rapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:34 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 01/10] fbdev/broadsheetfb: Select FB_SYS_HELPERS_DEFERRED Date: Thu, 6 Jul 2023 17:08:44 +0200 Message-ID: <20230706151432.20674-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The Kconfig token FB_SYS_HELPERS_DEFERRED selects everything that is required for deferred I/O on system-memory framebuffers. Select it from FB_BROADSHEET in favor of the existing identical selection. Signed-off-by: Thomas Zimmermann Acked-by: Helge Deller --- drivers/video/fbdev/Kconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index f14229757311..fd862faafe66 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -2179,11 +2179,7 @@ config FB_MX3 config FB_BROADSHEET tristate "E-Ink Broadsheet/Epson S1D13521 controller support" depends on FB && (ARCH_PXA || COMPILE_TEST) - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS - select FB_DEFERRED_IO + select FB_SYS_HELPERS_DEFERRED help This driver implements support for the E-Ink Broadsheet controller. The release name for this device was Epson S1D13521 From patchwork Thu Jul 6 15:08:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303909 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9925BC001DF for ; Thu, 6 Jul 2023 15:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232728AbjGFPOj (ORCPT ); Thu, 6 Jul 2023 11:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbjGFPOh (ORCPT ); Thu, 6 Jul 2023 11:14:37 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4666B119 for ; Thu, 6 Jul 2023 08:14:36 -0700 (PDT) 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 EFEF21FDDE; Thu, 6 Jul 2023 15:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656474; 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=jQo6aolElvvRcJn1/52a83zykwUTIrP8B81NEDQhyik=; b=q9swbigEJyWiCEsvcIKmYNw86mQlweyGII4bQQzfZ4eTzm8SKCK1Uk/rs8GmWy9wVWVFOV o9nqpco7g6G6q5J/PixCV3+i2eR0T/Ijp7oVQ0GJ1x7yv1Z7qWakzvbfaJUIvqkJ6dAvxn IZQ/zGarRKLT/yOhbG/JNpUd694Cr8I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656474; 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=jQo6aolElvvRcJn1/52a83zykwUTIrP8B81NEDQhyik=; b=D7iCDoiDtjNyCSe1bA/zXML6m16xHIkRShmiYBDqA6rFClS+h8xnReCgOxtonp1AqDG/FY IWPYUwhXlWlbwDCg== 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 CE1311390F; Thu, 6 Jul 2023 15:14:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +HJFMVrapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:34 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 02/10] fbdev/broadsheetfb: Generate deferred I/O ops Date: Thu, 6 Jul 2023 17:08:45 +0200 Message-ID: <20230706151432.20674-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use the existing generator macros to create deferred-I/O helpers for broadsheetfb and set them in the fb_ops structure. Functions for damage handling on memory ranges and areas are provided by the driver. Broadsheedfb's implementation of fb_write writes to system memory, so the generated code can use the respective helper internally. This also fixes a long-standing bug where fb_write returned an errno code instead of the number of written bytes. See the commit message of commit 921b7383f348 ("fbdev: Return number of bytes read or written") for more details. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/broadsheetfb.c | 78 +++--------------------------- 1 file changed, 8 insertions(+), 70 deletions(-) diff --git a/drivers/video/fbdev/broadsheetfb.c b/drivers/video/fbdev/broadsheetfb.c index 5a5fe4bbc10b..cb725a91b6bb 100644 --- a/drivers/video/fbdev/broadsheetfb.c +++ b/drivers/video/fbdev/broadsheetfb.c @@ -970,90 +970,28 @@ static void broadsheetfb_dpy_deferred_io(struct fb_info *info, struct list_head } } -static void broadsheetfb_fillrect(struct fb_info *info, - const struct fb_fillrect *rect) +static void broadsheetfb_defio_damage_range(struct fb_info *info, off_t off, size_t len) { struct broadsheetfb_par *par = info->par; - sys_fillrect(info, rect); - broadsheetfb_dpy_update(par); } -static void broadsheetfb_copyarea(struct fb_info *info, - const struct fb_copyarea *area) +static void broadsheetfb_defio_damage_area(struct fb_info *info, u32 x, u32 y, + u32 width, u32 height) { struct broadsheetfb_par *par = info->par; - sys_copyarea(info, area); - broadsheetfb_dpy_update(par); } -static void broadsheetfb_imageblit(struct fb_info *info, - const struct fb_image *image) -{ - struct broadsheetfb_par *par = info->par; - - sys_imageblit(info, image); - - broadsheetfb_dpy_update(par); -} - -/* - * this is the slow path from userspace. they can seek and write to - * the fb. it's inefficient to do anything less than a full screen draw - */ -static ssize_t broadsheetfb_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct broadsheetfb_par *par = info->par; - unsigned long p = *ppos; - void *dst; - int err = 0; - unsigned long total_size; - - if (!info->screen_buffer) - return -ENODEV; - - total_size = info->fix.smem_len; - - if (p > total_size) - return -EFBIG; - - if (count > total_size) { - err = -EFBIG; - count = total_size; - } - - if (count + p > total_size) { - if (!err) - err = -ENOSPC; - - count = total_size - p; - } - - dst = info->screen_buffer + p; - - if (copy_from_user(dst, buf, count)) - err = -EFAULT; - - if (!err) - *ppos += count; - - broadsheetfb_dpy_update(par); - - return (err) ? err : count; -} +FB_GEN_DEFAULT_DEFERRED_SYS_OPS(broadsheetfb, + broadsheetfb_defio_damage_range, + broadsheetfb_defio_damage_area) static const struct fb_ops broadsheetfb_ops = { - .owner = THIS_MODULE, - .fb_read = fb_sys_read, - .fb_write = broadsheetfb_write, - .fb_fillrect = broadsheetfb_fillrect, - .fb_copyarea = broadsheetfb_copyarea, - .fb_imageblit = broadsheetfb_imageblit, - .fb_mmap = fb_deferred_io_mmap, + .owner = THIS_MODULE, + FB_DEFAULT_DEFERRED_OPS(broadsheetfb), }; static struct fb_deferred_io broadsheetfb_defio = { From patchwork Thu Jul 6 15:08:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303908 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F7A3C001B0 for ; Thu, 6 Jul 2023 15:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232571AbjGFPOi (ORCPT ); Thu, 6 Jul 2023 11:14:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjGFPOh (ORCPT ); Thu, 6 Jul 2023 11:14:37 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6779DE70 for ; Thu, 6 Jul 2023 08:14:36 -0700 (PDT) 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 241D321A85; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656475; 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=gykiKqsC+RIJJ1Kkk+Ae5baDTD+6GqSNQhm49BPnI0o=; b=xGrheN4rwXAsk9pfANJBScM+pQMEKLfUs6Okm4Xoj1ExypPj6cNEzmGhMK66uy35hrScTp Ic5ZkgU1w3IZiNPUx/GFFJRF3IE1y8gxbpnl8/vQ6yRd7vvrqydbyrFZq15JOK98X7jKxR 2sO+C0kaaFcORKy1s48vM5kc/D3p0rc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656475; 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=gykiKqsC+RIJJ1Kkk+Ae5baDTD+6GqSNQhm49BPnI0o=; b=Ip2jzEQWsBlthP409CQ0y+1W6cELLYIG5zqpkwVaAN5sd9WjzMp+/GNCOnsGGatzEMvlsR FX2qGHrjUGtCNXAg== 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 006DD138FC; Thu, 6 Jul 2023 15:14:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YIqoOlrapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:34 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 03/10] fbdev/hecubafb: Select FB_SYS_HELPERS_DEFERRED Date: Thu, 6 Jul 2023 17:08:46 +0200 Message-ID: <20230706151432.20674-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The Kconfig token FB_SYS_HELPERS_DEFERRED selects everything that is required for deferred I/O on system-memory framebuffers. Select it from FB_HECUBA. Deferred I/O helpers were previously selected by n411, which builds upon hecubafb. Remove these select statements in favor of the new one. N411 does not implement any framebuffer I/O by itself. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/Kconfig | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index fd862faafe66..7587f06cb793 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -200,7 +200,7 @@ config FB_SYS_HELPERS_DEFERRED config FB_HECUBA tristate depends on FB - depends on FB_DEFERRED_IO + select FB_SYS_HELPERS_DEFERRED config FB_SVGALIB tristate @@ -691,11 +691,6 @@ config FB_EFI config FB_N411 tristate "N411 Apollo/Hecuba devkit support" depends on FB && X86 && MMU - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS - select FB_DEFERRED_IO select FB_HECUBA help This enables support for the Apollo display controller in its From patchwork Thu Jul 6 15:08:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303911 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDAEAC00528 for ; Thu, 6 Jul 2023 15:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232364AbjGFPOk (ORCPT ); Thu, 6 Jul 2023 11:14:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232203AbjGFPOi (ORCPT ); Thu, 6 Jul 2023 11:14:38 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4ED1732 for ; Thu, 6 Jul 2023 08:14:36 -0700 (PDT) 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 49ABE22853; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656475; 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=5NagF6vJZmPBPjZYwJAr2QCnSInNpMOX6TMIQwcD5js=; b=yCk36NuvH4UXAfBO5Jz3A1Gb0FR1n+g6fyQ8nmWB/QSuTCmJSd61Mu+bUxciNZNr9ZyJ6U DGDf/h0NHOfIXLutWBbipUijjCnIBd0ElJyZqgVdqXB/1sohOXynXH2JjYtb5OClPT0RZo C//ypRUuYifbsY9yw1ucAdTljgsyw2s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656475; 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=5NagF6vJZmPBPjZYwJAr2QCnSInNpMOX6TMIQwcD5js=; b=92pjfVp72qDxllbfvTQsh9O2ewHKTs8zTcdLRmAxKbWoLTz/y22ApMDrq0CiP6OgPkEJuR YARBTyJxVr1/c8AQ== 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 2882F1390F; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yB/iCFvapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:35 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 04/10] fbdev/hecubafb: Generate deferred I/O ops Date: Thu, 6 Jul 2023 17:08:47 +0200 Message-ID: <20230706151432.20674-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use the existing generator macros to create deferred-I/O helpers for hecubafb and set them in the fb_ops structure. Functions for damage handling on memory ranges and areas are provided by the driver. Hecubafb's implementation of fb_write writes to system memory, so the generated code can use the respective helper internally. This also fixes a long-standing bug where fb_write returned an errno code instead of the number of written bytes. See the commit message of commit 921b7383f348 ("fbdev: Return number of bytes read or written") for more details. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/hecubafb.c | 78 ++++------------------------------ 1 file changed, 8 insertions(+), 70 deletions(-) diff --git a/drivers/video/fbdev/hecubafb.c b/drivers/video/fbdev/hecubafb.c index 7ce0a16ce8b9..5043d08ade54 100644 --- a/drivers/video/fbdev/hecubafb.c +++ b/drivers/video/fbdev/hecubafb.c @@ -120,90 +120,28 @@ static void hecubafb_dpy_deferred_io(struct fb_info *info, struct list_head *pag hecubafb_dpy_update(info->par); } -static void hecubafb_fillrect(struct fb_info *info, - const struct fb_fillrect *rect) +static void hecubafb_defio_damage_range(struct fb_info *info, off_t off, size_t len) { struct hecubafb_par *par = info->par; - sys_fillrect(info, rect); - hecubafb_dpy_update(par); } -static void hecubafb_copyarea(struct fb_info *info, - const struct fb_copyarea *area) +static void hecubafb_defio_damage_area(struct fb_info *info, u32 x, u32 y, + u32 width, u32 height) { struct hecubafb_par *par = info->par; - sys_copyarea(info, area); - hecubafb_dpy_update(par); } -static void hecubafb_imageblit(struct fb_info *info, - const struct fb_image *image) -{ - struct hecubafb_par *par = info->par; - - sys_imageblit(info, image); - - hecubafb_dpy_update(par); -} - -/* - * this is the slow path from userspace. they can seek and write to - * the fb. it's inefficient to do anything less than a full screen draw - */ -static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct hecubafb_par *par = info->par; - unsigned long p = *ppos; - void *dst; - int err = 0; - unsigned long total_size; - - if (!info->screen_buffer) - return -ENODEV; - - total_size = info->fix.smem_len; - - if (p > total_size) - return -EFBIG; - - if (count > total_size) { - err = -EFBIG; - count = total_size; - } - - if (count + p > total_size) { - if (!err) - err = -ENOSPC; - - count = total_size - p; - } - - dst = info->screen_buffer + p; - - if (copy_from_user(dst, buf, count)) - err = -EFAULT; - - if (!err) - *ppos += count; - - hecubafb_dpy_update(par); - - return (err) ? err : count; -} +FB_GEN_DEFAULT_DEFERRED_SYS_OPS(hecubafb, + hecubafb_defio_damage_range, + hecubafb_defio_damage_area) static const struct fb_ops hecubafb_ops = { - .owner = THIS_MODULE, - .fb_read = fb_sys_read, - .fb_write = hecubafb_write, - .fb_fillrect = hecubafb_fillrect, - .fb_copyarea = hecubafb_copyarea, - .fb_imageblit = hecubafb_imageblit, - .fb_mmap = fb_deferred_io_mmap, + .owner = THIS_MODULE, + FB_DEFAULT_DEFERRED_OPS(hecubafb), }; static struct fb_deferred_io hecubafb_defio = { From patchwork Thu Jul 6 15:08:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303907 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EFD3EB64DC for ; Thu, 6 Jul 2023 15:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231860AbjGFPOj (ORCPT ); Thu, 6 Jul 2023 11:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232364AbjGFPOi (ORCPT ); Thu, 6 Jul 2023 11:14:38 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C238E173F for ; Thu, 6 Jul 2023 08:14:36 -0700 (PDT) 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 71A4B22858; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656475; 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=44HRkRuEyibkGd0p7+sOBcABlE9d9l6W5NynsyfUK9s=; b=DMm8SADzaWvpZUUHo4/+oLLJbPNUqxMhE2QP0UxWrcuQxMCt+7Wkk4ylGtSkFy15nsB+2l 3nPd71gnj1We3rLgTy+8msSmGPGINmJwlKkJSbpl66eLuGDgVmXBgsbXwRAP7LVxsvIbLe NiHgglHIqpK2NN8XdUmT0milaL27WWM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656475; 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=44HRkRuEyibkGd0p7+sOBcABlE9d9l6W5NynsyfUK9s=; b=b/Kk/dlK6/twgUeDZv6CzuPSK2WtbrgQd2KPvwuEGGImsxxz/lx+4uZW0VUEbTBOarhNxd vsaXyVS51d+mnSAA== 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 4F0D7138FC; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CEJnElvapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:35 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 05/10] fbdev/metronomefb: Select FB_SYS_HELPERS_DEFERRED Date: Thu, 6 Jul 2023 17:08:48 +0200 Message-ID: <20230706151432.20674-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The Kconfig token FB_SYS_HELPERS_DEFERRED selects everything that is required for deferred I/O on system-memory framebuffers. Select it from FB_METRONOME in favor of the existing identical selection. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/Kconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 7587f06cb793..1155d7aa0917 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -2088,11 +2088,7 @@ config XEN_FBDEV_FRONTEND config FB_METRONOME tristate "E-Ink Metronome/8track controller support" depends on FB - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS - select FB_DEFERRED_IO + select FB_SYS_HELPERS_DEFERRED help This driver implements support for the E-Ink Metronome controller. The pre-release name for this device was 8track From patchwork Thu Jul 6 15:08:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303915 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03E64EB64D9 for ; Thu, 6 Jul 2023 15:14:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232117AbjGFPOl (ORCPT ); Thu, 6 Jul 2023 11:14:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232523AbjGFPOi (ORCPT ); Thu, 6 Jul 2023 11:14:38 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23B83F0 for ; Thu, 6 Jul 2023 08:14:37 -0700 (PDT) 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 99B661FDD8; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656475; 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=FAcsa10uv3EiV7S+XtXQF0w8NZrWo/NANzWi+Iocj7A=; b=XK5VFfILZ2CcwaU+ySc66wZoJ2OcRtXjht+EpWqjwPiPNsHxYXk8oFpFJy5GtDe0DFAJus Rjsdxq7lCrCYTw//n5T8W9otzlXQfr5m1UVqJr2MWwfhe2pRDvbthvvCYyx/XXNb0dw2Ih Rj5cUg+E+cGMT897TNjfxVPVHQSrCmI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656475; 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=FAcsa10uv3EiV7S+XtXQF0w8NZrWo/NANzWi+Iocj7A=; b=nrsA1OE+v8Kzp5NwlKhGloesQEmwK1LNi9zAPjg4hIAHEv58QoWbN2toshdmRdrnqLmA1M PQcqHuUfRHWP6qCQ== 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 76A871390F; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qB/gG1vapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:35 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 06/10] fbdev/metronomefb: Generate deferred I/O ops Date: Thu, 6 Jul 2023 17:08:49 +0200 Message-ID: <20230706151432.20674-7-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use the existing generator macros to create deferred-I/O helpers for metronomefb and set them in the fb_ops structure. Functions for damage handling on memory ranges and areas are provided by the driver. Metronomefb's implementation of fb_write writes to system memory, so the generated code can use the respective helper internally. This also fixes a long-standing bug where fb_write returned an errno code instead of the number of written bytes. See the commit message of commit 921b7383f348 ("fbdev: Return number of bytes read or written") for more details. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/metronomefb.c | 74 ++++--------------------------- 1 file changed, 8 insertions(+), 66 deletions(-) diff --git a/drivers/video/fbdev/metronomefb.c b/drivers/video/fbdev/metronomefb.c index 3e1daca76e11..667bef10738c 100644 --- a/drivers/video/fbdev/metronomefb.c +++ b/drivers/video/fbdev/metronomefb.c @@ -483,86 +483,28 @@ static void metronomefb_dpy_deferred_io(struct fb_info *info, struct list_head * metronome_display_cmd(par); } -static void metronomefb_fillrect(struct fb_info *info, - const struct fb_fillrect *rect) +static void metronomefb_defio_damage_range(struct fb_info *info, off_t off, size_t len) { struct metronomefb_par *par = info->par; - sys_fillrect(info, rect); metronomefb_dpy_update(par); } -static void metronomefb_copyarea(struct fb_info *info, - const struct fb_copyarea *area) +static void metronomefb_defio_damage_area(struct fb_info *info, u32 x, u32 y, + u32 width, u32 height) { struct metronomefb_par *par = info->par; - sys_copyarea(info, area); metronomefb_dpy_update(par); } -static void metronomefb_imageblit(struct fb_info *info, - const struct fb_image *image) -{ - struct metronomefb_par *par = info->par; - - sys_imageblit(info, image); - metronomefb_dpy_update(par); -} - -/* - * this is the slow path from userspace. they can seek and write to - * the fb. it is based on fb_sys_write - */ -static ssize_t metronomefb_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct metronomefb_par *par = info->par; - unsigned long p = *ppos; - void *dst; - int err = 0; - unsigned long total_size; - - if (!info->screen_buffer) - return -ENODEV; - - total_size = info->fix.smem_len; - - if (p > total_size) - return -EFBIG; - - if (count > total_size) { - err = -EFBIG; - count = total_size; - } - - if (count + p > total_size) { - if (!err) - err = -ENOSPC; - - count = total_size - p; - } - - dst = info->screen_buffer + p; - - if (copy_from_user(dst, buf, count)) - err = -EFAULT; - - if (!err) - *ppos += count; - - metronomefb_dpy_update(par); - - return (err) ? err : count; -} +FB_GEN_DEFAULT_DEFERRED_SYS_OPS(metronomefb, + metronomefb_defio_damage_range, + metronomefb_defio_damage_area) static const struct fb_ops metronomefb_ops = { - .owner = THIS_MODULE, - .fb_write = metronomefb_write, - .fb_fillrect = metronomefb_fillrect, - .fb_copyarea = metronomefb_copyarea, - .fb_imageblit = metronomefb_imageblit, - .fb_mmap = fb_deferred_io_mmap, + .owner = THIS_MODULE, + FB_DEFAULT_DEFERRED_OPS(metronomefb), }; static struct fb_deferred_io metronomefb_defio = { From patchwork Thu Jul 6 15:08:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303912 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37CC1C001E0 for ; Thu, 6 Jul 2023 15:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233487AbjGFPOk (ORCPT ); Thu, 6 Jul 2023 11:14:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232469AbjGFPOi (ORCPT ); Thu, 6 Jul 2023 11:14:38 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 276C11996 for ; Thu, 6 Jul 2023 08:14:37 -0700 (PDT) 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 BD3931FDFE; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656475; 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=fWhorBn5uehAGZQnjrjmdfm2a0lk+Z9qAAgVU6GXqK0=; b=cokmoNjowROkAqkc3awZyrgqgEkkLqwko1Djxv11ty1jMxaLZZtKd9WtuGOdmTFJPlPIwm cfovIcK/SWtTgGsmOZrbjA5YbnJgrBVpdWq3shigGilwGoBUbZtRQ2FApjA4SijcjBfHCI 1OKmGcZmbu1vxvn6/kmOZL1cTLUOvdk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656475; 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=fWhorBn5uehAGZQnjrjmdfm2a0lk+Z9qAAgVU6GXqK0=; b=W43sP9/etPj/ijMNyFwSof/boKJbI07A1CYb+lCKNo5HhcuOEKSYhGNz52GzvP8NmouOZh RYwF7VveH6BBfNCw== 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 9E7CF1390F; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ED6qJVvapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:35 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 07/10] fbdev/ssd1307fb: Select FB_SYS_HELPERS_DEFERRED Date: Thu, 6 Jul 2023 17:08:50 +0200 Message-ID: <20230706151432.20674-8-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The Kconfig token FB_SYS_HELPERS_DEFERRED selects everything that is required for deferred I/O on system-memory framebuffers. Select it from FB_SSD1307 in favor of the existing identical selection. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/Kconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 1155d7aa0917..763316acfc02 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -2211,12 +2211,8 @@ config FB_SSD1307 tristate "Solomon SSD1307 framebuffer support" depends on FB && I2C depends on GPIOLIB || COMPILE_TEST - select FB_SYS_FOPS - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_DEFERRED_IO select FB_BACKLIGHT + select FB_SYS_HELPERS_DEFERRED help This driver implements support for the Solomon SSD1307 OLED controller over I2C. From patchwork Thu Jul 6 15:08:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303913 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88557EB64DD for ; Thu, 6 Jul 2023 15:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232203AbjGFPOl (ORCPT ); Thu, 6 Jul 2023 11:14:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232611AbjGFPOi (ORCPT ); Thu, 6 Jul 2023 11:14:38 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6095F1997 for ; Thu, 6 Jul 2023 08:14:37 -0700 (PDT) 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 E4B1A2285D; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656475; 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=NVf0m2es0yK7mPVaVFTp11XST+fQvUNnxDouX4Snpik=; b=vVKHog6M2zMVJmKreFiO2PXXnSa+MDmONM8BN8EUlqebplGdgTGUqtT8Wnxr+H+olhMCrF V3OpAvtP9PGtu+kRzUjLZNQidDlZ5ebQ3iRFYu859+wj1lKZTDMWpJlsxL7Bsr5xGAdvM6 qEgTB1GPJvQ1R6Wiw3Y5znB2jgL0MOQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656475; 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=NVf0m2es0yK7mPVaVFTp11XST+fQvUNnxDouX4Snpik=; b=/kFIB5cjjeNXQ37FbSj8+JRIL9r+qD/dIiDNGzd7xx/IcC37Hvqxd55Cp2KztMi1jOXnCc CEh2OPRoIrDSsCBQ== 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 C37BD138FC; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WGyULlvapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:35 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 08/10] fbdev/ssd1307fb: Generate deferred I/O ops Date: Thu, 6 Jul 2023 17:08:51 +0200 Message-ID: <20230706151432.20674-9-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use the existing generator macros to create deferred-I/O helpers for ssd1307fb and set them in the fb_ops structure. Functions for damage handling on memory ranges and areas are provided by the driver. Ssd1307fb's implementation of fb_write writes to system memory, so the generated code can use the respective helper internally. This also fixes a long-standing bug where fb_write returned an errno code instead of the number of written bytes. See the commit message of commit 921b7383f348 ("fbdev: Return number of bytes read or written") for more details. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/ssd1307fb.c | 69 ++++++--------------------------- 1 file changed, 11 insertions(+), 58 deletions(-) diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 11c373798279..a2b939342a4f 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -292,43 +292,6 @@ static int ssd1307fb_update_display(struct ssd1307fb_par *par) return ssd1307fb_update_rect(par, 0, 0, par->width, par->height); } -static ssize_t ssd1307fb_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct ssd1307fb_par *par = info->par; - unsigned long total_size; - unsigned long p = *ppos; - void *dst; - int ret; - - if (!info->screen_buffer) - return -ENODEV; - - total_size = info->fix.smem_len; - - if (p > total_size) - return -EINVAL; - - if (count + p > total_size) - count = total_size - p; - - if (!count) - return -EINVAL; - - dst = info->screen_buffer + p; - - if (copy_from_user(dst, buf, count)) - return -EFAULT; - - ret = ssd1307fb_update_display(par); - if (ret < 0) - return ret; - - *ppos += count; - - return count; -} - static int ssd1307fb_blank(int blank_mode, struct fb_info *info) { struct ssd1307fb_par *par = info->par; @@ -339,39 +302,29 @@ static int ssd1307fb_blank(int blank_mode, struct fb_info *info) return ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON); } -static void ssd1307fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) +static void ssd1307fb_defio_damage_range(struct fb_info *info, off_t off, size_t len) { struct ssd1307fb_par *par = info->par; - sys_fillrect(info, rect); - ssd1307fb_update_rect(par, rect->dx, rect->dy, rect->width, - rect->height); -} -static void ssd1307fb_copyarea(struct fb_info *info, const struct fb_copyarea *area) -{ - struct ssd1307fb_par *par = info->par; - sys_copyarea(info, area); - ssd1307fb_update_rect(par, area->dx, area->dy, area->width, - area->height); + ssd1307fb_update_display(par); } -static void ssd1307fb_imageblit(struct fb_info *info, const struct fb_image *image) +static void ssd1307fb_defio_damage_area(struct fb_info *info, u32 x, u32 y, + u32 width, u32 height) { struct ssd1307fb_par *par = info->par; - sys_imageblit(info, image); - ssd1307fb_update_rect(par, image->dx, image->dy, image->width, - image->height); + + ssd1307fb_update_rect(par, x, y, width, height); } +FB_GEN_DEFAULT_DEFERRED_SYS_OPS(ssd1307fb, + ssd1307fb_defio_damage_range, + ssd1307fb_defio_damage_area) + static const struct fb_ops ssd1307fb_ops = { .owner = THIS_MODULE, - .fb_read = fb_sys_read, - .fb_write = ssd1307fb_write, + FB_DEFAULT_DEFERRED_OPS(ssd1307fb), .fb_blank = ssd1307fb_blank, - .fb_fillrect = ssd1307fb_fillrect, - .fb_copyarea = ssd1307fb_copyarea, - .fb_imageblit = ssd1307fb_imageblit, - .fb_mmap = fb_deferred_io_mmap, }; static void ssd1307fb_deferred_io(struct fb_info *info, struct list_head *pagereflist) From patchwork Thu Jul 6 15:08:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303914 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB1D9C04A6A for ; Thu, 6 Jul 2023 15:14:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232469AbjGFPOm (ORCPT ); Thu, 6 Jul 2023 11:14:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbjGFPOi (ORCPT ); Thu, 6 Jul 2023 11:14:38 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D9AE119 for ; Thu, 6 Jul 2023 08:14:38 -0700 (PDT) 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 133EF1FDF3; Thu, 6 Jul 2023 15:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656476; 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=0S6OE/6vVwojx8uLdiLFqAty3LxGvxsG3EamOo9J62k=; b=tHn0fLlbpOw54dXdjN5mGJ9MqLA2gu82wyEgYkITomxhck8a5/5fqr3ox3UrAc+Vforbr+ WwEvP4koKxW+QLU1RGny3RET5D/JsCRrHjdDrA5SkQyj0+OfQqPTHWoFvaGner67shs7hj 13uWIMUeYVpuzQkxD5OXb/VM2wKknV8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656476; 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=0S6OE/6vVwojx8uLdiLFqAty3LxGvxsG3EamOo9J62k=; b=GtvqXWhQtxMC2IcbVbDRPTM/VLVMrRrNncA1dJ+jaaWWwy7C/4pfQ4A3EnIcI0Z/6pVkpD fwfqRGr7WZeIYrDQ== 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 E895F1390F; Thu, 6 Jul 2023 15:14:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8LLZN1vapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:35 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 09/10] fbdev/xen-fbfront: Select FB_SYS_HELPERS_DEFERRED Date: Thu, 6 Jul 2023 17:08:52 +0200 Message-ID: <20230706151432.20674-10-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The Kconfig token FB_SYS_HELPERS_DEFERRED selects everything that is required for deferred I/O on system-memory framebuffers. Select it from XEN_FBDEV_FRONTEND in favor of the existing identical selection. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/Kconfig | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 763316acfc02..ec2abe882ed9 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -2073,11 +2073,7 @@ config FB_VIRTUAL config XEN_FBDEV_FRONTEND tristate "Xen virtual frame buffer support" depends on FB && XEN - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS - select FB_DEFERRED_IO + select FB_SYS_HELPERS_DEFERRED select XEN_XENBUS_FRONTEND default y help From patchwork Thu Jul 6 15:08:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13303916 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 691BDC04A94 for ; Thu, 6 Jul 2023 15:14:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232523AbjGFPOl (ORCPT ); Thu, 6 Jul 2023 11:14:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjGFPOi (ORCPT ); Thu, 6 Jul 2023 11:14:38 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B17CFC for ; Thu, 6 Jul 2023 08:14:37 -0700 (PDT) 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 380AE22860; Thu, 6 Jul 2023 15:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688656476; 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=36EIUUn7Yddtfbgxzy5lfozydt7DISbFzo5nF9ZHH3o=; b=zLnWrW8ENRb2PwLcNw6WSNL3uc0e9ZSBTCtqq3yGV1GR/LKwHvcm3ACeHy1i/1x8e7YX60 4LmqzmmFhDVk5AoHyoc+i5fHW3ZGmwim0N0zXqTZK7BUy9ailLcqBKa2+jpcXD9dfjtMZQ YlZft7LdxzmF3VJp4/qqpDZ8O+XDeV4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688656476; 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=36EIUUn7Yddtfbgxzy5lfozydt7DISbFzo5nF9ZHH3o=; b=tXPFfkJQBzZ9NTBfXtMfi9QfaovS4qJv1KDKvtrBlLDQhsqZDfS4Sqvh+LGk9Nk1YiLHMP 3o8OF9SLiCVz50BA== 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 183E0138FC; Thu, 6 Jul 2023 15:14:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wMH7BFzapmRvDgAAMHmgww (envelope-from ); Thu, 06 Jul 2023 15:14:36 +0000 From: Thomas Zimmermann To: javierm@redhat.com, deller@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH 10/10] fbdev/xen-fbfront: Generate deferred I/O ops Date: Thu, 6 Jul 2023 17:08:53 +0200 Message-ID: <20230706151432.20674-11-tzimmermann@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706151432.20674-1-tzimmermann@suse.de> References: <20230706151432.20674-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use the existing generator macros to create deferred-I/O helpers for xen-fbfront and set them in the fb_ops structure. Functions for damage handling on memory ranges and areas are provided by the driver. Xen-fbfront's implementation of fb_write writes to system memory, so the generated code can use the respective helper internally. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/xen-fbfront.c | 61 ++++++++++--------------------- 1 file changed, 20 insertions(+), 41 deletions(-) diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c index 9b2a786621a6..6664dc7a5a41 100644 --- a/drivers/video/fbdev/xen-fbfront.c +++ b/drivers/video/fbdev/xen-fbfront.c @@ -240,41 +240,6 @@ static int xenfb_setcolreg(unsigned regno, unsigned red, unsigned green, return 0; } -static void xenfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect) -{ - struct xenfb_info *info = p->par; - - sys_fillrect(p, rect); - xenfb_refresh(info, rect->dx, rect->dy, rect->width, rect->height); -} - -static void xenfb_imageblit(struct fb_info *p, const struct fb_image *image) -{ - struct xenfb_info *info = p->par; - - sys_imageblit(p, image); - xenfb_refresh(info, image->dx, image->dy, image->width, image->height); -} - -static void xenfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) -{ - struct xenfb_info *info = p->par; - - sys_copyarea(p, area); - xenfb_refresh(info, area->dx, area->dy, area->width, area->height); -} - -static ssize_t xenfb_write(struct fb_info *p, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct xenfb_info *info = p->par; - ssize_t res; - - res = fb_sys_write(p, buf, count, ppos); - xenfb_refresh(info, 0, 0, info->page->width, info->page->height); - return res; -} - static int xenfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { @@ -326,17 +291,31 @@ static int xenfb_set_par(struct fb_info *info) return 0; } +static void xenfb_defio_damage_range(struct fb_info *info, off_t off, size_t len) +{ + struct xenfb_info *xenfb_info = info->par; + + xenfb_refresh(xenfb_info, 0, 0, xenfb_info->page->width, xenfb_info->page->height); +} + +static void xenfb_defio_damage_area(struct fb_info *info, u32 x, u32 y, + u32 width, u32 height) +{ + struct xenfb_info *xenfb_info = info->par; + + xenfb_refresh(xenfb_info, x, y, width, height); +} + +FB_GEN_DEFAULT_DEFERRED_SYS_OPS(xenfb, + xenfb_defio_damage_range, + xenfb_defio_damage_area) + static const struct fb_ops xenfb_fb_ops = { .owner = THIS_MODULE, - .fb_read = fb_sys_read, - .fb_write = xenfb_write, + FB_DEFAULT_DEFERRED_OPS(xenfb), .fb_setcolreg = xenfb_setcolreg, - .fb_fillrect = xenfb_fillrect, - .fb_copyarea = xenfb_copyarea, - .fb_imageblit = xenfb_imageblit, .fb_check_var = xenfb_check_var, .fb_set_par = xenfb_set_par, - .fb_mmap = fb_deferred_io_mmap, }; static irqreturn_t xenfb_event_handler(int rq, void *dev_id)