From: Isaku Yamahata <yamahata@valinux.co.jp>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: skandasa@cisco.com, adnan@khaleel.us, etmartin@cisco.com,
qemu-devel@nongnu.org, wexu2@cisco.com
Subject: [Qemu-devel] Re: [PATCH v6 02/12] pci/bridge: fix pci_bridge_reset()
Date: Wed, 20 Oct 2010 18:04:49 +0900 [thread overview]
Message-ID: <20101020090449.GA20484@valinux.co.jp> (raw)
In-Reply-To: <20101020084920.GB10783@redhat.com>
On Wed, Oct 20, 2010 at 10:49:20AM +0200, Michael S. Tsirkin wrote:
> On Wed, Oct 20, 2010 at 05:18:51PM +0900, Isaku Yamahata wrote:
> > The default value of base/limit registers aren't specified in the spec.
> > So pci_bridge_reset() shouldn't touch them.
> > Instead, introduced two functions to reset those registers in a way
> > of typical implementation. zero base/limit registers or disable forwarding.
> > They will be used later.
> >
> > Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
>
> The commit message seems to be out of date?
Oops. Here's the update one. Only the commit log change.
Should I resend the whole series?
>From a3e0fd4d19879156d40f87228d09c660fc512b16 Mon Sep 17 00:00:00 2001
Message-Id: <a3e0fd4d19879156d40f87228d09c660fc512b16.1287565438.git.yamahata@valinux.co.jp>
In-Reply-To: <cover.1287565438.git.yamahata@valinux.co.jp>
References: <cover.1287565438.git.yamahata@valinux.co.jp>
From: Isaku Yamahata <yamahata@valinux.co.jp>
Date: Fri, 15 Oct 2010 19:33:50 +0900
Subject: [PATCH v6 02/12] pci/bridge: fix pci_bridge_reset()
The lower bits of base/limit registers is RO and shouldn't be zero cleared
on reset. This patch fixes it.
In fact, the default value of base/limit registers aren't specified
in the spec. And some bridges disable forwarding on reset instead of
zeroing base/limit registers.
So introduce one function to disable bridge forwarding so that
such bridges can use it. It will be used later.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
Changes v5 -> v6:
- pci_bridge_disable_base_limit()
Changes v4 -> v5:
- drop the lines in pci_bridge_reset()
- introduced two functions to reset base/limit registers.
---
hw/pci_bridge.c | 48 ++++++++++++++++++++++++++++++++++++++++++------
hw/pci_bridge.h | 1 +
2 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c
index 638e3b3..7e8488a 100644
--- a/hw/pci_bridge.c
+++ b/hw/pci_bridge.c
@@ -151,6 +151,26 @@ void pci_bridge_write_config(PCIDevice *d,
}
}
+void pci_bridge_disable_base_limit(PCIDevice *dev)
+{
+ uint8_t *conf = dev->config;
+
+ pci_byte_test_and_set_mask(conf + PCI_IO_BASE,
+ PCI_IO_RANGE_MASK & 0xff);
+ pci_byte_test_and_clear_mask(conf + PCI_IO_LIMIT,
+ PCI_IO_RANGE_MASK & 0xff);
+ pci_word_test_and_set_mask(conf + PCI_MEMORY_BASE,
+ PCI_MEMORY_RANGE_MASK & 0xffff);
+ pci_word_test_and_clear_mask(conf + PCI_MEMORY_LIMIT,
+ PCI_MEMORY_RANGE_MASK & 0xffff);
+ pci_word_test_and_set_mask(conf + PCI_PREF_MEMORY_BASE,
+ PCI_PREF_RANGE_MASK & 0xffff);
+ pci_word_test_and_clear_mask(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);
+}
+
/* reset bridge specific configuration registers */
void pci_bridge_reset_reg(PCIDevice *dev)
{
@@ -161,12 +181,28 @@ 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);
+ /*
+ * the default values for base/limit registers aren't specified
+ * in the PCI-to-PCI-bridge spec. So we don't thouch them here.
+ * Each implementation can override it.
+ * typical implementation does
+ * zero base/limit registers or
+ * disable forwarding: pci_bridge_disable_base_limit()
+ * If disable forwarding is wanted, call pci_bridge_disable_base_limit()
+ * after this function.
+ */
+ pci_byte_test_and_clear_mask(conf + PCI_IO_BASE,
+ PCI_IO_RANGE_MASK & 0xff);
+ pci_byte_test_and_clear_mask(conf + PCI_IO_LIMIT,
+ PCI_IO_RANGE_MASK & 0xff);
+ pci_word_test_and_clear_mask(conf + PCI_MEMORY_BASE,
+ PCI_MEMORY_RANGE_MASK & 0xffff);
+ pci_word_test_and_clear_mask(conf + PCI_MEMORY_LIMIT,
+ PCI_MEMORY_RANGE_MASK & 0xffff);
+ pci_word_test_and_clear_mask(conf + PCI_PREF_MEMORY_BASE,
+ PCI_PREF_RANGE_MASK & 0xffff);
+ pci_word_test_and_clear_mask(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);
diff --git a/hw/pci_bridge.h b/hw/pci_bridge.h
index f6fade0..84411a6 100644
--- a/hw/pci_bridge.h
+++ b/hw/pci_bridge.h
@@ -39,6 +39,7 @@ 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);
+void pci_bridge_disable_base_limit(PCIDevice *dev);
void pci_bridge_reset_reg(PCIDevice *dev);
void pci_bridge_reset(DeviceState *qdev);
--
1.7.1.1
--
yamahata
next prev parent reply other threads:[~2010-10-20 9:04 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-20 8:18 [Qemu-devel] [PATCH v6 00/12] pcie port switch emulators Isaku Yamahata
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 01/12] pcie: comment on hpev_intx Isaku Yamahata
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 02/12] pci/bridge: fix pci_bridge_reset() Isaku Yamahata
2010-10-20 8:49 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-20 9:04 ` Isaku Yamahata [this message]
2010-10-20 10:00 ` Michael S. Tsirkin
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 03/12] pcie port: define struct PCIEPort/PCIESlot and helper functions Isaku Yamahata
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 04/12] ioh3420: pcie root port in X58 ioh Isaku Yamahata
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 05/12] x3130: pcie upstream port Isaku Yamahata
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 06/12] x3130: pcie downstream port Isaku Yamahata
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 07/12] pcie/hotplug: introduce pushing attention button command Isaku Yamahata
2010-10-20 10:00 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-21 3:46 ` Isaku Yamahata
2010-10-21 8:02 ` Michael S. Tsirkin
2010-10-21 9:41 ` Isaku Yamahata
2010-10-22 11:35 ` Markus Armbruster
2010-10-22 14:38 ` Michael S. Tsirkin
2010-10-22 14:52 ` Anthony Liguori
2010-10-25 4:16 ` Michael S. Tsirkin
2010-10-25 3:29 ` Isaku Yamahata
2010-10-25 4:15 ` Michael S. Tsirkin
2010-10-25 5:53 ` Isaku Yamahata
2010-10-25 5:55 ` Michael S. Tsirkin
2010-10-25 7:02 ` Isaku Yamahata
2010-10-25 7:27 ` Michael S. Tsirkin
2010-10-27 1:47 ` Isaku Yamahata
2010-10-27 13:31 ` Michael S. Tsirkin
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 08/12] pcie/aer: helper functions for pcie aer capability Isaku Yamahata
2010-10-20 9:56 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-21 5:15 ` Isaku Yamahata
2010-10-21 8:07 ` Michael S. Tsirkin
2010-10-21 23:53 ` Isaku Yamahata
2010-10-22 9:27 ` Michael S. Tsirkin
2010-10-22 11:28 ` Markus Armbruster
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 09/12] pcie/aer: glue aer error injection into qemu monitor Isaku Yamahata
2010-10-20 9:44 ` [Qemu-devel] " Michael S. Tsirkin
2010-10-20 8:18 ` [Qemu-devel] [PATCH v6 10/12] ioh3420: support aer Isaku Yamahata
2010-10-20 8:19 ` [Qemu-devel] [PATCH v6 11/12] x3130/upstream: " Isaku Yamahata
2010-10-20 8:19 ` [Qemu-devel] [PATCH v6 12/12] x3130/downstream: " Isaku Yamahata
2010-10-20 10:09 ` [Qemu-devel] Re: [PATCH v6 00/12] 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=20101020090449.GA20484@valinux.co.jp \
--to=yamahata@valinux.co.jp \
--cc=adnan@khaleel.us \
--cc=etmartin@cisco.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=skandasa@cisco.com \
--cc=wexu2@cisco.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 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).