[PATCH 2/9] dma-mapping: fix the prototype of dma_unmap_single()
Rick Chen
rickchen36 at gmail.com
Thu Feb 6 02:13:56 CET 2020
> From: Masahiro Yamada [mailto:yamada.masahiro at socionext.com]
> Sent: Tuesday, February 04, 2020 7:09 PM
> To: u-boot at lists.denx.de
> Cc: Masahiro Yamada; Bin Meng; Joe Hershberger; Lukasz Majewski; Marek Vasut; Peng Fan; Rick Jian-Zhi Chen(é³å»ºå¿); Simon Glass
> Subject: [PATCH 2/9] dma-mapping: fix the prototype of dma_unmap_single()
>
> dma_unmap_single() takes the dma address, not virtual address.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
Acked-by: Rick Chen <rick at andestech.com>
> ---
>
> arch/arm/include/asm/dma-mapping.h | 4 +---
> arch/nds32/include/asm/dma-mapping.h | 4 +--- arch/riscv/include/asm/dma-mapping.h | 4 +---
> arch/x86/include/asm/dma-mapping.h | 4 +---
> drivers/mmc/tmio-common.c | 2 +-
> drivers/mtd/nand/raw/denali.c | 2 +-
> drivers/net/macb.c | 2 +-
> drivers/usb/dwc3/core.c | 6 +++---
> drivers/usb/gadget/udc/udc-core.c | 2 +-
> 9 files changed, 11 insertions(+), 19 deletions(-)
>
> diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
> index d0895a209666..efdbed7280dd 100644
> --- a/arch/arm/include/asm/dma-mapping.h
> +++ b/arch/arm/include/asm/dma-mapping.h
> @@ -42,11 +42,9 @@ static inline dma_addr_t dma_map_single(void *vaddr, size_t len,
> return addr;
> }
>
> -static inline void dma_unmap_single(volatile void *vaddr, size_t len,
> +static inline void dma_unmap_single(dma_addr_t addr, size_t len,
> enum dma_data_direction dir)
> {
> - unsigned long addr = (unsigned long)vaddr;
> -
> len = ALIGN(len, ARCH_DMA_MINALIGN);
>
> if (dir != DMA_TO_DEVICE)
> diff --git a/arch/nds32/include/asm/dma-mapping.h b/arch/nds32/include/asm/dma-mapping.h
> index 9387dec34768..784f489db54e 100644
> --- a/arch/nds32/include/asm/dma-mapping.h
> +++ b/arch/nds32/include/asm/dma-mapping.h
> @@ -34,11 +34,9 @@ static inline dma_addr_t dma_map_single(void *vaddr, size_t len,
> return addr;
> }
>
> -static inline void dma_unmap_single(volatile void *vaddr, size_t len,
> +static inline void dma_unmap_single(dma_addr_t addr, size_t len,
> enum dma_data_direction dir)
> {
> - unsigned long addr = (unsigned long)vaddr;
> -
> len = ALIGN(len, ARCH_DMA_MINALIGN);
>
> if (dir != DMA_TO_DEVICE)
> diff --git a/arch/riscv/include/asm/dma-mapping.h b/arch/riscv/include/asm/dma-mapping.h
> index eac56f8fbdfa..1ac4a4fed58d 100644
> --- a/arch/riscv/include/asm/dma-mapping.h
> +++ b/arch/riscv/include/asm/dma-mapping.h
> @@ -44,11 +44,9 @@ static inline dma_addr_t dma_map_single(void *vaddr, size_t len,
> return addr;
> }
>
> -static inline void dma_unmap_single(volatile void *vaddr, size_t len,
> +static inline void dma_unmap_single(dma_addr_t addr, size_t len,
> enum dma_data_direction dir)
> {
> - unsigned long addr = (unsigned long)vaddr;
> -
> len = ALIGN(len, ARCH_DMA_MINALIGN);
>
> if (dir != DMA_TO_DEVICE)
> diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
> index 7e205e3313ac..37704da5dd4f 100644
> --- a/arch/x86/include/asm/dma-mapping.h
> +++ b/arch/x86/include/asm/dma-mapping.h
> @@ -42,11 +42,9 @@ static inline dma_addr_t dma_map_single(void *vaddr, size_t len,
> return addr;
> }
>
> -static inline void dma_unmap_single(volatile void *vaddr, size_t len,
> +static inline void dma_unmap_single(dma_addr_t addr, size_t len,
> enum dma_data_direction dir)
> {
> - unsigned long addr = (unsigned long)vaddr;
> -
> len = ALIGN(len, ARCH_DMA_MINALIGN);
>
> if (dir != DMA_TO_DEVICE)
> diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c index 5a8506dcb6bd..e5d9d64b9684 100644
> --- a/drivers/mmc/tmio-common.c
> +++ b/drivers/mmc/tmio-common.c
> @@ -352,7 +352,7 @@ static int tmio_sd_dma_xfer(struct udevice *dev, struct mmc_data *data)
> if (poll_flag == TMIO_SD_DMA_INFO1_END_RD)
> udelay(1);
>
> - dma_unmap_single(buf, len, dir);
> + dma_unmap_single(dma_addr, len, dir);
>
> return ret;
> }
> diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index 8537c609fb62..8dfffad63b60 100644
> --- a/drivers/mtd/nand/raw/denali.c
> +++ b/drivers/mtd/nand/raw/denali.c
> @@ -577,7 +577,7 @@ static int denali_dma_xfer(struct denali_nand_info *denali, void *buf,
>
> iowrite32(0, denali->reg + DMA_ENABLE);
>
> - dma_unmap_single(buf, size, dir);
> + dma_unmap_single(dma_addr, size, dir);
>
> if (irq_status & INTR__ERASED_PAGE)
> memset(buf, 0xff, size);
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 0d4929bec131..7a2b1abeeb03 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -342,7 +342,7 @@ static int _macb_send(struct macb_device *macb, const char *name, void *packet,
> udelay(1);
> }
>
> - dma_unmap_single(packet, length, DMA_TO_DEVICE);
> + dma_unmap_single(paddr, length, DMA_TO_DEVICE);
>
> if (i <= MACB_TX_TIMEOUT) {
> if (ctrl & MACB_BIT(TX_UNDERRUN))
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 77c555e76924..c5907534692e 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -285,8 +285,8 @@ static int dwc3_setup_scratch_buffers(struct dwc3 *dwc)
> return 0;
>
> err1:
> - dma_unmap_single((void *)(uintptr_t)dwc->scratch_addr, dwc->nr_scratch *
> - DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
> + dma_unmap_single(scratch_addr, dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE,
> + DMA_BIDIRECTIONAL);
>
> err0:
> return ret;
> @@ -300,7 +300,7 @@ static void dwc3_free_scratch_buffers(struct dwc3 *dwc)
> if (!dwc->nr_scratch)
> return;
>
> - dma_unmap_single((void *)(uintptr_t)dwc->scratch_addr, dwc->nr_scratch *
> + dma_unmap_single(dwc->scratch_addr, dwc->nr_scratch *
> DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL);
> kfree(dwc->scratchbuf);
> }
> diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
> index 8d1d90e3e39f..8437d9079bef 100644
> --- a/drivers/usb/gadget/udc/udc-core.c
> +++ b/drivers/usb/gadget/udc/udc-core.c
> @@ -65,7 +65,7 @@ void usb_gadget_unmap_request(struct usb_gadget *gadget,
> if (req->length == 0)
> return;
>
> - dma_unmap_single((void *)(uintptr_t)req->dma, req->length,
> + dma_unmap_single(req->dma, req->length,
> is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); } EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
> --
> 2.17.1
More information about the U-Boot
mailing list