From: Thomas Huth <thuth@redhat.com>
To: Alexander Gordeev <agordeev@redhat.com>, kvm@vger.kernel.org
Cc: Andrew Jones <drjones@redhat.com>
Subject: Re: [kvm-unit-tests PATCH v4 03/12] pci: x86: Add remaining PCI configuration space accessors
Date: Tue, 7 Jun 2016 08:48:46 +0200 [thread overview]
Message-ID: <57566E4E.4020602@redhat.com> (raw)
In-Reply-To: <a7b518d7d1336cbd60dabc102d9f274c8d7c86bd.1465214743.git.agordeev@redhat.com>
On 06.06.2016 14:46, Alexander Gordeev wrote:
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Andrew Jones <drjones@redhat.com>
> Reviewed-by: Andrew Jones <drjones@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
> lib/pci.c | 5 ++---
> lib/x86/asm/pci.h | 23 +++++++++++++++++++++--
> 2 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/lib/pci.c b/lib/pci.c
> index 7ddaac639006..b0d89bf98067 100644
> --- a/lib/pci.c
> +++ b/lib/pci.c
> @@ -13,9 +13,8 @@ pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id)
> pcidevaddr_t dev;
>
> for (dev = 0; dev < 256; ++dev) {
> - uint32_t id = pci_config_readl(dev, 0);
> -
> - if ((id & 0xFFFF) == vendor_id && (id >> 16) == device_id)
> + if (pci_config_readw(dev, PCI_VENDOR_ID) == vendor_id &&
> + pci_config_readw(dev, PCI_DEVICE_ID) == device_id)
> return dev;
> }
>
> diff --git a/lib/x86/asm/pci.h b/lib/x86/asm/pci.h
> index d00438fe91e4..821a2c1e180a 100644
> --- a/lib/x86/asm/pci.h
> +++ b/lib/x86/asm/pci.h
> @@ -9,11 +9,30 @@
> #include "pci.h"
> #include "x86/asm/io.h"
>
> +#define PCI_CONF1_ADDRESS(dev, reg) ((0x1 << 31) | (dev << 8) | reg)
> +
> +static inline uint8_t pci_config_readb(pcidevaddr_t dev, uint8_t reg)
> +{
> + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8);
> + return inb(0xCFC);
> +}
> +
> +static inline uint16_t pci_config_readw(pcidevaddr_t dev, uint8_t reg)
> +{
> + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8);
> + return inw(0xCFC);
> +}
> +
> static inline uint32_t pci_config_readl(pcidevaddr_t dev, uint8_t reg)
> {
> - uint32_t index = reg | (dev << 8) | (0x1 << 31);
> - outl(index, 0xCF8);
> + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8);
> return inl(0xCFC);
> }
>
> +static inline void pci_config_writel(pcidevaddr_t dev, uint8_t reg, uint32_t val)
> +{
> + outl(PCI_CONF1_ADDRESS(dev, reg), 0xCF8);
> + outl(val, 0xCFC);
> +}
> +
> #endif
Maybe add a #define for that magic value 0xCF8, now that you use it
multiple times?
Anyway,
Reviewed-by: Thomas Huth <thuth@redhat.com>
next prev parent reply other threads:[~2016-06-07 6:48 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 12:46 [kvm-unit-tests PATCH v4 00/12] PCI bus support Alexander Gordeev
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 01/12] pci: Fix coding style in generic PCI files Alexander Gordeev
2016-06-06 13:22 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 02/12] pci: x86: Rename pci_config_read() to pci_config_readl() Alexander Gordeev
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 03/12] pci: x86: Add remaining PCI configuration space accessors Alexander Gordeev
2016-06-07 6:48 ` Thomas Huth [this message]
2016-06-08 6:21 ` Alexander Gordeev
2016-06-08 10:08 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 04/12] pci: Rework pci_bar_addr() Alexander Gordeev
2016-06-06 14:12 ` Andrew Jones
2016-06-07 6:38 ` Alexander Gordeev
2016-06-07 7:03 ` Andrew Jones
2016-06-07 10:33 ` Alexander Gordeev
2016-06-07 11:23 ` Alexander Gordeev
2016-06-07 14:10 ` Andrew Jones
2016-06-07 14:08 ` Andrew Jones
2016-06-07 20:00 ` Alexander Gordeev
2016-06-08 11:59 ` Andrew Jones
2016-06-09 20:41 ` Alexander Gordeev
2016-06-10 7:14 ` Andrew Jones
2016-06-07 6:55 ` Alexander Gordeev
2016-06-10 18:56 ` Alexander Gordeev
2016-06-12 13:41 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 05/12] pci: Factor out pci_bar_get() Alexander Gordeev
2016-06-06 15:19 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 06/12] pci: Add pci_bar_set_addr() Alexander Gordeev
2016-06-06 15:38 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 07/12] pci: Add pci_dev_exists() Alexander Gordeev
2016-06-06 15:40 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 08/12] pci: Add pci_print() Alexander Gordeev
2016-06-06 15:48 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 09/12] pci: Add generic ECAM host support Alexander Gordeev
2016-06-06 16:27 ` Andrew Jones
2016-06-08 6:36 ` Alexander Gordeev
2016-06-11 20:10 ` Alexander Gordeev
2016-06-12 13:42 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 10/12] arm/arm64: pci: Add PCI bus operation test Alexander Gordeev
2016-06-06 16:39 ` Andrew Jones
2016-06-08 6:53 ` Alexander Gordeev
2016-06-08 12:08 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 11/12] pci: Add pci-testdev PCI bus test device Alexander Gordeev
2016-06-06 17:00 ` Andrew Jones
2016-06-06 12:46 ` [kvm-unit-tests PATCH v4 12/12] arm/arm64: pci: Add pci-testdev PCI device operation test Alexander Gordeev
2016-06-06 17:04 ` Andrew Jones
2016-06-06 17:11 ` [kvm-unit-tests PATCH v4 00/12] PCI bus support Andrew Jones
2016-06-21 7:02 ` Alexander Gordeev
2016-06-27 12:59 ` Alexander Gordeev
2016-06-27 13:46 ` Andrew Jones
2016-06-28 10:54 ` Alexander Gordeev
2016-06-28 11:18 ` Andrew Jones
2016-06-28 11:28 ` Alexander Gordeev
2016-06-28 11:32 ` Andrew Jones
2016-06-28 11:56 ` Alexander Gordeev
2016-06-28 12:38 ` Andrew Jones
2016-06-28 13:04 ` Alexander Gordeev
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=57566E4E.4020602@redhat.com \
--to=thuth@redhat.com \
--cc=agordeev@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
/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