diff options
| author | Michael Brown | 2025-07-10 15:33:34 +0200 |
|---|---|---|
| committer | Michael Brown | 2025-07-10 15:39:07 +0200 |
| commit | bbabde8ff8182fcef738893c29a698783758a489 (patch) | |
| tree | 2cf11a67941a992ccedfce0390169fcf9d7b683e /src/include | |
| parent | [riscv] Add optimised TCP/IP checksumming (diff) | |
| download | ipxe-bbabde8ff8182fcef738893c29a698783758a489.tar.gz ipxe-bbabde8ff8182fcef738893c29a698783758a489.tar.xz ipxe-bbabde8ff8182fcef738893c29a698783758a489.zip | |
[riscv] Invalidate data cache on completed RX DMA buffers
The data cache must be invalidated twice for RX DMA buffers: once
before passing ownership to the DMA device (in case the cache happens
to contain dirty data that will be written back at an undefined future
point), and once after receiving ownership from the DMA device (in
case the CPU happens to have speculatively accessed data in the buffer
while it was owned by the hardware).
Only the used portion of the buffer needs to be invalidated after
completion, since we do not care about data within the unused portion.
Update the DMA API to include the used length as an additional
parameter to dma_unmap(), and add the necessary second cache
invalidation pass to the RISC-V DMA API implementation.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/ipxe/dma.h | 11 | ||||
| -rw-r--r-- | src/include/ipxe/iobuf.h | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h index b675df212..a6e41c1ab 100644 --- a/src/include/ipxe/dma.h +++ b/src/include/ipxe/dma.h @@ -74,8 +74,10 @@ struct dma_operations { * * @v dma DMA device * @v map DMA mapping + * @v len Used length */ - void ( * unmap ) ( struct dma_device *dma, struct dma_mapping *map ); + void ( * unmap ) ( struct dma_device *dma, struct dma_mapping *map, + size_t len ); /** * Allocate and map DMA-coherent buffer * @@ -194,9 +196,11 @@ DMAAPI_INLINE ( flat, dma_map ) ( struct dma_device *dma, * Unmap buffer * * @v map DMA mapping + * @v len Used length */ static inline __always_inline void -DMAAPI_INLINE ( flat, dma_unmap ) ( struct dma_mapping *map ) { +DMAAPI_INLINE ( flat, dma_unmap ) ( struct dma_mapping *map, + size_t len __unused ) { /* Decrement mapping count (for debugging) */ if ( DBG_LOG ) { @@ -365,8 +369,9 @@ int dma_map ( struct dma_device *dma, struct dma_mapping *map, * Unmap buffer * * @v map DMA mapping + * @v len Used length */ -void dma_unmap ( struct dma_mapping *map ); +void dma_unmap ( struct dma_mapping *map, size_t len ); /** * Allocate and map DMA-coherent buffer diff --git a/src/include/ipxe/iobuf.h b/src/include/ipxe/iobuf.h index df8d0b854..46b350458 100644 --- a/src/include/ipxe/iobuf.h +++ b/src/include/ipxe/iobuf.h @@ -276,7 +276,7 @@ static inline __always_inline physaddr_t iob_dma ( struct io_buffer *iobuf ) { * @ret rc Return status code */ static inline __always_inline void iob_unmap ( struct io_buffer *iobuf ) { - dma_unmap ( &iobuf->map ); + dma_unmap ( &iobuf->map, iob_len ( iobuf ) ); } extern struct io_buffer * __malloc alloc_iob_raw ( size_t len, size_t align, |
