From: "Michael S. Tsirkin" <mst@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: skandasa@cisco.com, Anthony Liguori <aliguori@us.ibm.com>,
etmartin@cisco.com, qemu-devel@nongnu.org, wexu2@cisco.com
Subject: [Qemu-devel] Re: [PATCH 7/7] pci bridge: implement secondary bus reset
Date: Fri, 19 Nov 2010 13:27:32 +0200 [thread overview]
Message-ID: <20101119112732.GC4052@redhat.com> (raw)
In-Reply-To: <20101119081519.GA16942@valinux.co.jp>
On Fri, Nov 19, 2010 at 05:15:19PM +0900, Isaku Yamahata wrote:
> On Thu, Nov 18, 2010 at 10:46:25AM +0200, Michael S. Tsirkin wrote:
> > On Thu, Nov 18, 2010 at 04:29:10PM +0900, Isaku Yamahata wrote:
> > > On Thu, Nov 18, 2010 at 09:05:30AM +0200, Michael S. Tsirkin wrote:
> > > > On Wed, Nov 17, 2010 at 01:50:27PM +0900, Isaku Yamahata wrote:
> > > > > Emulates secondary bus reset when secondary bus reset bit
> > > > > is written from 0 to 1.
> > > > >
> > > > > Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> > > > > Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> > > > > ---
> > > > > hw/pci_bridge.c | 12 +++++++++++-
> > > > > 1 files changed, 11 insertions(+), 1 deletions(-)
> > > > >
> > > > > diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c
> > > > > index 58cc2e4..618a81e 100644
> > > > > --- a/hw/pci_bridge.c
> > > > > +++ b/hw/pci_bridge.c
> > > > > @@ -139,6 +139,10 @@ pcibus_t pci_bridge_get_limit(const PCIDevice *bridge, uint8_t type)
> > > > > void pci_bridge_write_config(PCIDevice *d,
> > > > > uint32_t address, uint32_t val, int len)
> > > > > {
> > > > > + PCIBridge *s = container_of(d, PCIBridge, dev);
> > > > > + uint16_t bridge_control = pci_get_word(d->config + PCI_BRIDGE_CONTROL);
> > > > > + uint16_t bridge_control_new;
> > > > > +
> > > > > pci_default_write_config(d, address, val, len);
> > > > >
> > > > > if (/* io base/limit */
> > > > > @@ -147,9 +151,15 @@ void pci_bridge_write_config(PCIDevice *d,
> > > > > /* memory base/limit, prefetchable base/limit and
> > > > > io base/limit upper 16 */
> > > > > ranges_overlap(address, len, PCI_MEMORY_BASE, 20)) {
> > > > > - PCIBridge *s = container_of(d, PCIBridge, dev);
> > > > > pci_bridge_update_mappings(&s->sec_bus);
> > > > > }
> > > > > +
> > > > > + bridge_control_new = pci_get_word(d->config + PCI_BRIDGE_CONTROL);
> > > > > + if (!(bridge_control & PCI_BRIDGE_CTL_BUS_RESET) &&
> > > > > + (bridge_control_new & PCI_BRIDGE_CTL_BUS_RESET)) {
> > > > > + /* 0 -> 1 */
> > > > > + pci_bus_reset(&s->sec_bus);
> > > > > + }
> > > > > }
> > > > >
> > > > > void pci_bridge_disable_base_limit(PCIDevice *dev)
> > > >
> > > > Presumably this bit will have to be made writeable?
> > >
> > > Yes, it's already writable.
> > > static void pci_init_wmask_bridge(PCIDevice *d)
> > > ...
> > > pci_set_word(d->wmask + PCI_BRIDGE_CONTROL, 0xffff);
> >
> > Ouch, that's wrong, isn't it?
> > Bits 15:12 are reserved, readonly, 0.
> >
> > I think we need the following (untested).
> > Comments?
>
> Basically it looks good if you left bits 8-11 RO intentional.
> qemu doesn't emulate pci bus cycles, so it won't matter.
Hmm, no, not intentional. I'll fix it up.
> Also, please include following hunk.
>
> commit 8c76e0427234290a640499c1305cabd998d6f777
> Author: Isaku Yamahata <yamahata@valinux.co.jp>
> Date: Fri Nov 19 17:08:57 2010 +0900
>
> pcie/port: initialize bridge control register properly
>
> pci generic layer initialized bridge control register
> according to pci spec. pcie deviates slightly from it,
> so initializes it properly.
>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Applied, thanks.
> diff --git a/hw/pcie_port.c b/hw/pcie_port.c
> index 117de61..340dcdb 100644
> --- a/hw/pcie_port.c
> +++ b/hw/pcie_port.c
> @@ -27,6 +27,14 @@ void pcie_port_init_reg(PCIDevice *d)
> pci_set_word(d->config + PCI_STATUS, 0);
> pci_set_word(d->config + PCI_SEC_STATUS, 0);
>
> + /* Unlike conventional pci bridge, some bits are hardwared to 0. */
> + pci_set_word(d->wmask + PCI_BRIDGE_CONTROL,
> + PCI_BRIDGE_CTL_PARITY |
> + PCI_BRIDGE_CTL_ISA |
> + PCI_BRIDGE_CTL_VGA |
> + PCI_BRIDGE_CTL_SERR |
> + PCI_BRIDGE_CTL_BUS_RESET);
> +
> /* 7.5.3.5 Prefetchable Memory Base Limit
> * The Prefetchable Memory Base and Prefetchable Memory Limit registers
> * must indicate that 64-bit addresses are supported, as defined in
>
>
> >
> > pci: fix bridge control bit wmask
> >
> > Bits 12 to 15 in bridge control register are reserver and must be
> > read-only zero, curent mask is 0xffff which makes them writeable. Fix
> > this up by using symbolic bit names for writeable bits instead of a
> > hardcoded constant.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> >
> > --
> >
> > diff --git a/hw/pci.c b/hw/pci.c
> > index 00ec8ea..7d6d5ad 100644
> > --- a/hw/pci.c
> > +++ b/hw/pci.c
> > @@ -588,7 +588,17 @@ static void pci_init_wmask_bridge(PCIDevice *d)
> > /* PCI_PREF_BASE_UPPER32 and PCI_PREF_LIMIT_UPPER32 */
> > memset(d->wmask + PCI_PREF_BASE_UPPER32, 0xff, 8);
> >
> > - pci_set_word(d->wmask + PCI_BRIDGE_CONTROL, 0xffff);
> > +/* TODO: add this define to pci_regs.h in linux and then in qemu. */
> > +#define PCI_BRIDGE_CTL_VGA_16BIT 0x10 /* VGA 16-bit decode */
> > + pci_set_word(d->wmask + PCI_BRIDGE_CONTROL,
> > + PCI_BRIDGE_CTL_PARITY |
> > + PCI_BRIDGE_CTL_SERR |
> > + PCI_BRIDGE_CTL_ISA |
> > + PCI_BRIDGE_CTL_VGA |
> > + PCI_BRIDGE_CTL_VGA_16BIT |
> > + PCI_BRIDGE_CTL_MASTER_ABORT |
> > + PCI_BRIDGE_CTL_BUS_RESET |
> > + PCI_BRIDGE_CTL_FAST_BACK);
> > }
> >
> > static int pci_init_multifunction(PCIBus *bus, PCIDevice *dev)
> >
>
> --
> yamahata
next prev parent reply other threads:[~2010-11-19 11:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-17 4:50 [Qemu-devel] [PATCH 0/7] qdev reset refactoring and pci bus reset Isaku Yamahata
2010-11-17 4:50 ` [Qemu-devel] [PATCH 1/7] qbus: add functions to walk both devices and busses Isaku Yamahata
2010-11-17 11:57 ` [Qemu-devel] " Paolo Bonzini
2010-11-17 4:50 ` [Qemu-devel] [PATCH 2/7] qdev: reset qdev along with qdev tree Isaku Yamahata
2010-11-17 4:50 ` [Qemu-devel] [PATCH 3/7] qdev: introduce reset call back for qbus level Isaku Yamahata
2010-11-17 4:50 ` [Qemu-devel] [PATCH 4/7] qdev: introduce a helper function which triggers reset from a given device Isaku Yamahata
2010-11-17 4:50 ` [Qemu-devel] [PATCH 5/7] pci: make use of qdev reset frame work to pci bus reset Isaku Yamahata
2010-11-18 7:02 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-18 8:22 ` Isaku Yamahata
2010-11-18 8:58 ` Michael S. Tsirkin
2010-11-17 4:50 ` [Qemu-devel] [PATCH 6/7] pci: teach pci devices that have reset callback how to reset common registers Isaku Yamahata
2010-11-17 4:50 ` [Qemu-devel] [PATCH 7/7] pci bridge: implement secondary bus reset Isaku Yamahata
2010-11-18 7:05 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-18 7:29 ` Isaku Yamahata
2010-11-18 8:46 ` Michael S. Tsirkin
2010-11-19 8:15 ` Isaku Yamahata
2010-11-19 11:27 ` Michael S. Tsirkin [this message]
2010-11-19 12:08 ` Michael S. Tsirkin
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=20101119112732.GC4052@redhat.com \
--to=mst@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=etmartin@cisco.com \
--cc=qemu-devel@nongnu.org \
--cc=skandasa@cisco.com \
--cc=wexu2@cisco.com \
--cc=yamahata@valinux.co.jp \
/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).