All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: skandasa@cisco.com, adnan@khaleel.us, etmartin@cisco.com,
	qemu-devel@nongnu.org, wexu2@cisco.com
Subject: [Qemu-devel] Re: [PATCH v4 05/15] pci/bridge: fix pci_bridge_reset()
Date: Mon, 18 Oct 2010 09:08:09 +0200	[thread overview]
Message-ID: <20101018070809.GA20146@redhat.com> (raw)
In-Reply-To: <20101018071017.GC31699@valinux.co.jp>

On Mon, Oct 18, 2010 at 04:10:17PM +0900, Isaku Yamahata wrote:
> On Mon, Oct 18, 2010 at 08:22:24AM +0200, Michael S. Tsirkin wrote:
> > On Mon, Oct 18, 2010 at 12:17:46PM +0900, Isaku Yamahata wrote:
> > > lower 4bits of base/limit register is RO, and
> > > should not be modified on reset.
> > > 
> > > Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> > > ---
> > >  hw/pci_bridge.c |   15 +++++++++------
> > >  1 files changed, 9 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c
> > > index 638e3b3..7229610 100644
> > > --- a/hw/pci_bridge.c
> > > +++ b/hw/pci_bridge.c
> > > @@ -161,12 +161,15 @@ void pci_bridge_reset_reg(PCIDevice *dev)
> > >      conf[PCI_SUBORDINATE_BUS] = 0;
> > >      conf[PCI_SEC_LATENCY_TIMER] = 0;
> > >  
> > > -    conf[PCI_IO_BASE] = 0;
> > > -    conf[PCI_IO_LIMIT] = 0;
> > > -    pci_set_word(conf + PCI_MEMORY_BASE, 0);
> > > -    pci_set_word(conf + PCI_MEMORY_LIMIT, 0);
> > > -    pci_set_word(conf + PCI_PREF_MEMORY_BASE, 0);
> > > -    pci_set_word(conf + PCI_PREF_MEMORY_LIMIT, 0);
> > > +    pci_clear_bit_byte(conf + PCI_IO_BASE, PCI_IO_RANGE_MASK & 0xff);
> > > +    pci_clear_bit_byte(conf + PCI_IO_LIMIT, PCI_IO_RANGE_MASK & 0xff);
> > 
> > No need for & 0xff and & 0xfffff here and below.
> 
> gcc complains like this without them.
> hw/pci_bridge.c:165: error: large integer implicitly truncated to unsigned type

I see.

> 
> > also, PCI spec also says that these registers' value
> > is undefined after reset, so no need to clear them?
> > If there's a reason, pls put it in comment.
> 
> The spec says the lower bits are read-only and they have its meaning.

Yes. but my question is why even touch io base/io limit at all
in this function?
It looks like guest can not rely on these being 0 after reset.

> Anyway I'll add the reference as comment.
> 
> For example.
> 
> > 3.2.5.6 I/O Base Register and I/O Limit Register
> >
> > If the low four bits of the I/O Base and I/O Limit registers are 01h,
> > then the bridge supports 32-bit I/O address decoding, and the I/O Base
> > Upper 16 Bits and the I/O Limit Upper 16 Bits hold the upper 16 bits,
> > corresponding to AD[31::16], of the 32-bit I/O Base and I/O Limit
> > addresses respectively. In this case, system configuration software is
> > permitted to locate the I/O address range supported by the bridge
> > anywhere in the 4-GB I/O Space. Note that the 4-KB alignment and
> > granularity restrictions still apply when the bridge supports 32-bit
> > I/O addressing.
> > table 3-7

I don't think this is required but up to you.

> > 
> > 
> > > +    pci_clear_bit_word(conf + PCI_MEMORY_BASE, PCI_MEMORY_RANGE_MASK & 0xffff);
> > > +    pci_clear_bit_word(conf + PCI_MEMORY_LIMIT,
> > > +                       PCI_MEMORY_RANGE_MASK & 0xffff);
> > > +    pci_clear_bit_word(conf + PCI_PREF_MEMORY_BASE,
> > > +                       PCI_PREF_RANGE_MASK & 0xffff);
> > > +    pci_clear_bit_word(conf + PCI_PREF_MEMORY_LIMIT,
> > > +                       PCI_PREF_RANGE_MASK & 0xffff);
> > >      pci_set_word(conf + PCI_PREF_BASE_UPPER32, 0);
> > >      pci_set_word(conf + PCI_PREF_LIMIT_UPPER32, 0);
> > >  
> > > -- 
> > > 1.7.1.1
> > 
> 
> -- 
> yamahata

  reply	other threads:[~2010-10-18  7:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-18  3:17 [Qemu-devel] [PATCH v4 00/15] pcie port switch emulators Isaku Yamahata
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 01/15] pci: make pci_del_capability() update for w1cmask Isaku Yamahata
2010-10-18  6:06   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 02/15] pci: introduce helper functions to clear/set bits in configuration space Isaku Yamahata
2010-10-18  5:42   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18  6:32   ` Michael S. Tsirkin
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 03/15] pci: use pci_clear_bit_word() in pci_device_reset() Isaku Yamahata
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 04/15] pci: record which is written into pci configuration space Isaku Yamahata
2010-10-18  5:38   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18  7:17     ` Isaku Yamahata
2010-10-18  7:32       ` Michael S. Tsirkin
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 05/15] pci/bridge: fix pci_bridge_reset() Isaku Yamahata
2010-10-18  6:22   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18  7:10     ` Isaku Yamahata
2010-10-18  7:08       ` Michael S. Tsirkin [this message]
2010-10-18  7:44         ` Isaku Yamahata
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 06/15] msi: implements msi Isaku Yamahata
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 07/15] pcie: add pcie constants to pcie_regs.h Isaku Yamahata
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 08/15] pcie: helper functions for pcie capability and extended capability Isaku Yamahata
2010-10-18  5:38   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 09/15] pcie/aer: helper functions for pcie aer capability Isaku Yamahata
2010-10-18  5:45   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 10/15] pcie port: define struct PCIEPort/PCIESlot and helper functions Isaku Yamahata
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 11/15] ioh3420: pcie root port in X58 ioh Isaku Yamahata
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 12/15] x3130: pcie upstream port Isaku Yamahata
2010-10-18  4:59   ` [Qemu-devel] " Michael S. Tsirkin
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 13/15] x3130: pcie downstream port Isaku Yamahata
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 14/15] pcie/hotplug: introduce pushing attention button command Isaku Yamahata
2010-10-18  3:17 ` [Qemu-devel] [PATCH v4 15/15] pcie/aer: glue aer error injection into qemu monitor Isaku Yamahata
2010-10-18  6:24 ` [Qemu-devel] Re: [PATCH v4 00/15] pcie port switch emulators 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=20101018070809.GA20146@redhat.com \
    --to=mst@redhat.com \
    --cc=adnan@khaleel.us \
    --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 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.