PCI DAC routines for SN
Here's an implementation of the PCI DAC API for SN, along with some fixes to the existing implementation. If this looks ok, I'd like it to get integrated into the next release, otherwise I'll fix it up. Please take a look.
Thanks,
Jesse
arch/ia64/lib/swiotlb.c +46 -0
@@ -489,6 +489,47 @@return SG_ENT_PHYS_ADDRESS (sg); } +/* +* Return whether the given PCI device DMA address mask can be supported properly. For +* example, if your device can only drive the low 24-bits during PCI bus mastering, then +* you would pass 0x00ffffff as the mask to this function. +*/ +int +swiotlb_pci_dma_supported (struct pci_dev *hwdev,u64 mask) +{ +return 1 ; +} + +int +swiotlb_pci_dac_dma_supported (struct pci_dev *hwdev,u64 mask) +{ +return 1 ; +} + +dma64_addr_t +swiotlb_pci_dac_page_to_dma (struct pci_dev *hwdev,struct page *pg,unsigned long off,int dir) +{ +if (dir =PCI_DMA_NONE ) +BUG (); + +return ((dma64_addr_t )page_to_bus (pg) + (off)); +} + +struct page * +swiotlb_pci_dac_dma_to_page (struct pci_dev *hwdev,dma64_addr_t addr) +{ +return (virt_to_page (bus_to_virt (addr))); +} + +void +swiotlb_pci_dac_dma_sync_single (struct pci_dev *hwdev,dma64_addr_t addr,size_t len,int dir) +{ +if (dir =PCI_DMA_NONE ) +BUG (); + +return ;/* nothing to do for this arch */ +} +EXPORT_SYMBOL (swiotlb_init);EXPORT_SYMBOL (swiotlb_map_single);EXPORT_SYMBOL (swiotlb_unmap_single);
@@ -499,3 +540,8 @@EXPORT_SYMBOL (swiotlb_dma_address);EXPORT_SYMBOL (swiotlb_alloc_consistent);EXPORT_SYMBOL (swiotlb_free_consistent); +EXPORT_SYMBOL (swiotlb_pci_dma_supported); +EXPORT_SYMBOL (swiotlb_pci_dac_dma_supported); +EXPORT_SYMBOL (swiotlb_pci_dac_page_to_dma); +EXPORT_SYMBOL (swiotlb_pci_dac_dma_to_page); +EXPORT_SYMBOL (swiotlb_pci_dac_dma_sync_single);
arch/ia64/sn/io/Makefile +1 -1
@@ -18,7 +18,7 @@ O_TARGET := sgiio.o ifeq ($(CONFIG_MODULES),y) -export-objs = pciio.o hcl.o +export-objs = pciio.o hcl.o pci_dma.o endif obj-y := stubs.o sgi_if.o pciio.o xtalk.o xbow.o xswitch.o klgraph_hack.o \
arch/ia64/sn/io/pci_dma.c +432 -237
911 lines not on this page · raw message
arch/ia64/sn/kernel/sn_ksyms.c +1 -12
@@ -17,15 +17,6 @@#include <asm/machvec.h> #include <asm/sn/intr.h> -/* -* other stuff (more to be added later, cleanup then) -*/ -EXPORT_SYMBOL (sn_pci_map_sg); -EXPORT_SYMBOL (sn_pci_unmap_sg); -EXPORT_SYMBOL (sn_pci_alloc_consistent); -EXPORT_SYMBOL (sn_pci_free_consistent); -EXPORT_SYMBOL (sn_dma_address); -#include <linux/mm.h> #include <linux/devfs_fs_kernel.h> extern devfs_handle_t base_io_scsi_ctlr_vhdl[];
@@ -62,6 +53,4 @@EXPORT_SYMBOL (sn_send_IPI_phys);#include <linux/mmzone.h> -EXPORT_SYMBOL (sn_pci_unmap_single); -EXPORT_SYMBOL (sn_pci_map_single); -EXPORT_SYMBOL (sn_pci_dma_sync_single); +
include/asm-ia64/machvec.h +36 -0
@@ -18,6 +18,7 @@struct pt_regs ;struct scatterlist ;struct irq_desc ; +struct page ;typedef void ia64_mv_setup_t (char **);typedef void ia64_mv_cpu_init_t (void );
@@ -45,6 +46,11 @@typedef void ia64_mv_pci_dma_sync_single (struct pci_dev *,dma_addr_t ,size_t ,int );typedef void ia64_mv_pci_dma_sync_sg (struct pci_dev *,struct scatterlist *,int ,int );typedef unsigned long ia64_mv_pci_dma_address (struct scatterlist *); +typedef int ia64_mv_pci_dma_supported (struct pci_dev *,u64 ); +typedef int ia64_mv_pci_dac_dma_supported (struct pci_dev *,u64 ); +typedef dma64_addr_t ia64_mv_pci_dac_page_to_dma (struct pci_dev *,struct page *,unsigned long ,int ); +typedef struct page *ia64_mv_pci_dac_dma_to_page (struct pci_dev *,dma64_addr_t ); +typedef void ia64_mv_pci_dac_dma_sync_single (struct pci_dev *,dma64_addr_t ,size_t ,int );/* * WARNING: The legacy I/O space is _architected_. Platforms are * expected to follow this architected model (see Section 10.7 in the
@@ -100,6 +106,11 @@# define platform_pci_dma_sync_single ia64_mv.sync_single# define platform_pci_dma_sync_sg ia64_mv.sync_sg# define platform_pci_dma_address ia64_mv.dma_address +# define platform_pci_dma_supported ia64_mv.dma_supported +# define platform_pci_dac_dma_supported ia64_mv.dac_dma_supported +# define platform_pci_dac_page_to_dma ia64_mv.pci_dac_page_to_dma +# define platform_pci_dac_dma_to_page ia64_mv.pci_dac_dma_to_page +# define platform_pci_dac_dma_sync_single ia64_mv.dac_dma_sync_single# define platform_irq_desc ia64_mv.irq_desc# define platform_irq_to_vector ia64_mv.irq_to_vector# define platform_local_vector_to_irq ia64_mv.local_vector_to_irq
@@ -134,6 +145,11 @@ia64_mv_pci_dma_sync_single *sync_single;ia64_mv_pci_dma_sync_sg *sync_sg;ia64_mv_pci_dma_address *dma_address; +ia64_mv_pci_dma_supported *dma_supported; +ia64_mv_pci_dac_dma_supported *dac_dma_supported; +ia64_mv_pci_dac_page_to_dma *pci_dac_page_to_dma; +ia64_mv_pci_dac_dma_to_page *pci_dac_dma_to_page; +ia64_mv_pci_dac_dma_sync_single *pci_dac_dma_sync_single;ia64_mv_irq_desc *irq_desc;ia64_mv_irq_to_vector *irq_to_vector;ia64_mv_local_vector_to_irq *local_vector_to_irq;
@@ -169,6 +185,11 @@ platform_pci_dma_sync_single, \ platform_pci_dma_sync_sg, \ platform_pci_dma_address, \ + platform_pci_dma_supported, \ + platform_pci_dac_dma_supported, \ + platform_pci_dac_page_to_dma, \ + platform_pci_dac_dma_to_page, \ + platform_pci_dac_dma_sync_single, \ platform_irq_desc, \ platform_irq_to_vector, \ platform_local_vector_to_irq, \
@@ -264,6 +285,21 @@#endif #ifndef platform_pci_dma_address# define platform_pci_dma_address swiotlb_dma_address +#endif +#ifndef platform_pci_dma_supported +# define platform_pci_dma_supported swiotlb_pci_dma_supported +#endif +#ifndef platform_pci_dac_dma_supported +# define platform_pci_dac_dma_supported swiotlb_pci_dac_dma_supported +#endif +#ifndef platform_pci_dac_page_to_dma +# define platform_pci_dac_page_to_dma swiotlb_pci_dac_page_to_dma +#endif +#ifndef platform_pci_dac_dma_to_page +# define platform_pci_dac_dma_to_page swiotlb_pci_dac_dma_to_page +#endif +#ifndef platform_pci_dac_dma_sync_single +# define platform_pci_dac_dma_sync_single swiotlb_pci_dac_dma_sync_single#endif #ifndef platform_irq_desc# define platform_irq_desc __ia64_irq_desc
include/asm-ia64/machvec_sn1.h +10 -0
@@ -59,6 +59,11 @@extern ia64_mv_pci_dma_sync_single sn_pci_dma_sync_single;extern ia64_mv_pci_dma_sync_sg sn_pci_dma_sync_sg;extern ia64_mv_pci_dma_address sn_dma_address; +extern ia64_mv_pci_dma_supported sn_pci_dma_supported; +extern ia64_mv_pci_dac_dma_supported sn_pci_dac_dma_supported; +extern ia64_mv_pci_dac_page_to_dma sn_pci_dac_page_to_dma; +extern ia64_mv_pci_dac_dma_to_page sn_pci_dac_dma_to_page; +extern ia64_mv_pci_dac_dma_sync_single sn_pci_dac_dma_sync_single;/* * This stuff has dual use!
@@ -95,5 +100,10 @@#define platform_pci_dma_sync_single sn_pci_dma_sync_single#define platform_pci_dma_sync_sg sn_pci_dma_sync_sg#define platform_pci_dma_address sn_dma_address +#define platform_pci_dma_supported sn_pci_dma_supported +#define platform_pci_dac_dma_supported sn_pci_dac_dma_supported +#define platform_pci_dac_page_to_dma sn_pci_dac_page_to_dma +#define platform_pci_dac_dma_to_page sn_pci_dac_dma_to_page +#define platform_pci_dac_dma_sync_single sn_pci_dac_dma_sync_single#endif /* _ASM_IA64_MACHVEC_SN1_h */
include/asm-ia64/machvec_sn2.h +10 -0
@@ -59,6 +59,11 @@extern ia64_mv_pci_dma_sync_single sn_pci_dma_sync_single;extern ia64_mv_pci_dma_sync_sg sn_pci_dma_sync_sg;extern ia64_mv_pci_dma_address sn_dma_address; +extern ia64_mv_pci_dma_supported sn_pci_dma_supported; +extern ia64_mv_pci_dac_dma_supported sn_pci_dac_dma_supported; +extern ia64_mv_pci_dac_page_to_dma sn_pci_dac_page_to_dma; +extern ia64_mv_pci_dac_dma_to_page sn_pci_dac_dma_to_page; +extern ia64_mv_pci_dac_dma_sync_single sn_pci_dac_dma_sync_single;/* * This stuff has dual use!
@@ -95,5 +100,10 @@#define platform_pci_dma_sync_single sn_pci_dma_sync_single#define platform_pci_dma_sync_sg sn_pci_dma_sync_sg#define platform_pci_dma_address sn_dma_address +#define platform_pci_dma_supported sn_pci_dma_supported +#define platform_pci_dac_dma_supported sn_pci_dac_dma_supported +#define platform_pci_dac_page_to_dma sn_pci_dac_page_to_dma +#define platform_pci_dac_dma_to_page sn_pci_dac_dma_to_page +#define platform_pci_dac_dma_sync_single sn_pci_dac_dma_sync_single#endif /* _ASM_IA64_MACHVEC_SN2_H */
include/asm-ia64/pci.h +10 -18
@@ -50,6 +50,7 @@#define pci_dma_sync_single platform_pci_dma_sync_single#define pci_dma_sync_sg platform_pci_dma_sync_sg#define sg_dma_address platform_pci_dma_address +#define pci_dma_supported platform_pci_dma_supported/* pci_unmap_{single,page} is not a nop, thus... */ #define DECLARE_PCI_UNMAP_ADDR (addr_name) dma_addr_t addr_name;
@@ -59,29 +60,20 @@#define pci_unmap_len (ptr, len_name) ((ptr)->len_name)#define pci_unmap_len_set (ptr, len_name, val) (((ptr)->len_name) = (val)) -/* -* Return whether the given PCI device DMA address mask can be supported properly. For -* example, if your device can only drive the low 24-bits during PCI bus mastering, then -* you would pass 0x00ffffff as the mask to this function. -*/ -static inline int -pci_dma_supported (struct pci_dev *hwdev,u64 mask) -{ -return 1 ; -} -#define pci_map_page (dev,pg,off,size,dir) \ pci_map_single((dev), page_address(pg) + (off), (size), (dir))#define pci_unmap_page (dev,dma_addr,size,dir) \ pci_unmap_single((dev), (dma_addr), (size), (dir)) -/* The ia64 platform always supports 64-bit addressing. */ -#define pci_dac_dma_supported (pci_dev, mask) (1) - -#define pci_dac_page_to_dma (dev,pg,off,dir) ((dma64_addr_t) page_to_bus(pg) + (off)) -#define pci_dac_dma_to_page (dev,dma_addr) (virt_to_page(bus_to_virt(dma_addr))) -#define pci_dac_dma_to_offset (dev,dma_addr) ((dma_addr) & ~PAGE_MASK) -#define pci_dac_dma_sync_single (dev,dma_addr,len,dir) do {/* nothing */ }while (0 ) +/* +* PCI DAC DMA mapping routines +*/ +#define pci_dac_dma_supported platform_pci_dac_dma_supported +#define pci_dac_page_to_dma platform_pci_dac_page_to_dma +#define pci_dac_dma_to_page platform_pci_dac_dma_to_page +#define pci_dac_dma_sync_single platform_pci_dac_dma_sync_single + +#define pci_dac_dma_to_offset (hwdev,dma_addr) ((dma_addr) & ~PAGE_MASK)/* Return the index of the PCI controller for device PDEV. */ #define pci_controller_num (PDEV ) (0)
include/asm-ia64/types.h +1 -0
@@ -63,6 +63,7 @@/* DMA addresses are 64-bits wide, in general. */ typedef u64 dma_addr_t ; +typedef u64 dma64_addr_t ;# endif /* __KERNEL__ */ #endif /* !__ASSEMBLY__ */