[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 05/13] dma: Let dma_memory_rw() propagate MemTxResult
From: |
Li Qiang |
Subject: |
Re: [PATCH 05/13] dma: Let dma_memory_rw() propagate MemTxResult |
Date: |
Mon, 7 Sep 2020 09:06:14 +0800 |
Philippe Mathieu-Daudé <philmd@redhat.com> 于2020年9月4日周五 下午11:46写道:
>
> address_space_rw() returns a MemTxResult type.
> Do not discard it, return it to the caller.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
> ---
> include/sysemu/dma.h | 30 ++++++++++++++++++++++--------
> 1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index ad8a3f82f47..661d7d0ca88 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -80,12 +80,13 @@ static inline bool dma_memory_valid(AddressSpace *as,
> MEMTXATTRS_UNSPECIFIED);
> }
>
> -static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr,
> - void *buf, dma_addr_t len,
> - DMADirection dir)
> +static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as,
> + dma_addr_t addr,
> + void *buf, dma_addr_t len,
> + DMADirection dir)
> {
> - return (bool)address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED,
> - buf, len, dir ==
> DMA_DIRECTION_FROM_DEVICE);
> + return address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED,
> + buf, len, dir == DMA_DIRECTION_FROM_DEVICE);
> }
>
> static inline int dma_memory_read_relaxed(AddressSpace *as, dma_addr_t addr,
> @@ -101,9 +102,22 @@ static inline int dma_memory_write_relaxed(AddressSpace
> *as, dma_addr_t addr,
> DMA_DIRECTION_FROM_DEVICE);
> }
>
> -static inline int dma_memory_rw(AddressSpace *as, dma_addr_t addr,
> - void *buf, dma_addr_t len,
> - DMADirection dir)
> +/**
> + * dma_memory_rw: Read from or write to an address space from DMA controller.
> + *
> + * Return a MemTxResult indicating whether the operation succeeded
> + * or failed (eg unassigned memory, device rejected the transaction,
> + * IOMMU fault).
> + *
> + * @as: #AddressSpace to be accessed
> + * @addr: address within that address space
> + * @buf: buffer with the data transferred
> + * @len: the number of bytes to read or write
> + * @dir: indicates the transfer direction
> + */
> +static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr,
> + void *buf, dma_addr_t len,
> + DMADirection dir)
> {
> dma_barrier(as, dir);
>
> --
> 2.26.2
>
>
- [PATCH 02/13] docs/devel/loads-stores: Add regexp for DMA functions, (continued)
- [PATCH 02/13] docs/devel/loads-stores: Add regexp for DMA functions, Philippe Mathieu-Daudé, 2020/09/04
- [PATCH 03/13] dma: Document address_space_map/address_space_unmap() prototypes, Philippe Mathieu-Daudé, 2020/09/04
- [PATCH 04/13] dma: Let dma_memory_set() propagate MemTxResult, Philippe Mathieu-Daudé, 2020/09/04
- [PATCH 05/13] dma: Let dma_memory_rw() propagate MemTxResult, Philippe Mathieu-Daudé, 2020/09/04
- [PATCH 06/13] dma: Let dma_memory_read() propagate MemTxResult, Philippe Mathieu-Daudé, 2020/09/04
- [PATCH 07/13] dma: Let dma_memory_write() propagate MemTxResult, Philippe Mathieu-Daudé, 2020/09/04
- [PATCH 08/13] dma: Let dma_memory_valid() take MemTxAttrs argument, Philippe Mathieu-Daudé, 2020/09/04
- [PATCH 09/13] dma: Let dma_memory_set() take MemTxAttrs argument, Philippe Mathieu-Daudé, 2020/09/04