qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Thomas Huth <thuth@redhat.com>, Eric Blake <eblake@redhat.com>,
	qemu-devel@nongnu.org
Cc: Igor Mammedov <imammedo@redhat.com>, John Snow <jsnow@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Ben Warren <ben@skyportsystems.com>
Subject: Re: [Qemu-devel] [PATCH for-3.2 2/7] tests/libqos/pci: Make PCI access functions independent of global_qtest
Date: Mon, 12 Nov 2018 20:33:03 +0100	[thread overview]
Message-ID: <84f888a7-a34d-16ee-aed3-5a95d5122591@redhat.com> (raw)
In-Reply-To: <1542049690-12826-3-git-send-email-thuth@redhat.com>

On 12/11/2018 20:08, Thomas Huth wrote:
> QPCIBus already tracks QTestState, so use that state instead of an
> implicit reliance on global_qtest.
> 
> Based on an earlier patch ("libqos: Use explicit QTestState for pci
> operations") from Eric Blake.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

This will be converted to qgraph, so I think this patch can be dropped.
 I'll send the qgraph patches tomorrow.

Paolo

> ---
>  tests/libqos/pci-pc.c    | 47 ++++++++++++++++++++++++-----------------------
>  tests/libqos/pci-spapr.c | 20 ++++++++++----------
>  2 files changed, 34 insertions(+), 33 deletions(-)
> 
> diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
> index 585f528..a4fc02b 100644
> --- a/tests/libqos/pci-pc.c
> +++ b/tests/libqos/pci-pc.c
> @@ -29,90 +29,91 @@ typedef struct QPCIBusPC
>  
>  static uint8_t qpci_pc_pio_readb(QPCIBus *bus, uint32_t addr)
>  {
> -    return inb(addr);
> +    return qtest_inb(bus->qts, addr);
>  }
>  
>  static void qpci_pc_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val)
>  {
> -    outb(addr, val);
> +    qtest_outb(bus->qts, addr, val);
>  }
>  
>  static uint16_t qpci_pc_pio_readw(QPCIBus *bus, uint32_t addr)
>  {
> -    return inw(addr);
> +    return qtest_inw(bus->qts, addr);
>  }
>  
>  static void qpci_pc_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val)
>  {
> -    outw(addr, val);
> +    qtest_outw(bus->qts, addr, val);
>  }
>  
>  static uint32_t qpci_pc_pio_readl(QPCIBus *bus, uint32_t addr)
>  {
> -    return inl(addr);
> +    return qtest_inl(bus->qts, addr);
>  }
>  
>  static void qpci_pc_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)
>  {
> -    outl(addr, val);
> +    qtest_outl(bus->qts, addr, val);
>  }
>  
>  static uint64_t qpci_pc_pio_readq(QPCIBus *bus, uint32_t addr)
>  {
> -    return (uint64_t)inl(addr) + ((uint64_t)inl(addr + 4) << 32);
> +    return (uint64_t)qtest_inl(bus->qts, addr) +
> +        ((uint64_t)qtest_inl(bus->qts, addr + 4) << 32);
>  }
>  
>  static void qpci_pc_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val)
>  {
> -    outl(addr, val & 0xffffffff);
> -    outl(addr + 4, val >> 32);
> +    qtest_outl(bus->qts, addr, val & 0xffffffff);
> +    qtest_outl(bus->qts, addr + 4, val >> 32);
>  }
>  
>  static void qpci_pc_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t len)
>  {
> -    memread(addr, buf, len);
> +    qtest_memread(bus->qts, addr, buf, len);
>  }
>  
>  static void qpci_pc_memwrite(QPCIBus *bus, uint32_t addr,
>                               const void *buf, size_t len)
>  {
> -    memwrite(addr, buf, len);
> +    qtest_memwrite(bus->qts, addr, buf, len);
>  }
>  
>  static uint8_t qpci_pc_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
>  {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    return inb(0xcfc);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    return qtest_inb(bus->qts, 0xcfc);
>  }
>  
>  static uint16_t qpci_pc_config_readw(QPCIBus *bus, int devfn, uint8_t offset)
>  {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    return inw(0xcfc);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    return qtest_inw(bus->qts, 0xcfc);
>  }
>  
>  static uint32_t qpci_pc_config_readl(QPCIBus *bus, int devfn, uint8_t offset)
>  {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    return inl(0xcfc);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    return qtest_inl(bus->qts, 0xcfc);
>  }
>  
>  static void qpci_pc_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, uint8_t value)
>  {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    outb(0xcfc, value);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    qtest_outb(bus->qts, 0xcfc, value);
>  }
>  
>  static void qpci_pc_config_writew(QPCIBus *bus, int devfn, uint8_t offset, uint16_t value)
>  {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    outw(0xcfc, value);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    qtest_outw(bus->qts, 0xcfc, value);
>  }
>  
>  static void qpci_pc_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint32_t value)
>  {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    outl(0xcfc, value);
> +    qtest_outl(bus->qts, 0xcf8, (1U << 31) | (devfn << 8) | offset);
> +    qtest_outl(bus->qts, 0xcfc, value);
>  }
>  
>  QPCIBus *qpci_init_pc(QTestState *qts, QGuestAllocator *alloc)
> diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c
> index c0f7e6d..4c29889 100644
> --- a/tests/libqos/pci-spapr.c
> +++ b/tests/libqos/pci-spapr.c
> @@ -45,63 +45,63 @@ typedef struct QPCIBusSPAPR {
>  static uint8_t qpci_spapr_pio_readb(QPCIBus *bus, uint32_t addr)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    return readb(s->pio_cpu_base + addr);
> +    return qtest_readb(bus->qts, s->pio_cpu_base + addr);
>  }
>  
>  static void qpci_spapr_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t val)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    writeb(s->pio_cpu_base + addr, val);
> +    qtest_writeb(bus->qts, s->pio_cpu_base + addr, val);
>  }
>  
>  static uint16_t qpci_spapr_pio_readw(QPCIBus *bus, uint32_t addr)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    return bswap16(readw(s->pio_cpu_base + addr));
> +    return bswap16(qtest_readw(bus->qts, s->pio_cpu_base + addr));
>  }
>  
>  static void qpci_spapr_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t val)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    writew(s->pio_cpu_base + addr, bswap16(val));
> +    qtest_writew(bus->qts, s->pio_cpu_base + addr, bswap16(val));
>  }
>  
>  static uint32_t qpci_spapr_pio_readl(QPCIBus *bus, uint32_t addr)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    return bswap32(readl(s->pio_cpu_base + addr));
> +    return bswap32(qtest_readl(bus->qts, s->pio_cpu_base + addr));
>  }
>  
>  static void qpci_spapr_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t val)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    writel(s->pio_cpu_base + addr, bswap32(val));
> +    qtest_writel(bus->qts, s->pio_cpu_base + addr, bswap32(val));
>  }
>  
>  static uint64_t qpci_spapr_pio_readq(QPCIBus *bus, uint32_t addr)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    return bswap64(readq(s->pio_cpu_base + addr));
> +    return bswap64(qtest_readq(bus->qts, s->pio_cpu_base + addr));
>  }
>  
>  static void qpci_spapr_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t val)
>  {
>      QPCIBusSPAPR *s = container_of(bus, QPCIBusSPAPR, bus);
> -    writeq(s->pio_cpu_base + addr, bswap64(val));
> +    qtest_writeq(bus->qts, s->pio_cpu_base + addr, bswap64(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);
> +    qtest_memread(bus->qts, 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);
> +    qtest_memwrite(bus->qts, s->mmio32_cpu_base + addr, buf, len);
>  }
>  
>  static uint8_t qpci_spapr_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
> 

  reply	other threads:[~2018-11-12 19:33 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-12 19:08 [Qemu-devel] [PATCH v1 for-3.2 0/7] Get rid of global_qtest in some of the qtests Thomas Huth
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 1/7] tests/pvpanic: Make the pvpanic test independent of global_qtest Thomas Huth
2018-11-13  0:47   ` Eric Blake
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 2/7] tests/libqos/pci: Make PCI access functions " Thomas Huth
2018-11-12 19:33   ` Paolo Bonzini [this message]
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 3/7] ahci-test: Drop dependence on global_qtest Thomas Huth
2018-11-14  0:10   ` John Snow
2018-11-27 14:55   ` Eric Blake
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 4/7] ivshmem-test: " Thomas Huth
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 5/7] tests/acpi-utils: " Thomas Huth
2018-11-27 14:30   ` Igor Mammedov
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 6/7] tests/vmgenid: Make test independent of global_qtest Thomas Huth
2018-11-27 14:38   ` Igor Mammedov
2018-11-12 19:08 ` [Qemu-devel] [PATCH for-3.2 7/7] tests/boot-serial: Get rid of global_qtest variable Thomas Huth
2018-11-13 11:38 ` [Qemu-devel] [PATCH v1 for-3.2 0/7] Get rid of global_qtest in some of the qtests no-reply
2018-11-13 12:31   ` Thomas Huth
2018-11-13 13:36     ` Laurent Vivier
2018-11-13 14:28       ` Thomas Huth
2018-11-13 15:11         ` [Qemu-devel] [PATCH] tests/ide: Free pcibus when finishing a test Thomas Huth
2018-11-13 15:54           ` Eric Blake
2018-11-13 16:34           ` Philippe Mathieu-Daudé
2018-11-14  0:56           ` John Snow
2018-11-14 13:05 ` [Qemu-devel] [PATCH v1 for-3.2 0/7] Get rid of global_qtest in some of the qtests no-reply

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=84f888a7-a34d-16ee-aed3-5a95d5122591@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ben@skyportsystems.com \
    --cc=eblake@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --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).