sparclinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h>
@ 2023-05-04  7:45 Thomas Zimmermann
  2023-05-04  7:45 ` [PATCH v4 1/6] fbdev/matrox: Remove trailing whitespaces Thomas Zimmermann
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-04  7:45 UTC (permalink / raw)
  To: deller, geert, javierm, daniel, vgupta, chenhuacai, kernel,
	davem, James.Bottomley, arnd, sam
  Cc: linux-fbdev, dri-devel, linux-arch, linux-snps-arc, linux-kernel,
	linux-ia64, loongarch, linux-m68k, sparclinux, linux-arm-kernel,
	linux-parisc, Thomas Zimmermann

Fbdev provides helpers for framebuffer I/O, such as fb_readl(),
fb_writel() or fb_memcpy_to_fb(). The implementation of each helper
depends on the architecture, but they are all equivalent to regular
I/O functions of similar names. So use regular functions instead and
move all helpers into <asm-generic/fb.h>

The first patch a simple whitespace cleanup.

Until now, <linux/fb.h> contained an include of <asm/io.h>. As this
will go away, patches 2 to 4 prepare include statements in the various
drivers. Source files that use regular I/O helpers, such as readl(),
now include <linux/io.h>. Source files that use framebuffer I/O
helpers, such as fb_readl(), now include <linux/fb.h>.

Patch 5 replaces the architecture-based if-else branching in 
<linux/fb.h> by helpers in <asm-generic/fb.h>. All helpers use Linux'
existing I/O functions.

Patch 6 harmonizes naming among fbdev and existing I/O functions.

The patchset has been built for a variety of platforms, such as x86-64,
arm, aarch64, ppc64, parisc, m64k, mips and sparc.

v4:
	* keep fb_mem*() as-is on ia64, loongarch, sparc64 (Arnd)
	* don't include <asm/fb.h> (Sam)
v3:
	* add the new helpers in <asm-generic/fb.h>
	* support reordering and native byte order (Geert, Arnd)
v2:
	* use Linux I/O helpers (Sam, Arnd)

Thomas Zimmermann (6):
  fbdev/matrox: Remove trailing whitespaces
  ipu-v3: Include <linux/io.h>
  fbdev: Include <linux/io.h> in various drivers
  fbdev: Include <linux/fb.h> instead of <asm/fb.h>
  fbdev: Move framebuffer I/O helpers into <asm/fb.h>
  fbdev: Rename fb_mem*() helpers

 arch/ia64/include/asm/fb.h                  |  20 ++++
 arch/loongarch/include/asm/fb.h             |  21 ++++
 arch/parisc/video/fbdev.c                   |   3 +-
 arch/sparc/include/asm/fb.h                 |  20 ++++
 arch/sparc/video/fbdev.c                    |   1 -
 arch/x86/video/fbdev.c                      |   2 -
 drivers/gpu/ipu-v3/ipu-prv.h                |   1 +
 drivers/staging/sm750fb/sm750.c             |   2 +-
 drivers/video/fbdev/arcfb.c                 |   1 +
 drivers/video/fbdev/aty/atyfb.h             |   2 +
 drivers/video/fbdev/aty/mach64_cursor.c     |   2 +-
 drivers/video/fbdev/chipsfb.c               |   2 +-
 drivers/video/fbdev/core/fbcon.c            |   1 -
 drivers/video/fbdev/core/fbmem.c            |   6 +-
 drivers/video/fbdev/kyro/fbdev.c            |   2 +-
 drivers/video/fbdev/matrox/matroxfb_accel.c |   6 +-
 drivers/video/fbdev/matrox/matroxfb_base.h  |   4 +-
 drivers/video/fbdev/pvr2fb.c                |   2 +-
 drivers/video/fbdev/sstfb.c                 |   2 +-
 drivers/video/fbdev/stifb.c                 |   4 +-
 drivers/video/fbdev/tdfxfb.c                |   2 +-
 drivers/video/fbdev/wmt_ge_rops.c           |   2 +
 include/asm-generic/fb.h                    | 101 ++++++++++++++++++++
 include/linux/fb.h                          |  55 +----------
 24 files changed, 187 insertions(+), 77 deletions(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v4 1/6] fbdev/matrox: Remove trailing whitespaces
  2023-05-04  7:45 [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Thomas Zimmermann
@ 2023-05-04  7:45 ` Thomas Zimmermann
  2023-05-04 11:25   ` [v4,1/6] " Sui Jingfeng
  2023-05-04  7:45 ` [PATCH v4 2/6] ipu-v3: Include <linux/io.h> Thomas Zimmermann
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-04  7:45 UTC (permalink / raw)
  To: deller, geert, javierm, daniel, vgupta, chenhuacai, kernel,
	davem, James.Bottomley, arnd, sam
  Cc: linux-fbdev, dri-devel, linux-arch, linux-snps-arc, linux-kernel,
	linux-ia64, loongarch, linux-m68k, sparclinux, linux-arm-kernel,
	linux-parisc, Thomas Zimmermann

Fix coding style. No functional changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
---
 drivers/video/fbdev/matrox/matroxfb_accel.c | 6 +++---
 drivers/video/fbdev/matrox/matroxfb_base.h  | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/matrox/matroxfb_accel.c b/drivers/video/fbdev/matrox/matroxfb_accel.c
index 9cb0685feddd..ce51227798a1 100644
--- a/drivers/video/fbdev/matrox/matroxfb_accel.c
+++ b/drivers/video/fbdev/matrox/matroxfb_accel.c
@@ -88,7 +88,7 @@
 
 static inline void matrox_cfb4_pal(u_int32_t* pal) {
 	unsigned int i;
-	
+
 	for (i = 0; i < 16; i++) {
 		pal[i] = i * 0x11111111U;
 	}
@@ -96,7 +96,7 @@ static inline void matrox_cfb4_pal(u_int32_t* pal) {
 
 static inline void matrox_cfb8_pal(u_int32_t* pal) {
 	unsigned int i;
-	
+
 	for (i = 0; i < 16; i++) {
 		pal[i] = i * 0x01010101U;
 	}
@@ -482,7 +482,7 @@ static void matroxfb_1bpp_imageblit(struct matrox_fb_info *minfo, u_int32_t fgx,
 			/* Tell... well, why bother... */
 			while (height--) {
 				size_t i;
-				
+
 				for (i = 0; i < step; i += 4) {
 					/* Hope that there are at least three readable bytes beyond the end of bitmap */
 					fb_writel(get_unaligned((u_int32_t*)(chardata + i)),mmio.vaddr);
diff --git a/drivers/video/fbdev/matrox/matroxfb_base.h b/drivers/video/fbdev/matrox/matroxfb_base.h
index 958be6805f87..c93c69bbcd57 100644
--- a/drivers/video/fbdev/matrox/matroxfb_base.h
+++ b/drivers/video/fbdev/matrox/matroxfb_base.h
@@ -301,9 +301,9 @@ struct matrox_altout {
 	int		(*verifymode)(void* altout_dev, u_int32_t mode);
 	int		(*getqueryctrl)(void* altout_dev,
 					struct v4l2_queryctrl* ctrl);
-	int		(*getctrl)(void* altout_dev, 
+	int		(*getctrl)(void *altout_dev,
 				   struct v4l2_control* ctrl);
-	int		(*setctrl)(void* altout_dev, 
+	int		(*setctrl)(void *altout_dev,
 				   struct v4l2_control* ctrl);
 };
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 2/6] ipu-v3: Include <linux/io.h>
  2023-05-04  7:45 [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Thomas Zimmermann
  2023-05-04  7:45 ` [PATCH v4 1/6] fbdev/matrox: Remove trailing whitespaces Thomas Zimmermann
@ 2023-05-04  7:45 ` Thomas Zimmermann
  2023-05-04 11:30   ` [v4,2/6] " Sui Jingfeng
  2023-05-04  7:45 ` [PATCH v4 3/6] fbdev: Include <linux/io.h> in various drivers Thomas Zimmermann
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-04  7:45 UTC (permalink / raw)
  To: deller, geert, javierm, daniel, vgupta, chenhuacai, kernel,
	davem, James.Bottomley, arnd, sam
  Cc: linux-fbdev, dri-devel, linux-arch, linux-snps-arc, linux-kernel,
	linux-ia64, loongarch, linux-m68k, sparclinux, linux-arm-kernel,
	linux-parisc, Thomas Zimmermann

The code uses readl() and writel(). Include the header file to
get the declarations.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
---
 drivers/gpu/ipu-v3/ipu-prv.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/ipu-v3/ipu-prv.h b/drivers/gpu/ipu-v3/ipu-prv.h
index 291ac1bab66d..d4621b1ea7f1 100644
--- a/drivers/gpu/ipu-v3/ipu-prv.h
+++ b/drivers/gpu/ipu-v3/ipu-prv.h
@@ -8,6 +8,7 @@
 
 struct ipu_soc;
 
+#include <linux/io.h>
 #include <linux/types.h>
 #include <linux/device.h>
 #include <linux/clk.h>
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 3/6] fbdev: Include <linux/io.h> in various drivers
  2023-05-04  7:45 [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Thomas Zimmermann
  2023-05-04  7:45 ` [PATCH v4 1/6] fbdev/matrox: Remove trailing whitespaces Thomas Zimmermann
  2023-05-04  7:45 ` [PATCH v4 2/6] ipu-v3: Include <linux/io.h> Thomas Zimmermann
@ 2023-05-04  7:45 ` Thomas Zimmermann
  2023-05-04 11:31   ` [v4,3/6] " Sui Jingfeng
  2023-05-04  7:45 ` [PATCH v4 4/6] fbdev: Include <linux/fb.h> instead of <asm/fb.h> Thomas Zimmermann
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-04  7:45 UTC (permalink / raw)
  To: deller, geert, javierm, daniel, vgupta, chenhuacai, kernel,
	davem, James.Bottomley, arnd, sam
  Cc: linux-fbdev, dri-devel, linux-arch, linux-snps-arc, linux-kernel,
	linux-ia64, loongarch, linux-m68k, sparclinux, linux-arm-kernel,
	linux-parisc, Thomas Zimmermann

The code uses writel() and similar I/O-memory helpers. Include
the header file to get the declarations.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
---
 drivers/video/fbdev/arcfb.c       | 1 +
 drivers/video/fbdev/aty/atyfb.h   | 2 ++
 drivers/video/fbdev/wmt_ge_rops.c | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
index 45e64016db32..d631d53f42ad 100644
--- a/drivers/video/fbdev/arcfb.c
+++ b/drivers/video/fbdev/arcfb.c
@@ -41,6 +41,7 @@
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/io.h>
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/arcfb.h>
diff --git a/drivers/video/fbdev/aty/atyfb.h b/drivers/video/fbdev/aty/atyfb.h
index 465f55beb97f..30da3e82ed3c 100644
--- a/drivers/video/fbdev/aty/atyfb.h
+++ b/drivers/video/fbdev/aty/atyfb.h
@@ -3,8 +3,10 @@
  *  ATI Frame Buffer Device Driver Core Definitions
  */
 
+#include <linux/io.h>
 #include <linux/spinlock.h>
 #include <linux/wait.h>
+
     /*
      *  Elements of the hardware specific atyfb_par structure
      */
diff --git a/drivers/video/fbdev/wmt_ge_rops.c b/drivers/video/fbdev/wmt_ge_rops.c
index 42255d27a1db..99c7b0aea615 100644
--- a/drivers/video/fbdev/wmt_ge_rops.c
+++ b/drivers/video/fbdev/wmt_ge_rops.c
@@ -9,7 +9,9 @@
 
 #include <linux/module.h>
 #include <linux/fb.h>
+#include <linux/io.h>
 #include <linux/platform_device.h>
+
 #include "core/fb_draw.h"
 #include "wmt_ge_rops.h"
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 4/6] fbdev: Include <linux/fb.h> instead of <asm/fb.h>
  2023-05-04  7:45 [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Thomas Zimmermann
                   ` (2 preceding siblings ...)
  2023-05-04  7:45 ` [PATCH v4 3/6] fbdev: Include <linux/io.h> in various drivers Thomas Zimmermann
@ 2023-05-04  7:45 ` Thomas Zimmermann
  2023-05-04 11:34   ` [v4,4/6] " Sui Jingfeng
  2023-05-04 15:37   ` [PATCH v4 4/6] " Sam Ravnborg
  2023-05-04  7:45 ` [PATCH v4 5/6] fbdev: Move framebuffer I/O helpers into <asm/fb.h> Thomas Zimmermann
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-04  7:45 UTC (permalink / raw)
  To: deller, geert, javierm, daniel, vgupta, chenhuacai, kernel,
	davem, James.Bottomley, arnd, sam
  Cc: linux-fbdev, dri-devel, linux-arch, linux-snps-arc, linux-kernel,
	linux-ia64, loongarch, linux-m68k, sparclinux, linux-arm-kernel,
	linux-parisc, Thomas Zimmermann

Replace include statements for <asm/fb.h> with <linux/fb.h>. Fixes
the coding style: if a header is available in asm/ and linux/, it
is preferable to include the header from linux/. This only affects
a few source files, most of which already include <linux/fb.h>.

Suggested-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 arch/parisc/video/fbdev.c        | 3 +--
 arch/sparc/video/fbdev.c         | 1 -
 arch/x86/video/fbdev.c           | 2 --
 drivers/staging/sm750fb/sm750.c  | 2 +-
 drivers/video/fbdev/core/fbcon.c | 1 -
 drivers/video/fbdev/core/fbmem.c | 2 --
 include/linux/fb.h               | 2 ++
 7 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/arch/parisc/video/fbdev.c b/arch/parisc/video/fbdev.c
index 4a0ae08fc75b..137561d98246 100644
--- a/arch/parisc/video/fbdev.c
+++ b/arch/parisc/video/fbdev.c
@@ -5,10 +5,9 @@
  * Copyright (C) 2001-2002 Thomas Bogendoerfer <tsbogend@alpha.franken.de>
  */
 
+#include <linux/fb.h>
 #include <linux/module.h>
 
-#include <asm/fb.h>
-
 #include <video/sticore.h>
 
 int fb_is_primary_device(struct fb_info *info)
diff --git a/arch/sparc/video/fbdev.c b/arch/sparc/video/fbdev.c
index dadd5799fbb3..25837f128132 100644
--- a/arch/sparc/video/fbdev.c
+++ b/arch/sparc/video/fbdev.c
@@ -4,7 +4,6 @@
 #include <linux/fb.h>
 #include <linux/module.h>
 
-#include <asm/fb.h>
 #include <asm/prom.h>
 
 int fb_is_primary_device(struct fb_info *info)
diff --git a/arch/x86/video/fbdev.c b/arch/x86/video/fbdev.c
index 57ee3c158f97..f41a17ebac48 100644
--- a/arch/x86/video/fbdev.c
+++ b/arch/x86/video/fbdev.c
@@ -7,8 +7,6 @@
  *
  */
 
-#include <asm/fb.h>
-
 #include <linux/fb.h>
 #include <linux/module.h>
 #include <linux/pci.h>
diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 22ace3168723..55e302a27847 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -16,7 +16,7 @@
 #include <linux/pagemap.h>
 #include <linux/screen_info.h>
 #include <linux/console.h>
-#include <asm/fb.h>
+
 #include "sm750.h"
 #include "sm750_accel.h"
 #include "sm750_cursor.h"
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index eb565a10e5cd..c6c9d040bdec 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -75,7 +75,6 @@
 #include <linux/interrupt.h>
 #include <linux/crc32.h> /* For counting font checksums */
 #include <linux/uaccess.h>
-#include <asm/fb.h>
 #include <asm/irq.h>
 
 #include "fbcon.h"
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 3fd95a79e4c3..38f7e83fa6e3 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -37,8 +37,6 @@
 #include <linux/mem_encrypt.h>
 #include <linux/pci.h>
 
-#include <asm/fb.h>
-
 #include <video/nomodeset.h>
 #include <video/vga.h>
 
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 08cb47da71f8..c0f97160ebbf 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -15,6 +15,8 @@
 #include <linux/list.h>
 #include <linux/backlight.h>
 #include <linux/slab.h>
+
+#include <asm/fb.h>
 #include <asm/io.h>
 
 struct vm_area_struct;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 5/6] fbdev: Move framebuffer I/O helpers into <asm/fb.h>
  2023-05-04  7:45 [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Thomas Zimmermann
                   ` (3 preceding siblings ...)
  2023-05-04  7:45 ` [PATCH v4 4/6] fbdev: Include <linux/fb.h> instead of <asm/fb.h> Thomas Zimmermann
@ 2023-05-04  7:45 ` Thomas Zimmermann
  2023-05-04 11:59   ` [v4,5/6] " Sui Jingfeng
  2023-05-04  7:45 ` [PATCH v4 6/6] fbdev: Rename fb_mem*() helpers Thomas Zimmermann
  2023-05-04  8:08 ` [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Arnd Bergmann
  6 siblings, 1 reply; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-04  7:45 UTC (permalink / raw)
  To: deller, geert, javierm, daniel, vgupta, chenhuacai, kernel,
	davem, James.Bottomley, arnd, sam
  Cc: linux-fbdev, dri-devel, linux-arch, linux-snps-arc, linux-kernel,
	linux-ia64, loongarch, linux-m68k, sparclinux, linux-arm-kernel,
	linux-parisc, Thomas Zimmermann

Implement framebuffer I/O helpers, such as fb_read*() and fb_write*(),
in the architecture's <asm/fb.h> header file or the generic one.

The common case has been the use of regular I/O functions, such as
__raw_readb() or memset_io(). A few architectures used plain system-
memory reads and writes. Sparc used helpers for its SBus.

The architectures that used special cases provide the same code in
their __raw_*() I/O helpers. So the patch replaces this code with the
__raw_*() functions and moves it to <asm-generic/fb.h> for all
architectures.

v4:
	* ia64, loongarch, sparc64: add fb_mem*() to arch headers
	  to keep current semantics (Arnd)
v3:
	* implement all architectures with generic helpers
	* support reordering and native byte order (Geert, Arnd)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 arch/ia64/include/asm/fb.h      |  20 +++++++
 arch/loongarch/include/asm/fb.h |  21 +++++++
 arch/sparc/include/asm/fb.h     |  20 +++++++
 include/asm-generic/fb.h        | 101 ++++++++++++++++++++++++++++++++
 include/linux/fb.h              |  53 -----------------
 5 files changed, 162 insertions(+), 53 deletions(-)

diff --git a/arch/ia64/include/asm/fb.h b/arch/ia64/include/asm/fb.h
index 0208f64a0da0..bcf982043a5c 100644
--- a/arch/ia64/include/asm/fb.h
+++ b/arch/ia64/include/asm/fb.h
@@ -2,7 +2,9 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
+#include <linux/compiler.h>
 #include <linux/efi.h>
+#include <linux/string.h>
 
 #include <asm/page.h>
 
@@ -18,6 +20,24 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 }
 #define fb_pgprotect fb_pgprotect
 
+static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
+{
+	memcpy(to, (void __force *)from, n);
+}
+#define fb_memcpy_fromfb fb_memcpy_fromfb
+
+static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
+{
+	memcpy((void __force *)to, from, n);
+}
+#define fb_memcpy_tofb fb_memcpy_tofb
+
+static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
+{
+	memset((void __force *)addr, c, n);
+}
+#define fb_memset fb_memset
+
 #include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
diff --git a/arch/loongarch/include/asm/fb.h b/arch/loongarch/include/asm/fb.h
index ff82f20685c8..c6fc7ef374a4 100644
--- a/arch/loongarch/include/asm/fb.h
+++ b/arch/loongarch/include/asm/fb.h
@@ -5,6 +5,27 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
+#include <linux/compiler.h>
+#include <linux/string.h>
+
+static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
+{
+	memcpy(to, (void __force *)from, n);
+}
+#define fb_memcpy_fromfb fb_memcpy_fromfb
+
+static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
+{
+	memcpy((void __force *)to, from, n);
+}
+#define fb_memcpy_tofb fb_memcpy_tofb
+
+static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
+{
+	memset((void __force *)addr, c, n);
+}
+#define fb_memset fb_memset
+
 #include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
index 689ee5c60054..077da91aeba1 100644
--- a/arch/sparc/include/asm/fb.h
+++ b/arch/sparc/include/asm/fb.h
@@ -2,6 +2,8 @@
 #ifndef _SPARC_FB_H_
 #define _SPARC_FB_H_
 
+#include <linux/io.h>
+
 struct fb_info;
 struct file;
 struct vm_area_struct;
@@ -16,6 +18,24 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 int fb_is_primary_device(struct fb_info *info);
 #define fb_is_primary_device fb_is_primary_device
 
+static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
+{
+	sbus_memcpy_fromio(to, from, n);
+}
+#define fb_memcpy_fromfb fb_memcpy_fromfb
+
+static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
+{
+	sbus_memcpy_toio(to, from, n);
+}
+#define fb_memcpy_tofb fb_memcpy_tofb
+
+static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
+{
+	sbus_memset_io(addr, c, n);
+}
+#define fb_memset fb_memset
+
 #include <asm-generic/fb.h>
 
 #endif /* _SPARC_FB_H_ */
diff --git a/include/asm-generic/fb.h b/include/asm-generic/fb.h
index c8af99f5a535..6ef624b3ce12 100644
--- a/include/asm-generic/fb.h
+++ b/include/asm-generic/fb.h
@@ -30,4 +30,105 @@ static inline int fb_is_primary_device(struct fb_info *info)
 }
 #endif
 
+/*
+ * I/O helpers for the framebuffer. Prefer these functions over their
+ * regular counterparts. The regular I/O functions provide in-order
+ * access and swap bytes to/from little-endian ordering. Neither is
+ * required for framebuffers. Instead, the helpers read and write
+ * raw framebuffer data. Independent operations can be reordered for
+ * improved performance.
+ */
+
+#ifndef fb_readb
+static inline u8 fb_readb(const volatile void __iomem *addr)
+{
+	return __raw_readb(addr);
+}
+#define fb_readb fb_readb
+#endif
+
+#ifndef fb_readw
+static inline u16 fb_readw(const volatile void __iomem *addr)
+{
+	return __raw_readw(addr);
+}
+#define fb_readw fb_readw
+#endif
+
+#ifndef fb_readl
+static inline u32 fb_readl(const volatile void __iomem *addr)
+{
+	return __raw_readl(addr);
+}
+#define fb_readl fb_readl
+#endif
+
+#ifndef fb_readq
+#if defined(__raw_readq)
+static inline u64 fb_readq(const volatile void __iomem *addr)
+{
+	return __raw_readq(addr);
+}
+#define fb_readq fb_readq
+#endif
+#endif
+
+#ifndef fb_writeb
+static inline void fb_writeb(u8 b, volatile void __iomem *addr)
+{
+	__raw_writeb(b, addr);
+}
+#define fb_writeb fb_writeb
+#endif
+
+#ifndef fb_writew
+static inline void fb_writew(u16 b, volatile void __iomem *addr)
+{
+	__raw_writew(b, addr);
+}
+#define fb_writew fb_writew
+#endif
+
+#ifndef fb_writel
+static inline void fb_writel(u32 b, volatile void __iomem *addr)
+{
+	__raw_writel(b, addr);
+}
+#define fb_writel fb_writel
+#endif
+
+#ifndef fb_writeq
+#if defined(__raw_writeq)
+static inline void fb_writeq(u64 b, volatile void __iomem *addr)
+{
+	__raw_writeq(b, addr);
+}
+#define fb_writeq fb_writeq
+#endif
+#endif
+
+#ifndef fb_memcpy_fromfb
+static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
+{
+	memcpy_fromio(to, from, n);
+}
+#define fb_memcpy_fromfb fb_memcpy_fromfb
+#endif
+
+#ifndef fb_memcpy_tofb
+static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
+{
+	memcpy_toio(to, from, n);
+}
+#define fb_memcpy_tofb fb_memcpy_tofb
+#endif
+
+#ifndef fb_memset
+static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
+{
+	memset_io(addr, c, n);
+}
+#define fb_memset fb_memset
+#endif
+
 #endif /* __ASM_GENERIC_FB_H_ */
diff --git a/include/linux/fb.h b/include/linux/fb.h
index c0f97160ebbf..eb7e52940c60 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -17,7 +17,6 @@
 #include <linux/slab.h>
 
 #include <asm/fb.h>
-#include <asm/io.h>
 
 struct vm_area_struct;
 struct fb_info;
@@ -513,58 +512,6 @@ struct fb_info {
  */
 #define STUPID_ACCELF_TEXT_SHIT
 
-// This will go away
-#if defined(__sparc__)
-
-/* We map all of our framebuffers such that big-endian accesses
- * are what we want, so the following is sufficient.
- */
-
-// This will go away
-#define fb_readb sbus_readb
-#define fb_readw sbus_readw
-#define fb_readl sbus_readl
-#define fb_readq sbus_readq
-#define fb_writeb sbus_writeb
-#define fb_writew sbus_writew
-#define fb_writel sbus_writel
-#define fb_writeq sbus_writeq
-#define fb_memset sbus_memset_io
-#define fb_memcpy_fromfb sbus_memcpy_fromio
-#define fb_memcpy_tofb sbus_memcpy_toio
-
-#elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) ||	\
-	defined(__hppa__) || defined(__sh__) || defined(__powerpc__) ||	\
-	defined(__arm__) || defined(__aarch64__) || defined(__mips__)
-
-#define fb_readb __raw_readb
-#define fb_readw __raw_readw
-#define fb_readl __raw_readl
-#define fb_readq __raw_readq
-#define fb_writeb __raw_writeb
-#define fb_writew __raw_writew
-#define fb_writel __raw_writel
-#define fb_writeq __raw_writeq
-#define fb_memset memset_io
-#define fb_memcpy_fromfb memcpy_fromio
-#define fb_memcpy_tofb memcpy_toio
-
-#else
-
-#define fb_readb(addr) (*(volatile u8 *) (addr))
-#define fb_readw(addr) (*(volatile u16 *) (addr))
-#define fb_readl(addr) (*(volatile u32 *) (addr))
-#define fb_readq(addr) (*(volatile u64 *) (addr))
-#define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
-#define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
-#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
-#define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b))
-#define fb_memset memset
-#define fb_memcpy_fromfb memcpy
-#define fb_memcpy_tofb memcpy
-
-#endif
-
 #define FB_LEFT_POS(p, bpp)          (fb_be_math(p) ? (32 - (bpp)) : 0)
 #define FB_SHIFT_HIGH(p, val, bits)  (fb_be_math(p) ? (val) >> (bits) : \
 						      (val) << (bits))
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v4 6/6] fbdev: Rename fb_mem*() helpers
  2023-05-04  7:45 [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Thomas Zimmermann
                   ` (4 preceding siblings ...)
  2023-05-04  7:45 ` [PATCH v4 5/6] fbdev: Move framebuffer I/O helpers into <asm/fb.h> Thomas Zimmermann
@ 2023-05-04  7:45 ` Thomas Zimmermann
  2023-05-04 11:33   ` [v4,6/6] " Sui Jingfeng
  2023-05-04  8:08 ` [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Arnd Bergmann
  6 siblings, 1 reply; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-04  7:45 UTC (permalink / raw)
  To: deller, geert, javierm, daniel, vgupta, chenhuacai, kernel,
	davem, James.Bottomley, arnd, sam
  Cc: linux-fbdev, dri-devel, linux-arch, linux-snps-arc, linux-kernel,
	linux-ia64, loongarch, linux-m68k, sparclinux, linux-arm-kernel,
	linux-parisc, Thomas Zimmermann

Update the names of the fb_mem*() helpers to be consistent with their
regular counterparts. Hence, fb_memset() now becomes fb_memset_io(),
fb_memcpy_fromfb() now becomes fb_memcpy_fromio() and fb_memcpy_tofb()
becomes fb_memcpy_toio(). No functional changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/ia64/include/asm/fb.h              | 12 ++++++------
 arch/loongarch/include/asm/fb.h         | 12 ++++++------
 arch/sparc/include/asm/fb.h             | 12 ++++++------
 drivers/video/fbdev/aty/mach64_cursor.c |  2 +-
 drivers/video/fbdev/chipsfb.c           |  2 +-
 drivers/video/fbdev/core/fbmem.c        |  4 ++--
 drivers/video/fbdev/kyro/fbdev.c        |  2 +-
 drivers/video/fbdev/pvr2fb.c            |  2 +-
 drivers/video/fbdev/sstfb.c             |  2 +-
 drivers/video/fbdev/stifb.c             |  4 ++--
 drivers/video/fbdev/tdfxfb.c            |  2 +-
 include/asm-generic/fb.h                | 16 ++++++++--------
 12 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/arch/ia64/include/asm/fb.h b/arch/ia64/include/asm/fb.h
index bcf982043a5c..1717b26fd423 100644
--- a/arch/ia64/include/asm/fb.h
+++ b/arch/ia64/include/asm/fb.h
@@ -20,23 +20,23 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 }
 #define fb_pgprotect fb_pgprotect
 
-static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
+static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
 {
 	memcpy(to, (void __force *)from, n);
 }
-#define fb_memcpy_fromfb fb_memcpy_fromfb
+#define fb_memcpy_fromio fb_memcpy_fromio
 
-static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
+static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
 {
 	memcpy((void __force *)to, from, n);
 }
-#define fb_memcpy_tofb fb_memcpy_tofb
+#define fb_memcpy_toio fb_memcpy_toio
 
-static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
+static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
 {
 	memset((void __force *)addr, c, n);
 }
-#define fb_memset fb_memset
+#define fb_memset fb_memset_io
 
 #include <asm-generic/fb.h>
 
diff --git a/arch/loongarch/include/asm/fb.h b/arch/loongarch/include/asm/fb.h
index c6fc7ef374a4..0b218b10a9ec 100644
--- a/arch/loongarch/include/asm/fb.h
+++ b/arch/loongarch/include/asm/fb.h
@@ -8,23 +8,23 @@
 #include <linux/compiler.h>
 #include <linux/string.h>
 
-static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
+static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
 {
 	memcpy(to, (void __force *)from, n);
 }
-#define fb_memcpy_fromfb fb_memcpy_fromfb
+#define fb_memcpy_fromio fb_memcpy_fromio
 
-static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
+static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
 {
 	memcpy((void __force *)to, from, n);
 }
-#define fb_memcpy_tofb fb_memcpy_tofb
+#define fb_memcpy_toio fb_memcpy_toio
 
-static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
+static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
 {
 	memset((void __force *)addr, c, n);
 }
-#define fb_memset fb_memset
+#define fb_memset fb_memset_io
 
 #include <asm-generic/fb.h>
 
diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
index 077da91aeba1..572ecd3e1cc4 100644
--- a/arch/sparc/include/asm/fb.h
+++ b/arch/sparc/include/asm/fb.h
@@ -18,23 +18,23 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 int fb_is_primary_device(struct fb_info *info);
 #define fb_is_primary_device fb_is_primary_device
 
-static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
+static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
 {
 	sbus_memcpy_fromio(to, from, n);
 }
-#define fb_memcpy_fromfb fb_memcpy_fromfb
+#define fb_memcpy_fromio fb_memcpy_fromio
 
-static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
+static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
 {
 	sbus_memcpy_toio(to, from, n);
 }
-#define fb_memcpy_tofb fb_memcpy_tofb
+#define fb_memcpy_toio fb_memcpy_toio
 
-static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
+static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
 {
 	sbus_memset_io(addr, c, n);
 }
-#define fb_memset fb_memset
+#define fb_memset fb_memset_io
 
 #include <asm-generic/fb.h>
 
diff --git a/drivers/video/fbdev/aty/mach64_cursor.c b/drivers/video/fbdev/aty/mach64_cursor.c
index 4ad0331a8c57..971355c2cd7e 100644
--- a/drivers/video/fbdev/aty/mach64_cursor.c
+++ b/drivers/video/fbdev/aty/mach64_cursor.c
@@ -153,7 +153,7 @@ static int atyfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
 	    u8 m, b;
 
 	    // Clear cursor image with 1010101010...
-	    fb_memset(dst, 0xaa, 1024);
+	    fb_memset_io(dst, 0xaa, 1024);
 
 	    offset = align - width*2;
 
diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c
index 7799d52a651f..2a27ba94f652 100644
--- a/drivers/video/fbdev/chipsfb.c
+++ b/drivers/video/fbdev/chipsfb.c
@@ -332,7 +332,7 @@ static const struct fb_var_screeninfo chipsfb_var = {
 
 static void init_chips(struct fb_info *p, unsigned long addr)
 {
-	fb_memset(p->screen_base, 0, 0x100000);
+	fb_memset_io(p->screen_base, 0, 0x100000);
 
 	p->fix = chipsfb_fix;
 	p->fix.smem_start = addr;
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 38f7e83fa6e3..d433ba8015a7 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -802,7 +802,7 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	while (count) {
 		c  = (count > PAGE_SIZE) ? PAGE_SIZE : count;
 		dst = buffer;
-		fb_memcpy_fromfb(dst, src, c);
+		fb_memcpy_fromio(dst, src, c);
 		dst += c;
 		src += c;
 
@@ -879,7 +879,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 			break;
 		}
 
-		fb_memcpy_tofb(dst, src, c);
+		fb_memcpy_toio(dst, src, c);
 		dst += c;
 		src += c;
 		*ppos += c;
diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
index 0596573ef140..3f277bdb3a32 100644
--- a/drivers/video/fbdev/kyro/fbdev.c
+++ b/drivers/video/fbdev/kyro/fbdev.c
@@ -737,7 +737,7 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 			       info->var.bits_per_pixel);
 	size *= info->var.yres_virtual;
 
-	fb_memset(info->screen_base, 0, size);
+	fb_memset_io(info->screen_base, 0, size);
 
 	if (register_framebuffer(info) < 0)
 		goto out_unmap;
diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c
index 6888127a5eb8..d8d97a9d2436 100644
--- a/drivers/video/fbdev/pvr2fb.c
+++ b/drivers/video/fbdev/pvr2fb.c
@@ -798,7 +798,7 @@ static int __maybe_unused pvr2fb_common_init(void)
 		goto out_err;
 	}
 
-	fb_memset(fb_info->screen_base, 0, pvr2_fix.smem_len);
+	fb_memset_io(fb_info->screen_base, 0, pvr2_fix.smem_len);
 
 	pvr2_fix.ypanstep	= nopan  ? 0 : 1;
 	pvr2_fix.ywrapstep	= nowrap ? 0 : 1;
diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c
index da296b2ab54a..582324f5d869 100644
--- a/drivers/video/fbdev/sstfb.c
+++ b/drivers/video/fbdev/sstfb.c
@@ -335,7 +335,7 @@ static int sst_calc_pll(const int freq, int *freq_out, struct pll_timing *t)
 static void sstfb_clear_screen(struct fb_info *info)
 {
 	/* clear screen */
-	fb_memset(info->screen_base, 0, info->fix.smem_len);
+	fb_memset_io(info->screen_base, 0, info->fix.smem_len);
 }
 
 
diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c
index baca6974e288..01363dccfdaf 100644
--- a/drivers/video/fbdev/stifb.c
+++ b/drivers/video/fbdev/stifb.c
@@ -527,8 +527,8 @@ rattlerSetupPlanes(struct stifb_info *fb)
 	fb->id = saved_id;
 
 	for (y = 0; y < fb->info.var.yres; ++y)
-		fb_memset(fb->info.screen_base + y * fb->info.fix.line_length,
-			0xff, fb->info.var.xres * fb->info.var.bits_per_pixel/8);
+		fb_memset_io(fb->info.screen_base + y * fb->info.fix.line_length,
+			     0xff, fb->info.var.xres * fb->info.var.bits_per_pixel/8);
 
 	CRX24_SET_OVLY_MASK(fb);
 	SETUP_FB(fb);
diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c
index d17e5e1472aa..cdf8e9fe9948 100644
--- a/drivers/video/fbdev/tdfxfb.c
+++ b/drivers/video/fbdev/tdfxfb.c
@@ -1116,7 +1116,7 @@ static int tdfxfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
 		u8 *mask = (u8 *)cursor->mask;
 		int i;
 
-		fb_memset(cursorbase, 0, 1024);
+		fb_memset_io(cursorbase, 0, 1024);
 
 		for (i = 0; i < cursor->image.height; i++) {
 			int h = 0;
diff --git a/include/asm-generic/fb.h b/include/asm-generic/fb.h
index 6ef624b3ce12..1964611f1ce2 100644
--- a/include/asm-generic/fb.h
+++ b/include/asm-generic/fb.h
@@ -107,28 +107,28 @@ static inline void fb_writeq(u64 b, volatile void __iomem *addr)
 #endif
 #endif
 
-#ifndef fb_memcpy_fromfb
-static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
+#ifndef fb_memcpy_fromio
+static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
 {
 	memcpy_fromio(to, from, n);
 }
-#define fb_memcpy_fromfb fb_memcpy_fromfb
+#define fb_memcpy_fromio fb_memcpy_fromio
 #endif
 
-#ifndef fb_memcpy_tofb
-static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
+#ifndef fb_memcpy_toio
+static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
 {
 	memcpy_toio(to, from, n);
 }
-#define fb_memcpy_tofb fb_memcpy_tofb
+#define fb_memcpy_toio fb_memcpy_toio
 #endif
 
 #ifndef fb_memset
-static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
+static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
 {
 	memset_io(addr, c, n);
 }
-#define fb_memset fb_memset
+#define fb_memset fb_memset_io
 #endif
 
 #endif /* __ASM_GENERIC_FB_H_ */
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h>
  2023-05-04  7:45 [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Thomas Zimmermann
                   ` (5 preceding siblings ...)
  2023-05-04  7:45 ` [PATCH v4 6/6] fbdev: Rename fb_mem*() helpers Thomas Zimmermann
@ 2023-05-04  8:08 ` Arnd Bergmann
  2023-05-05  7:01   ` Thomas Zimmermann
  6 siblings, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2023-05-04  8:08 UTC (permalink / raw)
  To: Thomas Zimmermann, Helge Deller, Geert Uytterhoeven,
	Javier Martinez Canillas, Daniel Vetter, Vineet Gupta,
	Huacai Chen, WANG Xuerui, David S . Miller,
	James E . J . Bottomley, Sam Ravnborg
  Cc: linux-fbdev, dri-devel, Linux-Arch, linux-snps-arc, linux-kernel,
	linux-ia64, loongarch, linux-m68k, sparclinux, linux-arm-kernel,
	linux-parisc

On Thu, May 4, 2023, at 09:45, Thomas Zimmermann wrote:
> Fbdev provides helpers for framebuffer I/O, such as fb_readl(),
> fb_writel() or fb_memcpy_to_fb(). The implementation of each helper
> depends on the architecture, but they are all equivalent to regular
> I/O functions of similar names. So use regular functions instead and
> move all helpers into <asm-generic/fb.h>
>
> The first patch a simple whitespace cleanup.
>
> Until now, <linux/fb.h> contained an include of <asm/io.h>. As this
> will go away, patches 2 to 4 prepare include statements in the various
> drivers. Source files that use regular I/O helpers, such as readl(),
> now include <linux/io.h>. Source files that use framebuffer I/O
> helpers, such as fb_readl(), now include <linux/fb.h>.
>
> Patch 5 replaces the architecture-based if-else branching in 
> <linux/fb.h> by helpers in <asm-generic/fb.h>. All helpers use Linux'
> existing I/O functions.
>
> Patch 6 harmonizes naming among fbdev and existing I/O functions.
>
> The patchset has been built for a variety of platforms, such as x86-64,
> arm, aarch64, ppc64, parisc, m64k, mips and sparc.

The whole series looks good to me now,

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [v4,1/6] fbdev/matrox: Remove trailing whitespaces
  2023-05-04  7:45 ` [PATCH v4 1/6] fbdev/matrox: Remove trailing whitespaces Thomas Zimmermann
@ 2023-05-04 11:25   ` Sui Jingfeng
  0 siblings, 0 replies; 18+ messages in thread
From: Sui Jingfeng @ 2023-05-04 11:25 UTC (permalink / raw)
  To: Thomas Zimmermann, deller, geert, javierm, daniel, vgupta,
	chenhuacai, kernel, davem, James.Bottomley, arnd, sam
  Cc: linux-arch, linux-fbdev, linux-ia64, linux-parisc, linux-kernel,
	dri-devel, linux-m68k, loongarch, sparclinux, linux-snps-arc,
	linux-arm-kernel


Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>

Tested-by: Sui Jingfeng <suijingfeng@loongson.cn>


On 2023/5/4 15:45, Thomas Zimmermann wrote:
> Fix coding style. No functional changes.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>   drivers/video/fbdev/matrox/matroxfb_accel.c | 6 +++---
>   drivers/video/fbdev/matrox/matroxfb_base.h  | 4 ++--
>   2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/video/fbdev/matrox/matroxfb_accel.c b/drivers/video/fbdev/matrox/matroxfb_accel.c
> index 9cb0685feddd..ce51227798a1 100644
> --- a/drivers/video/fbdev/matrox/matroxfb_accel.c
> +++ b/drivers/video/fbdev/matrox/matroxfb_accel.c
> @@ -88,7 +88,7 @@
>   
>   static inline void matrox_cfb4_pal(u_int32_t* pal) {
>   	unsigned int i;
> -	
> +
>   	for (i = 0; i < 16; i++) {
>   		pal[i] = i * 0x11111111U;
>   	}
> @@ -96,7 +96,7 @@ static inline void matrox_cfb4_pal(u_int32_t* pal) {
>   
>   static inline void matrox_cfb8_pal(u_int32_t* pal) {
>   	unsigned int i;
> -	
> +
>   	for (i = 0; i < 16; i++) {
>   		pal[i] = i * 0x01010101U;
>   	}
> @@ -482,7 +482,7 @@ static void matroxfb_1bpp_imageblit(struct matrox_fb_info *minfo, u_int32_t fgx,
>   			/* Tell... well, why bother... */
>   			while (height--) {
>   				size_t i;
> -				
> +
>   				for (i = 0; i < step; i += 4) {
>   					/* Hope that there are at least three readable bytes beyond the end of bitmap */
>   					fb_writel(get_unaligned((u_int32_t*)(chardata + i)),mmio.vaddr);
> diff --git a/drivers/video/fbdev/matrox/matroxfb_base.h b/drivers/video/fbdev/matrox/matroxfb_base.h
> index 958be6805f87..c93c69bbcd57 100644
> --- a/drivers/video/fbdev/matrox/matroxfb_base.h
> +++ b/drivers/video/fbdev/matrox/matroxfb_base.h
> @@ -301,9 +301,9 @@ struct matrox_altout {
>   	int		(*verifymode)(void* altout_dev, u_int32_t mode);
>   	int		(*getqueryctrl)(void* altout_dev,
>   					struct v4l2_queryctrl* ctrl);
> -	int		(*getctrl)(void* altout_dev,
> +	int		(*getctrl)(void *altout_dev,
>   				   struct v4l2_control* ctrl);
> -	int		(*setctrl)(void* altout_dev,
> +	int		(*setctrl)(void *altout_dev,
>   				   struct v4l2_control* ctrl);
>   };
>   

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [v4,2/6] ipu-v3: Include <linux/io.h>
  2023-05-04  7:45 ` [PATCH v4 2/6] ipu-v3: Include <linux/io.h> Thomas Zimmermann
@ 2023-05-04 11:30   ` Sui Jingfeng
  0 siblings, 0 replies; 18+ messages in thread
From: Sui Jingfeng @ 2023-05-04 11:30 UTC (permalink / raw)
  To: Thomas Zimmermann, deller, geert, javierm, daniel, vgupta,
	chenhuacai, kernel, davem, James.Bottomley, arnd, sam
  Cc: linux-arch, linux-fbdev, linux-ia64, linux-parisc, linux-kernel,
	dri-devel, linux-m68k, loongarch, sparclinux, linux-snps-arc,
	linux-arm-kernel


Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>


On 2023/5/4 15:45, Thomas Zimmermann wrote:
> The code uses readl() and writel(). Include the header file to
> get the declarations.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>   drivers/gpu/ipu-v3/ipu-prv.h | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/ipu-v3/ipu-prv.h b/drivers/gpu/ipu-v3/ipu-prv.h
> index 291ac1bab66d..d4621b1ea7f1 100644
> --- a/drivers/gpu/ipu-v3/ipu-prv.h
> +++ b/drivers/gpu/ipu-v3/ipu-prv.h
> @@ -8,6 +8,7 @@
>   
>   struct ipu_soc;
>   
> +#include <linux/io.h>
>   #include <linux/types.h>
>   #include <linux/device.h>
>   #include <linux/clk.h>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [v4,3/6] fbdev: Include <linux/io.h> in various drivers
  2023-05-04  7:45 ` [PATCH v4 3/6] fbdev: Include <linux/io.h> in various drivers Thomas Zimmermann
@ 2023-05-04 11:31   ` Sui Jingfeng
  0 siblings, 0 replies; 18+ messages in thread
From: Sui Jingfeng @ 2023-05-04 11:31 UTC (permalink / raw)
  To: Thomas Zimmermann, deller, geert, javierm, daniel, vgupta,
	chenhuacai, kernel, davem, James.Bottomley, arnd, sam
  Cc: linux-arch, linux-fbdev, linux-ia64, linux-parisc, linux-kernel,
	dri-devel, linux-m68k, loongarch, sparclinux, linux-snps-arc,
	linux-arm-kernel


Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>


On 2023/5/4 15:45, Thomas Zimmermann wrote:
> The code uses writel() and similar I/O-memory helpers. Include
> the header file to get the declarations.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>   drivers/video/fbdev/arcfb.c       | 1 +
>   drivers/video/fbdev/aty/atyfb.h   | 2 ++
>   drivers/video/fbdev/wmt_ge_rops.c | 2 ++
>   3 files changed, 5 insertions(+)
>
> diff --git a/drivers/video/fbdev/arcfb.c b/drivers/video/fbdev/arcfb.c
> index 45e64016db32..d631d53f42ad 100644
> --- a/drivers/video/fbdev/arcfb.c
> +++ b/drivers/video/fbdev/arcfb.c
> @@ -41,6 +41,7 @@
>   #include <linux/vmalloc.h>
>   #include <linux/delay.h>
>   #include <linux/interrupt.h>
> +#include <linux/io.h>
>   #include <linux/fb.h>
>   #include <linux/init.h>
>   #include <linux/arcfb.h>
> diff --git a/drivers/video/fbdev/aty/atyfb.h b/drivers/video/fbdev/aty/atyfb.h
> index 465f55beb97f..30da3e82ed3c 100644
> --- a/drivers/video/fbdev/aty/atyfb.h
> +++ b/drivers/video/fbdev/aty/atyfb.h
> @@ -3,8 +3,10 @@
>    *  ATI Frame Buffer Device Driver Core Definitions
>    */
>   
> +#include <linux/io.h>
>   #include <linux/spinlock.h>
>   #include <linux/wait.h>
> +
>       /*
>        *  Elements of the hardware specific atyfb_par structure
>        */
> diff --git a/drivers/video/fbdev/wmt_ge_rops.c b/drivers/video/fbdev/wmt_ge_rops.c
> index 42255d27a1db..99c7b0aea615 100644
> --- a/drivers/video/fbdev/wmt_ge_rops.c
> +++ b/drivers/video/fbdev/wmt_ge_rops.c
> @@ -9,7 +9,9 @@
>   
>   #include <linux/module.h>
>   #include <linux/fb.h>
> +#include <linux/io.h>
>   #include <linux/platform_device.h>
> +
>   #include "core/fb_draw.h"
>   #include "wmt_ge_rops.h"
>   

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [v4,6/6] fbdev: Rename fb_mem*() helpers
  2023-05-04  7:45 ` [PATCH v4 6/6] fbdev: Rename fb_mem*() helpers Thomas Zimmermann
@ 2023-05-04 11:33   ` Sui Jingfeng
  0 siblings, 0 replies; 18+ messages in thread
From: Sui Jingfeng @ 2023-05-04 11:33 UTC (permalink / raw)
  To: Thomas Zimmermann, deller, geert, javierm, daniel, vgupta,
	chenhuacai, kernel, davem, James.Bottomley, arnd, sam
  Cc: linux-arch, linux-fbdev, linux-ia64, linux-parisc, linux-kernel,
	dri-devel, linux-m68k, loongarch, sparclinux, linux-snps-arc,
	linux-arm-kernel


Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>


On 2023/5/4 15:45, Thomas Zimmermann wrote:
> Update the names of the fb_mem*() helpers to be consistent with their
> regular counterparts. Hence, fb_memset() now becomes fb_memset_io(),
> fb_memcpy_fromfb() now becomes fb_memcpy_fromio() and fb_memcpy_tofb()
> becomes fb_memcpy_toio(). No functional changes.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>   arch/ia64/include/asm/fb.h              | 12 ++++++------
>   arch/loongarch/include/asm/fb.h         | 12 ++++++------
>   arch/sparc/include/asm/fb.h             | 12 ++++++------
>   drivers/video/fbdev/aty/mach64_cursor.c |  2 +-
>   drivers/video/fbdev/chipsfb.c           |  2 +-
>   drivers/video/fbdev/core/fbmem.c        |  4 ++--
>   drivers/video/fbdev/kyro/fbdev.c        |  2 +-
>   drivers/video/fbdev/pvr2fb.c            |  2 +-
>   drivers/video/fbdev/sstfb.c             |  2 +-
>   drivers/video/fbdev/stifb.c             |  4 ++--
>   drivers/video/fbdev/tdfxfb.c            |  2 +-
>   include/asm-generic/fb.h                | 16 ++++++++--------
>   12 files changed, 36 insertions(+), 36 deletions(-)
>
> diff --git a/arch/ia64/include/asm/fb.h b/arch/ia64/include/asm/fb.h
> index bcf982043a5c..1717b26fd423 100644
> --- a/arch/ia64/include/asm/fb.h
> +++ b/arch/ia64/include/asm/fb.h
> @@ -20,23 +20,23 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
>   }
>   #define fb_pgprotect fb_pgprotect
>   
> -static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
> +static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
>   {
>   	memcpy(to, (void __force *)from, n);
>   }
> -#define fb_memcpy_fromfb fb_memcpy_fromfb
> +#define fb_memcpy_fromio fb_memcpy_fromio
>   
> -static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
> +static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
>   {
>   	memcpy((void __force *)to, from, n);
>   }
> -#define fb_memcpy_tofb fb_memcpy_tofb
> +#define fb_memcpy_toio fb_memcpy_toio
>   
> -static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
> +static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
>   {
>   	memset((void __force *)addr, c, n);
>   }
> -#define fb_memset fb_memset
> +#define fb_memset fb_memset_io
>   
>   #include <asm-generic/fb.h>
>   
> diff --git a/arch/loongarch/include/asm/fb.h b/arch/loongarch/include/asm/fb.h
> index c6fc7ef374a4..0b218b10a9ec 100644
> --- a/arch/loongarch/include/asm/fb.h
> +++ b/arch/loongarch/include/asm/fb.h
> @@ -8,23 +8,23 @@
>   #include <linux/compiler.h>
>   #include <linux/string.h>
>   
> -static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
> +static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
>   {
>   	memcpy(to, (void __force *)from, n);
>   }
> -#define fb_memcpy_fromfb fb_memcpy_fromfb
> +#define fb_memcpy_fromio fb_memcpy_fromio
>   
> -static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
> +static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
>   {
>   	memcpy((void __force *)to, from, n);
>   }
> -#define fb_memcpy_tofb fb_memcpy_tofb
> +#define fb_memcpy_toio fb_memcpy_toio
>   
> -static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
> +static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
>   {
>   	memset((void __force *)addr, c, n);
>   }
> -#define fb_memset fb_memset
> +#define fb_memset fb_memset_io
>   
>   #include <asm-generic/fb.h>
>   
> diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
> index 077da91aeba1..572ecd3e1cc4 100644
> --- a/arch/sparc/include/asm/fb.h
> +++ b/arch/sparc/include/asm/fb.h
> @@ -18,23 +18,23 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
>   int fb_is_primary_device(struct fb_info *info);
>   #define fb_is_primary_device fb_is_primary_device
>   
> -static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
> +static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
>   {
>   	sbus_memcpy_fromio(to, from, n);
>   }
> -#define fb_memcpy_fromfb fb_memcpy_fromfb
> +#define fb_memcpy_fromio fb_memcpy_fromio
>   
> -static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
> +static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
>   {
>   	sbus_memcpy_toio(to, from, n);
>   }
> -#define fb_memcpy_tofb fb_memcpy_tofb
> +#define fb_memcpy_toio fb_memcpy_toio
>   
> -static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
> +static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
>   {
>   	sbus_memset_io(addr, c, n);
>   }
> -#define fb_memset fb_memset
> +#define fb_memset fb_memset_io
>   
>   #include <asm-generic/fb.h>
>   
> diff --git a/drivers/video/fbdev/aty/mach64_cursor.c b/drivers/video/fbdev/aty/mach64_cursor.c
> index 4ad0331a8c57..971355c2cd7e 100644
> --- a/drivers/video/fbdev/aty/mach64_cursor.c
> +++ b/drivers/video/fbdev/aty/mach64_cursor.c
> @@ -153,7 +153,7 @@ static int atyfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
>   	    u8 m, b;
>   
>   	    // Clear cursor image with 1010101010...
> -	    fb_memset(dst, 0xaa, 1024);
> +	    fb_memset_io(dst, 0xaa, 1024);
>   
>   	    offset = align - width*2;
>   
> diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c
> index 7799d52a651f..2a27ba94f652 100644
> --- a/drivers/video/fbdev/chipsfb.c
> +++ b/drivers/video/fbdev/chipsfb.c
> @@ -332,7 +332,7 @@ static const struct fb_var_screeninfo chipsfb_var = {
>   
>   static void init_chips(struct fb_info *p, unsigned long addr)
>   {
> -	fb_memset(p->screen_base, 0, 0x100000);
> +	fb_memset_io(p->screen_base, 0, 0x100000);
>   
>   	p->fix = chipsfb_fix;
>   	p->fix.smem_start = addr;
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index 38f7e83fa6e3..d433ba8015a7 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -802,7 +802,7 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
>   	while (count) {
>   		c  = (count > PAGE_SIZE) ? PAGE_SIZE : count;
>   		dst = buffer;
> -		fb_memcpy_fromfb(dst, src, c);
> +		fb_memcpy_fromio(dst, src, c);
>   		dst += c;
>   		src += c;
>   
> @@ -879,7 +879,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
>   			break;
>   		}
>   
> -		fb_memcpy_tofb(dst, src, c);
> +		fb_memcpy_toio(dst, src, c);
>   		dst += c;
>   		src += c;
>   		*ppos += c;
> diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
> index 0596573ef140..3f277bdb3a32 100644
> --- a/drivers/video/fbdev/kyro/fbdev.c
> +++ b/drivers/video/fbdev/kyro/fbdev.c
> @@ -737,7 +737,7 @@ static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   			       info->var.bits_per_pixel);
>   	size *= info->var.yres_virtual;
>   
> -	fb_memset(info->screen_base, 0, size);
> +	fb_memset_io(info->screen_base, 0, size);
>   
>   	if (register_framebuffer(info) < 0)
>   		goto out_unmap;
> diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c
> index 6888127a5eb8..d8d97a9d2436 100644
> --- a/drivers/video/fbdev/pvr2fb.c
> +++ b/drivers/video/fbdev/pvr2fb.c
> @@ -798,7 +798,7 @@ static int __maybe_unused pvr2fb_common_init(void)
>   		goto out_err;
>   	}
>   
> -	fb_memset(fb_info->screen_base, 0, pvr2_fix.smem_len);
> +	fb_memset_io(fb_info->screen_base, 0, pvr2_fix.smem_len);
>   
>   	pvr2_fix.ypanstep	= nopan  ? 0 : 1;
>   	pvr2_fix.ywrapstep	= nowrap ? 0 : 1;
> diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c
> index da296b2ab54a..582324f5d869 100644
> --- a/drivers/video/fbdev/sstfb.c
> +++ b/drivers/video/fbdev/sstfb.c
> @@ -335,7 +335,7 @@ static int sst_calc_pll(const int freq, int *freq_out, struct pll_timing *t)
>   static void sstfb_clear_screen(struct fb_info *info)
>   {
>   	/* clear screen */
> -	fb_memset(info->screen_base, 0, info->fix.smem_len);
> +	fb_memset_io(info->screen_base, 0, info->fix.smem_len);
>   }
>   
>   
> diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c
> index baca6974e288..01363dccfdaf 100644
> --- a/drivers/video/fbdev/stifb.c
> +++ b/drivers/video/fbdev/stifb.c
> @@ -527,8 +527,8 @@ rattlerSetupPlanes(struct stifb_info *fb)
>   	fb->id = saved_id;
>   
>   	for (y = 0; y < fb->info.var.yres; ++y)
> -		fb_memset(fb->info.screen_base + y * fb->info.fix.line_length,
> -			0xff, fb->info.var.xres * fb->info.var.bits_per_pixel/8);
> +		fb_memset_io(fb->info.screen_base + y * fb->info.fix.line_length,
> +			     0xff, fb->info.var.xres * fb->info.var.bits_per_pixel/8);
>   
>   	CRX24_SET_OVLY_MASK(fb);
>   	SETUP_FB(fb);
> diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c
> index d17e5e1472aa..cdf8e9fe9948 100644
> --- a/drivers/video/fbdev/tdfxfb.c
> +++ b/drivers/video/fbdev/tdfxfb.c
> @@ -1116,7 +1116,7 @@ static int tdfxfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
>   		u8 *mask = (u8 *)cursor->mask;
>   		int i;
>   
> -		fb_memset(cursorbase, 0, 1024);
> +		fb_memset_io(cursorbase, 0, 1024);
>   
>   		for (i = 0; i < cursor->image.height; i++) {
>   			int h = 0;
> diff --git a/include/asm-generic/fb.h b/include/asm-generic/fb.h
> index 6ef624b3ce12..1964611f1ce2 100644
> --- a/include/asm-generic/fb.h
> +++ b/include/asm-generic/fb.h
> @@ -107,28 +107,28 @@ static inline void fb_writeq(u64 b, volatile void __iomem *addr)
>   #endif
>   #endif
>   
> -#ifndef fb_memcpy_fromfb
> -static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
> +#ifndef fb_memcpy_fromio
> +static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
>   {
>   	memcpy_fromio(to, from, n);
>   }
> -#define fb_memcpy_fromfb fb_memcpy_fromfb
> +#define fb_memcpy_fromio fb_memcpy_fromio
>   #endif
>   
> -#ifndef fb_memcpy_tofb
> -static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
> +#ifndef fb_memcpy_toio
> +static inline void fb_memcpy_toio(volatile void __iomem *to, const void *from, size_t n)
>   {
>   	memcpy_toio(to, from, n);
>   }
> -#define fb_memcpy_tofb fb_memcpy_tofb
> +#define fb_memcpy_toio fb_memcpy_toio
>   #endif
>   
>   #ifndef fb_memset
> -static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
> +static inline void fb_memset_io(volatile void __iomem *addr, int c, size_t n)
>   {
>   	memset_io(addr, c, n);
>   }
> -#define fb_memset fb_memset
> +#define fb_memset fb_memset_io
>   #endif
>   
>   #endif /* __ASM_GENERIC_FB_H_ */

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [v4,4/6] fbdev: Include <linux/fb.h> instead of <asm/fb.h>
  2023-05-04  7:45 ` [PATCH v4 4/6] fbdev: Include <linux/fb.h> instead of <asm/fb.h> Thomas Zimmermann
@ 2023-05-04 11:34   ` Sui Jingfeng
  2023-05-04 15:37   ` [PATCH v4 4/6] " Sam Ravnborg
  1 sibling, 0 replies; 18+ messages in thread
From: Sui Jingfeng @ 2023-05-04 11:34 UTC (permalink / raw)
  To: Thomas Zimmermann, deller, geert, javierm, daniel, vgupta,
	chenhuacai, kernel, davem, James.Bottomley, arnd, sam
  Cc: linux-arch, linux-fbdev, linux-ia64, linux-parisc, linux-kernel,
	dri-devel, linux-m68k, loongarch, sparclinux, linux-snps-arc,
	linux-arm-kernel


Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>


On 2023/5/4 15:45, Thomas Zimmermann wrote:
> Replace include statements for <asm/fb.h> with <linux/fb.h>. Fixes
> the coding style: if a header is available in asm/ and linux/, it
> is preferable to include the header from linux/. This only affects
> a few source files, most of which already include <linux/fb.h>.
>
> Suggested-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>   arch/parisc/video/fbdev.c        | 3 +--
>   arch/sparc/video/fbdev.c         | 1 -
>   arch/x86/video/fbdev.c           | 2 --
>   drivers/staging/sm750fb/sm750.c  | 2 +-
>   drivers/video/fbdev/core/fbcon.c | 1 -
>   drivers/video/fbdev/core/fbmem.c | 2 --
>   include/linux/fb.h               | 2 ++
>   7 files changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/arch/parisc/video/fbdev.c b/arch/parisc/video/fbdev.c
> index 4a0ae08fc75b..137561d98246 100644
> --- a/arch/parisc/video/fbdev.c
> +++ b/arch/parisc/video/fbdev.c
> @@ -5,10 +5,9 @@
>    * Copyright (C) 2001-2002 Thomas Bogendoerfer <tsbogend@alpha.franken.de>
>    */
>   
> +#include <linux/fb.h>
>   #include <linux/module.h>
>   
> -#include <asm/fb.h>
> -
>   #include <video/sticore.h>
>   
>   int fb_is_primary_device(struct fb_info *info)
> diff --git a/arch/sparc/video/fbdev.c b/arch/sparc/video/fbdev.c
> index dadd5799fbb3..25837f128132 100644
> --- a/arch/sparc/video/fbdev.c
> +++ b/arch/sparc/video/fbdev.c
> @@ -4,7 +4,6 @@
>   #include <linux/fb.h>
>   #include <linux/module.h>
>   
> -#include <asm/fb.h>
>   #include <asm/prom.h>
>   
>   int fb_is_primary_device(struct fb_info *info)
> diff --git a/arch/x86/video/fbdev.c b/arch/x86/video/fbdev.c
> index 57ee3c158f97..f41a17ebac48 100644
> --- a/arch/x86/video/fbdev.c
> +++ b/arch/x86/video/fbdev.c
> @@ -7,8 +7,6 @@
>    *
>    */
>   
> -#include <asm/fb.h>
> -
>   #include <linux/fb.h>
>   #include <linux/module.h>
>   #include <linux/pci.h>
> diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> index 22ace3168723..55e302a27847 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -16,7 +16,7 @@
>   #include <linux/pagemap.h>
>   #include <linux/screen_info.h>
>   #include <linux/console.h>
> -#include <asm/fb.h>
> +
>   #include "sm750.h"
>   #include "sm750_accel.h"
>   #include "sm750_cursor.h"
> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index eb565a10e5cd..c6c9d040bdec 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -75,7 +75,6 @@
>   #include <linux/interrupt.h>
>   #include <linux/crc32.h> /* For counting font checksums */
>   #include <linux/uaccess.h>
> -#include <asm/fb.h>
>   #include <asm/irq.h>
>   
>   #include "fbcon.h"
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index 3fd95a79e4c3..38f7e83fa6e3 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -37,8 +37,6 @@
>   #include <linux/mem_encrypt.h>
>   #include <linux/pci.h>
>   
> -#include <asm/fb.h>
> -
>   #include <video/nomodeset.h>
>   #include <video/vga.h>
>   
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index 08cb47da71f8..c0f97160ebbf 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -15,6 +15,8 @@
>   #include <linux/list.h>
>   #include <linux/backlight.h>
>   #include <linux/slab.h>
> +
> +#include <asm/fb.h>
>   #include <asm/io.h>
>   
>   struct vm_area_struct;

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [v4,5/6] fbdev: Move framebuffer I/O helpers into <asm/fb.h>
  2023-05-04  7:45 ` [PATCH v4 5/6] fbdev: Move framebuffer I/O helpers into <asm/fb.h> Thomas Zimmermann
@ 2023-05-04 11:59   ` Sui Jingfeng
  2023-05-05  6:59     ` Thomas Zimmermann
  0 siblings, 1 reply; 18+ messages in thread
From: Sui Jingfeng @ 2023-05-04 11:59 UTC (permalink / raw)
  To: Thomas Zimmermann, deller, geert, javierm, daniel, vgupta,
	chenhuacai, kernel, davem, James.Bottomley, arnd, sam
  Cc: linux-arch, linux-fbdev, linux-ia64, linux-parisc, linux-kernel,
	dri-devel, linux-m68k, loongarch, sparclinux, linux-snps-arc,
	linux-arm-kernel

Hi,

I tested the whole patch set on a LS3A5000(LoongArch)machine with efifb 
driver,

with both fbtest and fbdev of IGT,  The test result say passed and I can 
not see anything wired happen.


Tested-by: Sui Jingfeng <suijingfeng@loongson.cn>


On 2023/5/4 15:45, Thomas Zimmermann wrote:
> Implement framebuffer I/O helpers, such as fb_read*() and fb_write*(),
> in the architecture's <asm/fb.h> header file or the generic one.
>
> The common case has been the use of regular I/O functions, such as
> __raw_readb() or memset_io(). A few architectures used plain system-
> memory reads and writes. Sparc used helpers for its SBus.
>
> The architectures that used special cases provide the same code in
> their __raw_*() I/O helpers. So the patch replaces this code with the
> __raw_*() functions and moves it to <asm-generic/fb.h> for all
> architectures.
>
> v4:
> 	* ia64, loongarch, sparc64: add fb_mem*() to arch headers
> 	  to keep current semantics (Arnd)
> v3:
> 	* implement all architectures with generic helpers
> 	* support reordering and native byte order (Geert, Arnd)
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>   arch/ia64/include/asm/fb.h      |  20 +++++++
>   arch/loongarch/include/asm/fb.h |  21 +++++++
>   arch/sparc/include/asm/fb.h     |  20 +++++++
>   include/asm-generic/fb.h        | 101 ++++++++++++++++++++++++++++++++
>   include/linux/fb.h              |  53 -----------------
>   5 files changed, 162 insertions(+), 53 deletions(-)
>
> diff --git a/arch/ia64/include/asm/fb.h b/arch/ia64/include/asm/fb.h
> index 0208f64a0da0..bcf982043a5c 100644
> --- a/arch/ia64/include/asm/fb.h
> +++ b/arch/ia64/include/asm/fb.h
> @@ -2,7 +2,9 @@
>   #ifndef _ASM_FB_H_
>   #define _ASM_FB_H_
>   
> +#include <linux/compiler.h>
>   #include <linux/efi.h>
> +#include <linux/string.h>
>   
>   #include <asm/page.h>
>   
> @@ -18,6 +20,24 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
>   }
>   #define fb_pgprotect fb_pgprotect
>   
> +static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
> +{
> +	memcpy(to, (void __force *)from, n);
> +}
> +#define fb_memcpy_fromfb fb_memcpy_fromfb
> +
> +static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
> +{
> +	memcpy((void __force *)to, from, n);
> +}
> +#define fb_memcpy_tofb fb_memcpy_tofb
> +
> +static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
> +{
> +	memset((void __force *)addr, c, n);
> +}
> +#define fb_memset fb_memset
> +
>   #include <asm-generic/fb.h>
>   
>   #endif /* _ASM_FB_H_ */
> diff --git a/arch/loongarch/include/asm/fb.h b/arch/loongarch/include/asm/fb.h
> index ff82f20685c8..c6fc7ef374a4 100644
> --- a/arch/loongarch/include/asm/fb.h
> +++ b/arch/loongarch/include/asm/fb.h
> @@ -5,6 +5,27 @@
>   #ifndef _ASM_FB_H_
>   #define _ASM_FB_H_
>   
> +#include <linux/compiler.h>
> +#include <linux/string.h>
> +
> +static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
> +{
> +	memcpy(to, (void __force *)from, n);
> +}
> +#define fb_memcpy_fromfb fb_memcpy_fromfb
> +
> +static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
> +{
> +	memcpy((void __force *)to, from, n);
> +}
> +#define fb_memcpy_tofb fb_memcpy_tofb
> +
> +static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
> +{
> +	memset((void __force *)addr, c, n);
> +}
> +#define fb_memset fb_memset
> +
>   #include <asm-generic/fb.h>
>   

Here works as the past, but  why bother cast it to (void __force *) ?

why not use __memcpy_fromio, __memcpy_toio and __memset_io directly?

I modify it this patch as following, it still works.



  static inline void fb_memcpy_fromio(void *to, const volatile void 
__iomem *from, size_t n)
  {
-       memcpy(to, (void __force *)from, n);
+       __memcpy_fromio(to, from, n);
  }
  #define fb_memcpy_fromio fb_memcpy_fromio

  static inline void fb_memcpy_toio(volatile void __iomem *to, const 
void *from, size_t n)
  {
-       memcpy((void __force *)to, from, n);
+       __memcpy_toio(to, from, n);
  }
  #define fb_memcpy_toio fb_memcpy_toio

  static inline void fb_memset_io(volatile void __iomem *addr, int c, 
size_t n)
  {
-       memset((void __force *)addr, c, n);
+       __memset_io(addr, c, n);
  }
  #define fb_memset fb_memset_io

>   #endif /* _ASM_FB_H_ */
> diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
> index 689ee5c60054..077da91aeba1 100644
> --- a/arch/sparc/include/asm/fb.h
> +++ b/arch/sparc/include/asm/fb.h
> @@ -2,6 +2,8 @@
>   #ifndef _SPARC_FB_H_
>   #define _SPARC_FB_H_
>   
> +#include <linux/io.h>
> +
>   struct fb_info;
>   struct file;
>   struct vm_area_struct;
> @@ -16,6 +18,24 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
>   int fb_is_primary_device(struct fb_info *info);
>   #define fb_is_primary_device fb_is_primary_device
>   
> +static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
> +{
> +	sbus_memcpy_fromio(to, from, n);
> +}
> +#define fb_memcpy_fromfb fb_memcpy_fromfb
> +
> +static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
> +{
> +	sbus_memcpy_toio(to, from, n);
> +}
> +#define fb_memcpy_tofb fb_memcpy_tofb
> +
> +static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
> +{
> +	sbus_memset_io(addr, c, n);
> +}
> +#define fb_memset fb_memset
> +
>   #include <asm-generic/fb.h>
>   
>   #endif /* _SPARC_FB_H_ */
> diff --git a/include/asm-generic/fb.h b/include/asm-generic/fb.h
> index c8af99f5a535..6ef624b3ce12 100644
> --- a/include/asm-generic/fb.h
> +++ b/include/asm-generic/fb.h
> @@ -30,4 +30,105 @@ static inline int fb_is_primary_device(struct fb_info *info)
>   }
>   #endif
>   
> +/*
> + * I/O helpers for the framebuffer. Prefer these functions over their
> + * regular counterparts. The regular I/O functions provide in-order
> + * access and swap bytes to/from little-endian ordering. Neither is
> + * required for framebuffers. Instead, the helpers read and write
> + * raw framebuffer data. Independent operations can be reordered for
> + * improved performance.
> + */
> +
> +#ifndef fb_readb
> +static inline u8 fb_readb(const volatile void __iomem *addr)
> +{
> +	return __raw_readb(addr);
> +}
> +#define fb_readb fb_readb
> +#endif
> +
> +#ifndef fb_readw
> +static inline u16 fb_readw(const volatile void __iomem *addr)
> +{
> +	return __raw_readw(addr);
> +}
> +#define fb_readw fb_readw
> +#endif
> +
> +#ifndef fb_readl
> +static inline u32 fb_readl(const volatile void __iomem *addr)
> +{
> +	return __raw_readl(addr);
> +}
> +#define fb_readl fb_readl
> +#endif
> +
> +#ifndef fb_readq
> +#if defined(__raw_readq)
> +static inline u64 fb_readq(const volatile void __iomem *addr)
> +{
> +	return __raw_readq(addr);
> +}
> +#define fb_readq fb_readq
> +#endif
> +#endif
> +
> +#ifndef fb_writeb
> +static inline void fb_writeb(u8 b, volatile void __iomem *addr)
> +{
> +	__raw_writeb(b, addr);
> +}
> +#define fb_writeb fb_writeb
> +#endif
> +
> +#ifndef fb_writew
> +static inline void fb_writew(u16 b, volatile void __iomem *addr)
> +{
> +	__raw_writew(b, addr);
> +}
> +#define fb_writew fb_writew
> +#endif
> +
> +#ifndef fb_writel
> +static inline void fb_writel(u32 b, volatile void __iomem *addr)
> +{
> +	__raw_writel(b, addr);
> +}
> +#define fb_writel fb_writel
> +#endif
> +
> +#ifndef fb_writeq
> +#if defined(__raw_writeq)
> +static inline void fb_writeq(u64 b, volatile void __iomem *addr)
> +{
> +	__raw_writeq(b, addr);
> +}
> +#define fb_writeq fb_writeq
> +#endif
> +#endif
> +
> +#ifndef fb_memcpy_fromfb
> +static inline void fb_memcpy_fromfb(void *to, const volatile void __iomem *from, size_t n)
> +{
> +	memcpy_fromio(to, from, n);
> +}
> +#define fb_memcpy_fromfb fb_memcpy_fromfb
> +#endif
> +
> +#ifndef fb_memcpy_tofb
> +static inline void fb_memcpy_tofb(volatile void __iomem *to, const void *from, size_t n)
> +{
> +	memcpy_toio(to, from, n);
> +}
> +#define fb_memcpy_tofb fb_memcpy_tofb
> +#endif
> +
> +#ifndef fb_memset
> +static inline void fb_memset(volatile void __iomem *addr, int c, size_t n)
> +{
> +	memset_io(addr, c, n);
> +}
> +#define fb_memset fb_memset
> +#endif
> +
>   #endif /* __ASM_GENERIC_FB_H_ */
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index c0f97160ebbf..eb7e52940c60 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -17,7 +17,6 @@
>   #include <linux/slab.h>
>   
>   #include <asm/fb.h>
> -#include <asm/io.h>
>   
>   struct vm_area_struct;
>   struct fb_info;
> @@ -513,58 +512,6 @@ struct fb_info {
>    */
>   #define STUPID_ACCELF_TEXT_SHIT
>   
> -// This will go away
> -#if defined(__sparc__)
> -
> -/* We map all of our framebuffers such that big-endian accesses
> - * are what we want, so the following is sufficient.
> - */
> -
> -// This will go away
> -#define fb_readb sbus_readb
> -#define fb_readw sbus_readw
> -#define fb_readl sbus_readl
> -#define fb_readq sbus_readq
> -#define fb_writeb sbus_writeb
> -#define fb_writew sbus_writew
> -#define fb_writel sbus_writel
> -#define fb_writeq sbus_writeq
> -#define fb_memset sbus_memset_io
> -#define fb_memcpy_fromfb sbus_memcpy_fromio
> -#define fb_memcpy_tofb sbus_memcpy_toio
> -
> -#elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) ||	\
> -	defined(__hppa__) || defined(__sh__) || defined(__powerpc__) ||	\
> -	defined(__arm__) || defined(__aarch64__) || defined(__mips__)
> -
> -#define fb_readb __raw_readb
> -#define fb_readw __raw_readw
> -#define fb_readl __raw_readl
> -#define fb_readq __raw_readq
> -#define fb_writeb __raw_writeb
> -#define fb_writew __raw_writew
> -#define fb_writel __raw_writel
> -#define fb_writeq __raw_writeq
> -#define fb_memset memset_io
> -#define fb_memcpy_fromfb memcpy_fromio
> -#define fb_memcpy_tofb memcpy_toio
> -
> -#else
> -
> -#define fb_readb(addr) (*(volatile u8 *) (addr))
> -#define fb_readw(addr) (*(volatile u16 *) (addr))
> -#define fb_readl(addr) (*(volatile u32 *) (addr))
> -#define fb_readq(addr) (*(volatile u64 *) (addr))
> -#define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
> -#define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
> -#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
> -#define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b))
> -#define fb_memset memset
> -#define fb_memcpy_fromfb memcpy
> -#define fb_memcpy_tofb memcpy
> -
> -#endif
> -
>   #define FB_LEFT_POS(p, bpp)          (fb_be_math(p) ? (32 - (bpp)) : 0)
>   #define FB_SHIFT_HIGH(p, val, bits)  (fb_be_math(p) ? (val) >> (bits) : \
>   						      (val) << (bits))

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 4/6] fbdev: Include <linux/fb.h> instead of <asm/fb.h>
  2023-05-04  7:45 ` [PATCH v4 4/6] fbdev: Include <linux/fb.h> instead of <asm/fb.h> Thomas Zimmermann
  2023-05-04 11:34   ` [v4,4/6] " Sui Jingfeng
@ 2023-05-04 15:37   ` Sam Ravnborg
  2023-05-05  7:02     ` Thomas Zimmermann
  1 sibling, 1 reply; 18+ messages in thread
From: Sam Ravnborg @ 2023-05-04 15:37 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: deller, geert, javierm, daniel, vgupta, chenhuacai, kernel,
	davem, James.Bottomley, arnd, linux-fbdev, dri-devel, linux-arch,
	linux-snps-arc, linux-kernel, linux-ia64, loongarch, linux-m68k,
	sparclinux, linux-arm-kernel, linux-parisc

Hi Thomas,

On Thu, May 04, 2023 at 09:45:37AM +0200, Thomas Zimmermann wrote:
> Replace include statements for <asm/fb.h> with <linux/fb.h>. Fixes
> the coding style: if a header is available in asm/ and linux/, it
> is preferable to include the header from linux/. This only affects
> a few source files, most of which already include <linux/fb.h>.
> 
> Suggested-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

Thanks,
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [v4,5/6] fbdev: Move framebuffer I/O helpers into <asm/fb.h>
  2023-05-04 11:59   ` [v4,5/6] " Sui Jingfeng
@ 2023-05-05  6:59     ` Thomas Zimmermann
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-05  6:59 UTC (permalink / raw)
  To: Sui Jingfeng, deller, geert, javierm, daniel, vgupta, chenhuacai,
	kernel, davem, James.Bottomley, arnd, sam
  Cc: linux-arch, linux-fbdev, linux-ia64, linux-parisc, linux-kernel,
	dri-devel, linux-m68k, loongarch, sparclinux, linux-snps-arc,
	linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 12126 bytes --]

Hi

Am 04.05.23 um 13:59 schrieb Sui Jingfeng:
> Hi,
> 
> I tested the whole patch set on a LS3A5000(LoongArch)machine with efifb 
> driver,
> 
> with both fbtest and fbdev of IGT,  The test result say passed and I can 
> not see anything wired happen.
> 
> 
> Tested-by: Sui Jingfeng <suijingfeng@loongson.cn>

Thanks for testing.

> 
> 
> On 2023/5/4 15:45, Thomas Zimmermann wrote:
>> Implement framebuffer I/O helpers, such as fb_read*() and fb_write*(),
>> in the architecture's <asm/fb.h> header file or the generic one.
>>
>> The common case has been the use of regular I/O functions, such as
>> __raw_readb() or memset_io(). A few architectures used plain system-
>> memory reads and writes. Sparc used helpers for its SBus.
>>
>> The architectures that used special cases provide the same code in
>> their __raw_*() I/O helpers. So the patch replaces this code with the
>> __raw_*() functions and moves it to <asm-generic/fb.h> for all
>> architectures.
>>
>> v4:
>>     * ia64, loongarch, sparc64: add fb_mem*() to arch headers
>>       to keep current semantics (Arnd)
>> v3:
>>     * implement all architectures with generic helpers
>>     * support reordering and native byte order (Geert, Arnd)
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>>   arch/ia64/include/asm/fb.h      |  20 +++++++
>>   arch/loongarch/include/asm/fb.h |  21 +++++++
>>   arch/sparc/include/asm/fb.h     |  20 +++++++
>>   include/asm-generic/fb.h        | 101 ++++++++++++++++++++++++++++++++
>>   include/linux/fb.h              |  53 -----------------
>>   5 files changed, 162 insertions(+), 53 deletions(-)
>>
>> diff --git a/arch/ia64/include/asm/fb.h b/arch/ia64/include/asm/fb.h
>> index 0208f64a0da0..bcf982043a5c 100644
>> --- a/arch/ia64/include/asm/fb.h
>> +++ b/arch/ia64/include/asm/fb.h
>> @@ -2,7 +2,9 @@
>>   #ifndef _ASM_FB_H_
>>   #define _ASM_FB_H_
>> +#include <linux/compiler.h>
>>   #include <linux/efi.h>
>> +#include <linux/string.h>
>>   #include <asm/page.h>
>> @@ -18,6 +20,24 @@ static inline void fb_pgprotect(struct file *file, 
>> struct vm_area_struct *vma,
>>   }
>>   #define fb_pgprotect fb_pgprotect
>> +static inline void fb_memcpy_fromfb(void *to, const volatile void 
>> __iomem *from, size_t n)
>> +{
>> +    memcpy(to, (void __force *)from, n);
>> +}
>> +#define fb_memcpy_fromfb fb_memcpy_fromfb
>> +
>> +static inline void fb_memcpy_tofb(volatile void __iomem *to, const 
>> void *from, size_t n)
>> +{
>> +    memcpy((void __force *)to, from, n);
>> +}
>> +#define fb_memcpy_tofb fb_memcpy_tofb
>> +
>> +static inline void fb_memset(volatile void __iomem *addr, int c, 
>> size_t n)
>> +{
>> +    memset((void __force *)addr, c, n);
>> +}
>> +#define fb_memset fb_memset
>> +
>>   #include <asm-generic/fb.h>
>>   #endif /* _ASM_FB_H_ */
>> diff --git a/arch/loongarch/include/asm/fb.h 
>> b/arch/loongarch/include/asm/fb.h
>> index ff82f20685c8..c6fc7ef374a4 100644
>> --- a/arch/loongarch/include/asm/fb.h
>> +++ b/arch/loongarch/include/asm/fb.h
>> @@ -5,6 +5,27 @@
>>   #ifndef _ASM_FB_H_
>>   #define _ASM_FB_H_
>> +#include <linux/compiler.h>
>> +#include <linux/string.h>
>> +
>> +static inline void fb_memcpy_fromfb(void *to, const volatile void 
>> __iomem *from, size_t n)
>> +{
>> +    memcpy(to, (void __force *)from, n);
>> +}
>> +#define fb_memcpy_fromfb fb_memcpy_fromfb
>> +
>> +static inline void fb_memcpy_tofb(volatile void __iomem *to, const 
>> void *from, size_t n)
>> +{
>> +    memcpy((void __force *)to, from, n);
>> +}
>> +#define fb_memcpy_tofb fb_memcpy_tofb
>> +
>> +static inline void fb_memset(volatile void __iomem *addr, int c, 
>> size_t n)
>> +{
>> +    memset((void __force *)addr, c, n);
>> +}
>> +#define fb_memset fb_memset
>> +
>>   #include <asm-generic/fb.h>
> 
> Here works as the past, but  why bother cast it to (void __force *) ?
> 
> why not use __memcpy_fromio, __memcpy_toio and __memset_io directly?
> 
> I modify it this patch as following, it still works.
> 
> 
> 
>   static inline void fb_memcpy_fromio(void *to, const volatile void 
> __iomem *from, size_t n)
>   {
> -       memcpy(to, (void __force *)from, n);
> +       __memcpy_fromio(to, from, n);
>   }
>   #define fb_memcpy_fromio fb_memcpy_fromio
> 
>   static inline void fb_memcpy_toio(volatile void __iomem *to, const 
> void *from, size_t n)
>   {
> -       memcpy((void __force *)to, from, n);
> +       __memcpy_toio(to, from, n);
>   }
>   #define fb_memcpy_toio fb_memcpy_toio
> 
>   static inline void fb_memset_io(volatile void __iomem *addr, int c, 
> size_t n)
>   {
> -       memset((void __force *)addr, c, n);
> +       __memset_io(addr, c, n);
>   }
>   #define fb_memset fb_memset_io
> 
>>   #endif /* _ASM_FB_H_ */
>> diff --git a/arch/sparc/include/asm/fb.h b/arch/sparc/include/asm/fb.h
>> index 689ee5c60054..077da91aeba1 100644
>> --- a/arch/sparc/include/asm/fb.h
>> +++ b/arch/sparc/include/asm/fb.h
>> @@ -2,6 +2,8 @@
>>   #ifndef _SPARC_FB_H_
>>   #define _SPARC_FB_H_
>> +#include <linux/io.h>
>> +
>>   struct fb_info;
>>   struct file;
>>   struct vm_area_struct;
>> @@ -16,6 +18,24 @@ static inline void fb_pgprotect(struct file *file, 
>> struct vm_area_struct *vma,
>>   int fb_is_primary_device(struct fb_info *info);
>>   #define fb_is_primary_device fb_is_primary_device
>> +static inline void fb_memcpy_fromfb(void *to, const volatile void 
>> __iomem *from, size_t n)
>> +{
>> +    sbus_memcpy_fromio(to, from, n);
>> +}
>> +#define fb_memcpy_fromfb fb_memcpy_fromfb
>> +
>> +static inline void fb_memcpy_tofb(volatile void __iomem *to, const 
>> void *from, size_t n)
>> +{
>> +    sbus_memcpy_toio(to, from, n);
>> +}
>> +#define fb_memcpy_tofb fb_memcpy_tofb
>> +
>> +static inline void fb_memset(volatile void __iomem *addr, int c, 
>> size_t n)
>> +{
>> +    sbus_memset_io(addr, c, n);
>> +}
>> +#define fb_memset fb_memset
>> +
>>   #include <asm-generic/fb.h>
>>   #endif /* _SPARC_FB_H_ */
>> diff --git a/include/asm-generic/fb.h b/include/asm-generic/fb.h
>> index c8af99f5a535..6ef624b3ce12 100644
>> --- a/include/asm-generic/fb.h
>> +++ b/include/asm-generic/fb.h
>> @@ -30,4 +30,105 @@ static inline int fb_is_primary_device(struct 
>> fb_info *info)
>>   }
>>   #endif
>> +/*
>> + * I/O helpers for the framebuffer. Prefer these functions over their
>> + * regular counterparts. The regular I/O functions provide in-order
>> + * access and swap bytes to/from little-endian ordering. Neither is
>> + * required for framebuffers. Instead, the helpers read and write
>> + * raw framebuffer data. Independent operations can be reordered for
>> + * improved performance.
>> + */
>> +
>> +#ifndef fb_readb
>> +static inline u8 fb_readb(const volatile void __iomem *addr)
>> +{
>> +    return __raw_readb(addr);
>> +}
>> +#define fb_readb fb_readb
>> +#endif
>> +
>> +#ifndef fb_readw
>> +static inline u16 fb_readw(const volatile void __iomem *addr)
>> +{
>> +    return __raw_readw(addr);
>> +}
>> +#define fb_readw fb_readw
>> +#endif
>> +
>> +#ifndef fb_readl
>> +static inline u32 fb_readl(const volatile void __iomem *addr)
>> +{
>> +    return __raw_readl(addr);
>> +}
>> +#define fb_readl fb_readl
>> +#endif
>> +
>> +#ifndef fb_readq
>> +#if defined(__raw_readq)
>> +static inline u64 fb_readq(const volatile void __iomem *addr)
>> +{
>> +    return __raw_readq(addr);
>> +}
>> +#define fb_readq fb_readq
>> +#endif
>> +#endif
>> +
>> +#ifndef fb_writeb
>> +static inline void fb_writeb(u8 b, volatile void __iomem *addr)
>> +{
>> +    __raw_writeb(b, addr);
>> +}
>> +#define fb_writeb fb_writeb
>> +#endif
>> +
>> +#ifndef fb_writew
>> +static inline void fb_writew(u16 b, volatile void __iomem *addr)
>> +{
>> +    __raw_writew(b, addr);
>> +}
>> +#define fb_writew fb_writew
>> +#endif
>> +
>> +#ifndef fb_writel
>> +static inline void fb_writel(u32 b, volatile void __iomem *addr)
>> +{
>> +    __raw_writel(b, addr);
>> +}
>> +#define fb_writel fb_writel
>> +#endif
>> +
>> +#ifndef fb_writeq
>> +#if defined(__raw_writeq)
>> +static inline void fb_writeq(u64 b, volatile void __iomem *addr)
>> +{
>> +    __raw_writeq(b, addr);
>> +}
>> +#define fb_writeq fb_writeq
>> +#endif
>> +#endif
>> +
>> +#ifndef fb_memcpy_fromfb
>> +static inline void fb_memcpy_fromfb(void *to, const volatile void 
>> __iomem *from, size_t n)
>> +{
>> +    memcpy_fromio(to, from, n);
>> +}
>> +#define fb_memcpy_fromfb fb_memcpy_fromfb
>> +#endif
>> +
>> +#ifndef fb_memcpy_tofb
>> +static inline void fb_memcpy_tofb(volatile void __iomem *to, const 
>> void *from, size_t n)
>> +{
>> +    memcpy_toio(to, from, n);
>> +}
>> +#define fb_memcpy_tofb fb_memcpy_tofb
>> +#endif
>> +
>> +#ifndef fb_memset
>> +static inline void fb_memset(volatile void __iomem *addr, int c, 
>> size_t n)
>> +{
>> +    memset_io(addr, c, n);
>> +}
>> +#define fb_memset fb_memset
>> +#endif
>> +
>>   #endif /* __ASM_GENERIC_FB_H_ */
>> diff --git a/include/linux/fb.h b/include/linux/fb.h
>> index c0f97160ebbf..eb7e52940c60 100644
>> --- a/include/linux/fb.h
>> +++ b/include/linux/fb.h
>> @@ -17,7 +17,6 @@
>>   #include <linux/slab.h>
>>   #include <asm/fb.h>
>> -#include <asm/io.h>
>>   struct vm_area_struct;
>>   struct fb_info;
>> @@ -513,58 +512,6 @@ struct fb_info {
>>    */
>>   #define STUPID_ACCELF_TEXT_SHIT
>> -// This will go away
>> -#if defined(__sparc__)
>> -
>> -/* We map all of our framebuffers such that big-endian accesses
>> - * are what we want, so the following is sufficient.
>> - */
>> -
>> -// This will go away
>> -#define fb_readb sbus_readb
>> -#define fb_readw sbus_readw
>> -#define fb_readl sbus_readl
>> -#define fb_readq sbus_readq
>> -#define fb_writeb sbus_writeb
>> -#define fb_writew sbus_writew
>> -#define fb_writel sbus_writel
>> -#define fb_writeq sbus_writeq
>> -#define fb_memset sbus_memset_io
>> -#define fb_memcpy_fromfb sbus_memcpy_fromio
>> -#define fb_memcpy_tofb sbus_memcpy_toio
>> -
>> -#elif defined(__i386__) || defined(__alpha__) || defined(__x86_64__) 
>> ||    \
>> -    defined(__hppa__) || defined(__sh__) || defined(__powerpc__) ||    \
>> -    defined(__arm__) || defined(__aarch64__) || defined(__mips__)
>> -
>> -#define fb_readb __raw_readb
>> -#define fb_readw __raw_readw
>> -#define fb_readl __raw_readl
>> -#define fb_readq __raw_readq
>> -#define fb_writeb __raw_writeb
>> -#define fb_writew __raw_writew
>> -#define fb_writel __raw_writel
>> -#define fb_writeq __raw_writeq
>> -#define fb_memset memset_io
>> -#define fb_memcpy_fromfb memcpy_fromio
>> -#define fb_memcpy_tofb memcpy_toio
>> -
>> -#else
>> -
>> -#define fb_readb(addr) (*(volatile u8 *) (addr))
>> -#define fb_readw(addr) (*(volatile u16 *) (addr))
>> -#define fb_readl(addr) (*(volatile u32 *) (addr))
>> -#define fb_readq(addr) (*(volatile u64 *) (addr))
>> -#define fb_writeb(b,addr) (*(volatile u8 *) (addr) = (b))
>> -#define fb_writew(b,addr) (*(volatile u16 *) (addr) = (b))
>> -#define fb_writel(b,addr) (*(volatile u32 *) (addr) = (b))
>> -#define fb_writeq(b,addr) (*(volatile u64 *) (addr) = (b))
>> -#define fb_memset memset
>> -#define fb_memcpy_fromfb memcpy
>> -#define fb_memcpy_tofb memcpy
>> -
>> -#endif
>> -
>>   #define FB_LEFT_POS(p, bpp)          (fb_be_math(p) ? (32 - (bpp)) : 0)
>>   #define FB_SHIFT_HIGH(p, val, bits)  (fb_be_math(p) ? (val) >> 
>> (bits) : \
>>                                 (val) << (bits))

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h>
  2023-05-04  8:08 ` [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Arnd Bergmann
@ 2023-05-05  7:01   ` Thomas Zimmermann
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-05  7:01 UTC (permalink / raw)
  To: Arnd Bergmann, Helge Deller, Geert Uytterhoeven,
	Javier Martinez Canillas, Daniel Vetter, Vineet Gupta,
	Huacai Chen, WANG Xuerui, David S . Miller,
	James E . J . Bottomley, Sam Ravnborg
  Cc: linux-fbdev, dri-devel, Linux-Arch, linux-snps-arc, linux-kernel,
	linux-ia64, loongarch, linux-m68k, sparclinux, linux-arm-kernel,
	linux-parisc


[-- Attachment #1.1: Type: text/plain, Size: 1680 bytes --]

Hi

Am 04.05.23 um 10:08 schrieb Arnd Bergmann:
> On Thu, May 4, 2023, at 09:45, Thomas Zimmermann wrote:
>> Fbdev provides helpers for framebuffer I/O, such as fb_readl(),
>> fb_writel() or fb_memcpy_to_fb(). The implementation of each helper
>> depends on the architecture, but they are all equivalent to regular
>> I/O functions of similar names. So use regular functions instead and
>> move all helpers into <asm-generic/fb.h>
>>
>> The first patch a simple whitespace cleanup.
>>
>> Until now, <linux/fb.h> contained an include of <asm/io.h>. As this
>> will go away, patches 2 to 4 prepare include statements in the various
>> drivers. Source files that use regular I/O helpers, such as readl(),
>> now include <linux/io.h>. Source files that use framebuffer I/O
>> helpers, such as fb_readl(), now include <linux/fb.h>.
>>
>> Patch 5 replaces the architecture-based if-else branching in
>> <linux/fb.h> by helpers in <asm-generic/fb.h>. All helpers use Linux'
>> existing I/O functions.
>>
>> Patch 6 harmonizes naming among fbdev and existing I/O functions.
>>
>> The patchset has been built for a variety of platforms, such as x86-64,
>> arm, aarch64, ppc64, parisc, m64k, mips and sparc.
> 
> The whole series looks good to me now,

This was a bit more effort to to untangle than I expected. Thanks for 
your help with cleaning this up.

Best regards
Thomas

> 
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v4 4/6] fbdev: Include <linux/fb.h> instead of <asm/fb.h>
  2023-05-04 15:37   ` [PATCH v4 4/6] " Sam Ravnborg
@ 2023-05-05  7:02     ` Thomas Zimmermann
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Zimmermann @ 2023-05-05  7:02 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-arch, linux-fbdev, linux-ia64, loongarch, arnd, deller,
	chenhuacai, javierm, dri-devel, linux-kernel, James.Bottomley,
	linux-m68k, geert, linux-parisc, vgupta, sparclinux, kernel,
	linux-snps-arc, davem, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 968 bytes --]

Hi

Am 04.05.23 um 17:37 schrieb Sam Ravnborg:
> Hi Thomas,
> 
> On Thu, May 04, 2023 at 09:45:37AM +0200, Thomas Zimmermann wrote:
>> Replace include statements for <asm/fb.h> with <linux/fb.h>. Fixes
>> the coding style: if a header is available in asm/ and linux/, it
>> is preferable to include the header from linux/. This only affects
>> a few source files, most of which already include <linux/fb.h>.
>>
>> Suggested-by: Sam Ravnborg <sam@ravnborg.org>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> 
> Thanks,
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

Thanks for reviewing. I intent to merge this early next week after the 
upcoming -rc1 has landed in the DRM misc trees.

Best regards
Thomas

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-05-05  7:02 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04  7:45 [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Thomas Zimmermann
2023-05-04  7:45 ` [PATCH v4 1/6] fbdev/matrox: Remove trailing whitespaces Thomas Zimmermann
2023-05-04 11:25   ` [v4,1/6] " Sui Jingfeng
2023-05-04  7:45 ` [PATCH v4 2/6] ipu-v3: Include <linux/io.h> Thomas Zimmermann
2023-05-04 11:30   ` [v4,2/6] " Sui Jingfeng
2023-05-04  7:45 ` [PATCH v4 3/6] fbdev: Include <linux/io.h> in various drivers Thomas Zimmermann
2023-05-04 11:31   ` [v4,3/6] " Sui Jingfeng
2023-05-04  7:45 ` [PATCH v4 4/6] fbdev: Include <linux/fb.h> instead of <asm/fb.h> Thomas Zimmermann
2023-05-04 11:34   ` [v4,4/6] " Sui Jingfeng
2023-05-04 15:37   ` [PATCH v4 4/6] " Sam Ravnborg
2023-05-05  7:02     ` Thomas Zimmermann
2023-05-04  7:45 ` [PATCH v4 5/6] fbdev: Move framebuffer I/O helpers into <asm/fb.h> Thomas Zimmermann
2023-05-04 11:59   ` [v4,5/6] " Sui Jingfeng
2023-05-05  6:59     ` Thomas Zimmermann
2023-05-04  7:45 ` [PATCH v4 6/6] fbdev: Rename fb_mem*() helpers Thomas Zimmermann
2023-05-04 11:33   ` [v4,6/6] " Sui Jingfeng
2023-05-04  8:08 ` [PATCH v4 0/6] fbdev: Move framebuffer I/O helpers to <asm/fb.h> Arnd Bergmann
2023-05-05  7:01   ` Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).