Skip to content

Commit 7d6db80

Browse files
author
Christoph Hellwig
committed
sparc32: use DMA_DIRECT_REMAP
Use the generic dma remapping allocator instead of open coding it. This also avoids setting up page tables from irq context which is generally dangerous and uses the atomic pool instead. Note that this changes the kernel virtual address at which the dma coherent memory is mapped from the DVMA_VADDR region to the general vmalloc pool. I could not find any indication that this matters for the hardware. Signed-off-by: Christoph Hellwig <[email protected]> Tested-by: Andreas Larsson <[email protected]> Acked-by: David S. Miller <[email protected]>
1 parent 837e80b commit 7d6db80

File tree

2 files changed

+2
-55
lines changed

2 files changed

+2
-55
lines changed

arch/sparc/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ config SPARC32
5353
def_bool !64BIT
5454
select ARCH_32BIT_OFF_T
5555
select ARCH_HAS_SYNC_DMA_FOR_CPU
56-
select GENERIC_ATOMIC64
5756
select CLZ_TAB
57+
select DMA_DIRECT_REMAP
58+
select GENERIC_ATOMIC64
5859
select HAVE_UID16
5960
select OLD_SIGACTION
6061
select ZONE_DMA

arch/sparc/kernel/ioport.c

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -300,60 +300,6 @@ arch_initcall(sparc_register_ioport);
300300

301301
#endif /* CONFIG_SBUS */
302302

303-
304-
/* Allocate and map kernel buffer using consistent mode DMA for a device.
305-
* hwdev should be valid struct pci_dev pointer for PCI devices.
306-
*/
307-
void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
308-
gfp_t gfp, unsigned long attrs)
309-
{
310-
unsigned long addr;
311-
void *va;
312-
313-
if (!size || size > 256 * 1024) /* __get_free_pages() limit */
314-
return NULL;
315-
316-
size = PAGE_ALIGN(size);
317-
va = (void *) __get_free_pages(gfp | __GFP_ZERO, get_order(size));
318-
if (!va) {
319-
printk("%s: no %zd pages\n", __func__, size >> PAGE_SHIFT);
320-
return NULL;
321-
}
322-
323-
addr = sparc_dma_alloc_resource(dev, size);
324-
if (!addr)
325-
goto err_nomem;
326-
327-
srmmu_mapiorange(0, virt_to_phys(va), addr, size);
328-
329-
*dma_handle = virt_to_phys(va);
330-
return (void *)addr;
331-
332-
err_nomem:
333-
free_pages((unsigned long)va, get_order(size));
334-
return NULL;
335-
}
336-
337-
/* Free and unmap a consistent DMA buffer.
338-
* cpu_addr is what was returned arch_dma_alloc, size must be the same as what
339-
* was passed into arch_dma_alloc, and likewise dma_addr must be the same as
340-
* what *dma_ndler was set to.
341-
*
342-
* References to the memory and mappings associated with cpu_addr/dma_addr
343-
* past this call are illegal.
344-
*/
345-
void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
346-
dma_addr_t dma_addr, unsigned long attrs)
347-
{
348-
size = PAGE_ALIGN(size);
349-
350-
if (!sparc_dma_free_resource(cpu_addr, size))
351-
return;
352-
353-
srmmu_unmapiorange((unsigned long)cpu_addr, size);
354-
free_pages((unsigned long)phys_to_virt(dma_addr), get_order(size));
355-
}
356-
357303
/*
358304
* IIep is write-through, not flushing on cpu to device transfer.
359305
*

0 commit comments

Comments
 (0)