Make all drivers that use dma_declare_coherent_memory depend on it
Subsystems (6)
PATCH 1/3 Make all drivers that use dma_declare_coherent_memory depend on it
There are two users of dma_declare_coherent_memory in tree. Make them dependent on the architectures who actually implement that instead of falling at runtime. All cases I checked fail fataly (no recovery) so these drivers will never work on these architectures.
I'm also a little puzzled why x86-64 allyesconfig worked with CONFIG_MFD_SM501 without this patch anyways.
arch/cris/Kconfig +5 -0
@@ -47,6 +47,11 @@ config GENERIC_CALIBRATE_DELAY config NO_IOPORT def_bool y +config HAS_DMA_DECLARE_COHERENT + # looks weird, but it really depends on that + depends on ETRAX_CARDBUS + def_bool y + config FORCE_MAX_ZONEORDER int default 6
arch/sh/Kconfig +3 -0
@@ -90,6 +90,9 @@ config ARCH_HAS_ILOG2_U64 config ARCH_NO_VIRT_TO_BUS def_bool y +config HAS_DMA_DECLARE_COHERENT + def_boot y + config ARCH_SUPPORTS_AOUT def_bool y
arch/x86/Kconfig +4 -0
@@ -157,6 +157,10 @@ config GENERIC_PENDING_IRQ depends on GENERIC_HARDIRQS && SMP default y +config HAS_DMA_DECLARE_COHERENT + def_bool y + depends on X86_32 + config X86_SMP bool depends on SMP && ((X86_32 && !X86_VOYAGER) || X86_64)
drivers/mfd/Kconfig +1 -0
@@ -7,6 +7,7 @@ menu "Multifunction device drivers" config MFD_SM501 tristate "Support for Silicon Motion SM501" + depends on HAS_DMA_DECLARE_COHERENT ---help--- This is the core driver for the Silicon Motion SM501 multimedia companion chip. This device is a multifunction device which may
drivers/scsi/Kconfig +1 -1
@@ -1163,7 +1163,7 @@ config SCSI_ZALON config SCSI_NCR_Q720 tristate "NCR Quad 720 MCA SCSI support" - depends on MCA && SCSI + depends on MCA && SCSI && HAS_DMA_DECLARE_COHERENT select SCSI_SPI_ATTRS help This is a driver for the MicroChannel Quad 720 card produced by
PATCH 3/3 Remove dmam_{declare,release}_coherent_memory
No callers in tree, so get rid of them.
include/linux/dma-mapping.h +0 -17
@@ -128,22 +128,5 @@ extern void *dmam_alloc_noncoherent(stru dma_addr_t *dma_handle, gfp_t gfp);extern void dmam_free_noncoherent (struct device *dev,size_t size,void *vaddr,dma_addr_t dma_handle); -#ifdef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY -extern int dmam_declare_coherent_memory (struct device *dev,dma_addr_t bus_addr, -dma_addr_t device_addr,size_t size, -int flags); -extern void dmam_release_declared_memory (struct device *dev); -#else /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */ -static inline int dmam_declare_coherent_memory (struct device *dev, -dma_addr_t bus_addr,dma_addr_t device_addr, -size_t size,gfp_t gfp) -{ -return 0 ; -} - -static inline void dmam_release_declared_memory (struct device *dev) -{ -} -#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */ #endif
drivers/base/dma-mapping.c +0 -55
58 lines not on this page · raw message
PATCH 2/3 Remove dma_declare_coherent_memory etc. from cris
In reply to Andi KleenThe DMA implementation seems to be only there for a single PCI driver and the driver does not use these interfaces. So remove it.
I don't have cris cross compilers so uncompiled/untested.
arch/cris/arch-v32/drivers/pci/dma.c +1 -96
@@ -27,24 +27,10 @@ void *dma_alloc_coherent(struct device * dma_addr_t *dma_handle, gfp_t gfp) { void *ret; -struct dma_coherent_mem *mem = dev ? dev->dma_mem :NULL ;int order =get_order (size);/* ignore region specifiers */ gfp &= ~(__GFP_DMA | __GFP_HIGHMEM); -if (mem) { -int page =bitmap_find_free_region (mem->bitmap, mem->size, - order); -if (page >=0 ) { - *dma_handle = mem->device_base + (page <<PAGE_SHIFT ); - ret = mem->virt_base + (page <<PAGE_SHIFT ); -memset (ret,0 , size); -return ret; - } -if (mem->flags &DMA_MEMORY_EXCLUSIVE ) -return NULL ; - } -if (dev ==NULL || (dev->coherent_dma_mask <0xffffffff )) gfp |=GFP_DMA ;
@@ -63,87 +49,6 @@ void dma_free_coherent(struct device *destruct dma_coherent_mem *mem = dev ? dev->dma_mem :NULL ;int order =get_order (size); -if (mem && vaddr >= mem->virt_base && vaddr < (mem->virt_base + (mem->size <<PAGE_SHIFT ))) { -int page = (vaddr - mem->virt_base) >>PAGE_SHIFT ; - -bitmap_release_region (mem->bitmap, page, order); - }else -free_pages ((unsigned long )vaddr, order); -} - -int dma_declare_coherent_memory (struct device *dev,dma_addr_t bus_addr, -dma_addr_t device_addr,size_t size,int flags) -{ -void __iomem *mem_base; -int pages = size >>PAGE_SHIFT ; -int bitmap_size =BITS_TO_LONGS (pages) *sizeof (long ); - -if ((flags & (DMA_MEMORY_MAP |DMA_MEMORY_IO )) ==0 ) - goto out; -if (!size) - goto out; -if (dev->dma_mem) - goto out; - -/* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */ - - mem_base =ioremap (bus_addr, size); -if (!mem_base) - goto out; - - dev->dma_mem =kzalloc (sizeof (struct dma_coherent_mem ),GFP_KERNEL ); -if (!dev->dma_mem) - goto iounmap_out; - dev->dma_mem->bitmap =kzalloc (bitmap_size,GFP_KERNEL ); -if (!dev->dma_mem->bitmap) - goto free1_out; - - dev->dma_mem->virt_base = mem_base; - dev->dma_mem->device_base = device_addr; - dev->dma_mem->size = pages; - dev->dma_mem->flags = flags; - -if (flags &DMA_MEMORY_MAP ) -return DMA_MEMORY_MAP ; - -return DMA_MEMORY_IO ; - - free1_out: -kfree (dev->dma_mem); - iounmap_out: -iounmap (mem_base); - out: -return 0 ; +free_pages ((unsigned long )vaddr, order); } -EXPORT_SYMBOL (dma_declare_coherent_memory); -void dma_release_declared_memory (struct device *dev) -{ -struct dma_coherent_mem *mem = dev->dma_mem; - -if (!mem) -return ; - dev->dma_mem =NULL ; -iounmap (mem->virt_base); -kfree (mem->bitmap); -kfree (mem); -} -EXPORT_SYMBOL (dma_release_declared_memory); - -void *dma_mark_declared_memory_occupied (struct device *dev, -dma_addr_t device_addr,size_t size) -{ -struct dma_coherent_mem *mem = dev->dma_mem; -int pages = (size + (device_addr & ~PAGE_MASK ) +PAGE_SIZE -1 ) >>PAGE_SHIFT ; -int pos, err; - -if (!mem) -return ERR_PTR (-EINVAL ); - - pos = (device_addr - mem->device_base) >>PAGE_SHIFT ; - err =bitmap_allocate_region (mem->bitmap, pos,get_order (pages)); -if (err !=0 ) -return ERR_PTR (err); -return mem->virt_base + (pos <<PAGE_SHIFT ); -} -EXPORT_SYMBOL (dma_mark_declared_memory_occupied);
arch/cris/Kconfig +0 -5
@@ -47,11 +47,6 @@ config GENERIC_CALIBRATE_DELAY config NO_IOPORT def_bool y -config HAS_DMA_DECLARE_COHERENT - # looks weird, but it really depends on that - depends on ETRAX_CARDBUS - def_bool y - config FORCE_MAX_ZONEORDER int default 6