[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240312093238-3025dd50-b84c-4165-9d02-0568b440dd58@linutronix.de>
Date: Tue, 12 Mar 2024 09:40:17 +0100
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Chris Leech <cleech@...hat.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Nilesh Javali <njavali@...vell.com>, Christoph Hellwig <hch@....de>,
John Meneghini <jmeneghi@...hat.com>, Lee Duncan <lduncan@...e.com>,
Mike Christie <michael.christie@...cle.com>, Hannes Reinecke <hare@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org,
GR-QLogic-Storage-Upstream@...vell.com
Subject: Re: [PATCH 1/2] uio: introduce UIO_MEM_DMA_COHERENT type
Hi,
On Wed, Jan 31, 2024 at 11:17:31AM -0800, Chris Leech wrote:
> Add a UIO memtype specifically for sharing dma_alloc_coherent
> memory with userspace, backed by dma_mmap_coherent.
>
> This is mainly for the bnx2/bnx2x/bnx2i "cnic" interface, although there
> are a few other uio drivers which map dma_alloc_coherent memory and
> could be converted to use dma_mmap_coherent as well.
>
> Signed-off-by: Nilesh Javali <njavali@...vell.com>
> Signed-off-by: Chris Leech <cleech@...hat.com>
> ---
> drivers/uio/uio.c | 40 ++++++++++++++++++++++++++++++++++++++
> include/linux/uio_driver.h | 3 +++
> 2 files changed, 43 insertions(+)
>
> diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
> index 2d572f6c8ec83..dde3f49855233 100644
> --- a/drivers/uio/uio.c
> +++ b/drivers/uio/uio.c
> @@ -24,6 +24,7 @@
[..]
> +static int uio_mmap_dma_coherent(struct vm_area_struct *vma)
> +{
> + struct uio_device *idev = vma->vm_private_data;
> + struct uio_mem *mem;
> + void *addr;
> + int ret = 0;
> + int mi;
> +
> + mi = uio_find_mem_index(vma);
> + if (mi < 0)
> + return -EINVAL;
> +
> + mem = idev->info->mem + mi;
> +
> + if (mem->dma_addr & ~PAGE_MASK)
> + return -ENODEV;
> + if (vma->vm_end - vma->vm_start > mem->size)
> + return -EINVAL;
> +
> + /*
> + * UIO uses offset to index into the maps for a device.
> + * We need to clear vm_pgoff for dma_mmap_coherent.
> + */
> + vma->vm_pgoff = 0;
> +
> + addr = (void *)mem->addr;
This cast introduces a build error when building with
sizeof(void *) != sizeof(phys_addr_t).
For example on i386 with PHYS_ADDR_T_64BIT.
(Enabled through allmodconfig)
drivers/uio/uio.c: In function 'uio_mmap_dma_coherent':
drivers/uio/uio.c:795:16: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
795 | addr = (void *)mem->addr;
| ^
drivers/uio/uio_pruss.c: In function 'pruss_probe':
drivers/uio/uio_pruss.c:194:34: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
194 | p->mem[2].addr = (phys_addr_t) gdev->ddr_vaddr;
| ^
drivers/uio/uio_dmem_genirq.c: In function 'uio_dmem_genirq_open':
drivers/uio/uio_dmem_genirq.c:63:39: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
63 | uiomem->addr = addr ? (phys_addr_t) addr : DMEM_MAP_ERROR;
| ^
drivers/uio/uio_dmem_genirq.c: In function 'uio_dmem_genirq_release':
drivers/uio/uio_dmem_genirq.c:92:43: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
92 | (void *) uiomem->addr,
As you can see some other files are also affected, which seem to be
triggered by other but related patches.
This is on next-20240312.
> + ret = dma_mmap_coherent(mem->dma_device,
> + vma,
> + addr,
> + mem->dma_addr,
> + vma->vm_end - vma->vm_start);
> + vma->vm_pgoff = mi;
> +
> + return ret;
> +}
> +
[..]
Thomas
Powered by blists - more mailing lists