From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: aik@ozlabs.ru, pbonzini@redhat.com, qemu-devel@nongnu.org,
qemu-ppc@nongnu.org, lvivier@redhat.com, agraf@suse.de,
stefanha@redhat.com, mst@redhat.com, mdroth@linux.vnet.ibm.com,
thuth@redhat.com
Subject: Re: [Qemu-devel] [PATCHv4 04/11] libqos: Better handling of PCI legacy IO
Date: Sat, 22 Oct 2016 15:50:11 +1100 [thread overview]
Message-ID: <20161022045011.GA19629@umbus.fritz.box> (raw)
In-Reply-To: <20161021120506.659ad412@bahia>
[-- Attachment #1: Type: text/plain, Size: 3798 bytes --]
On Fri, Oct 21, 2016 at 12:05:06PM +0200, Greg Kurz wrote:
> On Fri, 21 Oct 2016 12:19:45 +1100
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > The usual model for PCI IO with libqos is to use qpci_iomap() to map a
> > specific BAR for a PCI device, then perform IOs within that BAR using
> > qpci_io_{read,write}*().
> >
> > However, certain devices also have legacy PCI IO. In this case, instead of
> > (or as well as) being accessed via PCI BARs, the device can be accessed
> > via certain well-known, fixed addresses in PCI IO space.
> >
> > Two existing tests use legacy PCI IO, and take different flawed approaches
> > to it:
> > * tco-test manually constructs a tco_io_base value instead of calling
> > qpci_iomap(), which assumes internal knowledge of the structure of
> > the value it shouldn't have
> > * ide-test uses direct in*() and out*() calls instead of using
> > qpci_io_*() accessors, meaning it's not portable to non-x86 machine
> > types.
> >
> > This patch implements a new qpci_iomap_legacy() interface which gets a
> > handle in the same format as qpci_iomap() but refers to a region in
> > the legacy PIO space. For a device which has the same registers
> > available both in a BAR and in legacy space (quite common), this
> > allows the same test code to test both options with just a different
> > iomap() at the beginning.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > Reviewed-by: Laurent Vivier <lvivier@redhat.com>
> > ---
> > tests/libqos/pci.c | 5 +++++
> > tests/libqos/pci.h | 1 +
> > 2 files changed, 6 insertions(+)
> >
> > diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c
> > index bf1c532..98a2e56 100644
> > --- a/tests/libqos/pci.c
> > +++ b/tests/libqos/pci.c
> > @@ -350,6 +350,11 @@ void qpci_iounmap(QPCIDevice *dev, void *data)
> > /* FIXME */
> > }
> >
> > +void *qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr)
> > +{
> > + return (void *)(uintptr_t)addr;
> > +}
> > +
>
> Since both tco-test and ide-test are hardcoded for x86 machine types, is
> it right for this implementation to sit in common PCI code instead of
> the PC specific one ?
Those tests are x86 specific for now. tco-test is of some ICH9
internal device so it probably always will be. But it's absolutely
possible to have a legacy IDE controller on another platform.
Even if those specific tests don't happen, it's likely someone will
want to test some sort of legacy device on another platform at some
point.
[Even though the "legacy" in question is old PCs, it's not uncommon to
see these devices on other platforms - a PC-style southbridge chip
including an ISA bridge and legacy devices is a cheap way of getting a
bunch of useful gadgets on your board, so it's pretty common on many
archs]
> > void qpci_plug_device_test(const char *driver, const char *id,
> > uint8_t slot, const char *opts)
> > {
> > diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h
> > index f6f916d..b6f855e 100644
> > --- a/tests/libqos/pci.h
> > +++ b/tests/libqos/pci.h
> > @@ -94,6 +94,7 @@ void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t value);
> >
> > void *qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr);
> > void qpci_iounmap(QPCIDevice *dev, void *data);
> > +void *qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr);
> >
> > void qpci_plug_device_test(const char *driver, const char *id,
> > uint8_t slot, const char *opts);
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-10-22 6:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 1:19 [Qemu-devel] [PATCHv4 00/11] Cleanups to qtest PCI handling David Gibson
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 01/11] libqos: Give qvirtio_config_read*() consistent semantics David Gibson
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 02/11] libqos: Handle PCI IO de-multiplexing in common code David Gibson
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 03/11] libqos: Move BAR assignment to " David Gibson
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 04/11] libqos: Better handling of PCI legacy IO David Gibson
2016-10-21 10:05 ` Greg Kurz
2016-10-22 4:50 ` David Gibson [this message]
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 05/11] tests: Adjust tco-test to use qpci_legacy_iomap() David Gibson
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 06/11] libqos: Add streaming accessors for PCI MMIO David Gibson
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 07/11] libqos: Implement mmio accessors in terms of mem{read, write} David Gibson
2016-10-21 10:08 ` Greg Kurz
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 08/11] tests: Clean up IO handling in ide-test David Gibson
2016-10-21 8:31 ` Laurent Vivier
2016-10-21 9:05 ` David Gibson
2016-10-21 10:07 ` Laurent Vivier
2016-10-22 4:56 ` David Gibson
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 09/11] libqos: Add 64-bit PCI IO accessors David Gibson
2016-10-21 10:31 ` Greg Kurz
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 10/11] tests: Use qpci_mem{read, write} in ivshmem-test David Gibson
2016-10-21 1:19 ` [Qemu-devel] [PATCHv4 11/11] libqos: Change PCI accessors to take opaque BAR handle David Gibson
2016-10-21 13:23 ` Greg Kurz
2016-10-24 3:19 ` David Gibson
2016-10-24 4:31 ` David Gibson
2016-10-24 10:14 ` Greg Kurz
2016-10-24 10:02 ` Greg Kurz
2016-10-24 12:02 ` David Gibson
2016-10-21 9:38 ` [Qemu-devel] [PATCHv4 00/11] Cleanups to qtest PCI handling Laurent Vivier
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=20161022045011.GA19629@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=groug@kaod.org \
--cc=lvivier@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.