qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>,
	pbonzini@redhat.com, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, agraf@suse.de, stefanha@redhat.com,
	mst@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com,
	groug@kaod.org, thuth@redhat.com
Subject: Re: [Qemu-devel] [PATCH 5/8] libqos: Add streaming accessors for PCI MMIO
Date: Tue, 18 Oct 2016 17:17:43 +0200	[thread overview]
Message-ID: <d2df75cb-eed2-9268-f9a9-4f1f4386b483@redhat.com> (raw)
In-Reply-To: <1476787933-7180-6-git-send-email-david@gibson.dropbear.id.au>



On 18/10/2016 12:52, David Gibson wrote:
> Currently PCI memory (aka MMIO) space is accessed via a set of readb/writeb
> style accessors.  This is what we want for accessing discrete registers of
> a certain size.  However, there are a few cases where we instead need a
> "bag of bytes" style streaming interface to PCI MMIO space.  This can be
> either for streaming data style registers or when there's actual memory
> rather than registers in PCI space, for example frame buffers or ivshmem.
> 
> This patch adds backend callbacks, and libqos wrappers for this type of
> byte address order preserving accesses.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Reviewed-by: Laurent Vivier <lvivier@redhat.com>

> ---
>  tests/libqos/pci-pc.c    | 14 ++++++++++++++
>  tests/libqos/pci-spapr.c | 17 +++++++++++++++++
>  tests/libqos/pci.c       | 16 ++++++++++++++++
>  tests/libqos/pci.h       |  6 ++++++
>  4 files changed, 53 insertions(+)
> 
> diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
> index b087d13..0e95772 100644
> --- a/tests/libqos/pci-pc.c
> +++ b/tests/libqos/pci-pc.c
> @@ -95,6 +95,17 @@ static void qpci_pc_mmio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)
>      writel(addr, val);
>  }
>  
> +static void qpci_pc_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t len)
> +{
> +    memread(addr, buf, len);
> +}
> +
> +static void qpci_pc_memwrite(QPCIBus *bus, uint32_t addr,
> +                             const void *buf, size_t len)
> +{
> +    memwrite(addr, buf, len);
> +}
> +
>  static uint8_t qpci_pc_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
>  {
>      outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> @@ -153,6 +164,9 @@ QPCIBus *qpci_init_pc(QGuestAllocator *alloc)
>      ret->bus.mmio_writew = qpci_pc_mmio_writew;
>      ret->bus.mmio_writel = qpci_pc_mmio_writel;
>  
> +    ret->bus.memread = qpci_pc_memread;
> +    ret->bus.memwrite = qpci_pc_memwrite;
> +
>      ret->bus.config_readb = qpci_pc_config_readb;
>      ret->bus.config_readw = qpci_pc_config_readw;
>      ret->bus.config_readl = qpci_pc_config_readl;
> diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
> index 9a18d8a..b4c4b81 100644
> --- a/tests/libqos/pci-spapr.c
> +++ b/tests/libqos/pci-spapr.c
> @@ -122,6 +122,20 @@ static void qpci_spapr_mmio32_writel(QPCIBus *bus, uint32_t addr, uint32_t val)
>      writel(s->mmio32_cpu_base + addr, bswap32(val));
>  }
>  
> +static void qpci_spapr_memread(QPCIBus *bus, uint32_t addr,
> +                               void *buf, size_t len)
> +{
> +    QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> +    memread(s->mmio32_cpu_base + addr, buf, len);
> +}
> +
> +static void qpci_spapr_memwrite(QPCIBus *bus, uint32_t addr,
> +                                const void *buf, size_t len)
> +{
> +    QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> +    memwrite(s->mmio32_cpu_base + addr, buf, len);
> +}
> +
>  static uint8_t qpci_spapr_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> @@ -196,6 +210,9 @@ QPCIBus *qpci_init_spapr(QGuestAllocator *alloc)
>      ret->bus.mmio_writew = qpci_spapr_mmio32_writew;
>      ret->bus.mmio_writel = qpci_spapr_mmio32_writel;
>  
> +    ret->bus.memread = qpci_spapr_memread;
> +    ret->bus.memwrite = qpci_spapr_memwrite;
> +
>      ret->bus.config_readb = qpci_spapr_config_readb;
>      ret->bus.config_readw = qpci_spapr_config_readw;
>      ret->bus.config_readl = qpci_spapr_config_readl;
> diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c
> index bf1c532..1e242f9 100644
> --- a/tests/libqos/pci.c
> +++ b/tests/libqos/pci.c
> @@ -289,6 +289,22 @@ void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t value)
>      }
>  }
>  
> +void qpci_memread(QPCIDevice *dev, void *data, void *buf, size_t len)
> +{
> +    uintptr_t addr = (uintptr_t)data;
> +
> +    g_assert(addr >= QPCI_PIO_LIMIT);
> +    dev->bus->memread(dev->bus, addr, buf, len);
> +}
> +
> +void qpci_memwrite(QPCIDevice *dev, void *data, const void *buf, size_t len)
> +{
> +    uintptr_t addr = (uintptr_t)data;
> +
> +    g_assert(addr >= QPCI_PIO_LIMIT);
> +    dev->bus->memwrite(dev->bus, addr, buf, len);
> +}
> +
>  void *qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr)
>  {
>      QPCIBus *bus = dev->bus;
> diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h
> index f6f916d..2fa5b4f 100644
> --- a/tests/libqos/pci.h
> +++ b/tests/libqos/pci.h
> @@ -39,6 +39,9 @@ struct QPCIBus {
>      void (*mmio_writew)(QPCIBus *bus, uint32_t addr, uint16_t value);
>      void (*mmio_writel)(QPCIBus *bus, uint32_t addr, uint32_t value);
>  
> +    void (*memread)(QPCIBus *bus, uint32_t addr, void *buf, size_t len);
> +    void (*memwrite)(QPCIBus *bus, uint32_t addr, const void *buf, size_t len);
> +
>      uint8_t (*config_readb)(QPCIBus *bus, int devfn, uint8_t offset);
>      uint16_t (*config_readw)(QPCIBus *bus, int devfn, uint8_t offset);
>      uint32_t (*config_readl)(QPCIBus *bus, int devfn, uint8_t offset);
> @@ -92,6 +95,9 @@ void qpci_io_writeb(QPCIDevice *dev, void *data, uint8_t value);
>  void qpci_io_writew(QPCIDevice *dev, void *data, uint16_t value);
>  void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t value);
>  
> +void qpci_memread(QPCIDevice *bus, void *data, void *buf, size_t len);
> +void qpci_memwrite(QPCIDevice *bus, void *data, const void *buf, size_t len);
> +
>  void *qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr);
>  void qpci_iounmap(QPCIDevice *dev, void *data);
>  
> 

  reply	other threads:[~2016-10-18 15:17 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18 10:52 [Qemu-devel] [PATCH 0/8] Cleanups to qtest PCI handling David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 1/8] libqos: Give qvirtio_config_read*() consistent semantics David Gibson
2016-10-18 12:41   ` Laurent Vivier
2016-10-18 13:27   ` Greg Kurz
2016-10-19  2:41     ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 2/8] libqos: Handle PCI IO de-multiplexing in common code David Gibson
2016-10-18 13:28   ` Laurent Vivier
2016-10-19  2:59     ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 3/8] libqos: Move BAR assignment to " David Gibson
2016-10-18 15:00   ` Laurent Vivier
2016-10-19  3:07     ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 4/8] tests: Better handle legacy IO addresses in tco-test David Gibson
2016-10-18 15:14   ` Laurent Vivier
2016-10-18 16:28     ` Laurent Vivier
2016-10-19  3:19       ` David Gibson
2016-10-19  3:09     ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 5/8] libqos: Add streaming accessors for PCI MMIO David Gibson
2016-10-18 15:17   ` Laurent Vivier [this message]
2016-10-18 10:52 ` [Qemu-devel] [PATCH 6/8] libqos: Implement mmio accessors in terms of mem{read, write} David Gibson
2016-10-18 16:04   ` Laurent Vivier
2016-10-18 10:52 ` [Qemu-devel] [PATCH 7/8] tests: Use qpci_mem{read, write} in ivshmem-test David Gibson
2016-10-18 16:14   ` Laurent Vivier
2016-10-19  4:13     ` David Gibson
2016-10-18 10:52 ` [Qemu-devel] [PATCH 8/8] libqos: Change PCI accessors to take opaque BAR handle David Gibson
2016-10-18 16:48   ` Laurent Vivier
2016-10-19  4:06     ` David Gibson
2016-10-18 11:56 ` [Qemu-devel] [PATCH 0/8] Cleanups to qtest PCI handling Laurent Vivier
2016-10-19  1:11   ` 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=d2df75cb-eed2-9268-f9a9-4f1f4386b483@redhat.com \
    --to=lvivier@redhat.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /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).