dma: Let dma_buf_rw() propagate MemTxResult
dma_memory_rw() returns a MemTxResult type. Do not discard it, return it to the caller. Since dma_buf_rw() was previously returning the QEMUSGList size not consumed, add an extra argument where this size can be stored. Update the 2 callers. Reviewed-by: Klaus Jensen <k.jensen@samsung.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20211223115554.3155328-14-philmd@redhat.com>
This commit is contained in:
parent
1e5a3f8b2a
commit
292e13142d
@ -294,12 +294,14 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint64_t dma_buf_rw(void *buf, int32_t len, QEMUSGList *sg,
|
static MemTxResult dma_buf_rw(void *buf, int32_t len, uint64_t *residp,
|
||||||
DMADirection dir, MemTxAttrs attrs)
|
QEMUSGList *sg, DMADirection dir,
|
||||||
|
MemTxAttrs attrs)
|
||||||
{
|
{
|
||||||
uint8_t *ptr = buf;
|
uint8_t *ptr = buf;
|
||||||
uint64_t resid;
|
uint64_t resid;
|
||||||
int sg_cur_index;
|
int sg_cur_index;
|
||||||
|
MemTxResult res = MEMTX_OK;
|
||||||
|
|
||||||
resid = sg->size;
|
resid = sg->size;
|
||||||
sg_cur_index = 0;
|
sg_cur_index = 0;
|
||||||
@ -307,23 +309,34 @@ 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, attrs);
|
res |= dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, attrs);
|
||||||
ptr += xfer;
|
ptr += xfer;
|
||||||
len -= xfer;
|
len -= xfer;
|
||||||
resid -= xfer;
|
resid -= xfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return resid;
|
if (residp) {
|
||||||
|
*residp = resid;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs)
|
uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs)
|
||||||
{
|
{
|
||||||
return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_FROM_DEVICE, attrs);
|
uint64_t resid;
|
||||||
|
|
||||||
|
dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_FROM_DEVICE, attrs);
|
||||||
|
|
||||||
|
return resid;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs)
|
uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs)
|
||||||
{
|
{
|
||||||
return dma_buf_rw(ptr, len, sg, DMA_DIRECTION_TO_DEVICE, attrs);
|
uint64_t resid;
|
||||||
|
|
||||||
|
dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_TO_DEVICE, attrs);
|
||||||
|
|
||||||
|
return resid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie,
|
void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie,
|
||||||
|
Loading…
Reference in New Issue
Block a user