diff mbox

[2/5] dma-helpers: allow including from target-independent code

Message ID 1315408862-15178-3-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Sept. 7, 2011, 3:20 p.m. UTC
Target-independent code cannot construct sglists, but it can take
them from the outside as a black box.  Allow this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 dma.h         |    8 ++++++--
 qemu-common.h |    1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Kevin Wolf Sept. 9, 2011, 11:39 a.m. UTC | #1
Am 07.09.2011 17:20, schrieb Paolo Bonzini:
> Target-independent code cannot construct sglists, but it can take
> them from the outside as a black box.  Allow this.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

I was hoping to find the use case for this somewhere in the rest of the
series, but there doesn't seem to be an example.

How can you make use of the dma.h functions when you can't build a
QEMUSGList? Or would you have a target-dependent part that builds it and
passes it to a target-independent part?

Kevin
Paolo Bonzini Sept. 9, 2011, 11:53 a.m. UTC | #2
On 09/09/2011 01:39 PM, Kevin Wolf wrote:
> Am 07.09.2011 17:20, schrieb Paolo Bonzini:
>> Target-independent code cannot construct sglists, but it can take
>> them from the outside as a black box.  Allow this.
>>
>> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
>
> I was hoping to find the use case for this somewhere in the rest of the
> series, but there doesn't seem to be an example.

Indeed, unfortunately not yet.

> How can you make use of the dma.h functions when you can't build a
> QEMUSGList? Or would you have a target-dependent part that builds it and
> passes it to a target-independent part?

Exactly, scsi-disk/scsi-bus will pick the QEMUSGList from the HBA and 
treat it opaquely.

Paolo
diff mbox

Patch

diff --git a/dma.h b/dma.h
index a6db5ba..f7e0142 100644
--- a/dma.h
+++ b/dma.h
@@ -15,10 +15,13 @@ 
 #include "hw/hw.h"
 #include "block.h"
 
-typedef struct {
+typedef struct ScatterGatherEntry ScatterGatherEntry;
+
+#if defined(TARGET_PHYS_ADDR_BITS)
+struct ScatterGatherEntry {
     target_phys_addr_t base;
     target_phys_addr_t len;
-} ScatterGatherEntry;
+};
 
 struct QEMUSGList {
     ScatterGatherEntry *sg;
@@ -31,6 +34,7 @@  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_destroy(QEMUSGList *qsg);
+#endif
 
 typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num,
                                  QEMUIOVector *iov, int nb_sectors,
diff --git a/qemu-common.h b/qemu-common.h
index 404c421..ef9a2bb 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -18,6 +18,7 @@  typedef struct DeviceState DeviceState;
 
 struct Monitor;
 typedef struct Monitor Monitor;
+typedef struct QEMUSGList QEMUSGList;
 
 /* we put basic includes here to avoid repeating them in device drivers */
 #include <stdlib.h>