[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/14] vmw_pvscsi: use PCI DMA APIs
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 07/14] vmw_pvscsi: use PCI DMA APIs |
Date: |
Thu, 26 Mar 2015 17:02:27 +0100 |
It is wrong to use address_space_memory directly, because there could be an
IOMMU in the middle. Passing the entire PVSCSIRingInfo to RS_GET_FIELD
and RS_SET_FIELD makes it easy to go back to the PVSCSIState.
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi/vmw_pvscsi.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index d3a92fb..c6148d3 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -42,12 +42,12 @@
#define PVSCSI_MAX_CMD_DATA_WORDS \
(sizeof(PVSCSICmdDescSetupRings)/sizeof(uint32_t))
-#define RS_GET_FIELD(rs_pa, field) \
- (ldl_le_phys(&address_space_memory, \
- rs_pa + offsetof(struct PVSCSIRingsState, field)))
-#define RS_SET_FIELD(rs_pa, field, val) \
- (stl_le_phys(&address_space_memory, \
- rs_pa + offsetof(struct PVSCSIRingsState, field), val))
+#define RS_GET_FIELD(m, field) \
+ (ldl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \
+ (m)->rs_pa + offsetof(struct PVSCSIRingsState, field)))
+#define RS_SET_FIELD(m, field, val) \
+ (stl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \
+ (m)->rs_pa + offsetof(struct PVSCSIRingsState, field), val))
#define TYPE_PVSCSI "pvscsi"
#define PVSCSI(obj) OBJECT_CHECK(PVSCSIState, (obj), TYPE_PVSCSI)
@@ -153,13 +153,13 @@ pvscsi_ring_init_data(PVSCSIRingInfo *m,
PVSCSICmdDescSetupRings *ri)
m->cmp_ring_pages_pa[i] = ri->cmpRingPPNs[i] << VMW_PAGE_SHIFT;
}
- RS_SET_FIELD(m->rs_pa, reqProdIdx, 0);
- RS_SET_FIELD(m->rs_pa, reqConsIdx, 0);
- RS_SET_FIELD(m->rs_pa, reqNumEntriesLog2, txr_len_log2);
+ RS_SET_FIELD(m, reqProdIdx, 0);
+ RS_SET_FIELD(m, reqConsIdx, 0);
+ RS_SET_FIELD(m, reqNumEntriesLog2, txr_len_log2);
- RS_SET_FIELD(m->rs_pa, cmpProdIdx, 0);
- RS_SET_FIELD(m->rs_pa, cmpConsIdx, 0);
- RS_SET_FIELD(m->rs_pa, cmpNumEntriesLog2, rxr_len_log2);
+ RS_SET_FIELD(m, cmpProdIdx, 0);
+ RS_SET_FIELD(m, cmpConsIdx, 0);
+ RS_SET_FIELD(m, cmpNumEntriesLog2, rxr_len_log2);
trace_pvscsi_ring_init_data(txr_len_log2, rxr_len_log2);
@@ -185,9 +185,9 @@ pvscsi_ring_init_msg(PVSCSIRingInfo *m,
PVSCSICmdDescSetupMsgRing *ri)
m->msg_ring_pages_pa[i] = ri->ringPPNs[i] << VMW_PAGE_SHIFT;
}
- RS_SET_FIELD(m->rs_pa, msgProdIdx, 0);
- RS_SET_FIELD(m->rs_pa, msgConsIdx, 0);
- RS_SET_FIELD(m->rs_pa, msgNumEntriesLog2, len_log2);
+ RS_SET_FIELD(m, msgProdIdx, 0);
+ RS_SET_FIELD(m, msgConsIdx, 0);
+ RS_SET_FIELD(m, msgNumEntriesLog2, len_log2);
trace_pvscsi_ring_init_msg(len_log2);
@@ -213,7 +213,7 @@ pvscsi_ring_cleanup(PVSCSIRingInfo *mgr)
static hwaddr
pvscsi_ring_pop_req_descr(PVSCSIRingInfo *mgr)
{
- uint32_t ready_ptr = RS_GET_FIELD(mgr->rs_pa, reqProdIdx);
+ uint32_t ready_ptr = RS_GET_FIELD(mgr, reqProdIdx);
if (ready_ptr != mgr->consumed_ptr) {
uint32_t next_ready_ptr =
@@ -233,7 +233,7 @@ pvscsi_ring_pop_req_descr(PVSCSIRingInfo *mgr)
static void
pvscsi_ring_flush_req(PVSCSIRingInfo *mgr)
{
- RS_SET_FIELD(mgr->rs_pa, reqConsIdx, mgr->consumed_ptr);
+ RS_SET_FIELD(mgr, reqConsIdx, mgr->consumed_ptr);
}
static hwaddr
@@ -278,14 +278,14 @@ pvscsi_ring_flush_cmp(PVSCSIRingInfo *mgr)
trace_pvscsi_ring_flush_cmp(mgr->filled_cmp_ptr);
- RS_SET_FIELD(mgr->rs_pa, cmpProdIdx, mgr->filled_cmp_ptr);
+ RS_SET_FIELD(mgr, cmpProdIdx, mgr->filled_cmp_ptr);
}
static bool
pvscsi_ring_msg_has_room(PVSCSIRingInfo *mgr)
{
- uint32_t prodIdx = RS_GET_FIELD(mgr->rs_pa, msgProdIdx);
- uint32_t consIdx = RS_GET_FIELD(mgr->rs_pa, msgConsIdx);
+ uint32_t prodIdx = RS_GET_FIELD(mgr, msgProdIdx);
+ uint32_t consIdx = RS_GET_FIELD(mgr, msgConsIdx);
return (prodIdx - consIdx) < (mgr->msg_len_mask + 1);
}
@@ -298,7 +298,7 @@ pvscsi_ring_flush_msg(PVSCSIRingInfo *mgr)
trace_pvscsi_ring_flush_msg(mgr->filled_msg_ptr);
- RS_SET_FIELD(mgr->rs_pa, msgProdIdx, mgr->filled_msg_ptr);
+ RS_SET_FIELD(mgr, msgProdIdx, mgr->filled_msg_ptr);
}
static void
--
2.3.3
- [Qemu-devel] [PULL 00/14] Misc bugfixes for 2.3.0-rc2, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 01/14] rcu tests: fix compilation on 32-bit ppc, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 04/14] i6300esb: Fix signed integer overflow, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 05/14] cpus: Don't kick un-realized cpus., Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 02/14] fw_cfg: factor out initialization of FW_CFG_ID (rev. number), Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 07/14] vmw_pvscsi: use PCI DMA APIs,
Paolo Bonzini <=
- [Qemu-devel] [PULL 08/14] nbd: Fix up comment after commit e140177, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 06/14] megasas: use PCI DMA APIs, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 03/14] i6300esb: Correct endiannness, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 13/14] misc: fix typos in copyright declaration, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 12/14] exec: avoid possible overwriting of mmaped area in qemu_ram_remap, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 09/14] m68k: memory: Replace memory_region_init_ram with memory_region_allocate_system_memory, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 10/14] mips: memory: Replace memory_region_init_ram with memory_region_allocate_system_memory, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 11/14] sparc: memory: Replace memory_region_init_ram with memory_region_allocate_system_memory, Paolo Bonzini, 2015/03/26
- [Qemu-devel] [PULL 14/14] virtio-scsi-dataplane: fix memory leak for VirtIOSCSIVring, Paolo Bonzini, 2015/03/26
- Re: [Qemu-devel] [PULL 00/14] Misc bugfixes for 2.3.0-rc2, Peter Maydell, 2015/03/26