1. 28 6月, 2012 4 次提交
    • B
      Add a memory barrier to DMA functions · 7a0bac4d
      Benjamin Herrenschmidt 提交于
      The emulated devices can run simultaneously with the guest, so
      we need to be careful with ordering of load and stores done by
      them to the guest system memory, which need to be observed in
      the right order by the guest operating system.
      
      This adds a barrier call to the basic DMA read/write ops which
      is currently implemented as a smp_mb(), but could be later
      improved for more fine grained control of barriers.
      
      Additionally, a _relaxed() variant of the accessors is provided
      to easily convert devices who would be performance sensitive
      and negatively impacted by the change.
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      7a0bac4d
    • D
      iommu: Introduce IOMMU emulation infrastructure · e5332e63
      David Gibson 提交于
      This patch adds the basic infrastructure necessary to emulate an IOMMU
      visible to the guest.  The DMAContext structure is extended with
      information and a callback describing the translation, and the various
      DMA functions used by devices will now perform IOMMU translation using
      this callback.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Signed-off-by: NEduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      e5332e63
    • D
      iommu: Make sglists and dma_bdrv helpers use new universal DMA helpers · c65bcef3
      David Gibson 提交于
      dma-helpers.c contains a number of helper functions for doing
      scatter/gather DMA, and various block device related DMA.  Currently,
      these directly access guest memory using cpu_physical_memory_*(),
      assuming no IOMMU translation.
      
      This patch updates this code to use the new universal DMA helper
      functions.  qemu_sglist_init() now takes a DMAContext * to describe
      the DMA address space in which the scatter/gather will take place.
      
      We minimally update the callers qemu_sglist_init() to pass NULL
      (i.e. no translation, same as current behaviour).  Some of those
      callers should pass something else in some cases to allow proper IOMMU
      translation in future, but that will be fixed in later patches.
      
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      c65bcef3
    • D
      iommu: Add universal DMA helper functions · d86a77f8
      David Gibson 提交于
      Not that long ago, every device implementation using DMA directly
      accessed guest memory using cpu_physical_memory_*().  This meant that
      adding support for a guest visible IOMMU would require changing every
      one of these devices to go through IOMMU translation.
      
      Shortly before qemu 1.0, I made a start on fixing this by providing
      helper functions for PCI DMA.  These are currently just stubs which
      call the direct access functions, but mean that an IOMMU can be
      implemented in one place, rather than for every PCI device.
      
      Clearly, this doesn't help for non PCI devices, which could also be
      IOMMU translated on some platforms.  It is also problematic for the
      devices which have both PCI and non-PCI version (e.g. OHCI, AHCI) - we
      cannot use the the pci_dma_*() functions, because they assume the
      presence of a PCIDevice, but we don't want to have to check between
      pci_dma_*() and cpu_physical_memory_*() every time we do a DMA in the
      device code.
      
      This patch makes the first step on addressing both these problems, by
      introducing new (stub) dma helper functions which can be used for any
      DMA capable device.
      
      These dma functions take a DMAContext *, a new (currently empty)
      variable describing the DMA address space in which the operation is to
      take place.  NULL indicates untranslated DMA directly into guest
      physical address space.  The intention is that in future non-NULL
      values will given information about any necessary IOMMU translation.
      
      DMA using devices must obtain a DMAContext (or, potentially, contexts)
      from their bus or platform.  For now this patch just converts the PCI
      wrappers to be implemented in terms of the universal wrappers,
      converting other drivers can take place over time.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
      Cc: Richard Henderson <rth@twiddle.net>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      d86a77f8
  2. 05 4月, 2012 2 次提交
  3. 22 2月, 2012 2 次提交
  4. 15 12月, 2011 1 次提交
    • P
      dma: the passed io_func does not return NULL · 6bee44ea
      Paolo Bonzini 提交于
      Initially found with the following semantic patch:
      
      @ type @
      BlockDriverAIOCB *x;
      expression E;
      @@
        x = E;
      - if (x == NULL) { ... }
      
      @ acb1 @
      expression E, E1;
      @@
        E1->acb = E;
      - if (E1->acb == NULL) { ... }
      
      @ aiocb1 @
      expression E, E1;
      @@
        E1->aiocb = E;
      - if (E1->aiocb == NULL) { ... }
      
      @ acb @
      expression E, E1;
      @@
        E1.acb = E;
      - if (E1.acb == NULL) { ... }
      
      @ aiocb @
      expression E, E1;
      @@
        E1.aiocb = E;
      - if (E1.aiocb == NULL) { ... }
      
      but changed manually to include an assert.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      6bee44ea
  5. 05 12月, 2011 1 次提交
  6. 02 11月, 2011 1 次提交
  7. 20 9月, 2011 1 次提交
    • P
      dma-helpers: rewrite completion/cancellation · c3adb5b9
      Paolo Bonzini 提交于
      This fixes various problems with completion/cancellation:
      
      * if the io_func fails to get an AIOCB, the callback wasn't called
      
      * If DMA encounters a bounce buffer conflict, and the DMA operation is
      canceled before the bottom half fires, bad things happen.
      
      * memory is not unmapped after cancellation, again causing problems
      when doing DMA to I/O areas
      
      * cancellation could leak the iovec
      
      * the callback was missed if the I/O operation failed without returning
      an AIOCB
      
      and probably more that I've missed.  The patch fixes them by sharing
      the cleanup code between completion and cancellation.  The dma_bdrv_cb
      now returns a boolean completed/not completed flag, and the wrapper
      dma_continue takes care of tasks to do upon completion.
      
      Most of these are basically impossible in practice, but it is better
      to be tidy...
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      c3adb5b9
  8. 19 9月, 2011 1 次提交
  9. 21 8月, 2011 1 次提交
  10. 15 6月, 2011 1 次提交
  11. 02 10月, 2009 2 次提交
  12. 27 5月, 2009 1 次提交
  13. 08 4月, 2009 1 次提交
  14. 29 3月, 2009 1 次提交
  15. 21 3月, 2009 2 次提交
  16. 06 2月, 2009 2 次提交