Skip to content

Commit c2781e4

Browse files
arndbandersson
authored andcommitted
remoteproc: mtk_scp: use dma_addr_t for DMA API
dma_addr_t and phys_addr_t are distinct types and must not be mixed, as both the values and the size of the type may be different depending on what the remote device uses. In this driver the compiler warns when the two types are different: drivers/remoteproc/mtk_scp.c: In function 'scp_map_memory_region': drivers/remoteproc/mtk_scp.c:454:9: error: passing argument 3 of 'dma_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types] 454 | &scp->phys_addr, GFP_KERNEL); | ^~~~~~~~~~~~~~~ | | | phys_addr_t * {aka unsigned int *} In file included from drivers/remoteproc/mtk_scp.c:7: include/linux/dma-mapping.h:642:15: note: expected 'dma_addr_t *' {aka 'long long unsigned int *'} but argument is of type 'phys_addr_t *' {aka 'unsigned int *'} 642 | dma_addr_t *dma_handle, gfp_t gfp) Change the phys_addr member to be typed and named according to how it is allocated. Fixes: 63c13d6 ("remoteproc/mediatek: add SCP support for mt8183") Signed-off-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 5839681 commit c2781e4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/remoteproc/mtk_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct mtk_scp {
6868
wait_queue_head_t ack_wq;
6969

7070
void __iomem *cpu_addr;
71-
phys_addr_t phys_addr;
71+
dma_addr_t dma_addr;
7272
size_t dram_size;
7373

7474
struct rproc_subdev *rpmsg_subdev;

drivers/remoteproc/mtk_scp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len)
330330
if (offset >= 0 && (offset + len) < scp->sram_size)
331331
return (void __force *)scp->sram_base + offset;
332332
} else {
333-
offset = da - scp->phys_addr;
333+
offset = da - scp->dma_addr;
334334
if (offset >= 0 && (offset + len) < scp->dram_size)
335335
return (void __force *)scp->cpu_addr + offset;
336336
}
@@ -451,7 +451,7 @@ static int scp_map_memory_region(struct mtk_scp *scp)
451451
/* Reserved SCP code size */
452452
scp->dram_size = MAX_CODE_SIZE;
453453
scp->cpu_addr = dma_alloc_coherent(scp->dev, scp->dram_size,
454-
&scp->phys_addr, GFP_KERNEL);
454+
&scp->dma_addr, GFP_KERNEL);
455455
if (!scp->cpu_addr)
456456
return -ENOMEM;
457457

@@ -461,7 +461,7 @@ static int scp_map_memory_region(struct mtk_scp *scp)
461461
static void scp_unmap_memory_region(struct mtk_scp *scp)
462462
{
463463
dma_free_coherent(scp->dev, scp->dram_size, scp->cpu_addr,
464-
scp->phys_addr);
464+
scp->dma_addr);
465465
of_reserved_mem_device_release(scp->dev);
466466
}
467467

0 commit comments

Comments
 (0)