mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
s390/virtio_ccw: use DMA handle from DMA API
Change and use ccw_device_dma_zalloc() so it returns a virtual address like before, which can be used to access data. However also pass a new dma32_t pointer type handle, which correlates to the returned virtual address. This pointer is used to directly pass/set the DMA handle as returned by the DMA API. Signed-off-by: Halil Pasic <pasic@linux.ibm.com> Reviewed-by: Eric Farman <farman@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
committed by
Heiko Carstens
parent
d5cc416869
commit
e3e9bda38e
@@ -1114,26 +1114,33 @@ static int cio_dma_pool_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *cio_gp_dma_zalloc(struct gen_pool *gp_dma, struct device *dma_dev,
|
||||
size_t size)
|
||||
void *__cio_gp_dma_zalloc(struct gen_pool *gp_dma, struct device *dma_dev,
|
||||
size_t size, dma32_t *dma_handle)
|
||||
{
|
||||
dma_addr_t dma_addr;
|
||||
unsigned long addr;
|
||||
size_t chunk_size;
|
||||
void *addr;
|
||||
|
||||
if (!gp_dma)
|
||||
return NULL;
|
||||
addr = gen_pool_alloc(gp_dma, size);
|
||||
addr = gen_pool_dma_alloc(gp_dma, size, &dma_addr);
|
||||
while (!addr) {
|
||||
chunk_size = round_up(size, PAGE_SIZE);
|
||||
addr = (unsigned long) dma_alloc_coherent(dma_dev,
|
||||
chunk_size, &dma_addr, CIO_DMA_GFP);
|
||||
addr = dma_alloc_coherent(dma_dev, chunk_size, &dma_addr, CIO_DMA_GFP);
|
||||
if (!addr)
|
||||
return NULL;
|
||||
gen_pool_add_virt(gp_dma, addr, dma_addr, chunk_size, -1);
|
||||
addr = gen_pool_alloc(gp_dma, size);
|
||||
gen_pool_add_virt(gp_dma, (unsigned long)addr, dma_addr, chunk_size, -1);
|
||||
addr = gen_pool_dma_alloc(gp_dma, size, dma_handle ? &dma_addr : NULL);
|
||||
}
|
||||
return (void *) addr;
|
||||
if (dma_handle)
|
||||
*dma_handle = (__force dma32_t)dma_addr;
|
||||
return addr;
|
||||
}
|
||||
|
||||
void *cio_gp_dma_zalloc(struct gen_pool *gp_dma, struct device *dma_dev,
|
||||
size_t size)
|
||||
{
|
||||
return __cio_gp_dma_zalloc(gp_dma, dma_dev, size, NULL);
|
||||
}
|
||||
|
||||
void cio_gp_dma_free(struct gen_pool *gp_dma, void *cpu_addr, size_t size)
|
||||
|
||||
Reference in New Issue
Block a user