Message ID | 1331269308-22372-9-git-send-email-david@gibson.dropbear.id.au |
---|---|
State | New |
Headers | show |
Am 09.03.2012 06:01, schrieb David Gibson: > The AHCI device can provide both PCI and SysBus AHCI device > emulations. For this reason, it wasn't previously converted to use > the pci_dma_*() helper functions. Now that we have universal DMA > helper functions, this converts AHCI to use them. > > The DMAContext is obtained from pci_dma_context() in the PCI case and > set to NULL in the SysBus case (i.e. we assume for now that a SysBus > AHCI has no IOMMU translation). > > Cc: Kevin Wolf <kwolf@redhat.com> > Cc: Michael S. Tsirkin <mst@redhat.com> > > Signed-off-by: David Gibson <david@gibson.dropbear.id.au> > --- > hw/ide/ahci.c | 7 ++++--- > hw/ide/ahci.h | 3 ++- > hw/ide/ich.c | 2 +- > 3 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c > index 6a218b5..3d31179 100644 > --- a/hw/ide/ahci.c > +++ b/hw/ide/ahci.c > @@ -668,7 +668,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist) > AHCI_SG *tbl = (AHCI_SG *)prdt; > > /* FIXME: pass the correct DMAContext */ > - qemu_sglist_init(sglist, sglist_alloc_hint, NULL); > + qemu_sglist_init(sglist, sglist_alloc_hint, ad->hba->dma); Does the FIXME still apply after this change? Kevin
On Fri, Mar 09, 2012 at 10:48:20AM +0100, Kevin Wolf wrote: > Am 09.03.2012 06:01, schrieb David Gibson: > > The AHCI device can provide both PCI and SysBus AHCI device > > emulations. For this reason, it wasn't previously converted to use > > the pci_dma_*() helper functions. Now that we have universal DMA > > helper functions, this converts AHCI to use them. > > > > The DMAContext is obtained from pci_dma_context() in the PCI case and > > set to NULL in the SysBus case (i.e. we assume for now that a SysBus > > AHCI has no IOMMU translation). > > > > Cc: Kevin Wolf <kwolf@redhat.com> > > Cc: Michael S. Tsirkin <mst@redhat.com> > > > > Signed-off-by: David Gibson <david@gibson.dropbear.id.au> > > --- > > hw/ide/ahci.c | 7 ++++--- > > hw/ide/ahci.h | 3 ++- > > hw/ide/ich.c | 2 +- > > 3 files changed, 7 insertions(+), 5 deletions(-) > > > > diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c > > index 6a218b5..3d31179 100644 > > --- a/hw/ide/ahci.c > > +++ b/hw/ide/ahci.c > > @@ -668,7 +668,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist) > > AHCI_SG *tbl = (AHCI_SG *)prdt; > > > > /* FIXME: pass the correct DMAContext */ > > - qemu_sglist_init(sglist, sglist_alloc_hint, NULL); > > + qemu_sglist_init(sglist, sglist_alloc_hint, ad->hba->dma); > > Does the FIXME still apply after this change? Ah, no, I'll fix that in the next version. I've also spotted there are still a bunch of cpu_physical_memory_*() calls in there that I either missed, or which have been added since I did the conversion. I'll tackle that next week.
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 6a218b5..3d31179 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -668,7 +668,7 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGList *sglist) AHCI_SG *tbl = (AHCI_SG *)prdt; /* FIXME: pass the correct DMAContext */ - qemu_sglist_init(sglist, sglist_alloc_hint, NULL); + qemu_sglist_init(sglist, sglist_alloc_hint, ad->hba->dma); for (i = 0; i < sglist_alloc_hint; i++) { /* flags_size is zero-based */ qemu_sglist_add(sglist, le64_to_cpu(tbl[i].addr), @@ -1115,11 +1115,12 @@ static const IDEDMAOps ahci_dma_ops = { .reset = ahci_dma_reset, }; -void ahci_init(AHCIState *s, DeviceState *qdev, int ports) +void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports) { qemu_irq *irqs; int i; + s->dma = dma; s->ports = ports; s->dev = g_malloc0(sizeof(AHCIDevice) * ports); ahci_reg_init(s); @@ -1182,7 +1183,7 @@ static const VMStateDescription vmstate_sysbus_ahci = { static int sysbus_ahci_init(SysBusDevice *dev) { SysbusAHCIState *s = FROM_SYSBUS(SysbusAHCIState, dev); - ahci_init(&s->ahci, &dev->qdev, s->num_ports); + ahci_init(&s->ahci, &dev->qdev, NULL, s->num_ports); sysbus_init_mmio(dev, &s->ahci.mem); sysbus_init_irq(dev, &s->ahci.irq); diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h index b223d2c..af8c6ef 100644 --- a/hw/ide/ahci.h +++ b/hw/ide/ahci.h @@ -299,6 +299,7 @@ typedef struct AHCIState { uint32_t idp_index; /* Current IDP index */ int ports; qemu_irq irq; + DMAContext *dma; } AHCIState; typedef struct AHCIPCIState { @@ -329,7 +330,7 @@ typedef struct NCQFrame { uint8_t reserved10; } QEMU_PACKED NCQFrame; -void ahci_init(AHCIState *s, DeviceState *qdev, int ports); +void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports); void ahci_uninit(AHCIState *s); void ahci_reset(void *opaque); diff --git a/hw/ide/ich.c b/hw/ide/ich.c index 560ae37..5354e13 100644 --- a/hw/ide/ich.c +++ b/hw/ide/ich.c @@ -91,7 +91,7 @@ static int pci_ich9_ahci_init(PCIDevice *dev) uint8_t *sata_cap; d = DO_UPCAST(struct AHCIPCIState, card, dev); - ahci_init(&d->ahci, &dev->qdev, 6); + ahci_init(&d->ahci, &dev->qdev, pci_dma_context(dev), 6); pci_config_set_prog_interface(d->card.config, AHCI_PROGMODE_MAJOR_REV_1);
The AHCI device can provide both PCI and SysBus AHCI device emulations. For this reason, it wasn't previously converted to use the pci_dma_*() helper functions. Now that we have universal DMA helper functions, this converts AHCI to use them. The DMAContext is obtained from pci_dma_context() in the PCI case and set to NULL in the SysBus case (i.e. we assume for now that a SysBus AHCI has no IOMMU translation). Cc: Kevin Wolf <kwolf@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> --- hw/ide/ahci.c | 7 ++++--- hw/ide/ahci.h | 3 ++- hw/ide/ich.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-)