Commit 01994780 authored by Chris Leech's avatar Chris Leech Committed by Greg Kroah-Hartman

uio_dmem_genirq: UIO_MEM_DMA_COHERENT conversion

Conversion of this driver to use UIO_MEM_DMA_COHERENT for
dma_alloc_coherent memory instead of UIO_MEM_PHYS.
Signed-off-by: default avatarChris Leech <cleech@redhat.com>
Link: https://lore.kernel.org/r/20240205200257.138376-1-cleech@redhat.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7722151e
...@@ -36,7 +36,6 @@ struct uio_dmem_genirq_platdata { ...@@ -36,7 +36,6 @@ struct uio_dmem_genirq_platdata {
struct platform_device *pdev; struct platform_device *pdev;
unsigned int dmem_region_start; unsigned int dmem_region_start;
unsigned int num_dmem_regions; unsigned int num_dmem_regions;
void *dmem_region_vaddr[MAX_UIO_MAPS];
struct mutex alloc_lock; struct mutex alloc_lock;
unsigned int refcnt; unsigned int refcnt;
}; };
...@@ -50,7 +49,6 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode) ...@@ -50,7 +49,6 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode)
{ {
struct uio_dmem_genirq_platdata *priv = info->priv; struct uio_dmem_genirq_platdata *priv = info->priv;
struct uio_mem *uiomem; struct uio_mem *uiomem;
int dmem_region = priv->dmem_region_start;
uiomem = &priv->uioinfo->mem[priv->dmem_region_start]; uiomem = &priv->uioinfo->mem[priv->dmem_region_start];
...@@ -61,11 +59,8 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode) ...@@ -61,11 +59,8 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode)
break; break;
addr = dma_alloc_coherent(&priv->pdev->dev, uiomem->size, addr = dma_alloc_coherent(&priv->pdev->dev, uiomem->size,
(dma_addr_t *)&uiomem->addr, GFP_KERNEL); &uiomem->dma_addr, GFP_KERNEL);
if (!addr) { uiomem->addr = addr ? (phys_addr_t) addr : DMEM_MAP_ERROR;
uiomem->addr = DMEM_MAP_ERROR;
}
priv->dmem_region_vaddr[dmem_region++] = addr;
++uiomem; ++uiomem;
} }
priv->refcnt++; priv->refcnt++;
...@@ -80,7 +75,6 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode) ...@@ -80,7 +75,6 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode)
{ {
struct uio_dmem_genirq_platdata *priv = info->priv; struct uio_dmem_genirq_platdata *priv = info->priv;
struct uio_mem *uiomem; struct uio_mem *uiomem;
int dmem_region = priv->dmem_region_start;
/* Tell the Runtime PM code that the device has become idle */ /* Tell the Runtime PM code that the device has become idle */
pm_runtime_put_sync(&priv->pdev->dev); pm_runtime_put_sync(&priv->pdev->dev);
...@@ -93,13 +87,12 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode) ...@@ -93,13 +87,12 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode)
while (!priv->refcnt && uiomem < &priv->uioinfo->mem[MAX_UIO_MAPS]) { while (!priv->refcnt && uiomem < &priv->uioinfo->mem[MAX_UIO_MAPS]) {
if (!uiomem->size) if (!uiomem->size)
break; break;
if (priv->dmem_region_vaddr[dmem_region]) { if (uiomem->addr) {
dma_free_coherent(&priv->pdev->dev, uiomem->size, dma_free_coherent(uiomem->dma_device, uiomem->size,
priv->dmem_region_vaddr[dmem_region], (void *) uiomem->addr,
uiomem->addr); uiomem->dma_addr);
} }
uiomem->addr = DMEM_MAP_ERROR; uiomem->addr = DMEM_MAP_ERROR;
++dmem_region;
++uiomem; ++uiomem;
} }
...@@ -264,7 +257,8 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev) ...@@ -264,7 +257,8 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
" dynamic and fixed memory regions.\n"); " dynamic and fixed memory regions.\n");
break; break;
} }
uiomem->memtype = UIO_MEM_PHYS; uiomem->memtype = UIO_MEM_DMA_COHERENT;
uiomem->dma_device = &pdev->dev;
uiomem->addr = DMEM_MAP_ERROR; uiomem->addr = DMEM_MAP_ERROR;
uiomem->size = pdata->dynamic_region_sizes[i]; uiomem->size = pdata->dynamic_region_sizes[i];
++uiomem; ++uiomem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment