dma: Let dma_buf_rw() take MemTxAttrs argument

Let devices specify transaction attributes when calling dma_buf_rw().

Keep the default MEMTXATTRS_UNSPECIFIED in the 2 callers.

Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20211223115554.3155328-11-philmd@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2021-12-15 22:59:46 +01:00
parent e2d784b67d
commit 959384e74e

View file

@ -295,7 +295,7 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk,
static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg, static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg,
DMADirection dir) DMADirection dir, MemTxAttrs attrs)
{ {
uint8_t *ptr = buf; uint8_t *ptr = buf;
uint64_t resid; uint64_t resid;
@ -307,8 +307,7 @@ static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg,
while (len > 0) { while (len > 0) {
ScatterGatherEntry entry = sg->sg[sg_cur_index++]; ScatterGatherEntry entry = sg->sg[sg_cur_index++];
int32_t xfer = MIN(len, entry.len); int32_t xfer = MIN(len, entry.len);
dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, attrs);
MEMTXATTRS_UNSPECIFIED);
ptr += xfer; ptr += xfer;
len -= xfer; len -= xfer;
resid -= xfer; resid -= xfer;
@ -319,12 +318,14 @@ static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg,
uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg) uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg)
{ {
return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_FROM_DEVICE); return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_FROM_DEVICE,
MEMTXATTRS_UNSPECIFIED);
} }
uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg) uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg)
{ {
return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_TO_DEVICE); return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_TO_DEVICE,
MEMTXATTRS_UNSPECIFIED);
} }
void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie,