From: David Gibson <david@gibson.dropbear.id.au>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, kraxel@redhat.com, mst@redhat.com,
joerg.roedel@amd.com, agraf@suse.de, avi@redhat.com,
eduard.munteanu@linux360.ro, rth@twiddle.net
Subject: [Qemu-devel] [PATCH 7/9] lsi53c895a: Use PCI DMA stub functions
Date: Mon, 5 Sep 2011 14:35:02 +1000 [thread overview]
Message-ID: <1315197304-22469-8-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1315197304-22469-1-git-send-email-david@gibson.dropbear.id.au>
From: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
This updates the lsi53c895a device emulation to use the explicit PCI DMA
functions, instead of directly calling physical memory access functions.
Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
hw/lsi53c895a.c | 30 ++++++++++++++----------------
1 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index 1643a63..f1f6800 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -16,6 +16,7 @@
#include "pci.h"
#include "scsi.h"
#include "block_int.h"
+#include "dma.h"
//#define DEBUG_LSI
//#define DEBUG_LSI_REG
@@ -391,10 +392,7 @@ static inline uint32_t read_dword(LSIState *s, uint32_t addr)
{
uint32_t buf;
- /* XXX: an optimization here used to fast-path the read from scripts
- * memory. But that bypasses any iommu.
- */
- cpu_physical_memory_read(addr, (uint8_t *)&buf, 4);
+ pci_dma_read(&s->dev, addr, (uint8_t *)&buf, 4);
return cpu_to_le32(buf);
}
@@ -533,7 +531,7 @@ static void lsi_bad_selection(LSIState *s, uint32_t id)
static void lsi_do_dma(LSIState *s, int out)
{
uint32_t count, id;
- target_phys_addr_t addr;
+ dma_addr_t addr;
SCSIDevice *dev;
assert(s->current);
@@ -572,9 +570,9 @@ static void lsi_do_dma(LSIState *s, int out)
}
/* ??? Set SFBR to first data byte. */
if (out) {
- cpu_physical_memory_read(addr, s->current->dma_buf, count);
+ pci_dma_read(&s->dev, addr, s->current->dma_buf, count);
} else {
- cpu_physical_memory_write(addr, s->current->dma_buf, count);
+ pci_dma_write(&s->dev, addr, s->current->dma_buf, count);
}
s->current->dma_len -= count;
if (s->current->dma_len == 0) {
@@ -767,7 +765,7 @@ static void lsi_do_command(LSIState *s)
DPRINTF("Send command len=%d\n", s->dbc);
if (s->dbc > 16)
s->dbc = 16;
- cpu_physical_memory_read(s->dnad, buf, s->dbc);
+ pci_dma_read(&s->dev, s->dnad, buf, s->dbc);
s->sfbr = buf[0];
s->command_complete = 0;
@@ -818,7 +816,7 @@ static void lsi_do_status(LSIState *s)
s->dbc = 1;
status = s->status;
s->sfbr = status;
- cpu_physical_memory_write(s->dnad, &status, 1);
+ pci_dma_write(&s->dev, s->dnad, &status, 1);
lsi_set_phase(s, PHASE_MI);
s->msg_action = 1;
lsi_add_msg_byte(s, 0); /* COMMAND COMPLETE */
@@ -832,7 +830,7 @@ static void lsi_do_msgin(LSIState *s)
len = s->msg_len;
if (len > s->dbc)
len = s->dbc;
- cpu_physical_memory_write(s->dnad, s->msg, len);
+ pci_dma_write(&s->dev, s->dnad, s->msg, len);
/* Linux drivers rely on the last byte being in the SIDL. */
s->sidl = s->msg[len - 1];
s->msg_len -= len;
@@ -864,7 +862,7 @@ static void lsi_do_msgin(LSIState *s)
static uint8_t lsi_get_msgbyte(LSIState *s)
{
uint8_t data;
- cpu_physical_memory_read(s->dnad, &data, 1);
+ pci_dma_read(&s->dev, s->dnad, &data, 1);
s->dnad++;
s->dbc--;
return data;
@@ -1019,8 +1017,8 @@ static void lsi_memcpy(LSIState *s, uint32_t dest, uint32_t src, int count)
DPRINTF("memcpy dest 0x%08x src 0x%08x count %d\n", dest, src, count);
while (count) {
n = (count > LSI_BUF_SIZE) ? LSI_BUF_SIZE : count;
- cpu_physical_memory_read(src, buf, n);
- cpu_physical_memory_write(dest, buf, n);
+ pci_dma_read(&s->dev, src, buf, n);
+ pci_dma_write(&s->dev, dest, buf, n);
src += n;
dest += n;
count -= n;
@@ -1088,7 +1086,7 @@ again:
/* 32-bit Table indirect */
offset = sxt24(addr);
- cpu_physical_memory_read(s->dsa + offset, (uint8_t *)buf, 8);
+ pci_dma_read(&s->dev, s->dsa + offset, (uint8_t *)buf, 8);
/* byte count is stored in bits 0:23 only */
s->dbc = cpu_to_le32(buf[0]) & 0xffffff;
s->rbc = s->dbc;
@@ -1447,7 +1445,7 @@ again:
n = (insn & 7);
reg = (insn >> 16) & 0xff;
if (insn & (1 << 24)) {
- cpu_physical_memory_read(addr, data, n);
+ pci_dma_read(&s->dev, addr, data, n);
DPRINTF("Load reg 0x%x size %d addr 0x%08x = %08x\n", reg, n,
addr, *(int *)data);
for (i = 0; i < n; i++) {
@@ -1458,7 +1456,7 @@ again:
for (i = 0; i < n; i++) {
data[i] = lsi_reg_readb(s, reg + i);
}
- cpu_physical_memory_write(addr, data, n);
+ pci_dma_write(&s->dev, addr, data, n);
}
}
}
--
1.7.5.4
next prev parent reply other threads:[~2011-09-05 4:35 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-05 4:34 [Qemu-devel] [0/9] Preliminary work for IOMMU emulation support; the easy bits (v2) David Gibson
2011-09-05 4:34 ` [Qemu-devel] [PATCH 1/9] Add stub functions for PCI device models to do PCI DMA David Gibson
2011-10-02 10:25 ` Michael S. Tsirkin
2011-10-02 10:29 ` Avi Kivity
2011-10-02 10:52 ` Michael S. Tsirkin
2011-10-02 10:58 ` Avi Kivity
2011-10-02 11:17 ` Michael S. Tsirkin
2011-10-02 11:28 ` Alexander Graf
2011-10-02 11:43 ` Michael S. Tsirkin
2011-10-02 12:01 ` Avi Kivity
2011-10-02 12:14 ` Michael S. Tsirkin
2011-10-02 12:26 ` Avi Kivity
2011-10-03 13:17 ` Anthony Liguori
2011-10-12 3:09 ` David Gibson
2011-10-12 9:12 ` Michael S. Tsirkin
2011-10-14 2:14 ` David Gibson
2011-10-16 12:50 ` Michael S. Tsirkin
2011-10-16 13:15 ` Avi Kivity
2011-10-18 1:46 ` David Gibson
2011-10-19 0:31 ` Rusty Russell
2011-10-19 1:22 ` Michael S. Tsirkin
2011-10-19 9:10 ` Avi Kivity
2011-10-20 2:58 ` David Gibson
2011-10-12 3:07 ` David Gibson
2011-10-12 7:22 ` Michael S. Tsirkin
2011-10-12 15:43 ` David Gibson
2011-10-12 15:45 ` David Gibson
2011-10-12 3:11 ` David Gibson
2011-10-12 8:44 ` Michael S. Tsirkin
2011-10-12 9:08 ` Gerd Hoffmann
2011-10-03 13:10 ` Anthony Liguori
2011-09-05 4:34 ` [Qemu-devel] [PATCH 2/9] rtl8139: Use PCI DMA stub functions David Gibson
2011-09-05 4:34 ` [Qemu-devel] [PATCH 3/9] eepro100: " David Gibson
2011-10-02 11:45 ` Michael S. Tsirkin
2011-10-14 2:15 ` David Gibson
2011-09-05 4:34 ` [Qemu-devel] [PATCH 4/9] ac97: " David Gibson
2011-09-05 4:35 ` [Qemu-devel] [PATCH 5/9] es1370: " David Gibson
2011-09-05 4:35 ` [Qemu-devel] [PATCH 6/9] e1000: " David Gibson
2011-09-05 4:35 ` David Gibson [this message]
2011-09-05 4:35 ` [Qemu-devel] [PATCH 8/9] pcnet-pci: " David Gibson
2011-09-05 4:35 ` [Qemu-devel] [PATCH 9/9] intel-hda: " David Gibson
2011-09-16 6:58 ` [Qemu-devel] [0/9] Preliminary work for IOMMU emulation support; the easy bits (v2) David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1315197304-22469-8-git-send-email-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=eduard.munteanu@linux360.ro \
--cc=joerg.roedel@amd.com \
--cc=kraxel@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).