Skip to content

Commit

Permalink
Use dma_addr_t type for scatter/gather code
Browse files Browse the repository at this point in the history
This patch uses the newly created dma_addr_t type throughout the
scatter/gather handling code in dma-helpers.c whenever we need to
represent a dma bus address.  This makes a better distinction as to
what is a bus address and what is a cpu physical address.  Since we
don't support IOMMUs yet, they can't be very different for now, but
that will change in future, and this preliminary helps clarify what's
going on.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
dgibson authored and Anthony Liguori committed Nov 1, 2011
1 parent d9d1055 commit d323118
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions dma-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint)
qsg->size = 0;
}

void qemu_sglist_add(QEMUSGList *qsg, target_phys_addr_t base,
target_phys_addr_t len)
void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len)
{
if (qsg->nsg == qsg->nalloc) {
qsg->nalloc = 2 * qsg->nalloc + 1;
Expand All @@ -45,7 +44,7 @@ typedef struct {
bool to_dev;
bool in_cancel;
int sg_cur_index;
target_phys_addr_t sg_cur_byte;
dma_addr_t sg_cur_byte;
QEMUIOVector iov;
QEMUBH *bh;
DMAIOFunc *io_func;
Expand Down
9 changes: 4 additions & 5 deletions dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@ typedef enum {
} DMADirection;

struct ScatterGatherEntry {
target_phys_addr_t base;
target_phys_addr_t len;
dma_addr_t base;
dma_addr_t len;
};

struct QEMUSGList {
ScatterGatherEntry *sg;
int nsg;
int nalloc;
target_phys_addr_t size;
dma_addr_t size;
};

void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint);
void qemu_sglist_add(QEMUSGList *qsg, target_phys_addr_t base,
target_phys_addr_t len);
void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len);
void qemu_sglist_destroy(QEMUSGList *qsg);
#endif

Expand Down

0 comments on commit d323118

Please sign in to comment.