qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/5] pc: define PC_PCI_CONFIG_ADDR and PC_PCI_CONFIG_DATA
Date: Tue, 04 Nov 2014 15:44:35 +0200	[thread overview]
Message-ID: <1415108675.2327.46.camel@localhost.localdomain> (raw)
In-Reply-To: <f07a74a7f895066e31dba946858e5e8659e4b750.1415091929.git.hutao@cn.fujitsu.com>

On Tue, 2014-11-04 at 17:12 +0800, Hu Tao wrote:
> PC_PCI_CONFIG_ADDR and PC_PCI_CONFIG_DATA are defined in PCI
> specification, so move them to common place.
> 
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>  hw/pci-host/piix.c        |  8 ++++----
>  hw/pci-host/q35.c         |  8 ++++----
>  include/hw/pci-host/q35.h |  3 ---
>  include/hw/pci/pci.h      |  5 +++++
>  tests/libqos/pci-pc.c     | 24 ++++++++++++------------
>  5 files changed, 25 insertions(+), 23 deletions(-)
> 
> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index 1530038..eb92bde 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -288,11 +288,11 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)
>      PCIHostState *s = PCI_HOST_BRIDGE(dev);
>      SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>  
> -    sysbus_add_io(sbd, 0xcf8, &s->conf_mem);
> -    sysbus_init_ioports(sbd, 0xcf8, 4);
> +    sysbus_add_io(sbd, PC_PCI_CONFIG_ADDR, &s->conf_mem);
> +    sysbus_init_ioports(sbd, PC_PCI_CONFIG_ADDR, 4);
>  
> -    sysbus_add_io(sbd, 0xcfc, &s->data_mem);
> -    sysbus_init_ioports(sbd, 0xcfc, 4);
> +    sysbus_add_io(sbd, PC_PCI_CONFIG_DATA, &s->data_mem);
> +    sysbus_init_ioports(sbd, PC_PCI_CONFIG_DATA, 4);
>  }
>  
>  static int i440fx_initfn(PCIDevice *dev)
> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> index b20bad8..9e66835 100644
> --- a/hw/pci-host/q35.c
> +++ b/hw/pci-host/q35.c
> @@ -41,11 +41,11 @@ static void q35_host_realize(DeviceState *dev, Error **errp)
>      Q35PCIHost *s = Q35_HOST_DEVICE(dev);
>      SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>  
> -    sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_ADDR, &pci->conf_mem);
> -    sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_ADDR, 4);
> +    sysbus_add_io(sbd, PC_PCI_CONFIG_ADDR, &pci->conf_mem);
> +    sysbus_init_ioports(sbd, PC_PCI_CONFIG_ADDR, 4);
>  
> -    sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem);
> -    sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, 4);
> +    sysbus_add_io(sbd, PC_PCI_CONFIG_DATA, &pci->data_mem);
> +    sysbus_init_ioports(sbd, PC_PCI_CONFIG_DATA, 4);
>  
>      pci->bus = pci_bus_new(DEVICE(s), "pcie.0",
>                             s->mch.pci_address_space, s->mch.address_space_io,
> diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h
> index 025d6e6..3a026b0 100644
> --- a/include/hw/pci-host/q35.h
> +++ b/include/hw/pci-host/q35.h
> @@ -82,9 +82,6 @@ typedef struct Q35PCIHost {
>  /* PCI configuration */
>  #define MCH_HOST_BRIDGE                        "MCH"
>  
> -#define MCH_HOST_BRIDGE_CONFIG_ADDR            0xcf8
> -#define MCH_HOST_BRIDGE_CONFIG_DATA            0xcfc
> -
>  /* D0:F0 configuration space */
>  #define MCH_HOST_BRIDGE_REVISION_DEFAULT       0x0
>  
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 3d42d7f..e42589a 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -13,6 +13,11 @@
>  
>  #include "hw/pci/pcie.h"
>  
> +/* PCI configuration */
> +
> +#define PC_PCI_CONFIG_ADDR      0xcf8
> +#define PC_PCI_CONFIG_DATA      0xcfc
I would move the macros also to hw/pci/pci_host.h,
and only personal opinion, change them to
PCI_HOST_BRIDGE_...

Thanks,
Marcel

> +
>  #define PC_PCI_CONFIG_ENABLED(addr) (addr & (1U << 31))
>  
>  /* PCI bus */
> diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c
> index 6dba0db..2762608 100644
> --- a/tests/libqos/pci-pc.c
> +++ b/tests/libqos/pci-pc.c
> @@ -113,38 +113,38 @@ static void qpci_pc_io_writel(QPCIBus *bus, void *addr, uint32_t value)
>  
>  static uint8_t qpci_pc_config_readb(QPCIBus *bus, int devfn, uint8_t offset)
>  {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    return inb(0xcfc);
> +    outl(PC_PCI_CONFIG_ADDR, (1U << 31) | (devfn << 8) | offset);
> +    return inb(PC_PCI_CONFIG_DATA);
>  }
>  
>  static uint16_t qpci_pc_config_readw(QPCIBus *bus, int devfn, uint8_t offset)
>  {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    return inw(0xcfc);
> +    outl(PC_PCI_CONFIG_ADDR, (1U << 31) | (devfn << 8) | offset);
> +    return inw(PC_PCI_CONFIG_DATA);
>  }
>  
>  static uint32_t qpci_pc_config_readl(QPCIBus *bus, int devfn, uint8_t offset)
>  {
> -    outl(0xcf8, (1U << 31) | (devfn << 8) | offset);
> -    return inl(0xcfc);
> +    outl(PC_PCI_CONFIG_ADDR, (1U << 31) | (devfn << 8) | offset);
> +    return inl(PC_PCI_CONFIG_DATA);
>  }
>  
>  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);
> +    outl(PC_PCI_CONFIG_ADDR, (1U << 31) | (devfn << 8) | offset);
> +    outb(PC_PCI_CONFIG_DATA, 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);
> +    outl(PC_PCI_CONFIG_ADDR, (1U << 31) | (devfn << 8) | offset);
> +    outw(PC_PCI_CONFIG_DATA, 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);
> +    outl(PC_PCI_CONFIG_ADDR, (1U << 31) | (devfn << 8) | offset);
> +    outl(PC_PCI_CONFIG_DATA, value);
>  }
>  
>  static void *qpci_pc_iomap(QPCIBus *bus, QPCIDevice *dev, int barno, uint64_t *sizeptr)

  reply	other threads:[~2014-11-04 13:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04  9:12 [Qemu-devel] [PATCH 0/5] Some PCI related cleanup patches Hu Tao
2014-11-04  9:12 ` [Qemu-devel] [PATCH 1/5] pci: introduce PC_PCI_CONFIG_ENABLED() Hu Tao
2014-11-04 13:41   ` Marcel Apfelbaum
2014-11-05  5:57     ` Hu Tao
2014-11-04  9:12 ` [Qemu-devel] [PATCH 2/5] pc: define PC_PCI_CONFIG_ADDR and PC_PCI_CONFIG_DATA Hu Tao
2014-11-04 13:44   ` Marcel Apfelbaum [this message]
2014-11-05  7:58     ` Hu Tao
2014-11-04  9:12 ` [Qemu-devel] [PATCH 3/5] pci: move initialization of pci's conf_addr and conf_data to common place Hu Tao
2014-11-04 14:21   ` Marcel Apfelbaum
2014-11-05  6:03     ` Hu Tao
2014-11-04  9:12 ` [Qemu-devel] [PATCH 4/5] pci: remove the limit parameter of pci_host_config_read_common Hu Tao
2014-11-04  9:12 ` [Qemu-devel] [PATCH 5/5] pci: remove the limit parameter of pci_host_config_write_common Hu Tao

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=1415108675.2327.46.camel@localhost.localdomain \
    --to=marcel.apfelbaum@gmail.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=marcel.a@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).