Skip to contentSkip to conversation

uio_dmem_genirq: Fix build failure on 32 bit builds with 64 bit physaddr

PATCH In review Guenter Roeck 2 participants 4 messages Mar 23, 2024 Userspace I/O (UIO)

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 uio_dmem_genirq: Fix build failure on 32 bit builds with 64 bit physaddr

Builds on 32-bit systems with 64 bit physical address fail with

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

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

The conversion itself is safe since sizeof(phys_addr_t) it in general equal to or larger than sizeof(void *). Solve the problem by double-casting the conversion.

Fixes 019947805a8d ("uio_dmem_genirq: UIO_MEM_DMA_COHERENT conversion")
Cc Chris Leech <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/uio/uio_dmem_genirq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/uio/uio_dmem_genirq.c +2 -2
index d5f9384df125..ac793e916f80 100644
@@ -60,7 +60,7 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode)
 
 		addr = dma_alloc_coherent(&priv->pdev->dev, uiomem->size,
 					  &uiomem->dma_addr, GFP_KERNEL);
-		uiomem->addr = addr ? (phys_addr_t) addr : DMEM_MAP_ERROR;
+		uiomem->addr = addr ? (phys_addr_t)(unsigned long)addr : DMEM_MAP_ERROR;
 		++uiomem;
 	}
 	priv->refcnt++;
@@ -89,7 +89,7 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode)
 			break;
 		if (uiomem->addr) {
 			dma_free_coherent(uiomem->dma_device, uiomem->size,
-					  (void *) uiomem->addr,
+					  (void *)(unsigned long)uiomem->addr,
 					  uiomem->dma_addr);
 		}
 		uiomem->addr = DMEM_MAP_ERROR;
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/3 uio: Fix build failure on 32 bit builds with 64 bit physaddr

Builds on 32-bit systems with 64 bit physical address fail with

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

The conversion itself is safe since sizeof(phys_addr_t) it in general equal to or larger than sizeof(void *). Solve the problem by double-casting the conversion.

Fixes 576882ef5e7f ("uio: introduce UIO_MEM_DMA_COHERENT type")
Cc Chris Leech <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/uio/uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/uio/uio.c +1 -1
index bb77de6fa067..1935b0f16477 100644
@@ -792,7 +792,7 @@ static int uio_mmap_dma_coherent(struct vm_area_struct *vma)
 	 */
 	vma->vm_pgoff = 0;
 
-	addr = (void *)mem->addr;
+	addr = (void *)(unsigned long)mem->addr;
 	ret = dma_mmap_coherent(mem->dma_device,
 				vma,
 				addr,
Signature · 1 line
2.39.2
#2 lore raw

PATCH 3/3 uio_pruss: Fix build failure on 32 bit builds with 64 bit physaddr

In reply to Guenter Roeck

Builds on 32-bit systems with 64 bit physical address fail with

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

The conversion itself is safe since sizeof(phys_addr_t) it in general equal to or larger than sizeof(void *). Solve the problem by double-casting the conversion.

Fixes 7722151e4651 ("uio_pruss: UIO_MEM_DMA_COHERENT conversion")
Cc Chris Leech <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/uio/uio_pruss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/uio/uio_pruss.c +1 -1
index 72b33f7d4c40..b8fedb6b4f29 100644
@@ -191,7 +191,7 @@ static int pruss_probe(struct platform_device *pdev)
 		p->mem[1].size = sram_pool_sz;
 		p->mem[1].memtype = UIO_MEM_PHYS;
 
-		p->mem[2].addr = (phys_addr_t) gdev->ddr_vaddr;
+		p->mem[2].addr = (phys_addr_t)(unsigned long)gdev->ddr_vaddr;
 		p->mem[2].dma_addr = gdev->ddr_paddr;
 		p->mem[2].size = extram_pool_sz;
 		p->mem[2].memtype = UIO_MEM_DMA_COHERENT;
Signature · 1 line
2.39.2
#3 lore raw
In reply to Guenter Roeck
Quoted 14 lines · Guenter Roeck

Builds on 32-bit systems with 64 bit physical address fail with

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

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

The conversion itself is safe since sizeof(phys_addr_t) it in general equal to or larger than sizeof(void *). Solve the problem by double-casting the conversion.

Quoted 7 lines
Fixes 019947805a8d ("uio_dmem_genirq: UIO_MEM_DMA_COHERENT conversion")
Cc Chris Leech <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/uio/uio_dmem_genirq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Thanks for these, Chris, any objection to me queueing them up?

greg k-h