alpha: misc fixes
PATCH 1/1 alpha: misc fixes
Patch set from Jay Estabrook:
./include/asm-alpha/dma.h
Add MAX_DMA_ADDR for SABLE and ALCOR
./include/asm-alpha/floppy.h
enable the full CROSS_64KB macro for all platforms
./include/asm-alpha/core_t2.h
fix HAE usage
./arch/alpha/kernel/pci.c
fiddle with quirk_cypress
./arch/alpha/kernel/traps.c
prevent opDEC_check() from multiple calls (EV4 SMP SABLEs)
./arch/alpha/kernel/proto.h
make t2_pci_tbi() real
./arch/alpha/kernel/time.c
shorten timeout delay
./arch/alpha/kernel/sys_alcor.c
use ALCOR_MAX_DMA_ADDR because of the 1GB limit on ISA devices
./arch/alpha/kernel/core_t2.c
add S/G support and allow direct-map to handle 2GB of memory
./arch/alpha/kernel/core_tsunami.c
rework alignment requirements for ISA DMA, esp. for ACER platforms
./arch/alpha/kernel/sys_sable.c
fix MAX_DMA_ADDR for the 1GB limitation
./arch/alpha/kernel/pci_impl.h
add T2_DEFAULT_MEM_BASE to help avoid HAE use
./arch/alpha/kernel/pci_iommu.c
fix ISA_DMA_MASK calculation, and force ISA alignment to 64KB
Ivan.
arch/alpha/kernel/pci_iommu.c +12 -8
@@ -30,6 +30,9 @@#define DEBUG_NODIRECT 0#define DEBUG_FORCEDAC 0 +/* Most Alphas support 32-bit ISA DMA. Exceptions are XL, Ruffian, +Nautilus, Sable, and Alcor (see asm-alpha/dma.h for details). */ +#define ISA_DMA_MASK (MAX_DMA_ADDRESS - IDENT_ADDR - 1)static inline unsigned long mk_iommu_pte (unsigned long paddr)
@@ -129,8 +132,8 @@ iommu_arena_find_pages(struct pci_iommu_return p; } -long -iommu_arena_alloc (struct pci_iommu_arena *arena,long n) +static long +iommu_arena_alloc (struct pci_iommu_arena *arena,long n,unsigned int align) {unsigned long flags;unsigned long *ptes;
@@ -140,7 +143,7 @@ iommu_arena_alloc(struct pci_iommu_arena/* Search for N empty ptes */ ptes = arena->ptes; - mask = arena->align_entry -1 ; + mask =max (align, arena->align_entry) -1 ; p =iommu_arena_find_pages (arena, n, mask);if (p <0 ) {spin_unlock_irqrestore (&arena->lock, flags);
@@ -181,7 +184,7 @@ pci_map_single_1(struct pci_dev *pdev, v int dac_allowed) {struct pci_controller *hose = pdev ? pdev->sysdata : pci_isa_hose; -dma_addr_t max_dma = pdev ? pdev->dma_mask :0x00ffffff ; +dma_addr_t max_dma = pdev ? pdev->dma_mask :ISA_DMA_MASK ;struct pci_iommu_arena *arena;long npages, dma_ofs, i;unsigned long paddr;
@@ -232,7 +235,8 @@ pci_map_single_1(struct pci_dev *pdev, v arena = hose->sg_isa; npages =calc_npages ((paddr & ~PAGE_MASK ) + size); - dma_ofs =iommu_arena_alloc (arena, npages); +/* Force allocation to 64KB boundary for all ISA devices. */ + dma_ofs =iommu_arena_alloc (arena, npages, pdev ?8 :0 );if (dma_ofs <0 ) {printk (KERN_WARNING "pci_map_single failed: " "could not allocate dma page tables\n" );
@@ -499,7 +503,7 @@ sg_fill(struct scatterlist *leader, stru paddr &= ~PAGE_MASK ; npages =calc_npages (paddr + size); - dma_ofs =iommu_arena_alloc (arena, npages); + dma_ofs =iommu_arena_alloc (arena, npages,0 );if (dma_ofs <0 ) {/* If we attempted a direct map above but failed, die. */ if (leader->dma_address ==0 )
@@ -588,7 +592,7 @@ pci_map_sg(struct pci_dev *pdev, struct/* Second, figure out where we're going to map things. */ if (alpha_mv.mv_pci_tbi) { hose = pdev ? pdev->sysdata : pci_isa_hose; - max_dma = pdev ? pdev->dma_mask :0x00ffffff ; + max_dma = pdev ? pdev->dma_mask :ISA_DMA_MASK ; arena = hose->sg_pci;if (!arena || arena->dma_base + arena->size -1 > max_dma) arena = hose->sg_isa;
@@ -651,7 +655,7 @@ pci_unmap_sg(struct pci_dev *pdev, strucreturn ; hose = pdev ? pdev->sysdata : pci_isa_hose; - max_dma = pdev ? pdev->dma_mask :0x00ffffff ; + max_dma = pdev ? pdev->dma_mask :ISA_DMA_MASK ; arena = hose->sg_pci;if (!arena || arena->dma_base + arena->size -1 > max_dma) arena = hose->sg_isa;
arch/alpha/kernel/core_t2.c +89 -37
170 lines not on this page · raw message
arch/alpha/kernel/core_tsunami.c +7 -0
@@ -317,10 +317,17 @@ tsunami_init_one_pchip(tsunami_pchip *pc* Window 0 is scatter-gather 8MB at 8MB (for isa) * Window 1 is scatter-gather (up to) 1GB at 1GB * Window 2 is direct access 2GB at 2GB +* +* NOTE: we need the align_entry settings for Acer devices on ES40, +* specifically floppy and IDE when memory is larger than 2GB. */ hose->sg_isa =iommu_arena_new (hose,0x00800000 ,0x00800000 ,0 ); +/* Initially set for 4 PTEs, but will be overridden to 64K for ISA. */ + hose->sg_isa->align_entry =4 ; + hose->sg_pci =iommu_arena_new (hose,0x40000000 ,size_for_memory (0x40000000 ),0 ); + hose->sg_pci->align_entry =4 ;/* Tsunami caches 4 PTEs at a time */ __direct_map_base =0x80000000 ; __direct_map_size =0x80000000 ;
arch/alpha/kernel/pci.c +13 -6
@@ -97,15 +97,22 @@ quirk_cypress(struct pci_dev *dev)way to turn this off. The bridge also supports several extended BIOS ranges (disabled after power-up), and some consoles do turn them on. So if we use a large direct-map window, or a large SG -window, we must avoid entire 0xfff00000-0xffffffff region. */ +window, we must avoid the entire 0xfff00000-0xffffffff region. */ else if (dev->class >> 8 == PCI_CLASS_BRIDGE_ISA) { -if (__direct_map_base + __direct_map_size >=0xfff00000 ) - __direct_map_size =0xfff00000 - __direct_map_base; -else { +#define DMAPSZ (max_low_pfn << PAGE_SHIFT)/* memory size, not window size */ +if ((__direct_map_base +DMAPSZ -1 ) >=0xfff00000UL ) { + __direct_map_size =0xfff00000UL - __direct_map_base; +printk ("%s: adjusting direct map size to 0x%x\n" , + __FUNCTION__, __direct_map_size); + }else {struct pci_controller *hose = dev->sysdata;struct pci_iommu_arena *pci = hose->sg_pci; -if (pci && pci->dma_base + pci->size >=0xfff00000 ) - pci->size =0xfff00000 - pci->dma_base; +if (pci && + (pci->dma_base + pci->size -1 ) >=0xfff00000UL ) { + pci->size =0xfff00000UL - pci->dma_base; +printk ("%s: adjusting PCI S/G size to 0x%x\n" , + __FUNCTION__, pci->size); + } } } }
arch/alpha/kernel/pci_impl.h +6 -7
@@ -52,15 +52,16 @@ struct pci_iommu_arena;#define APECS_AND_LCA_DEFAULT_MEM_BASE ((16+2)*1024*1024)/* -* Because the MCPCIA core logic supports more bits for physical addresses, -* it should allow an expanded range of SPARSE memory addresses. -* However, we do not use them all, in order to avoid the HAE manipulation -* that would be needed. +* Because MCPCIA and T2 core logic support more bits for +* physical addresses, they should allow an expanded range of SPARSE +* memory addresses. However, we do not use them all, in order to +* avoid the HAE manipulation that would be needed. */ #define MCPCIA_DEFAULT_MEM_BASE ((32+2)*1024*1024) +#define T2_DEFAULT_MEM_BASE ((16+1)*1024*1024)/* -* Because CIA and PYXIS and T2 have more bits for physical addresses, +* Because CIA and PYXIS have more bits for physical addresses, * they support an expanded range of SPARSE memory addresses. */ #define DEFAULT_MEM_BASE ((128+16)*1024*1024)
@@ -157,8 +158,6 @@ extern struct resource *alloc_resource(vextern struct pci_iommu_arena *iommu_arena_new (struct pci_controller *,dma_addr_t ,unsigned long ,unsigned long ); -extern long iommu_arena_alloc (struct pci_iommu_arena *arena,long n); -extern const char *const pci_io_names[];extern const char *const pci_mem_names[];extern const char pci_hae0_name[];
arch/alpha/kernel/proto.h +1 -1
@@ -59,7 +59,7 @@ extern void polaris_machine_check(u64, uextern struct pci_ops t2_pci_ops;extern void t2_init_arch (void );extern void t2_machine_check (u64 ,u64 ,struct pt_regs *); -#define t2_pci_tbi ((void *)0) +extern void t2_pci_tbi (struct pci_controller *,dma_addr_t ,dma_addr_t );/* core_titan.c */ extern struct pci_ops titan_pci_ops;
arch/alpha/kernel/sys_alcor.c +1 -1
@@ -251,7 +251,7 @@ struct alpha_machine_vector alcor_mv __i DO_CIA_IO,DO_CIA_BUS , machine_check: cia_machine_check, - max_dma_address: ALPHA_MAX_DMA_ADDRESS, + max_dma_address: ALPHA_ALCOR_MAX_DMA_ADDRESS, min_io_address: EISA_DEFAULT_IO_BASE, min_mem_address: CIA_DEFAULT_MEM_BASE,
arch/alpha/kernel/sys_sable.c +4 -4
@@ -290,9 +290,9 @@ struct alpha_machine_vector sable_mv __i DO_T2_IO,DO_T2_BUS , machine_check: t2_machine_check, - max_dma_address: ALPHA_MAX_DMA_ADDRESS, + max_dma_address: ALPHA_SABLE_MAX_DMA_ADDRESS, min_io_address: EISA_DEFAULT_IO_BASE, - min_mem_address: DEFAULT_MEM_BASE, + min_mem_address: T2_DEFAULT_MEM_BASE, nr_irqs: 40, device_interrupt: sable_srm_device_interrupt,
@@ -322,9 +322,9 @@ struct alpha_machine_vector sable_gamma_ DO_T2_IO,DO_T2_BUS , machine_check: t2_machine_check, - max_dma_address: ALPHA_MAX_DMA_ADDRESS, + max_dma_address: ALPHA_SABLE_MAX_DMA_ADDRESS, min_io_address: EISA_DEFAULT_IO_BASE, - min_mem_address: DEFAULT_MEM_BASE, + min_mem_address: T2_DEFAULT_MEM_BASE, nr_irqs: 40, device_interrupt: sable_srm_device_interrupt,
arch/alpha/kernel/time.c +4 -4
@@ -185,8 +185,8 @@ validate_cc_value(unsigned long cc)unsigned int min, max; } cpu_hz[] __initdata = { [EV3_CPU] = { 50000000, 200000000 }, /* guess */ - [EV4_CPU] = { 150000000, 300000000 }, - [LCA4_CPU] = { 150000000, 300000000 }, /* guess */ + [EV4_CPU] = { 100000000, 300000000 }, + [LCA4_CPU] = { 100000000, 300000000 }, /* guess */ [EV45_CPU] = { 200000000, 300000000 }, [EV5_CPU] = { 250000000, 433000000 }, [EV56_CPU] = { 333000000, 667000000 },
@@ -257,12 +257,12 @@ calibrate_cc_with_pic(void) cc =rpcc ();do { - count++; + count+=100 ;/* by 1 takes too long to timeout from 0 */ }while ((inb (0x61 ) &0x20 ) ==0 && count >0 ); cc =rpcc () - cc;/* Error: ECTCNEVERSET or ECPUTOOFAST. */ -if (count <=1 ) +if (count <=100 )return 0 ;/* Error: ECPUTOOSLOW. */
arch/alpha/kernel/traps.c +4 -0
@@ -29,6 +29,7 @@*/ static int opDEC_testing =0 ;static int opDEC_fix =0 ; +static int opDEC_checked =0 ;static unsigned long opDEC_test_pc =0 ; static void
@@ -36,6 +37,8 @@ opDEC_check(void) {unsigned long test_pc; +if (opDEC_checked)return ; +lock_kernel (); opDEC_testing =1 ;
@@ -48,6 +51,7 @@ opDEC_check(void) : ); opDEC_testing =0 ; + opDEC_checked =1 ;unlock_kernel (); }
include/asm-alpha/core_t2.h +15 -25
@@ -19,7 +19,7 @@* */ -#define T2_MEM_R1_MASK 0x03ffffff/* Mem sparse region 1 mask is 26 bits */ +#define T2_MEM_R1_MASK 0x07ffffff/* Mem sparse region 1 mask is 26 bits */ /* GAMMA-SABLE is a SABLE with EV5-based CPUs */ #define _GAMMA_BIAS 0x8000000000UL
@@ -402,13 +402,17 @@ __EXTERN_INLINE void t2_outl(u32 b, unsi* */ +#define t2_set_hae { \ + msb = addr >> 27; \ + addr &= T2_MEM_R1_MASK; \ + set_hae(msb); \ +} + __EXTERN_INLINE u8 t2_readb(unsigned long addr) {unsigned long result, msb; - msb = addr &0xE0000000 ; - addr &=T2_MEM_R1_MASK ; -set_hae (msb); + t2_set_hae; result = *(vip) ((addr <<5 ) +T2_SPARSE_MEM +0x00 );return __kernel_extbl (result, addr &3 );
@@ -418,9 +422,7 @@ __EXTERN_INLINE u16 t2_readw(unsigned lo {unsigned long result, msb; - msb = addr &0xE0000000 ; - addr &=T2_MEM_R1_MASK ; -set_hae (msb); + t2_set_hae; result = *(vuip) ((addr <<5 ) +T2_SPARSE_MEM +0x08 );return __kernel_extwl (result, addr &3 );
@@ -431,9 +433,7 @@ __EXTERN_INLINE u32 t2_readl(unsigned lo {unsigned long msb; - msb = addr &0xE0000000 ; - addr &=T2_MEM_R1_MASK ; -set_hae (msb); + t2_set_hae;return *(vuip) ((addr <<5 ) +T2_SPARSE_MEM +0x18 ); }
@@ -442,9 +442,7 @@ __EXTERN_INLINE u64 t2_readq(unsigned lo {unsigned long r0, r1, work, msb; - msb = addr &0xE0000000 ; - addr &=T2_MEM_R1_MASK ; -set_hae (msb); + t2_set_hae; work = (addr <<5 ) +T2_SPARSE_MEM +0x18 ; r0 = *(vuip)(work);
@@ -456,9 +454,7 @@ __EXTERN_INLINE void t2_writeb(u8 b, uns {unsigned long msb, w; - msb = addr &0xE0000000 ; - addr &=T2_MEM_R1_MASK ; -set_hae (msb); + t2_set_hae; w =__kernel_insbl (b, addr &3 ); *(vuip) ((addr <<5 ) +T2_SPARSE_MEM +0x00 ) = w;
@@ -468,9 +464,7 @@ __EXTERN_INLINE void t2_writew(u16 b, un {unsigned long msb, w; - msb = addr &0xE0000000 ; - addr &=T2_MEM_R1_MASK ; -set_hae (msb); + t2_set_hae; w =__kernel_inswl (b, addr &3 ); *(vuip) ((addr <<5 ) +T2_SPARSE_MEM +0x08 ) = w;
@@ -481,9 +475,7 @@ __EXTERN_INLINE void t2_writel(u32 b, un {unsigned long msb; - msb = addr &0xE0000000 ; - addr &=T2_MEM_R1_MASK ; -set_hae (msb); + t2_set_hae; *(vuip) ((addr <<5 ) +T2_SPARSE_MEM +0x18 ) = b; }
@@ -492,9 +484,7 @@ __EXTERN_INLINE void t2_writeq(u64 b, un {unsigned long msb, work; - msb = addr &0xE0000000 ; - addr &=T2_MEM_R1_MASK ; -set_hae (msb); + t2_set_hae; work = (addr <<5 ) +T2_SPARSE_MEM +0x18 ; *(vuip )work = b;
include/asm-alpha/dma.h +31 -16
65 lines not on this page · raw message
include/asm-alpha/floppy.h +10 -13
@@ -97,24 +97,21 @@ static int FDC2 = -1;/* * Most Alphas have no problems with floppy DMA crossing 64k borders, -* except for XL and RUFFIAN. They are also the only one with DMA -* limits, so we use that to test in the generic kernel. +* except for certain ones, like XL and RUFFIAN. +* +* However, the test is simple and fast, and this *is* floppy, after all, +* so we do it for all platforms, just to make sure. +* +* This is advantageous in other circumstances as well, as in moving +* about the PCI DMA windows and forcing the floppy to start doing +* scatter-gather when it never had before, and there *is* a problem +* on that platform... ;-} */ -#define __CROSS_64KB (a,s) \ +#define CROSS_64KB (a,s) \ ({ unsigned long __s64 = (unsigned long)(a); \ unsigned long __e64 = __s64 + (unsigned long)(s) - 1; \ (__s64 ^ __e64) & ~0xfffful; }) - -#ifdef CONFIG_ALPHA_GENERIC -# define CROSS_64KB (a,s) (__CROSS_64KB(a,s) && ~alpha_mv.max_dma_address) -#else -# if defined(CONFIG_ALPHA_XL ) || defined(CONFIG_ALPHA_RUFFIAN ) || defined(CONFIG_ALPHA_NAUTILUS ) -# define CROSS_64KB (a,s) __CROSS_64KB(a,s) -# else -# define CROSS_64KB (a,s) (0) -# endif -#endif #define EXTRA_FLOPPY_PARAMS