Skip to contentSkip to conversation

fbdev: maxinefb: fix build issues

RFC PATCH In review Randy Dunlap 5 participants 12 messages Aug 9 – Aug 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 fbdev: maxinefb: fix build issues

This is all ancient source code from the beginning of git time. Now builds cleanly on 32-bit and 64-bit MACH_DECSTATION.

Fixes these build errors/warnings:

../drivers/video/fbdev/maxinefb.c:64:6: warning: no previous prototype for 'maxinefb_ims332_write_register' [-Wmissing-prototypes]
64 | void maxinefb_ims332_write_register(int regno, register unsigned int val)

      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from ../drivers/video/fbdev/maxinefb.c:34:
../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_ims332_write_register':
../include/video/maxinefb.h:16:41: error: implicit declaration of function 'KSEG1ADDR'; did you mean 'CKSEG1ADDR'? [-Wimplicit-function-declaration]

   16 | #define MAXINEFB_IMS332_ADDRESS         KSEG1ADDR(0x1c140000)
      |                                         ^~~~~~~~~
../drivers/video/fbdev/maxinefb.c:66:49: note: in expansion of macro 'MAXINEFB_IMS332_ADDRESS'
   66 |         register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~

../drivers/video/fbdev/maxinefb.c:66:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
66 | register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
| ^
../drivers/video/fbdev/maxinefb.c: At top level:
../drivers/video/fbdev/maxinefb.c:74:14: warning: no previous prototype for 'maxinefb_ims332_read_register' [-Wmissing-prototypes]
74 | unsigned int maxinefb_ims332_read_register(int regno)

      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/video/fbdev/maxinefb.c: At top level:
../drivers/video/fbdev/maxinefb.c:74:21: warning: 'maxinefb_ims332_read_register' defined but not used [-Wunused-function]
   74 | static unsigned int maxinefb_ims332_read_register(int regno)
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_ims332_read_register':
../drivers/video/fbdev/maxinefb.c:76:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
76 | register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
| ^
../drivers/video/fbdev/maxinefb.c: At top level:
../drivers/video/fbdev/maxinefb.c:114:12: warning: no previous prototype for 'maxinefb_init' [-Wmissing-prototypes]
114 | int __init maxinefb_init(void)

      |            ^~~~~~~~~~~~~
In file included from ../drivers/video/fbdev/maxinefb.c:34:
../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_init':
../include/video/maxinefb.h:22:41: error: implicit declaration of function 'KSEG1ADDR'; did you mean 'CKSEG1ADDR'? [-Wimplicit-function-declaration]
   22 | #define DS5000_xx_ONBOARD_FBMEM_START   KSEG1ADDR(0x0a000000)
      |                                         ^~~~~~~~~
../drivers/video/fbdev/maxinefb.c:119:20: note: in expansion of macro 'DS5000_xx_ONBOARD_FBMEM_START'
  119 |         fb_start = DS5000_xx_ONBOARD_FBMEM_START;
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---
Cc: "Maciej W. Rozycki" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]

 drivers/video/fbdev/maxinefb.c |   17 ++---------------
 include/video/maxinefb.h       |    4 ++--
 2 files changed, 4 insertions(+), 17 deletions(-)
drivers/video/fbdev/maxinefb.c +2 -15
@@ -61,7 +61,7 @@ static struct fb_fix_screeninfo maxinefb
 
 /* Handle the funny Inmos RamDAC/video controller ... */
 
-void maxinefb_ims332_write_register(int regno, register unsigned int val)
+static void maxinefb_ims332_write_register(int regno, register unsigned int val)
 {
 	register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
 	unsigned char *wptr;
@@ -71,19 +71,6 @@ void maxinefb_ims332_write_register(int
 	*((volatile unsigned short *) (wptr)) = val;
 }
 
-unsigned int maxinefb_ims332_read_register(int regno)
-{
-	register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
-	unsigned char *rptr;
-	register unsigned int j, k;
-
-	rptr = regs + 0x80000 + (regno << 4);
-	j = *((volatile unsigned short *) rptr);
-	k = *((volatile unsigned short *) regs);
-
-	return (j & 0xffff) | ((k & 0xff00) << 8);
-}
-
 /* Set the palette */
 static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
 			      unsigned blue, unsigned transp, struct fb_info *info)
@@ -111,7 +98,7 @@ static const struct fb_ops maxinefb_ops
 	.fb_setcolreg	= maxinefb_setcolreg,
 };
 
-int __init maxinefb_init(void)
+static int __init maxinefb_init(void)
 {
 	unsigned long fboff;
 	unsigned long fb_start;
include/video/maxinefb.h +2 -2
@@ -13,13 +13,13 @@
 /*
  * IMS332 video controller register base address
  */
-#define MAXINEFB_IMS332_ADDRESS		KSEG1ADDR(0x1c140000)
+#define MAXINEFB_IMS332_ADDRESS		CKSEG1ADDR(0x1c140000)
 
 /*
  * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution
  * is 1024x768x8
  */
-#define DS5000_xx_ONBOARD_FBMEM_START	KSEG1ADDR(0x0a000000)
+#define DS5000_xx_ONBOARD_FBMEM_START	CKSEG1ADDR(0x0a000000)
 
 /*
  *      The IMS 332 video controller used in the DECstation 5000/xx series
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Initialization function returns positive value 1 on failure, breaking module load semantics and causing subsequent registered_fb array corruption on unload.
- [High] maxinefb_fix.smem_start is initialized with a virtual address (CKSEG1ADDR) instead of the hardware physical address, breaking user-space mmap(). --

--- Patch [1]: [RFC PATCH] fbdev: maxinefb: fix build issues --- commit e391418fa2f21f8c420eccb513c031674ef184c6
Author: Randy Dunlap <[email protected]>

fbdev: maxinefb: fix build issues

This commit fixes build errors and warnings for the maxinefb driver on 32-bit and 64-bit MACH_DECSTATION. It updates KSEG1ADDR to CKSEG1ADDR and adds the static keyword to missing prototypes.

Quoted 4 lines
drivers/video/fbdev/maxinefb.c +0 -0
index 52528eb4dfb41..8aa1389e2d4c8 100644

[ ... ]

drivers/video/fbdev/maxinefb.c static const struct fb_ops maxinefb_ops = { · line 101

Quoted 6 lines
drivers/video/fbdev/maxinefb.c +1 -1
@@ -111,7 +98,7 @@ static const struct fb_ops maxinefb_ops = {
 	.fb_setcolreg	= maxinefb_setcolreg,
 };
 
-int __init maxinefb_init(void)
+static int __init maxinefb_init(void)

[Severity: High]
This is a pre-existing issue, but does returning 1 on failure in this function cause issues with module load semantics?

In maxinefb_init():

if (register_framebuffer(&fb_info) < 0)
return 1;

If register_framebuffer() fails, returning a positive integer causes the kernel to treat the module as successfully loaded because the module init framework expects negative error codes for failure.

Later, when the module is unloaded, maxinefb_exit() calls unregister_framebuffer() on the unregistered fb_info. Since it was never successfully registered, its node field is 0.

Does this cause the generic do_unregister_framebuffer() to blindly execute registered_fb[0] = NULL, corrupting the kernel's framebuffer state by deleting the reference to whatever valid framebuffer occupied node 0?

Quoted 4 lines
include/video/maxinefb.h +0 -0
index 6aeb4acca2bdb..2b66b32f355cf 100644

[ ... ]

include/video/maxinefb.h line 22

Quoted 13 lines
include/video/maxinefb.h +2 -2
@@ -13,13 +13,13 @@
 /*
  * IMS332 video controller register base address
  */
-#define MAXINEFB_IMS332_ADDRESS		KSEG1ADDR(0x1c140000)
+#define MAXINEFB_IMS332_ADDRESS		CKSEG1ADDR(0x1c140000)
 
 /*
  * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution
  * is 1024x768x8
  */
-#define DS5000_xx_ONBOARD_FBMEM_START	KSEG1ADDR(0x0a000000)
+#define DS5000_xx_ONBOARD_FBMEM_START	CKSEG1ADDR(0x0a000000)

[Severity: High]
This is a pre-existing issue, but does assigning a virtual address to maxinefb_fix.smem_start break user-space mmap()?

In maxinefb_init():

        fb_start = DS5000_xx_ONBOARD_FBMEM_START;
        ...
        maxinefb_fix.smem_start = fb_start;

The smem_start field is passed to vm_iomap_memory() by the generic framebuffer mmap handler (fb_mmap()). Because vm_iomap_memory() strictly expects a physical address, does passing a KSEG1 virtual address set up user-space page tables pointing to an invalid physical address?

This could trigger an invalid physical memory access and a kernel panic when user-space accesses the mapped memory.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw

[adding Cc:s]

Quoted 33 lines · On 8/9/26 5:02 PM, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Initialization function returns positive value 1 on failure, breaking module load semantics and causing subsequent registered_fb array corruption on unload.
- [High] maxinefb_fix.smem_start is initialized with a virtual address (CKSEG1ADDR) instead of the hardware physical address, breaking user-space mmap(). --

--- Patch [1]: [RFC PATCH] fbdev: maxinefb: fix build issues --- commit e391418fa2f21f8c420eccb513c031674ef184c6
Author: Randy Dunlap <[email protected]>

fbdev: maxinefb: fix build issues

This commit fixes build errors and warnings for the maxinefb driver on 32-bit and 64-bit MACH_DECSTATION. It updates KSEG1ADDR to CKSEG1ADDR and adds the static keyword to missing prototypes.

Quoted 4 lines
drivers/video/fbdev/maxinefb.c +0 -0
index 52528eb4dfb41..8aa1389e2d4c8 100644

[ ... ]

drivers/video/fbdev/maxinefb.c static const struct fb_ops maxinefb_ops = { · line 101

Quoted 6 lines
drivers/video/fbdev/maxinefb.c +1 -1
@@ -111,7 +98,7 @@ static const struct fb_ops maxinefb_ops = {
 	.fb_setcolreg	= maxinefb_setcolreg,
 };
 
-int __init maxinefb_init(void)
+static int __init maxinefb_init(void)

[Severity: High]
This is a pre-existing issue, but does returning 1 on failure in this function cause issues with module load semantics?

Quoted 8 lines

In maxinefb_init():

if (register_framebuffer(&fb_info) < 0)
return 1;

If register_framebuffer() fails, returning a positive integer causes the kernel to treat the module as successfully loaded because the module init framework expects negative error codes for failure.

Ack. I'll change that.

Quoted 20 lines

Later, when the module is unloaded, maxinefb_exit() calls unregister_framebuffer() on the unregistered fb_info. Since it was never successfully registered, its node field is 0.

Does this cause the generic do_unregister_framebuffer() to blindly execute registered_fb[0] = NULL, corrupting the kernel's framebuffer state by deleting the reference to whatever valid framebuffer occupied node 0?

Quoted 4 lines
include/video/maxinefb.h +0 -0
index 6aeb4acca2bdb..2b66b32f355cf 100644

[ ... ]

Quoted 7 lines
include/video/maxinefb.h +1 -1
@@ -13,13 +13,13 @@
 /*
  * IMS332 video controller register base address
  */
-#define MAXINEFB_IMS332_ADDRESS		KSEG1ADDR(0x1c140000)
+#define MAXINEFB_IMS332_ADDRESS		CKSEG1ADDR(0x1c140000)
 
Quoted 6 lines

include/video/maxinefb.h line 22

Quoted 6 lines
include/video/maxinefb.h +1 -1
 /*
  * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution
  * is 1024x768x8
  */
-#define DS5000_xx_ONBOARD_FBMEM_START	KSEG1ADDR(0x0a000000)
+#define DS5000_xx_ONBOARD_FBMEM_START	CKSEG1ADDR(0x0a000000)

Maciej or anyone:
can you comment of this, please?

Quoted 18 lines

[Severity: High]
This is a pre-existing issue, but does assigning a virtual address to maxinefb_fix.smem_start break user-space mmap()?

In maxinefb_init():

        fb_start = DS5000_xx_ONBOARD_FBMEM_START;
        ...
        maxinefb_fix.smem_start = fb_start;

The smem_start field is passed to vm_iomap_memory() by the generic framebuffer mmap handler (fb_mmap()). Because vm_iomap_memory() strictly expects a physical address, does passing a KSEG1 virtual address set up user-space page tables pointing to an invalid physical address?

This could trigger an invalid physical memory access and a kernel panic when user-space accesses the mapped memory.

Signature · 1 line
~Randy
#3 lore raw
Quoted 38 lines · Randy Dunlap

[adding Cc:s]

Quoted 35 lines · On 8/9/26 5:02 PM, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Initialization function returns positive value 1 on failure, breaking module load semantics and causing subsequent registered_fb array corruption on unload.
- [High] maxinefb_fix.smem_start is initialized with a virtual address (CKSEG1ADDR) instead of the hardware physical address, breaking user-space mmap(). --

--- Patch [1]: [RFC PATCH] fbdev: maxinefb: fix build issues --- commit e391418fa2f21f8c420eccb513c031674ef184c6
Author: Randy Dunlap <[email protected]>

fbdev: maxinefb: fix build issues

This commit fixes build errors and warnings for the maxinefb driver on 32-bit and 64-bit MACH_DECSTATION. It updates KSEG1ADDR to CKSEG1ADDR and adds the static keyword to missing prototypes.

Quoted 4 lines
drivers/video/fbdev/maxinefb.c +0 -0
index 52528eb4dfb41..8aa1389e2d4c8 100644

[ ... ]

drivers/video/fbdev/maxinefb.c static const struct fb_ops maxinefb_ops = { · line 101

Quoted 6 lines
drivers/video/fbdev/maxinefb.c +1 -1
@@ -111,7 +98,7 @@ static const struct fb_ops maxinefb_ops = {
 	.fb_setcolreg	= maxinefb_setcolreg,
 };
 
-int __init maxinefb_init(void)
+static int __init maxinefb_init(void)

[Severity: High]
This is a pre-existing issue, but does returning 1 on failure in this function cause issues with module load semantics?

In maxinefb_init():

Quoted 8 lines
Quoted 6 lines

if (register_framebuffer(&fb_info) < 0)
return 1;

If register_framebuffer() fails, returning a positive integer causes the kernel to treat the module as successfully loaded because the module init framework expects negative error codes for failure.

Ack. I'll change that.

I had this fixed locally and then forgot about it in the 3-patch series. I'll add it as patch 04/04.

Signature · 1 line
~Randy
#4 lore raw
In reply to Randy Dunlap

Hi Randy,

Quoted 104 lines · Randy Dunlap

This is all ancient source code from the beginning of git time. Now builds cleanly on 32-bit and 64-bit MACH_DECSTATION.

Fixes these build errors/warnings:

../drivers/video/fbdev/maxinefb.c:64:6: warning: no previous prototype for 'maxinefb_ims332_write_register' [-Wmissing-prototypes]
64 | void maxinefb_ims332_write_register(int regno, register unsigned int val)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from ../drivers/video/fbdev/maxinefb.c:34:
../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_ims332_write_register':
../include/video/maxinefb.h:16:41: error: implicit declaration of function 'KSEG1ADDR'; did you mean 'CKSEG1ADDR'? [-Wimplicit-function-declaration]

    16 | #define MAXINEFB_IMS332_ADDRESS         KSEG1ADDR(0x1c140000)
       |                                         ^~~~~~~~~
../drivers/video/fbdev/maxinefb.c:66:49: note: in expansion of macro 'MAXINEFB_IMS332_ADDRESS'
    66 |         register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
       |                                                 ^~~~~~~~~~~~~~~~~~~~~~~
../drivers/video/fbdev/maxinefb.c:66:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    66 |         register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
       |                                        ^

../drivers/video/fbdev/maxinefb.c: At top level:
../drivers/video/fbdev/maxinefb.c:74:14: warning: no previous prototype for 'maxinefb_ims332_read_register' [-Wmissing-prototypes]
74 | unsigned int maxinefb_ims332_read_register(int regno)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/video/fbdev/maxinefb.c: At top level:
../drivers/video/fbdev/maxinefb.c:74:21: warning: 'maxinefb_ims332_read_register' defined but not used [-Wunused-function]
74 | static unsigned int maxinefb_ims332_read_register(int regno)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_ims332_read_register':
../drivers/video/fbdev/maxinefb.c:76:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

    76 |         register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
       |                                        ^
../drivers/video/fbdev/maxinefb.c: At top level:
../drivers/video/fbdev/maxinefb.c:114:12: warning: no previous prototype for 'maxinefb_init' [-Wmissing-prototypes]
   114 | int __init maxinefb_init(void)
       |            ^~~~~~~~~~~~~
In file included from ../drivers/video/fbdev/maxinefb.c:34:
../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_init':
../include/video/maxinefb.h:22:41: error: implicit declaration of function 'KSEG1ADDR'; did you mean 'CKSEG1ADDR'? [-Wimplicit-function-declaration]
    22 | #define DS5000_xx_ONBOARD_FBMEM_START   KSEG1ADDR(0x0a000000)
       |                                         ^~~~~~~~~
../drivers/video/fbdev/maxinefb.c:119:20: note: in expansion of macro 'DS5000_xx_ONBOARD_FBMEM_START'
   119 |         fb_start = DS5000_xx_ONBOARD_FBMEM_START;
       |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---
Cc: "Maciej W. Rozycki" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]

  drivers/video/fbdev/maxinefb.c |   17 ++---------------
  include/video/maxinefb.h       |    4 ++--
  2 files changed, 4 insertions(+), 17 deletions(-)
drivers/video/fbdev/maxinefb.c +2 -15
@@ -61,7 +61,7 @@ static struct fb_fix_screeninfo maxinefb
 
  /* Handle the funny Inmos RamDAC/video controller ... */
 
-void maxinefb_ims332_write_register(int regno, register unsigned int val)
+static void maxinefb_ims332_write_register(int regno, register unsigned int val)
  {
  	register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
  	unsigned char *wptr;
@@ -71,19 +71,6 @@ void maxinefb_ims332_write_register(int
  	*((volatile unsigned short *) (wptr)) = val;
  }
 
-unsigned int maxinefb_ims332_read_register(int regno)
-{
-	register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
-	unsigned char *rptr;
-	register unsigned int j, k;
-
-	rptr = regs + 0x80000 + (regno << 4);
-	j = *((volatile unsigned short *) rptr);
-	k = *((volatile unsigned short *) regs);
-
-	return (j & 0xffff) | ((k & 0xff00) << 8);
-}
-
  /* Set the palette */
  static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
  			      unsigned blue, unsigned transp, struct fb_info *info)
@@ -111,7 +98,7 @@ static const struct fb_ops maxinefb_ops
  	.fb_setcolreg	= maxinefb_setcolreg,
  };
 
-int __init maxinefb_init(void)
+static int __init maxinefb_init(void)
  {
  	unsigned long fboff;
  	unsigned long fb_start;
include/video/maxinefb.h +0 -0
@@ -13,13 +13,13 @@
  /*
   * IMS332 video controller register base address

include/video/maxinefb.h line 22

Quoted 10 lines
include/video/maxinefb.h +2 -2
   */
-#define MAXINEFB_IMS332_ADDRESS		KSEG1ADDR(0x1c140000)
+#define MAXINEFB_IMS332_ADDRESS		CKSEG1ADDR(0x1c140000)
 
  /*
   * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution
   * is 1024x768x8
   */
-#define DS5000_xx_ONBOARD_FBMEM_START	KSEG1ADDR(0x0a000000)
+#define DS5000_xx_ONBOARD_FBMEM_START	CKSEG1ADDR(0x0a000000)

The change looks correct, but clearly this has never been tested on a 64-bit DECstation, so I'm not sure having this code being now built is an improvement.

What about:

-- >8 --

drivers/video/fbdev/Kconfig +1 -1
index ac9ac4287c6a..ff17afe6b8b3 100644
@@ -1436,7 +1436,7 @@ config FB_PMAGB_B
 
 config FB_MAXINE
        bool "Maxine (Personal DECstation) onboard framebuffer support"
-       depends on (FB = y) && MACH_DECSTATION
+       depends on (FB = y) && MACH_DECSTATION && 32BIT
        select FB_IOMEM_HELPERS
        help
          Support for the onboard framebuffer (1024x768x8) in the Personal

---

?

Regards,

Phil.

#5 lore raw

Hi,

Quoted 135 lines · Philippe Mathieu-Daudé

Hi Randy,

Quoted 99 lines · Randy Dunlap

This is all ancient source code from the beginning of git time. Now builds cleanly on 32-bit and 64-bit MACH_DECSTATION.

Fixes these build errors/warnings:

../drivers/video/fbdev/maxinefb.c:64:6: warning: no previous prototype for 'maxinefb_ims332_write_register' [-Wmissing-prototypes] 64 | void maxinefb_ims332_write_register(int regno, register unsigned int val)
       |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from ../drivers/video/fbdev/maxinefb.c:34:
../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_ims332_write_register':
../include/video/maxinefb.h:16:41: error: implicit declaration of function 'KSEG1ADDR'; did you mean 'CKSEG1ADDR'? [-Wimplicit-function-declaration] 16 | #define MAXINEFB_IMS332_ADDRESS         KSEG1ADDR(0x1c140000)
       |                                         ^~~~~~~~~
../drivers/video/fbdev/maxinefb.c:66:49: note: in expansion of macro 'MAXINEFB_IMS332_ADDRESS'
    66 |         register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
       |                                                 ^~~~~~~~~~~~~~~~~~~~~~~
../drivers/video/fbdev/maxinefb.c:66:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    66 |         register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
       |                                        ^
../drivers/video/fbdev/maxinefb.c: At top level:
../drivers/video/fbdev/maxinefb.c:74:14: warning: no previous prototype for 'maxinefb_ims332_read_register' [-Wmissing-prototypes] 74 | unsigned int maxinefb_ims332_read_register(int regno)
       |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/video/fbdev/maxinefb.c: At top level:
../drivers/video/fbdev/maxinefb.c:74:21: warning: 'maxinefb_ims332_read_register' defined but not used [-Wunused-function] 74 | static unsigned int maxinefb_ims332_read_register(int regno)
       |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_ims332_read_register':
../drivers/video/fbdev/maxinefb.c:76:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    76 |         register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
       |                                        ^
../drivers/video/fbdev/maxinefb.c: At top level:
../drivers/video/fbdev/maxinefb.c:114:12: warning: no previous prototype for 'maxinefb_init' [-Wmissing-prototypes]
   114 | int __init maxinefb_init(void)
       |            ^~~~~~~~~~~~~
In file included from ../drivers/video/fbdev/maxinefb.c:34:
../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_init':
../include/video/maxinefb.h:22:41: error: implicit declaration of function 'KSEG1ADDR'; did you mean 'CKSEG1ADDR'? [-Wimplicit-function-declaration] 22 | #define DS5000_xx_ONBOARD_FBMEM_START   KSEG1ADDR(0x0a000000)
       |                                         ^~~~~~~~~
../drivers/video/fbdev/maxinefb.c:119:20: note: in expansion of macro 'DS5000_xx_ONBOARD_FBMEM_START'
   119 |         fb_start = DS5000_xx_ONBOARD_FBMEM_START;
       |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---
Cc: "Maciej W. Rozycki" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Thomas Bogendoerfer <[email protected]>
Cc: [email protected]

  drivers/video/fbdev/maxinefb.c |   17 ++--------------- include/video/maxinefb.h       |    4 ++--

  2 files changed, 4 insertions(+), 17 deletions(-)
drivers/video/fbdev/maxinefb.c +2 -12
@@ -61,7 +61,7 @@ static struct fb_fix_screeninfo maxinefb
     /* Handle the funny Inmos RamDAC/video controller ... */
   -void maxinefb_ims332_write_register(int regno, register unsigned int val)
+static void maxinefb_ims332_write_register(int regno, register unsigned int val)
   {
       register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
       unsigned char *wptr;
@@ -71,19 +71,6 @@ void maxinefb_ims332_write_register(int
       *((volatile unsigned short *) (wptr)) = val;
   }
   -unsigned int maxinefb_ims332_read_register(int regno)
-{
-    register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
-    unsigned char *rptr;
-    register unsigned int j, k;
-
-    rptr = regs + 0x80000 + (regno << 4);
-    j = *((volatile unsigned short *) rptr);
-    k = *((volatile unsigned short *) regs);
-
-    return (j & 0xffff) | ((k & 0xff00) << 8);
-}
-
   /* Set the palette */
   static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
                     unsigned blue, unsigned transp, struct fb_info *info)
@@ -111,7 +98,7 @@ static const struct fb_ops maxinefb_ops
       .fb_setcolreg    = maxinefb_setcolreg,
   };
   -int __init maxinefb_init(void)
+static int __init maxinefb_init(void)
   {
       unsigned long fboff;
       unsigned long fb_start;
include/video/maxinefb.h +0 -0
@@ -13,13 +13,13 @@
   /*

include/video/maxinefb.h line 21

Quoted 10 lines
include/video/maxinefb.h +2 -2
    * IMS332 video controller register base address
    */
-#define MAXINEFB_IMS332_ADDRESS        KSEG1ADDR(0x1c140000)
+#define MAXINEFB_IMS332_ADDRESS        CKSEG1ADDR(0x1c140000)
     /*
    * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution
    * is 1024x768x8
    */
-#define DS5000_xx_ONBOARD_FBMEM_START    KSEG1ADDR(0x0a000000)
+#define DS5000_xx_ONBOARD_FBMEM_START    CKSEG1ADDR(0x0a000000)

The change looks correct, but clearly this has never been tested on a 64-bit DECstation, so I'm not sure having this code being now built is an improvement.

What about:

-- >8 --

drivers/video/fbdev/Kconfig +0 -0
index ac9ac4287c6a..ff17afe6b8b3 100644
@@ -1436,7 +1436,7 @@ config FB_PMAGB_B
 

 config FB_MAXINE
        bool "Maxine (Personal DECstation) onboard framebuffer support" -       depends on (FB = y) && MACH_DECSTATION
+       depends on (FB = y) && MACH_DECSTATION && 32BIT
        select FB_IOMEM_HELPERS
        help
          Support for the onboard framebuffer (1024x768x8) in the Personal
---

Quoted 1 line

?

I guess I'm OK with that. I'm even OK with removing the driver completely.

Maciej did say in https://lore.kernel.org/all/[email protected]/
that: "the proper way would be by using `ioremap' really. I'll make a patch." [That was 15.Aug.2023.]

Signature · 1 line
~Randy
#6 lore raw
Quoted 10 lines · Randy Dunlap
Quoted 10 lines
Quoted 10 lines
include/video/maxinefb.h +1 -1
@@ -13,13 +13,13 @@
   /*
    * IMS332 video controller register base address
    */
-#define MAXINEFB_IMS332_ADDRESS        KSEG1ADDR(0x1c140000)
+#define MAXINEFB_IMS332_ADDRESS        CKSEG1ADDR(0x1c140000)
     /*
    * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution
Quoted 8 lines
Quoted 8 lines

include/video/maxinefb.h line 21

Quoted 4 lines
include/video/maxinefb.h +1 -1
    * is 1024x768x8
    */
-#define DS5000_xx_ONBOARD_FBMEM_START    KSEG1ADDR(0x0a000000)
+#define DS5000_xx_ONBOARD_FBMEM_START    CKSEG1ADDR(0x0a000000)

The change looks correct, but clearly this has never been tested on a 64-bit DECstation, so I'm not sure having this code being now built is an improvement.

I don't expect any issues and FWIW the Maxine does support a 64-bit CPU
module.

Quoted 15 lines
Quoted 15 lines
drivers/video/fbdev/Kconfig +0 -0
index ac9ac4287c6a..ff17afe6b8b3 100644
@@ -1436,7 +1436,7 @@ config FB_PMAGB_B
 

 config FB_MAXINE
        bool "Maxine (Personal DECstation) onboard framebuffer support" -       depends on (FB = y) && MACH_DECSTATION
+       depends on (FB = y) && MACH_DECSTATION && 32BIT
        select FB_IOMEM_HELPERS
        help
          Support for the onboard framebuffer (1024x768x8) in the Personal
---

Quoted 3 lines
Quoted 1 line

?

I guess I'm OK with that. I'm even OK with removing the driver completely.

No need to limit the driver to 32BIT and as I suggest in the other reply
fixing 64BIT will best be a separate change.

Quoted 3 lines

Maciej did say in https://lore.kernel.org/all/[email protected]/
that: "the proper way would be by using `ioremap' really. I'll make a patch." [That was 15.Aug.2023.]

Even more properly this will best be converted to a platform device and
then resource handling will DTRT. I do hope to get a specimen eventually, so I think there's no need to rush making changes on paper.

Maciej

maintainer
#7 lore raw
In reply to Randy Dunlap
Quoted 8 lines · Randy Dunlap

This is all ancient source code from the beginning of git time. Now builds cleanly on 32-bit and 64-bit MACH_DECSTATION.

Fixes these build errors/warnings:
.....

  drivers/video/fbdev/maxinefb.c |   17 ++---------------
  include/video/maxinefb.h       |    4 ++--
  2 files changed, 4 insertions(+), 17 deletions(-)

I've added the various comments from the mail thread to the patch and applied the patch as-is for now.

Thanks!
Helge

#8 lore raw
Quoted 5 lines · Helge Deller
Quoted 3 lines

This is all ancient source code from the beginning of git time. Now builds cleanly on 32-bit and 64-bit MACH_DECSTATION.

I've added the various comments from the mail thread to the patch and applied the patch as-is for now.

Given the statement of the problem as per the quotation above I don't
think there was a need to fast-track it without giving me a chance to chime in.

Maciej

maintainer
#9 lore raw
Quoted 11 lines · Maciej W. Rozycki
Quoted 5 lines · Helge Deller
Quoted 3 lines

This is all ancient source code from the beginning of git time. Now builds cleanly on 32-bit and 64-bit MACH_DECSTATION.

I've added the various comments from the mail thread to the patch and applied the patch as-is for now.

Given the statement of the problem as per the quotation above I don't
think there was a need to fast-track it without giving me a chance to chime in.

Don't worry. I'm happy to drop the intermediate patch anytime.

Helge

#10 lore raw
In reply to Randy Dunlap
Quoted 1 line · Randy Dunlap

This is all ancient source code from the beginning of git time.

I can dig out any further details you may need from the old LMO git tree.
Eventually it's planned to be put back online, but resources.

Quoted 1 line

Now builds cleanly on 32-bit and 64-bit MACH_DECSTATION.

Thanks for doing this work.

Quoted 1 line

Eventually this code should be converted to a platform device, so such
hacks won't be necessary. Sadly I declined an offer back in 2009 and I have been chasing a specimen for a while now. And since it's an onboard device unlike all the TURBOchannel framebuffers, there's no alternative.

Quoted 12 lines
drivers/video/fbdev/maxinefb.c +0 -6
@@ -71,19 +71,6 @@ void maxinefb_ims332_write_register(int
 	*((volatile unsigned short *) (wptr)) = val;
 }
 
-unsigned int maxinefb_ims332_read_register(int regno)
-{
-	register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
-	unsigned char *rptr;
-	register unsigned int j, k;
-

drivers/video/fbdev/maxinefb.c void maxinefb_ims332_write_register(int · line 76

Quoted 10 lines
drivers/video/fbdev/maxinefb.c +0 -7
-	rptr = regs + 0x80000 + (regno << 4);
-	j = *((volatile unsigned short *) rptr);
-	k = *((volatile unsigned short *) regs);
-
-	return (j & 0xffff) | ((k & 0xff00) << 8);
-}
-
 /* Set the palette */
 static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
 			      unsigned blue, unsigned transp, struct fb_info *info)

It might be worth mentioning in the change description that this is dead
code (and overall provide a summary as to making functions static, etc.). Though I'm not entirely convinced as to the removal since this function documents the hardware interface, which must have been the intent to put it there. Perhaps #if 0?

Quoted 8 lines
include/video/maxinefb.h +1 -1
@@ -13,13 +13,13 @@
 /*
  * IMS332 video controller register base address
  */
-#define MAXINEFB_IMS332_ADDRESS		KSEG1ADDR(0x1c140000)
+#define MAXINEFB_IMS332_ADDRESS		CKSEG1ADDR(0x1c140000)

include/video/maxinefb.h line 25

Quoted 10 lines
include/video/maxinefb.h +1 -1
 
 /*
  * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution
  * is 1024x768x8
  */
-#define DS5000_xx_ONBOARD_FBMEM_START	KSEG1ADDR(0x0a000000)
+#define DS5000_xx_ONBOARD_FBMEM_START	CKSEG1ADDR(0x0a000000)
 
 /*
  *      The IMS 332 video controller used in the DECstation 5000/xx series

This would probably best be a separate change, especially as it's not
needed for 32BIT.

I'm not sure how the actual maintainers see it (I should probably list
myself for all the scattered DECstation stuff), but I think this would best be a patch series of 3 for each of the individual classes of fixes. And since this borders on the obvious I wouldn't be too concerned as to the change descriptions; just one sentence plus the relevant error message quoted will do. And your introduction should suffice as the cover letter.

Let me know if this works for you and if you post such a series, I'll ack
it right away.

Maciej

#11 lore raw
Quoted 76 lines · Maciej W. Rozycki
Quoted 1 line · Randy Dunlap

This is all ancient source code from the beginning of git time.

I can dig out any further details you may need from the old LMO git tree.
Eventually it's planned to be put back online, but resources.

Quoted 1 line

Now builds cleanly on 32-bit and 64-bit MACH_DECSTATION.

Thanks for doing this work.

Quoted 1 line

Eventually this code should be converted to a platform device, so such
hacks won't be necessary. Sadly I declined an offer back in 2009 and I have been chasing a specimen for a while now. And since it's an onboard device unlike all the TURBOchannel framebuffers, there's no alternative.

Quoted 12 lines
drivers/video/fbdev/maxinefb.c +0 -6
@@ -71,19 +71,6 @@ void maxinefb_ims332_write_register(int
 	*((volatile unsigned short *) (wptr)) = val;
 }
 
-unsigned int maxinefb_ims332_read_register(int regno)
-{
-	register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
-	unsigned char *rptr;
-	register unsigned int j, k;
-

drivers/video/fbdev/maxinefb.c void maxinefb_ims332_write_register(int · line 76

Quoted 10 lines
drivers/video/fbdev/maxinefb.c +0 -7
-	rptr = regs + 0x80000 + (regno << 4);
-	j = *((volatile unsigned short *) rptr);
-	k = *((volatile unsigned short *) regs);
-
-	return (j & 0xffff) | ((k & 0xff00) << 8);
-}
-
 /* Set the palette */
 static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
 			      unsigned blue, unsigned transp, struct fb_info *info)

It might be worth mentioning in the change description that this is dead
code (and overall provide a summary as to making functions static, etc.). Though I'm not entirely convinced as to the removal since this function documents the hardware interface, which must have been the intent to put it there. Perhaps #if 0?

Quoted 8 lines
include/video/maxinefb.h +1 -1
@@ -13,13 +13,13 @@
 /*
  * IMS332 video controller register base address
  */
-#define MAXINEFB_IMS332_ADDRESS		KSEG1ADDR(0x1c140000)
+#define MAXINEFB_IMS332_ADDRESS		CKSEG1ADDR(0x1c140000)

include/video/maxinefb.h line 25

Quoted 10 lines
include/video/maxinefb.h +1 -1
 
 /*
  * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution
  * is 1024x768x8
  */
-#define DS5000_xx_ONBOARD_FBMEM_START	KSEG1ADDR(0x0a000000)
+#define DS5000_xx_ONBOARD_FBMEM_START	CKSEG1ADDR(0x0a000000)
 
 /*
  *      The IMS 332 video controller used in the DECstation 5000/xx series

This would probably best be a separate change, especially as it's not
needed for 32BIT.

I'm not sure how the actual maintainers see it (I should probably list
myself for all the scattered DECstation stuff), but I think this would best be a patch series of 3 for each of the individual classes of fixes. And since this borders on the obvious I wouldn't be too concerned as to the change descriptions; just one sentence plus the relevant error message quoted will do. And your introduction should suffice as the cover letter.

Quoted 2 lines

Let me know if this works for you and if you post such a series, I'll ack
it right away.

OK, I'll work on that.

Signature · 1 line
~Randy