ALPHA: support graphics on non-zero PCI domains
PATCH 7/7 ALPHA: support graphics on non-zero PCI domains
Files:
arch/alpha/Kconfigarch/alpha/kernel/console.carch/alpha/kernel/core_marvel.carch/alpha/kernel/core_titan.carch/alpha/kernel/core_tsunami.carch/alpha/kernel/proto.harch/alpha/kernel/sys_dp264.cinclude/asm-alpha/core_titan.hinclude/asm-alpha/core_tsunami.hinclude/asm-alpha/vga.h
This code replaces earlier and incomplete handling of graphics on non-zero PCI domains (aka hoses or peer PCI buses).
An option (CONFIG_VGA_HOSE) is available if configuring a GENERIC kernel, or a kernel for MARVEL, TITAN, or TSUNAMI machines, as these are the machines whose SRM consoles are capable of configuring and handling graphics options on non-zero hoses.
A routine, "locate_and_init_vga()", is used to find the graphics device and set a global (pci_vga_hose) for later use in managing access to the device.
Various adjustments are made to the ioremap and ioportmap routines for detecting and translating "legacy" VGA register and memory references to the real PCI domain.
---
arch/alpha/Kconfig +12 -0
@@ -481,6 +481,11 @@ config ALPHA_BROKEN_IRQ_MASK depends on ALPHA_GENERIC || ALPHA_PC164 default y +config VGA_HOSE + bool "VGA on arbitrary hose" + depends on ALPHA_GENERIC || ALPHA_TITAN || ALPHA_MARVEL || ALPHA_TSUNAMI + default y + config ALPHA_SRM bool "Use SRM as bootloader" if ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_NAUTILUS || ALPHA_NONAME default y if ALPHA_JENSEN || ALPHA_MIKASA || ALPHA_SABLE || ALPHA_LYNX || ALPHA_NORITAKE || ALPHA_DP264 || ALPHA_RAWHIDE || ALPHA_EIGER || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_SHARK || ALPHA_MARVEL
@@ -644,6 +649,13 @@ source "arch/alpha/oprofile/Kconfig" source "arch/alpha/Kconfig.debug" +# DUMMY_CONSOLE may be defined in drivers/video/console/Kconfig +# but we also need it if VGA_HOSE is set +config DUMMY_CONSOLE + bool + depends on VGA_HOSE + default y + source "security/Kconfig" source "crypto/Kconfig"
arch/alpha/kernel/console.c +14 -22
@@ -9,16 +9,15 @@#include <linux/init.h> #include <linux/tty.h> #include <linux/console.h> +#include <linux/vt.h> #include <asm/vga.h> #include <asm/machvec.h> +#include "pci_impl.h" +#ifdef CONFIG_VGA_HOSE -/* -* Externally-visible vga hose bases -*/ -unsigned long __vga_hose_io_base =0 ;/* base for default hose */ -unsigned long __vga_hose_mem_base =0 ;/* base for default hose */ +struct pci_controller *pci_vga_hose =NULL ;static struct pci_controller *__init default_vga_hose_select (struct pci_controller *h1,struct pci_controller *h2)
@@ -30,35 +29,28 @@ default_vga_hose_select(struct pci_contr }void __init -set_vga_hose (struct pci_controller *hose) -{ -if (hose) { - __vga_hose_io_base = hose->io_space->start; - __vga_hose_mem_base = hose->mem_space->start; - } -} - -void __init locate_and_init_vga (void *(*sel_func)(void *,void *)) {struct pci_controller *hose =NULL ;struct pci_dev *dev =NULL ; +/* Default the select function */ if (!sel_func) sel_func = (void *)default_vga_hose_select; +/* Find the console VGA device */ for (dev=NULL ; (dev=pci_get_class (PCI_CLASS_DISPLAY_VGA <<8 , dev));) { -if (!hose) hose = dev->sysdata; -else hose =sel_func (hose, dev->sysdata); +if (!hose) + hose = dev->sysdata; +else + hose =sel_func (hose, dev->sysdata); } -/* Did we already inititialize the correct one? */ -if (conswitchp == &vga_con && - __vga_hose_io_base == hose->io_space->start && - __vga_hose_mem_base == hose->mem_space->start) +/* Did we already initialize the correct one? Is there one? */ +if (!hose || (conswitchp == &vga_con && pci_vga_hose == hose))return ; -/* Set the VGA hose and init the new console */ -set_vga_hose (hose); +/* Set the VGA hose and init the new console. */ + pci_vga_hose = hose;take_over_console (&vga_con,0 ,MAX_NR_CONSOLES -1 ,1 ); }
arch/alpha/kernel/core_marvel.c +15 -19
@@ -25,6 +25,7 @@#include <asm/pgalloc.h> #include <asm/tlbflush.h> #include <asm/rtc.h> +#include <asm/vga.h> #include "proto.h" #include "pci_impl.h"
@@ -684,9 +685,6 @@ __marvel_rtc_io(u8 b, unsigned long addr/* * IO map support. */ - -#define __marvel_is_mem_vga (a) (((a) >= 0xa0000) && ((a) <= 0xc0000)) -void __iomem *marvel_ioremap (unsigned long addr,unsigned long size) {
@@ -698,13 +696,9 @@ marvel_ioremap(unsigned long addr, unsigunsigned long pfn;/* -* Adjust the addr. +* Adjust the address. */ -#ifdef CONFIG_VGA_HOSE -if (pci_vga_hose &&__marvel_is_mem_vga (addr)) { - addr += pci_vga_hose->mem_space->start; - } -#endif +FIXUP_MEMADDR_VGA (addr);/* * Find the hose.
@@ -781,7 +775,9 @@ marvel_ioremap(unsigned long addr, unsigreturn (void __iomem *) vaddr; } -return NULL ; +/* Assume it was already a reasonable address */ + vaddr = baddr + hose->mem_space->start; +return (void __iomem *) vaddr; }void
@@ -803,21 +799,15 @@ marvel_is_mmio(const volatile void __iomreturn (addr &0xFF000000UL ) ==0 ; } -#define __marvel_is_port_vga (a) \ - (((a) >= 0x3b0) && ((a) < 0x3e0) && ((a) != 0x3b3) && ((a) != 0x3d3))#define __marvel_is_port_kbd (a) (((a) == 0x60) || ((a) == 0x64))#define __marvel_is_port_rtc (a) (((a) == 0x70) || ((a) == 0x71))void __iomem *marvel_ioportmap (unsigned long addr) { -if (__marvel_is_port_rtc (addr) ||__marvel_is_port_kbd (addr)) - ;#ifdef CONFIG_VGA_HOSE - else if (__marvel_is_port_vga (addr) && pci_vga_hose) +if (pci_vga_hose &&__is_port_vga (addr)) addr += pci_vga_hose->io_space->start;#endif - else - return NULL;return (void __iomem *)addr; }
@@ -829,8 +819,14 @@ marvel_ioread8(void __iomem *xaddr)return 0 ; else if (__marvel_is_port_rtc(addr)) return __marvel_rtc_io(0, addr, 0); - else + else if (marvel_is_ioaddr(addr)) return __kernel_ldbu(*(vucp)addr); + else +/* this should catch other legacy addresses +that would normally fail on MARVEL, +because there really is nothing there... +*/ + return ~0; }void
@@ -841,7 +837,7 @@ marvel_iowrite8(u8 b, void __iomem *xaddreturn ; else if (__marvel_is_port_rtc(addr)) __marvel_rtc_io(b, addr, 1); - else + else if (marvel_is_ioaddr(addr)) __kernel_stb(b, *(vucp)addr); }
arch/alpha/kernel/core_titan.c +30 -12
122 lines not on this page · raw message
arch/alpha/kernel/core_tsunami.c +50 -0
68 lines not on this page · raw message
arch/alpha/kernel/proto.h +7 -0
@@ -108,6 +108,13 @@ extern int wildfire_cpuid_to_nid(int);extern unsigned long wildfire_node_mem_start (int );extern unsigned long wildfire_node_mem_size (int ); +/* console.c */ +#ifdef CONFIG_VGA_HOSE +extern void locate_and_init_vga (void *(*)(void *,void *)); +#else +#define locate_and_init_vga () do { } while (0) +#endif +/* setup.c */ extern unsigned long srm_hae;extern int boot_cpuid;
arch/alpha/kernel/sys_dp264.c +10 -1
@@ -543,6 +543,7 @@ dp264_init_pci(void) {common_init_pci ();SMC669_Init (0 ); +locate_and_init_vga (NULL ); } static void __init
@@ -551,6 +552,14 @@ monet_init_pci(void)common_init_pci ();SMC669_Init (1 );es1888_init (); +locate_and_init_vga (NULL ); +} + +static void __init +clipper_init_pci (void ) +{ +common_init_pci (); +locate_and_init_vga (NULL ); } static void __init
@@ -655,7 +664,7 @@ struct alpha_machine_vector clipper_mv _ .init_arch = tsunami_init_arch, .init_irq = clipper_init_irq, .init_rtc = common_init_rtc, - .init_pci = common_init_pci, + .init_pci = clipper_init_pci, .kill_arch = tsunami_kill_arch, .pci_map_irq = clipper_map_irq, .pci_swizzle = common_swizzle,
include/asm-alpha/core_titan.h +1 -6
@@ -380,12 +380,7 @@ struct el_PRIVATEER_envdata_mcheck {/* * Memory functions. all accesses are done through linear space. */ - -__EXTERN_INLINE void __iomem *titan_ioportmap(unsigned long addr) -{ -return (void __iomem *)(addr +TITAN_IO_BIAS ); -} - +extern void __iomem *titan_ioportmap (unsigned long addr);extern void __iomem *titan_ioremap (unsigned long addr,unsigned long size);extern void titan_iounmap (volatile void __iomem *addr);
include/asm-alpha/core_tsunami.h +3 -12
@@ -2,6 +2,7 @@#define __ALPHA_TSUNAMI__H__#include <linux/types.h> +#include <linux/pci.h> #include <asm/compiler.h> /*
@@ -302,18 +303,8 @@ struct el_TSUNAMI_sysdata_mcheck {/* * Memory functions. all accesses are done through linear space. */ - -__EXTERN_INLINE void __iomem *tsunami_ioportmap(unsigned long addr) -{ -return (void __iomem *)(addr +TSUNAMI_IO_BIAS ); -} - -__EXTERN_INLINE void __iomem *tsunami_ioremap(unsigned long addr, -unsigned long size) -{ -return (void __iomem *)(addr +TSUNAMI_MEM_BIAS ); -} - +extern void __iomem *tsunami_ioportmap (unsigned long addr); +extern void __iomem *tsunami_ioremap (unsigned long addr,unsigned long size); __EXTERN_INLINE int tsunami_is_ioaddr(unsigned long addr) {return addr >=TSUNAMI_BASE ;
include/asm-alpha/vga.h +47 -1
53 lines not on this page · raw message
include/asm-alpha/vga.h extern void scr_memcpyw(u16 *d, const u1 · line 66
Quoted 11 lines · Ivan Kokshaysky
include/asm-alpha/vga.h +11
-0+VGA_MAP_MEM(unsigned long xaddr, unsigned int size) +{ +/* Create a new VGA ioport resource WRT the hose it is on. */ +if (pci_vga_hose && pci_vga_hose->index) { +static struct resource alpha_vga = + { .name ="alpha-vga+" , .start =0x3C0 , .end =0x3DF }; +struct resource new_vga = alpha_vga; + + new_vga.start += pci_vga_hose->io_space->start; + new_vga.end += pci_vga_hose->io_space->start; +request_resource (&ioport_resource, &new_vga);
This leaks the local stack frame variable new_vga into the resource tree, does it not? Shouldn't you be kmallocing this?
r~
Quoted 19 lines · Richard Henderson
include/asm-alpha/vga.h extern void scr_memcpyw(u16 *d, const u1 · line 66
Quoted 12 lines · Ivan Kokshaysky
include/asm-alpha/vga.h +11
-0+VGA_MAP_MEM(unsigned long xaddr, unsigned int size) +{ +/* Create a new VGA ioport resource WRT the hose it is on. */ +if (pci_vga_hose && pci_vga_hose->index) { +static struct resource alpha_vga = + { .name ="alpha-vga+" , .start =0x3C0 , .end =0x3DF }; +struct resource new_vga = alpha_vga; + + new_vga.start += pci_vga_hose->io_space->start; + new_vga.end += pci_vga_hose->io_space->start; +request_resource (&ioport_resource, &new_vga);This leaks the local stack frame variable
new_vgainto the resource tree, does it not? Shouldn't you be kmallocing this?
Quoted 2 lines
r~
Yes, it does leak, and yes, it should be kmalloced. Something like this?
struct resource *new_vga;
new_vga = kmalloc(sizeof(struct resource), GFP_ATOMIC);
if (new_vga) {
*new_vga = alpha_vga;
new_vga->start += pci_vga_hose->io_space->start;
new_vga->end += pci_vga_hose->io_space->start;
request_resource(&ioport_resource, new_vga);
}Thanks, Richard, I'll regenerate this one...
--Jay++
Signature · 3 lines
Jay A Estabrook HPTC - XC I & B Hewlett-Packard Company - ZKO1-3/D-B.8 (603) 884-0301 110 Spit Brook Road, Nashua NH 03062 [email protected]
Quoted 11 lines · Jay Estabrook
Yes, it does leak, and yes, it should be kmalloced. Something like this?
struct resource *new_vga; new_vga = kmalloc(sizeof(struct resource), GFP_ATOMIC); if (new_vga) { *new_vga = alpha_vga; new_vga->start += pci_vga_hose->io_space->start; new_vga->end += pci_vga_hose->io_space->start; request_resource(&ioport_resource, new_vga); }
No. After closer inspection this looks like a dead code. This request_resource() always fails because the parent resource passed to it is incorrect - it must be pci_vga_hose->io_space, not ioport_resource.
On the other hand, I don't see why we should request VGA IO from VGA_MAP_MEM, which might be called multiple times. Wouldn't it be much cleaner to do it once right after VGA discovery? I'd suggest the appended patch on top of your original one.
Ivan.
arch/alpha/kernel/console.c +10 -0
@@ -18,6 +18,11 @@#ifdef CONFIG_VGA_HOSE struct pci_controller *pci_vga_hose =NULL ; +static struct resource alpha_vga = { + .name ="alpha-vga+" , + .start =0x3C0 , + .end =0x3DF +};static struct pci_controller *__init default_vga_hose_select (struct pci_controller *h1,struct pci_controller *h2)
@@ -48,6 +53,11 @@ locate_and_init_vga(void *(*sel_func)(vo/* Did we already initialize the correct one? Is there one? */ if (!hose || (conswitchp == &vga_con && pci_vga_hose == hose))return ; + +/* Create a new VGA ioport resource WRT the hose it is on. */ + alpha_vga.start += hose->io_space->start; + alpha_vga.end += hose->io_space->start; +request_resource (hose->io_space, &alpha_vga);/* Set the VGA hose and init the new console. */ pci_vga_hose = hose;
include/asm-alpha/vga.h +2 -19
@@ -52,24 +52,6 @@ extern void scr_memcpyw(u16 *d, const u1extern struct pci_controller *pci_vga_hose; -static inline unsigned long -VGA_MAP_MEM (unsigned long xaddr,unsigned int size) -{ -/* Create a new VGA ioport resource WRT the hose it is on. */ -if (pci_vga_hose && pci_vga_hose->index) { -static struct resource alpha_vga = - { .name ="alpha-vga+" , .start =0x3C0 , .end =0x3DF }; -struct resource new_vga = alpha_vga; - - new_vga.start += pci_vga_hose->io_space->start; - new_vga.end += pci_vga_hose->io_space->start; -request_resource (&ioport_resource, &new_vga); - } - -/* Return the ioremap. */ -return (unsigned long )ioremap (xaddr, size); -} -# define __is_port_vga (a) \ (((a) >= 0x3b0) && ((a) < 0x3e0) && \ ((a) != 0x3b3) && ((a) != 0x3d3))
@@ -88,10 +70,11 @@ VGA_MAP_MEM(unsigned long xaddr, unsigne } while(0)#else /* CONFIG_VGA_HOSE */ -# define VGA_MAP_MEM (x,s) ((unsigned long) ioremap(x, s))# define pci_vga_hose 0# define FIXUP_IOADDR_VGA (a)# define FIXUP_MEMADDR_VGA (a)#endif /* CONFIG_VGA_HOSE */ + +#define VGA_MAP_MEM (x,s) ((unsigned long) ioremap(x, s))#endif