Skip to contentSkip to conversation

arch: Consolidate <asm/fb.h>

PATCH Superseded Thomas Zimmermann 4 participants 30 messages Apr 6, 2023 – Apr 17, 2023

Subsystems (14)
Arm (32-bit) x86 PowerPC MIPS +10 more subsystems

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover arch: Consolidate <asm/fb.h>

Various architectures provide <arm/fb.h> with helpers for fbdev framebuffer devices. Share the contained code where possible. There is already <asm-generic/fb.h>, which implements generic (as in 'empty') functions of the fbdev helpers. The header was added in commit aafe4dbed0bf ("asm-generic: add generic versions of common headers"), but never used.

Each per-architecture header file declares and/or implements fbdev helpers and defines a preprocessor token for each. The generic header then provides the remaining helpers. It works like the I/O helpers in <asm/io.h>.

For PARISC, the architecture helpers are mixed up with helpers for the system's STI graphics firmware. We first move the STI code to appropriate locations under video/ and then move the architecture helper under arch/parisc.

For Sparc, there's an additional patch that moves the implementation from the header into a source file. This allows to avoid some include statements in the header file.

Built on arm, arm64, m68k, mips, parisc, powerpc, sparc and x86.

v2:
* make writecombine the default mapping mode (Arnd)
* rework fb_pgprotect() on m68k

Thomas Zimmermann (19):
fbdev: Prepare generic architecture helpers
arch/arc: Implement <asm/fb.h> with generic helpers arch/arm: Implement <asm/fb.h> with generic helpers arch/arm64: Implement <asm/fb.h> with generic helpers arch/ia64: Implement <asm/fb.h> with generic helpers arch/loongarch: Implement <asm/fb.h> with generic helpers arch/m68k: Merge variants of fb_pgprotect() into single function arch/m68k: Implement <asm/fb.h> with generic helpers arch/mips: Implement <asm/fb.h> with generic helpers
video: Remove trailing whitespaces
video: Move HP PARISC STI core code to shared location arch/parisc: Remove trailing whitespaces
arch/parisc: Implement fb_is_primary_device() under arch/parisc arch/parisc: Implement <asm/fb.h> with generic helpers arch/powerpc: Implement <asm/fb.h> with generic helpers arch/sh: Implement <asm/fb.h> with generic helpers arch/sparc: Implement fb_is_primary_device() in source file arch/sparc: Implement <asm/fb.h> with generic helpers arch/x86: Implement <asm/fb.h> with generic helpers

 arch/arc/include/asm/fb.h                     |  11 +-
 arch/arm/include/asm/fb.h                     |  15 +-
 arch/arm64/include/asm/fb.h                   |  15 +-
 arch/ia64/include/asm/fb.h                    |  11 +-
 arch/loongarch/include/asm/fb.h               |  15 +-
 arch/m68k/include/asm/fb.h                    |  22 +--
 arch/mips/include/asm/fb.h                    |  10 +-
 arch/parisc/Makefile                          |   4 +-
 arch/parisc/include/asm/fb.h                  |  17 +-
 arch/parisc/video/Makefile                    |   3 +
 arch/parisc/video/fbdev.c                     |  27 +++
 arch/powerpc/include/asm/fb.h                 |   8 +-
 arch/sh/include/asm/fb.h                      |  15 +-
 arch/sparc/Makefile                           |   1 +
 arch/sparc/include/asm/fb.h                   |  26 +--
 arch/sparc/video/Makefile                     |   3 +
 arch/sparc/video/fbdev.c                      |  24 +++
 arch/x86/include/asm/fb.h                     |  11 +-
 drivers/video/Kconfig                         |   7 +
 drivers/video/Makefile                        |   1 +
 drivers/video/console/Kconfig                 |   1 +
 drivers/video/console/Makefile                |   4 +-
 drivers/video/console/sticon.c                |   6 +-
 drivers/video/fbdev/Kconfig                   |   3 +-
 drivers/video/fbdev/stifb.c                   | 158 +++++++++---------
 drivers/video/{console => }/sticore.c         | 123 ++++++--------
 include/asm-generic/fb.h                      |  23 ++-
 .../video/fbdev => include/video}/sticore.h   |  16 +-
 28 files changed, 289 insertions(+), 291 deletions(-)
 create mode 100644 arch/parisc/video/Makefile
 create mode 100644 arch/parisc/video/fbdev.c
 create mode 100644 arch/sparc/video/Makefile
 create mode 100644 arch/sparc/video/fbdev.c
 rename drivers/video/{console => }/sticore.c (95%)
 rename {drivers/video/fbdev => include/video}/sticore.h (99%)

base-commit: a7180debb9c631375684f4d717466cfb9f238660
prerequisite-patch-id: 0aa359f6144c4015c140c8a6750be19099c676fb
prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
prerequisite-patch-id: d571861118316645b0124ac21260571720b632e2
prerequisite-patch-id: 15c0024c23be42851054ea840eec195f69716c08
prerequisite-patch-id: 441ee4341b183e4577c20a3f3bdebee529d21c34
prerequisite-patch-id: cbc453ee02fae02af22fbfdce56ab732c7a88c36

Signature · 1 line
2.40.0
#1 lore raw

PATCH v2 1/19 fbdev: Prepare generic architecture helpers

Generic implementations of fb_pgprotect() and fb_is_primary_device() have been in the source code for a long time. Prepare the header file to make use of them.

Improve the code by using an inline function for fb_pgprotect() and by removing include statements. The default mode set by fb_pgprotect() is now writecombine, which is what most platforms want.

Symbols are protected by preprocessor guards. Architectures that provide a symbol need to define a preprocessor token of the same name and value. Otherwise the header file will provide a generic implementation. This pattern has been taken from <asm/io.h>.

v2:
* use writecombine mappings by default (Arnd)

---
 include/asm-generic/fb.h | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
include/asm-generic/fb.h +21 -2
index f9f18101ed36..631d97c507ca 100644
@@ -1,13 +1,32 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+
 #ifndef __ASM_GENERIC_FB_H_
 #define __ASM_GENERIC_FB_H_
-#include <linux/fb.h>
 
-#define fb_pgprotect(...) do {} while (0)
+/*
+ * Only include this header file from your architecture's <asm/fb.h>.
+ */
+
+#include <asm/page.h>
+
+struct fb_info;
+struct file;
+
+#ifndef fb_pgprotect
+#define fb_pgprotect fb_pgprotect
+static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
+				unsigned long off)
+{
+	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+}
+#endif
 
+#ifndef fb_is_primary_device
+#define fb_is_primary_device fb_is_primary_device
 static inline int fb_is_primary_device(struct fb_info *info)
 {
 	return 0;
 }
+#endif
 
 #endif /* __ASM_GENERIC_FB_H_ */
Signature · 1 line
2.40.0
maintainer Acked-by on v2 1/19
#2 lore raw

Re: [PATCH v2 01/19] fbdev: Prepare generic architecture helpers

Quoted 14 lines · Thomas Zimmermann

Generic implementations of fb_pgprotect() and fb_is_primary_device() have been in the source code for a long time. Prepare the header file to make use of them.

Improve the code by using an inline function for fb_pgprotect() and by removing include statements. The default mode set by fb_pgprotect() is now writecombine, which is what most platforms want.

Symbols are protected by preprocessor guards. Architectures that provide a symbol need to define a preprocessor token of the same name and value. Otherwise the header file will provide a generic implementation. This pattern has been taken from <asm/io.h>.

Quoted 4 lines

v2:
* use writecombine mappings by default (Arnd)

#3 lore raw

Re: [PATCH v2 01/19] fbdev: Prepare generic architecture helpers

In reply to Thomas Zimmermann

Hi Thomas,

Quoted 14 lines · On Thu, Apr 6, 2023 at 4:30 PM Thomas Zimmermann <[email protected]> wrote:

Generic implementations of fb_pgprotect() and fb_is_primary_device() have been in the source code for a long time. Prepare the header file to make use of them.

Improve the code by using an inline function for fb_pgprotect() and by removing include statements. The default mode set by fb_pgprotect() is now writecombine, which is what most platforms want.

Symbols are protected by preprocessor guards. Architectures that provide a symbol need to define a preprocessor token of the same name and value. Otherwise the header file will provide a generic implementation. This pattern has been taken from <asm/io.h>.

Quoted 4 lines

v2:
* use writecombine mappings by default (Arnd)

Thanks for your patch!

Quoted 13 lines
include/asm-generic/fb.h +4 -2
@@ -1,13 +1,32 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+
 #ifndef __ASM_GENERIC_FB_H_
 #define __ASM_GENERIC_FB_H_
-#include <linux/fb.h>
 
-#define fb_pgprotect(...) do {} while (0)
+/*
+ * Only include this header file from your architecture's <asm/fb.h>.
+ */

include/asm-generic/fb.h line 18

Quoted 10 lines
include/asm-generic/fb.h +10 -0
+
+#include <asm/page.h>
+
+struct fb_info;
+struct file;
+
+#ifndef fb_pgprotect
+#define fb_pgprotect fb_pgprotect
+static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
+                               unsigned long off)

Does this affect any noMMU platforms that relied on fb_pgprotect() doing nothing before?
Perhaps the body below should be protected by "#ifdef CONFIG_MMU"?

include/asm-generic/fb.h line 20

Quoted 2 lines
include/asm-generic/fb.h +2 -0
+{
+       vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);

Shouldn't this use the pgprot_val() wrapper?

include/asm-generic/fb.h line 22

Quoted 2 lines
include/asm-generic/fb.h +2 -0
+}
+#endif

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#4 lore raw

Re: [PATCH v2 01/19] fbdev: Prepare generic architecture helpers

Hi Geert

Am 11.04.23 um 10:08 schrieb Geert Uytterhoeven:

Quoted 43 lines

Hi Thomas,

Quoted 14 lines · Thomas Zimmermann

Generic implementations of fb_pgprotect() and fb_is_primary_device() have been in the source code for a long time. Prepare the header file to make use of them.

Improve the code by using an inline function for fb_pgprotect() and by removing include statements. The default mode set by fb_pgprotect() is now writecombine, which is what most platforms want.

Symbols are protected by preprocessor guards. Architectures that provide a symbol need to define a preprocessor token of the same name and value. Otherwise the header file will provide a generic implementation. This pattern has been taken from <asm/io.h>.

Quoted 4 lines

v2:
* use writecombine mappings by default (Arnd)

Thanks for your patch!

Quoted 19 lines
include/asm-generic/fb.h +10 -2
@@ -1,13 +1,32 @@
  /* SPDX-License-Identifier: GPL-2.0 */
+
  #ifndef __ASM_GENERIC_FB_H_
  #define __ASM_GENERIC_FB_H_
-#include <linux/fb.h>
 
-#define fb_pgprotect(...) do {} while (0)
+/*
+ * Only include this header file from your architecture's <asm/fb.h>.
+ */
+
+#include <asm/page.h>
+
+struct fb_info;
+struct file;
+
Quoted 8 lines

include/asm-generic/fb.h line 18

Quoted 4 lines
include/asm-generic/fb.h +4 -0
+#ifndef fb_pgprotect
+#define fb_pgprotect fb_pgprotect
+static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
+                               unsigned long off)

Does this affect any noMMU platforms that relied on fb_pgprotect() doing nothing before?
Perhaps the body below should be protected by "#ifdef CONFIG_MMU"?

I cannot conclusively answer this question, but I did some grep'ing ('git grep ndef | grep CONFIG_MMU'):

Only the architectures in this patchset provide <asm/fb.h> but nothing anywhere uses <asm-generic/fb.h> yet. And of those architectures, only arm and m68k have !CONFIG_MMU cases. Those are handled in the rsp patches. I think we're good.

Quoted 5 lines

include/asm-generic/fb.h line 20

Quoted 3 lines
include/asm-generic/fb.h +2 -0
+{
+       vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);

Shouldn't this use the pgprot_val() wrapper?

No, I think. Grep'ing for vm_page_prot, I'm not seeing it being used in such assignments.

Best regards
Thomas

Quoted 8 lines

include/asm-generic/fb.h line 22

Quoted 3 lines
include/asm-generic/fb.h +2 -0
+}
+#endif

Gr{oetje,eeting}s,

Geert

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
maintainer
#5 lore raw

Re: [PATCH v2 01/19] fbdev: Prepare generic architecture helpers

Quoted 12 lines · Thomas Zimmermann

Am 11.04.23 um 10:08 schrieb Geert Uytterhoeven:

Quoted 10 lines · On Thu, Apr 6, 2023 at 4:30 PM Thomas Zimmermann <[email protected]> wrote:

include/asm-generic/fb.h line 18

Quoted 5 lines
include/asm-generic/fb.h +4 -0
+#ifndef fb_pgprotect
+#define fb_pgprotect fb_pgprotect
+static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
+                               unsigned long off)

Does this affect any noMMU platforms that relied on fb_pgprotect() doing nothing before?
Perhaps the body below should be protected by "#ifdef CONFIG_MMU"?

Quoted 7 lines

I cannot conclusively answer this question, but I did some grep'ing ('git grep ndef | grep CONFIG_MMU'):

Only the architectures in this patchset provide <asm/fb.h> but nothing anywhere uses <asm-generic/fb.h> yet. And of those architectures, only arm and m68k have !CONFIG_MMU cases. Those are handled in the rsp patches. I think we're good.

Agreed. The generic version is just a more elaborate way to do nothing here, as the

     vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);

line on nommu just turns into a self-assignment of the same member that was set the line before.

Arnd

#6 lore raw

PATCH v2 2/19 arch/arc: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fb_is_primary_device() with the generic one from <asm-generic/fb.h>. No functional changes.

---
 arch/arc/include/asm/fb.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
arch/arc/include/asm/fb.h +5 -6
index dc2e303cdbbb..dff149eaecaf 100644
@@ -1,20 +1,19 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
-#include <linux/fs.h>
 #include <asm/page.h>
 
+struct file;
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
 {
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
maintainer
#7 lore raw

Re: [PATCH v2 02/19] arch/arc: Implement <asm/fb.h> with generic helpers

arch/arc/include/asm/fb.h line 15

Quoted 7 lines · Thomas Zimmermann
arch/arc/include/asm/fb.h +2 -0
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
 {
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 }
+#define fb_pgprotect fb_pgprotect

I still feel that for architectures like arc that don't have pgprot_writecombine(), it would b best to go with the generic implementation that currently behaves the exact same way. If pgprot_writecombine() gets added in the future, it would cause the architecture to behave as expected rather than introducing the same bug that mips has.

Arnd

#8 lore raw

Re: [PATCH v2 02/19] arch/arc: Implement <asm/fb.h> with generic helpers

Am 06.04.23 um 16:43 schrieb Arnd Bergmann:

Quoted 7 lines · Thomas Zimmermann
Quoted 6 lines

+
static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
unsigned long off)
{
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
}

Quoted 8 lines
Quoted 1 line

+#define fb_pgprotect fb_pgprotect

I still feel that for architectures like arc that don't have pgprot_writecombine(), it would b best to go with the generic implementation that currently behaves the exact same way. If pgprot_writecombine() gets added in the future, it would cause the architecture to behave as expected rather than introducing the same bug that mips has.

OK, I'll change it.

Quoted 2 lines

Arnd

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
#9 lore raw

PATCH v2 3/19 arch/arm: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fbdev helpers with the generic ones from <asm-generic/fb.h>. No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

---
 arch/arm/include/asm/fb.h | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
arch/arm/include/asm/fb.h +1 -14
index d92e99cd8c8a..ce20a43c3033 100644
@@ -1,19 +1,6 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
-#include <linux/fs.h>
-#include <asm/page.h>
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-				unsigned long off)
-{
-	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
#10 lore raw

PATCH v2 4/19 arch/arm64: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fbdev helpers with the generic ones from <asm-generic/fb.h>. No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
---
 arch/arm64/include/asm/fb.h | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
arch/arm64/include/asm/fb.h +1 -14
index bdc735ee1f67..1a495d8fb2ce 100644
@@ -5,19 +5,6 @@
 #ifndef __ASM_FB_H_
 #define __ASM_FB_H_
 
-#include <linux/fb.h>
-#include <linux/fs.h>
-#include <asm/page.h>
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-				unsigned long off)
-{
-	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* __ASM_FB_H_ */
Signature · 1 line
2.40.0
#11 lore raw

PATCH v2 5/19 arch/ia64: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fb_is_primary_device() with the generic one from <asm-generic/fb.h>. No functional changes.

---
 arch/ia64/include/asm/fb.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
arch/ia64/include/asm/fb.h +5 -6
index 5f95782bfa46..0208f64a0da0 100644
@@ -2,11 +2,12 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
-#include <linux/fs.h>
 #include <linux/efi.h>
+
 #include <asm/page.h>
 
+struct file;
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
 {
@@ -15,10 +16,8 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 	else
 		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
#12 lore raw

PATCH v2 6/19 arch/loongarch: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fbdev helpers with the generic ones from <asm-generic/fb.h>. No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

---
 arch/loongarch/include/asm/fb.h | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
arch/loongarch/include/asm/fb.h +1 -14
index 3116bde8772d..ff82f20685c8 100644
@@ -5,19 +5,6 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
-#include <linux/fs.h>
-#include <asm/page.h>
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-				unsigned long off)
-{
-	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
#13 lore raw

PATCH v2 7/19 arch/m68k: Merge variants of fb_pgprotect() into single function

In reply to Thomas Zimmermann

Merge all variants of fb_pgprotect() into a single function body. There are two different cases for MMU systems. For non-MMU systems, the function body will be empty. No functional changes, but this will help with the switch to <asm-generic/fb.h>.

---
 arch/m68k/include/asm/fb.h | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
arch/m68k/include/asm/fb.h +3 -9
index b86c6e2e26dd..4f96989922af 100644
@@ -7,17 +7,13 @@
 #include <asm/page.h>
 #include <asm/setup.h>
 
-#ifdef CONFIG_MMU
-#ifdef CONFIG_SUN3
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
 {
+#ifdef CONFIG_MMU
+#ifdef CONFIG_SUN3
 	pgprot_val(vma->vm_page_prot) |= SUN3_PAGE_NOCACHE;
-}
 #else
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-				unsigned long off)
-{
 	if (CPU_IS_020_OR_030)
 		pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE030;
 	if (CPU_IS_040_OR_060) {
@@ -25,11 +21,9 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 		/* Use no-cache mode, serialized */
 		pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE_S;
 	}
-}
 #endif /* CONFIG_SUN3 */
-#else
-#define fb_pgprotect(...) do {} while (0)
 #endif /* CONFIG_MMU */
+}
 
 static inline int fb_is_primary_device(struct fb_info *info)
 {
Signature · 1 line
2.40.0
maintainer Reviewed-by Acked-by on v2 7/19
#14 lore raw

Re: [PATCH v2 07/19] arch/m68k: Merge variants of fb_pgprotect() into single function

Quoted 6 lines · On Thu, Apr 6, 2023 at 4:30 PM Thomas Zimmermann <[email protected]> wrote:

Merge all variants of fb_pgprotect() into a single function body. There are two different cases for MMU systems. For non-MMU systems, the function body will be empty. No functional changes, but this will help with the switch to <asm-generic/fb.h>.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#15 lore raw

PATCH v2 8/19 arch/m68k: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fb_is_primary_device() with the generic one from <asm-generic/fb.h>. No functional changes.

v2:
* provide empty fb_pgprotect() on non-MMU systems

Cc Geert Uytterhoeven <[email protected]>
---
 arch/m68k/include/asm/fb.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
arch/m68k/include/asm/fb.h +4 -6
index 4f96989922af..24273fc7ad91 100644
@@ -2,11 +2,11 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
-#include <linux/fs.h>
 #include <asm/page.h>
 #include <asm/setup.h>
 
+struct file;
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
 {
@@ -24,10 +24,8 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 #endif /* CONFIG_SUN3 */
 #endif /* CONFIG_MMU */
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
maintainer Acked-by on v2 8/19
#16 lore raw

Re: [PATCH v2 08/19] arch/m68k: Implement <asm/fb.h> with generic helpers

Quoted 8 lines · On Thu, Apr 6, 2023 at 4:30 PM Thomas Zimmermann <[email protected]> wrote:

Replace the architecture's fb_is_primary_device() with the generic one from <asm-generic/fb.h>. No functional changes.

v2:
* provide empty fb_pgprotect() on non-MMU systems

Cc Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#17 lore raw

PATCH v2 9/19 arch/mips: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fb_is_primary_device() with the generic one from <asm-generic/fb.h>. No functional changes.

Cc Thomas Bogendoerfer <[email protected]>
---
 arch/mips/include/asm/fb.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
arch/mips/include/asm/fb.h +4 -6
index bd3f68c9ddfc..6bda0a81d8ca 100644
@@ -1,19 +1,17 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
-#include <linux/fs.h>
 #include <asm/page.h>
 
+struct file;
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
 {
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
maintainer
#18 lore raw

Re: [PATCH v2 09/19] arch/mips: Implement <asm/fb.h> with generic helpers

Quoted 5 lines · Thomas Zimmermann

Replace the architecture's fb_is_primary_device() with the generic one from <asm-generic/fb.h>. No functional changes.

Cc Thomas Bogendoerfer <[email protected]>

I think you should at least mention that the existing fb_pgprotect() function is probably incorrect and should be replaced with the generic version.

For reference, the fb_pgprotect function using pgprot_uncached() was introduced in 2.6.22 along with all the other ones, but the pgprot_writecombine function was only added in commit 4b050ba7a66c ("MIPS: pgtable.h: Implement the pgprot_writecombine function for MIPS") for 3.18.

Arnd

#19 lore raw

PATCH v2 10/19 video: Remove trailing whitespaces

In reply to Thomas Zimmermann

Fix trailing whitespaces. No functional changes.

---
 drivers/video/console/sticon.c  |   4 +-
 drivers/video/console/sticore.c | 102 ++++++++++-----------
 drivers/video/fbdev/sticore.h   |  14 +--
 drivers/video/fbdev/stifb.c     | 156 ++++++++++++++++----------------
 4 files changed, 138 insertions(+), 138 deletions(-)
drivers/video/console/sticon.c +2 -2
index 2cea69418a83..89ad7ade6cf9 100644
@@ -282,7 +282,7 @@ static void sticon_init(struct vc_data *c, int init)
     vc_cols = sti_onscreen_x(sti) / sti->font->width;
     vc_rows = sti_onscreen_y(sti) / sti->font->height;
     c->vc_can_do_color = 1;
-    
+
     if (init) {
 	c->vc_cols = vc_cols;
 	c->vc_rows = vc_rows;
@@ -374,7 +374,7 @@ static const struct consw sti_con = {
 	.con_font_set		= sticon_font_set,
 	.con_font_default	= sticon_font_default,
 	.con_build_attr		= sticon_build_attr,
-	.con_invert_region	= sticon_invert_region, 
+	.con_invert_region	= sticon_invert_region,
 };
 
 
drivers/video/console/sticore.c +51 -51

322 lines not on this page · raw message

drivers/video/fbdev/sticore.h +7 -7
index 0ebdd28a0b81..c0879352cde4 100644
@@ -27,11 +27,11 @@
  *
  * Probably the best solution to all this is have the generic code manage
  * the screen buffer and a kernel thread to call STI occasionally.
- * 
+ *
  * Luckily, the frame buffer guys have the same problem so we can just wait
  * for them to fix it and steal their solution.   prumpf
  */
- 
+
 #include <asm/io.h>
 
 #define STI_WAIT 1
@@ -56,7 +56,7 @@
 /* STI function configuration structs */
 
 typedef union region {
-	struct { 
+	struct {
 		u32 offset	: 14;	/* offset in 4kbyte page */
 		u32 sys_only	: 1;	/* don't map to user space */
 		u32 cache	: 1;	/* map to data cache */
@@ -154,7 +154,7 @@ struct sti_conf_inptr {
 };
 
 struct sti_conf_outptr_ext {
-	u32 crt_config[3];	/* hardware specific X11/OGL information */	
+	u32 crt_config[3];	/* hardware specific X11/OGL information */
 	u32 crt_hdw[3];
 	u32 future_ptr;
 };
@@ -211,7 +211,7 @@ struct sti_rom {
 	u32 set_cm_entry;
 	u32 dma_ctrl;
 	 u8 res040[7 * 4];
-	
+
 	u32 init_graph_addr;
 	u32 state_mgmt_addr;
 	u32 font_unp_addr;
@@ -271,7 +271,7 @@ struct sti_font_flags {
 	u32 pad : 30;		/* pad to word boundary */
 	u32 future_ptr; 	/* pointer to future data */
 };
-	
+
 struct sti_font_outptr {
 	s32 errno;		/* error number on failure */
 	u32 future_ptr; 	/* pointer to future data */
@@ -338,7 +338,7 @@ struct sti_all_data {
 
 struct sti_struct {
 	spinlock_t lock;
-		
+
 	/* char **mon_strings; */
 	int sti_mem_request;
 	u32 graphics_id[2];
drivers/video/fbdev/stifb.c +78 -78

530 lines not on this page · raw message

Signature · 1 line
2.40.0
#20 lore raw

PATCH v2 11/19 video: Move HP PARISC STI core code to shared location

In reply to Thomas Zimmermann

STI core files have been located in console and fbdev code. Move the source code and header to the directories for video helpers. Also update the config and build rules such that the code depends on the config symbol CONFIG_STI_CORE, which STI console and STI framebuffer select automatically.

Cleans up the console makefile and prepares PARISC to implement fb_is_primary_device() within the arch/ directory. No functional changes.

---
 drivers/video/Kconfig                            | 7 +++++++
 drivers/video/Makefile                           | 1 +
 drivers/video/console/Kconfig                    | 1 +
 drivers/video/console/Makefile                   | 4 +---
 drivers/video/console/sticon.c                   | 2 +-
 drivers/video/fbdev/Kconfig                      | 3 +--
 drivers/video/fbdev/stifb.c                      | 2 +-
 drivers/video/{console => }/sticore.c            | 2 +-
 {drivers/video/fbdev => include/video}/sticore.h | 0
 9 files changed, 14 insertions(+), 8 deletions(-)
 rename drivers/video/{console => }/sticore.c (99%)
 rename {drivers/video/fbdev => include/video}/sticore.h (100%)
drivers/video/Kconfig +7 -0
index bf05363d8906..8b2b9ac37c3d 100644
@@ -11,6 +11,13 @@ config APERTURE_HELPERS
 	  Support tracking and hand-over of aperture ownership. Required
 	  by graphics drivers for firmware-provided framebuffers.
 
+config STI_CORE
+	bool
+	depends on PARISC
+	help
+	  STI refers to the HP "Standard Text Interface" which is a set of
+	  BIOS routines contained in a ROM chip in HP PA-RISC based machines.
+
 config VIDEO_CMDLINE
 	bool
 
drivers/video/Makefile +1 -0
index 831c9fa57a6c..6bbc03950899 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_APERTURE_HELPERS)    += aperture.o
+obj-$(CONFIG_STI_CORE)            += sticore.o
 obj-$(CONFIG_VGASTATE)            += vgastate.o
 obj-$(CONFIG_VIDEO_CMDLINE)       += cmdline.o
 obj-$(CONFIG_VIDEO_NOMODESET)     += nomodeset.o
drivers/video/console/Kconfig +1 -0
index 22cea5082ac4..a2a88d42edf0 100644
@@ -141,6 +141,7 @@ config STI_CONSOLE
 	depends on PARISC && HAS_IOMEM
 	select FONT_SUPPORT
 	select CRC32
+	select STI_CORE
 	default y
 	help
 	  The STI console is the builtin display/keyboard on HP-PARISC
drivers/video/console/Makefile +1 -3
index db07b784bd2c..fd79016a0d95 100644
@@ -5,8 +5,6 @@
 
 obj-$(CONFIG_DUMMY_CONSOLE)       += dummycon.o
 obj-$(CONFIG_SGI_NEWPORT_CONSOLE) += newport_con.o
-obj-$(CONFIG_STI_CONSOLE)         += sticon.o sticore.o
+obj-$(CONFIG_STI_CONSOLE)         += sticon.o
 obj-$(CONFIG_VGA_CONSOLE)         += vgacon.o
 obj-$(CONFIG_MDA_CONSOLE)         += mdacon.o
-
-obj-$(CONFIG_FB_STI)              += sticore.o
drivers/video/console/sticon.c +1 -1
index 89ad7ade6cf9..d11cfd2d68b5 100644
@@ -50,7 +50,7 @@
 
 #include <asm/io.h>
 
-#include "../fbdev/sticore.h"
+#include <video/sticore.h>
 
 /* switching to graphics mode */
 #define BLANK 0
drivers/video/fbdev/Kconfig +1 -2
index 96e91570cdd3..485e8c35d5c6 100644
@@ -551,10 +551,9 @@ config FB_STI
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
+	select STI_CORE
 	default y
 	help
-	  STI refers to the HP "Standard Text Interface" which is a set of
-	  BIOS routines contained in a ROM chip in HP PA-RISC based machines.
 	  Enabling this option will implement the linux framebuffer device
 	  using calls to the STI BIOS routines for initialisation.
 
drivers/video/fbdev/stifb.c +1 -1
index 99996bc7e6d9..baca6974e288 100644
@@ -69,7 +69,7 @@
 #include <asm/grfioctl.h>	/* for HP-UX compatibility */
 #include <linux/uaccess.h>
 
-#include "sticore.h"
+#include <video/sticore.h>
 
 /* REGION_BASE(fb_info, index) returns the virtual address for region <index> */
 #define REGION_BASE(fb_info, index) \
drivers/video/sticore.c renamed from drivers/video/console/sticore.c +1 -1
similarity index 99%
rename from drivers/video/console/sticore.c
rename to drivers/video/sticore.c
index 6ea9596a3c4b..f8aaedea437d 100644
@@ -32,7 +32,7 @@
 #include <asm/grfioctl.h>
 #include <asm/fb.h>
 
-#include "../fbdev/sticore.h"
+#include <video/sticore.h>
 
 #define STI_DRIVERVERSION "Version 0.9c"
 
include/video/sticore.h renamed from drivers/video/fbdev/sticore.h +0 -0
similarity index 100%
rename from drivers/video/fbdev/sticore.h
rename to include/video/sticore.h
Signature · 1 line
2.40.0
#21 lore raw

PATCH v2 12/19 arch/parisc: Remove trailing whitespaces

In reply to Thomas Zimmermann

Fix trailing whitespaces. No functional changes.

Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
---
 arch/parisc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/Makefile +1 -1
index a2d8600521f9..0d049a6f6a60 100644
@@ -11,7 +11,7 @@
 # Copyright (C) 1994 by Linus Torvalds
 # Portions Copyright (C) 1999 The Puffin Group
 #
-# Modified for PA-RISC Linux by Paul Lahaie, Alex deVries, 
+# Modified for PA-RISC Linux by Paul Lahaie, Alex deVries,
 # Mike Shaver, Helge Deller and Martin K. Petersen
 #
 
Signature · 1 line
2.40.0
#22 lore raw

PATCH v2 13/19 arch/parisc: Implement fb_is_primary_device() under arch/parisc

In reply to Thomas Zimmermann

Move PARISC's implementation of fb_is_primary_device() into the architecture directory. This the place of the declaration and where other architectures implement this function. No functional changes.

Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
---
 arch/parisc/Makefile         |  2 ++
 arch/parisc/include/asm/fb.h |  2 +-
 arch/parisc/video/Makefile   |  3 +++
 arch/parisc/video/fbdev.c    | 27 +++++++++++++++++++++++++++
 drivers/video/sticore.c      | 19 -------------------
 include/video/sticore.h      |  2 ++
 6 files changed, 35 insertions(+), 20 deletions(-)
 create mode 100644 arch/parisc/video/Makefile
 create mode 100644 arch/parisc/video/fbdev.c
arch/parisc/Makefile +2 -0
index 0d049a6f6a60..968ebe17494c 100644
@@ -119,6 +119,8 @@ export LIBGCC
 
 libs-y	+= arch/parisc/lib/ $(LIBGCC)
 
+drivers-y += arch/parisc/video/
+
 boot	:= arch/parisc/boot
 
 PALO := $(shell if (which palo 2>&1); then : ; \
arch/parisc/include/asm/fb.h +1 -1
index 55d29c4f716e..0b9a38ced5c8 100644
@@ -12,7 +12,7 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 	pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
 }
 
-#if defined(CONFIG_FB_STI)
+#if defined(CONFIG_STI_CORE)
 int fb_is_primary_device(struct fb_info *info);
 #else
 static inline int fb_is_primary_device(struct fb_info *info)
arch/parisc/video/Makefile new file +3 -0
new file mode 100644
index 000000000000..16a73cce4661
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-$(CONFIG_STI_CORE) += fbdev.o
arch/parisc/video/fbdev.c new file +27 -0
new file mode 100644
index 000000000000..4a0ae08fc75b
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2000 Philipp Rumpf <[email protected]>
+ * Copyright (C) 2001-2020 Helge Deller <[email protected]>
+ * Copyright (C) 2001-2002 Thomas Bogendoerfer <[email protected]>
+ */
+
+#include <linux/module.h>
+
+#include <asm/fb.h>
+
+#include <video/sticore.h>
+
+int fb_is_primary_device(struct fb_info *info)
+{
+	struct sti_struct *sti;
+
+	sti = sti_get_rom(0);
+
+	/* if no built-in graphics card found, allow any fb driver as default */
+	if (!sti)
+		return true;
+
+	/* return true if it's the default built-in framebuffer driver */
+	return (sti->info = info);
+}
+EXPORT_SYMBOL(fb_is_primary_device);
drivers/video/sticore.c +0 -19
index f8aaedea437d..7eb925f2ba9c 100644
@@ -30,7 +30,6 @@
 #include <asm/pdc.h>
 #include <asm/cacheflush.h>
 #include <asm/grfioctl.h>
-#include <asm/fb.h>
 
 #include <video/sticore.h>
 
@@ -1148,24 +1147,6 @@ int sti_call(const struct sti_struct *sti, unsigned long func,
 	return ret;
 }
 
-#if defined(CONFIG_FB_STI)
-/* check if given fb_info is the primary device */
-int fb_is_primary_device(struct fb_info *info)
-{
-	struct sti_struct *sti;
-
-	sti = sti_get_rom(0);
-
-	/* if no built-in graphics card found, allow any fb driver as default */
-	if (!sti)
-		return true;
-
-	/* return true if it's the default built-in framebuffer driver */
-	return (sti->info = info);
-}
-EXPORT_SYMBOL(fb_is_primary_device);
-#endif
-
 MODULE_AUTHOR("Philipp Rumpf, Helge Deller, Thomas Bogendoerfer");
 MODULE_DESCRIPTION("Core STI driver for HP's NGLE series graphics cards in HP PARISC machines");
 MODULE_LICENSE("GPL v2");
include/video/sticore.h +2 -0
index c0879352cde4..fbb78d7e7565 100644
@@ -2,6 +2,8 @@
 #ifndef STICORE_H
 #define STICORE_H
 
+struct fb_info;
+
 /* generic STI structures & functions */
 
 #define MAX_STI_ROMS 4		/* max no. of ROMs which this driver handles */
Signature · 1 line
2.40.0
#23 lore raw

PATCH v2 14/19 arch/parisc: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fb_is_primary_device() with the generic one from <asm-generic/fb.h> on systems without CONFIG_STI_CORE. No functional changes.

Cc "James E.J. Bottomley" <[email protected]>
Cc Helge Deller <[email protected]>
---
 arch/parisc/include/asm/fb.h | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
arch/parisc/include/asm/fb.h +8 -7
index 0b9a38ced5c8..66bb401c0cda 100644
@@ -2,23 +2,24 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
-#include <linux/fs.h>
 #include <asm/page.h>
+#include <asm/pgtable.h>
+
+struct fb_info;
+struct file;
 
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
 {
 	pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
 }
+#define fb_pgprotect fb_pgprotect
 
 #if defined(CONFIG_STI_CORE)
 int fb_is_primary_device(struct fb_info *info);
-#else
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#define fb_is_primary_device fb_is_primary_device
 #endif
 
+#include <asm-generic/fb.h>
+
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
#24 lore raw

PATCH v2 15/19 arch/powerpc: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fb_is_primary_device() with the generic one from <asm-generic/fb.h>. No functional changes.

Cc Michael Ellerman <[email protected]>
Cc Nicholas Piggin <[email protected]>
Cc Christophe Leroy <[email protected]>
---
 arch/powerpc/include/asm/fb.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/fb.h +3 -5
index 6541ab77c5b9..5f1a2e5f7654 100644
@@ -2,8 +2,8 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
 #include <linux/fs.h>
+
 #include <asm/page.h>
 
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
@@ -13,10 +13,8 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 						 vma->vm_end - vma->vm_start,
 						 vma->vm_page_prot);
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
reviewer Acked-by on v2 15/19
#25 lore raw

Re: [PATCH v2 15/19] arch/powerpc: Implement <asm/fb.h> with generic helpers

Quoted 10 lines · Thomas Zimmermann

Replace the architecture's fb_is_primary_device() with the generic one from <asm-generic/fb.h>. No functional changes.

Cc Michael Ellerman <[email protected]>
Cc Nicholas Piggin <[email protected]>
Cc Christophe Leroy <[email protected]>
---
 arch/powerpc/include/asm/fb.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Looks fine.

cheers

Quoted 29 lines
arch/powerpc/include/asm/fb.h +3 -5
index 6541ab77c5b9..5f1a2e5f7654 100644
@@ -2,8 +2,8 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
 #include <linux/fs.h>
+
 #include <asm/page.h>
 
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
@@ -13,10 +13,8 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 						 vma->vm_end - vma->vm_start,
 						 vma->vm_page_prot);
 }
+#define fb_pgprotect fb_pgprotect
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
#26 lore raw

PATCH v2 16/19 arch/sh: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Replace the architecture's fbdev helpers with the generic ones from <asm-generic/fb.h>. No functional changes.

v2:
* use default implementation for fb_pgprotect() (Arnd)

Cc Yoshinori Sato <[email protected]>
Cc Rich Felker <[email protected]>
Cc John Paul Adrian Glaubitz <[email protected]>
---
 arch/sh/include/asm/fb.h | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
arch/sh/include/asm/fb.h +1 -14
index 9a0bca2686fd..19df13ee9ca7 100644
@@ -2,19 +2,6 @@
 #ifndef _ASM_FB_H_
 #define _ASM_FB_H_
 
-#include <linux/fb.h>
-#include <linux/fs.h>
-#include <asm/page.h>
-
-static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
-				unsigned long off)
-{
-	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-}
-
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	return 0;
-}
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_FB_H_ */
Signature · 1 line
2.40.0
#27 lore raw

PATCH v2 17/19 arch/sparc: Implement fb_is_primary_device() in source file

In reply to Thomas Zimmermann

Other architectures implment fb_is_primary_device() in a source file. Do the same on sparc. No functional changes, but allows to remove several include statement from <asm/fb.h>.

v2:
* don't include <asm/prom.h> in header file

---
 arch/sparc/Makefile         |  1 +
 arch/sparc/include/asm/fb.h | 23 +++++------------------
 arch/sparc/video/Makefile   |  3 +++
 arch/sparc/video/fbdev.c    | 24 ++++++++++++++++++++++++
 4 files changed, 33 insertions(+), 18 deletions(-)
 create mode 100644 arch/sparc/video/Makefile
 create mode 100644 arch/sparc/video/fbdev.c
arch/sparc/Makefile +1 -0
index a4ea5b05f288..95a9211e48e3 100644
@@ -60,6 +60,7 @@ libs-y                 += arch/sparc/prom/
 libs-y                 += arch/sparc/lib/
 
 drivers-$(CONFIG_PM) += arch/sparc/power/
+drivers-$(CONFIG_FB) += arch/sparc/video/
 
 boot := arch/sparc/boot
 
arch/sparc/include/asm/fb.h +5 -18
index f699962e9ddf..28609f7a965c 100644
@@ -1,11 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _SPARC_FB_H_
 #define _SPARC_FB_H_
-#include <linux/console.h>
-#include <linux/fb.h>
+
 #include <linux/fs.h>
+
 #include <asm/page.h>
-#include <asm/prom.h>
+
+struct fb_info;
 
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
@@ -15,20 +16,6 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 #endif
 }
 
-static inline int fb_is_primary_device(struct fb_info *info)
-{
-	struct device *dev = info->device;
-	struct device_node *node;
-
-	if (console_set_on_cmdline)
-		return 0;
-
-	node = dev->of_node;
-	if (node &&
-	    node = of_console_device)
-		return 1;
-
-	return 0;
-}
+int fb_is_primary_device(struct fb_info *info);
 
 #endif /* _SPARC_FB_H_ */
arch/sparc/video/Makefile new file +3 -0
new file mode 100644
index 000000000000..6baddbd58e4d
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-$(CONFIG_FB) += fbdev.o
arch/sparc/video/fbdev.c new file +24 -0
new file mode 100644
index 000000000000..dadd5799fbb3
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/console.h>
+#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)
+{
+	struct device *dev = info->device;
+	struct device_node *node;
+
+	if (console_set_on_cmdline)
+		return 0;
+
+	node = dev->of_node;
+	if (node && node = of_console_device)
+		return 1;
+
+	return 0;
+}
+EXPORT_SYMBOL(fb_is_primary_device);
Signature · 1 line
2.40.0
#28 lore raw

PATCH v2 18/19 arch/sparc: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Include <asm-generic/fb.h> for correctness. Sparc does provide it's own implementation of the contained functions.

v2:
* restore the original fb_pgprotect()

---
 arch/sparc/include/asm/fb.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/sparc/include/asm/fb.h +5 -2
index 28609f7a965c..496e58d22e7b 100644
@@ -2,11 +2,10 @@
 #ifndef _SPARC_FB_H_
 #define _SPARC_FB_H_
 
-#include <linux/fs.h>
-
 #include <asm/page.h>
 
 struct fb_info;
+struct file;
 
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
@@ -15,7 +14,11 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 #endif
 }
+#define fb_pgprotect fb_pgprotect
 
 int fb_is_primary_device(struct fb_info *info);
+#define fb_is_primary_device fb_is_primary_device
+
+#include <asm-generic/fb.h>
 
 #endif /* _SPARC_FB_H_ */
Signature · 1 line
2.40.0
#29 lore raw

PATCH v2 19/19 arch/x86: Implement <asm/fb.h> with generic helpers

In reply to Thomas Zimmermann

Include <asm-generic/fb.h> and set the required preprocessor tokens correctly. x86 now implements its own set of fb helpers, but still follows the overall pattern.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/include/asm/fb.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
arch/x86/include/asm/fb.h +8 -3
index ab4c960146e3..a3fb801f12f1 100644
@@ -2,10 +2,11 @@
 #ifndef _ASM_X86_FB_H
 #define _ASM_X86_FB_H
 
-#include <linux/fb.h>
-#include <linux/fs.h>
 #include <asm/page.h>
 
+struct fb_info;
+struct file;
+
 static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 				unsigned long off)
 {
@@ -16,7 +17,11 @@ static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
 		pgprot_val(vma->vm_page_prot)  			prot | cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS);
 }
+#define fb_pgprotect fb_pgprotect
+
+int fb_is_primary_device(struct fb_info *info);
+#define fb_is_primary_device fb_is_primary_device
 
-extern int fb_is_primary_device(struct fb_info *info);
+#include <asm-generic/fb.h>
 
 #endif /* _ASM_X86_FB_H */
Signature · 1 line
2.40.0