Skip to contentSkip to conversation

SGI O2 framebuffer driver

PATCH In review Vivien Chappelier 4 participants 9 messages Dec 11, 2002 – Dec 12, 2002 1 message not in the archive MIPS

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 SGI O2 framebuffer driver

In reply to a message not in the archive

Hi,

Here's a patch to add support for the framebuffer on the SGI
O2. It has support for both static (bootmem) and dynamic video memory allocation (limited to 2MB due to the small number of available vmalloc mappings in the current mips64 kernel).

Vivien.

mips/sgi-ip32/ip32-setup.c +15 -0
@@ -13,6 +13,8 @@
 #include <linux/mc146818rtc.h>
 #include <linux/param.h>
 #include <linux/init.h>
+#include <linux/console.h>
+#include <linux/bootmem.h>
 
 #include <asm/time.h>
 #include <asm/mipsregs.h>
@@ -21,6 +21,7 @@
 #include <asm/ip32/crime.h>
 #include <asm/ip32/mace.h>
 #include <asm/ip32/ip32_ints.h>
+#include <asm/ip32/tile.h>
 #include <asm/sgialib.h>
 
 extern struct rtc_ops ip32_rtc_ops;
@@ -58,6 +59,18 @@
 }
 #endif
 
+void __init ip32_devsetup(void)
+{
+#if defined(CONFIG_FB_SGIO2) && !defined(CONFIG_FB_SGIO2_DYNAMIC)
+	{
+		extern void *sgio2fb_mem;
+
+		sgio2fb_mem = __alloc_bootmem(CONFIG_FB_SGIO2_MEM*1024*1024,
+					      TILE_SIZE,__pa(MAX_DMA_ADDRESS));
+	}
+#endif
+}
+
 extern void ip32_time_init(void);
 extern void ip32_reboot_setup(void);
 
mips64/kernel/setup.c +4 -0
@@ -451,6 +451,10 @@
 
 	bootmem_init();
 
+#ifdef CONFIG_SGI_IP32
+	ip32_devsetup();
+#endif
+
 	paging_init();
 
 	resource_init();
mips/sgi-ip32/ip32-reset.c +12 -0
@@ -10,14 +10,26 @@
 
 #include <asm/reboot.h>
 #include <asm/sgialib.h>
+#include <asm/addrspace.h>
+#include <asm/types.h>
+
+#ifdef CONFIG_FB_SGIO2
+extern void gbe_turn_off(void);
+#endif
 
 static void ip32_machine_restart(char *cmd)
 {
+#ifdef CONFIG_FB_SGIO2
+	gbe_turn_off();
+#endif 
 	ArcReboot();
 }
 
 static inline void ip32_machine_halt(void)
 {
+#ifdef CONFIG_FB_SGIO2
+	gbe_turn_off();
+#endif 
 	ArcEnterInteractiveMode();
 }
 
video/fbcon.h +2 -0
@@ -214,9 +214,11 @@
 #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
 
 #endif
video/Kconfig +27 -3
@@ -400,6 +400,30 @@
 	help
 	  SGI Visual Workstation support for framebuffer graphics.
 
+config FB_SGIO2
+	bool "SGI O2 frame buffer support"
+	depends on FB && SGI_IP32
+	help
+	  SGI O2 workstation framebuffer support. You probably
+	  want to enable this, unless you are using serial console.
+	  Even with serial console, this shouldn't hurt (much).
+
+config FB_SGIO2_MEM
+	int "Video memory size in MB"
+	depends on FB_SGIO2
+        default 8
+	help
+	  This is the amount of memory reserved for the framebuffer,
+	  which can be any value between 1MB and 8MB.
+
+config FB_SGIO2_DYNAMIC
+	bool "Dynamic video memory allocation (EXPERIMENTAL)"
+	depends on FB_SGIO2
+	default n
+	help
+	  Saying Y here allows the video memory to scale with the
+	  resolution of the framebuffer.
+
 config BUS_I2C
 	bool
 	depends on FB && VISWS
@@ -976,7 +1000,7 @@
 	tristate "8 bpp packed pixels support" if FBCON_ADVANCED
 	depends on FB
 	default m if !FBCON_ADVANCED && !FB_ACORN && !FB_ATARI && !FB_P9100 && FB_CYBER2000!=y && FB_RADEON!=y && FB_TGA!=y && FB_SIS!=y && FB_PM3!=y && !FB_TCX && !FB_CGTHREE && !FB_CONTROL && FB_CLGEN!=y && !FB_CGFOURTEEN && FB_TRIDENT!=y && !FB_VIRGE && FB_CYBER!=y && !FB_VALKYRIE && !FB_PLATINUM && !FB_IGA && FB_MATROX!=y && !FB_CT65550 && FB_PM2!=y && !FB_SA1100 && (FB_CYBER2000=m || FB_RADEON=m || FB_TGA=m || FB_SIS=m || FB_PM3=m || FB_CLGEN=m || FB_TRIDENT=m || FB_CYBER=m || FB_MATROX=m || FB_PM2=m)
-	default y if !FBCON_ADVANCED && (FB_ACORN || FB_ATARI || FB_P9100 || FB_CYBER2000=y || FB_RADEON=y || FB_TGA=y || FB_SIS=y || FB_PM3=y || FB_TCX || FB_CGTHREE || FB_CONTROL || FB_CLGEN=y || FB_CGFOURTEEN || FB_TRIDENT=y || FB_VIRGE || FB_CYBER=y || FB_VALKYRIE || FB_PLATINUM || FB_IGA || FB_MATROX=y || FB_CT65550 || FB_PM2=y || FB_SA1100)
+	default y if !FBCON_ADVANCED && (FB_ACORN || FB_ATARI || FB_P9100 || FB_CYBER2000=y || FB_RADEON=y || FB_TGA=y || FB_SIS=y || FB_PM3=y || FB_TCX || FB_CGTHREE || FB_CONTROL || FB_CLGEN=y || FB_CGFOURTEEN || FB_TRIDENT=y || FB_VIRGE || FB_CYBER=y || FB_VALKYRIE || FB_PLATINUM || FB_IGA || FB_MATROX=y || FB_CT65550 || FB_PM2=y || FB_SA1100 || FB_SGIO2=y)
 	help
 	  This is the low level frame buffer console driver for 8 bits per
 	  pixel (256 colors) packed pixels.
@@ -985,7 +1009,7 @@
 	tristate "16 bpp packed pixels support" if FBCON_ADVANCED
 	depends on FB
 	default m if !FBCON_ADVANCED && !FB_ATARI && FB_PM3!=y && FB_SIS!=y && FB_PVR2!=y && FB_TRIDENT!=y && !FB_TBOX && FB_VOODOO1!=y && FB_RADEON!=y && !FB_CONTROL && FB_CLGEN!=y && !FB_VIRGE && FB_CYBER!=y && !FB_VALKYRIE && !FB_PLATINUM && !FB_CT65550 && FB_MATROX!=y && FB_PM2!=y && FB_CYBER2000!=y && !FB_SA1100 && (FB_SIS=m || FB_RADEON=m || FB_PVR2=m || FB_TRIDENT=m || FB_VOODOO1=m || FB_PM3=m || FB_CLGEN=m || FB_CYBER=m || FB_MATROX=m || FB_PM2=m || FB_CYBER2000=m || FB_SA1100)
-	default y if !FBCON_ADVANCED && (FB_ATARI || FB_PM3=y || FB_SIS=y || FB_PVR2=y || FB_TRIDENT=y || FB_TBOX || FB_VOODOO1=y || FB_RADEON=y || FB_CONTROL || FB_CLGEN=y || FB_VIRGE || FB_CYBER=y || FB_VALKYRIE || FB_PLATINUM || FB_CT65550 || FB_MATROX=y || FB_PM2=y || FB_CYBER2000=y || FB_SA1100)
+	default y if !FBCON_ADVANCED && (FB_ATARI || FB_PM3=y || FB_SIS=y || FB_PVR2=y || FB_TRIDENT=y || FB_TBOX || FB_VOODOO1=y || FB_RADEON=y || FB_CONTROL || FB_CLGEN=y || FB_VIRGE || FB_CYBER=y || FB_VALKYRIE || FB_PLATINUM || FB_CT65550 || FB_MATROX=y || FB_PM2=y || FB_CYBER2000=y || FB_SA1100 || FB_SGIO2=y)
 	help
 	  This is the low level frame buffer console driver for 15 or 16 bits
 	  per pixel (32K or 64K colors, also known as `hicolor') packed
@@ -1005,7 +1029,7 @@
 	tristate "32 bpp packed pixels support" if FBCON_ADVANCED
 	depends on FB
 	default m if !FBCON_ADVANCED && !FB_ATARI && FB_RADEON!=y && FB_VOODOO1!=y && FB_TRIDENT!=y && !FB_CONTROL && FB_CLGEN!=y && FB_TGA!=y && !FB_PLATINUM && FB_MATROX!=y && FB_PM2!=y && FB_PVR2!=y && FB_PM3!=y && FB_SIS!=y && (FB_RADEON=m || FB_VOODOO1=m || FB_TRIDENT=m || FB_CLGEN=m || FB_TGA=m || FB_MATROX=m || FB_PM2=m || FB_SIS=m || FB_PVR2=m || FB_PM3=m)
-	default y if !FBCON_ADVANCED && (FB_ATARI || FB_RADEON=y || FB_VOODOO1=y || FB_TRIDENT=y || FB_CONTROL || FB_CLGEN=y || FB_TGA=y || FB_PLATINUM || FB_MATROX=y || FB_PM2=y || FB_PVR2=y || FB_PM3=y || FB_SIS=y)
+	default y if !FBCON_ADVANCED && (FB_ATARI || FB_RADEON=y || FB_VOODOO1=y || FB_TRIDENT=y || FB_CONTROL || FB_CLGEN=y || FB_TGA=y || FB_PLATINUM || FB_MATROX=y || FB_PM2=y || FB_PVR2=y || FB_PM3=y || FB_SIS=y || FB_SGIO2=y)
 	help
 	  This is the low level frame buffer console driver for 32 bits per
 	  pixel (16M colors, also known as `truecolor') sparse packed pixels.
video/Makefile +1 -0
@@ -56,6 +56,7 @@
 obj-$(CONFIG_FB_CLPS711X)         += clps711xfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
 obj-$(CONFIG_FB_CYBER)            += cyberfb.o
 obj-$(CONFIG_FB_CYBER2000)        += cyber2000fb.o
+obj-$(CONFIG_FB_SGIO2)            += sgio2fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o 
 obj-$(CONFIG_FB_SGIVW)            += sgivwfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
 obj-$(CONFIG_FB_3DFX)             += tdfxfb.o
 obj-$(CONFIG_FB_MAC)              += macfb.o macmodes.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o 
video/fbmem.c +5 -0
@@ -118,6 +118,8 @@
 extern int sun3fb_setup(char *);
 extern int sgivwfb_init(void);
 extern int sgivwfb_setup(char*);
+extern int sgio2fb_init(void);
+extern int sgio2fb_setup(char*);
 extern int rivafb_init(void);
 extern int rivafb_setup(char*);
 extern int tdfxfb_init(void);
@@ -262,6 +264,9 @@
 #ifdef CONFIG_FB_SGIVW
 	{ "sgivw", sgivwfb_init, sgivwfb_setup },
 #endif
+#ifdef CONFIG_FB_SGIO2
+	{ "sgio2", sgio2fb_init, sgio2fb_setup },
+#endif
 #ifdef CONFIG_FB_ACORN
 	{ "acorn", acornfb_init, acornfb_setup },
 #endif
video/sgio2fb.c +1446 -0

1,446 lines not on this page · raw message

video/sgio2fb.h +333 -0

333 lines not on this page · raw message

asm-mips64/ip32/tile.h +18 -0
@@ -0,0 +1,18 @@
+/*
+ * Definitions for the SGI O2 tiles
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2002 Vivien Chappelier
+ */
+
+#ifndef __ASM_IP32_TILE_H__
+#define __ASM_IP32_TILE_H__
+
+#define TILE_SHIFT 16 
+#define TILE_SIZE (1 << TILE_SHIFT)
+#define TILE_MASK (TILE_SIZE - 1)
+
+#endif /* __ASM_IP32_TILE_H__ */
#2 lore raw
Quoted 6 lines · Vivien Chappelier

Hi,

Here's a patch to add support for the framebuffer on the SGI
O2. It has support for both static (bootmem) and dynamic video memory allocation (limited to 2MB due to the small number of available vmalloc mappings in the current mips64 kernel).

Since vmalloc is physically non linear is there any reason you can't just use get_free_page() a lot ?

#3 lore raw
Quoted 2 lines · Alan Cox

Since vmalloc is physically non linear is there any reason you can't just use get_free_page() a lot ?

I'm not using vmalloc directly. I'm indeed using many get_free_pages of 64kB, as the O2 FB device has a TLB of it's own and can handle a non physically linear framebuffer (up to 8MB with 64kB granularity). I'm then remapping all those pages to one virtual region obtained from get_vm_area so that
1. caching attributes can be set to cacheable write-through no WA
2. the fbcon-cfb* code can be used as it sees the framebuffer as linear.
3. 64kB chuncks can be dynamically allocated and freed depending on the framebuffer resolution, keeping memory optimally shared between apps and framebuffer (compared to the static bootmem allocation).

However, as it is implemented currently, there are only 1024 kernel virtual->physical mappings available (include/asm-mips64/pgtable.h), that is only 4MB can be mapped. Maybe something like fixmap would help but it's not yet there for mips64.

regards,
Vivien.

#4 lore raw
Quoted 3 lines · Vivien Chappelier

linear framebuffer (up to 8MB with 64kB granularity). I'm then remapping all those pages to one virtual region obtained from get_vm_area so that
1. caching attributes can be set to cacheable write-through no WA

Ick. The framebuffer can't handle cached and write barriers ?

#5 lore raw
Quoted 6 lines · Alan Cox
Quoted 3 lines · Vivien Chappelier

linear framebuffer (up to 8MB with 64kB granularity). I'm then remapping all those pages to one virtual region obtained from get_vm_area so that
1. caching attributes can be set to cacheable write-through no WA

Ick. The framebuffer can't handle cached and write barriers ?

The O2 is non-cache coherent. So with the fairly large write-back second level caches enabled frame buffer write could potencially be delayed indefinately but in any case quite long. Frame buffers are usually only written to, so the cache mode "uncached accelerated" seems preferable but only the R10000 provides this mode, so for the R5000 write-though no write allocation is the next best solution.

Ralf

#6 lore raw
Quoted 3 lines · Ralf Baechle

The O2 is non-cache coherent. So with the fairly large write-back second level caches enabled frame buffer write could potencially be delayed indefinately but in any case quite long. Frame buffers are usually only

You can flush the frame buffer pages that were touched at the end of an operation though

#7 lore raw
Quoted 6 lines · Alan Cox
Quoted 3 lines

The O2 is non-cache coherent. So with the fairly large write-back second level caches enabled frame buffer write could potencially be delayed indefinately but in any case quite long. Frame buffers are usually only

You can flush the frame buffer pages that were touched at the end of an operation though

Flushes are very expensive operations, on the order of 16 cycles per cacheline plus memory delay. So why using them when just using the right cache mode does the right thing already.

Ralf

#8 lore raw
Quoted 2 lines · Ralf Baechle

Flushes are very expensive operations, on the order of 16 cycles per cacheline plus memory delay.

Hmm. Not on most MIPS CPUs; the internal cost of running the writeback cache-op instructions is typically around 3 clocks per cache-line. But this is misleading anyway... too CPU-centric.

The associated memory operations are the slowest thing about cacheops, always. Memory accesses (120ns is good) are much, much slower than an instruction time on a modern CPU (1-5ns).

So for your framebuffer, it's the write which does for you. If you use uncached mode and write 32-bit words that's 120ns/word. You can get a cacheline-sized burst of 8 words in and out in roughly the same amount of time.

In most cases this means that cacheing the framebuffer and then pushing it out will save a whole lot of time.

It's not absolutely certain: in most MIPS CPUs (write allocate as well as writeback) you also pay to read in the framebuffer data. And it tends to displace all sorts of other useful data from the cache, and then you have to pay to bring it back again.

But in general the memory operations associated with write-backs and invalidates are much more costly than the cacheops themselves.

Signature · 5 lines
Dominic Sweetman, 
MIPS Technologies (UK)
The Fruit Farm, Ely Road, Chittering, CAMBS CB5 9PH, ENGLAND
phone: +44 1223 706205 / fax: +44 1223 706250 / swbrd: +44 1223 706200
http://www.algor.co.uk
#9 lore raw
Quoted 6 lines · Dominic Sweetman
Quoted 2 lines

Flushes are very expensive operations, on the order of 16 cycles per cacheline plus memory delay.

Hmm. Not on most MIPS CPUs; the internal cost of running the writeback cache-op instructions is typically around 3 clocks per cache-line. But this is misleading anyway... too CPU-centric.

Most MIPS manuals unfortunately do not document the execution time of cache instructions at all. This thread is specific to the SGI IP32 aka O2 which comes with three processor options, the r5000, the R10000 and the R12000; the R5000's timing should not be too far off from the R4600.

So you got me to dig out my super dusty R4600/R4700 manual ... Hit_- Writeback_D costs 7 cycles for a miss, 12 for a hit if the line is clean and 14 if the line is dirty. Add another 3 cycles if the store or response buffers are busy, add even more if the writeback buffer was filled up.

Quoted 8 lines

The associated memory operations are the slowest thing about cacheops, always. Memory accesses (120ns is good) are much, much slower than an instruction time on a modern CPU (1-5ns).

So for your framebuffer, it's the write which does for you. If you use uncached mode and write 32-bit words that's 120ns/word. You can get a cacheline-sized burst of 8 words in and out in roughly the same amount of time.

Forgot the numbers but SGI's IP32 memory subsystem is rather fast even though it's fairly old.

Ralf