From: "Michael S. Tsirkin" <mst@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: stefano.stabellini@eu.citrix.com, jan.kiszka@siemens.com,
allen.m.kay@intel.com, qemu-devel@nongnu.org,
blauwirbel@gmail.com, kraxel@redhat.com, jean.guyader@gmail.com
Subject: [Qemu-devel] Re: [PATCH 03/10] pci: fix pci_bus_reset() with 64bit BAR and several clean ups.
Date: Thu, 17 Jun 2010 13:58:44 +0300 [thread overview]
Message-ID: <20100617105843.GA10383@redhat.com> (raw)
In-Reply-To: <551d7f5ea27a3bf8fcf69dea059d237493a92a2b.1276755023.git.yamahata@valinux.co.jp>
On Thu, Jun 17, 2010 at 03:15:45PM +0900, Isaku Yamahata wrote:
> fix pci_device_reset() with 64bit BAR.
> export pci_bus_reset(), pci_device_reset() and two helper functions
> for later use. And several clean ups.
>
> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
> ---
> hw/pci.c | 44 ++++++++++++++++++++++++++++++++++++--------
> hw/pci.h | 5 +++++
> 2 files changed, 41 insertions(+), 8 deletions(-)
>
> diff --git a/hw/pci.c b/hw/pci.c
> index 9ba62eb..87f5e6c 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -144,28 +144,50 @@ static void pci_update_irq_status(PCIDevice *dev)
> }
> }
>
> -static void pci_device_reset(PCIDevice *dev)
> +void pci_device_reset_default(PCIDevice *dev)
> {
> int r;
>
> dev->irq_state = 0;
> pci_update_irq_status(dev);
> - dev->config[PCI_COMMAND] &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
> - PCI_COMMAND_MASTER);
> + pci_set_word(dev->config + PCI_COMMAND,
> + pci_get_word(dev->config + PCI_COMMAND) &
> + ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER));
> dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
> dev->config[PCI_INTERRUPT_LINE] = 0x0;
> for (r = 0; r < PCI_NUM_REGIONS; ++r) {
> - if (!dev->io_regions[r].size) {
> + PCIIORegion *region = &dev->io_regions[r];
> + if (!region->size) {
> continue;
> }
> - pci_set_long(dev->config + pci_bar(dev, r), dev->io_regions[r].type);
> +
> + if (!(region->type & PCI_BASE_ADDRESS_SPACE_IO) &&
> + region->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
> + pci_set_quad(dev->config + pci_bar(dev, r), region->type);
> + } else {
> + pci_set_long(dev->config + pci_bar(dev, r), region->type);
> + }
> }
> pci_update_mappings(dev);
> }
>
I applied the first hunk. Looking at it
made me notice that we don't clear interrupt disable
bit on reset, and we really should as it is read/write.
Rather than duplicating code, we should just use wmask.
I ended up with this:
commit b82d3876099c4f1fd009082f052e3bac7e3062e7
Author: Isaku Yamahata <yamahata@valinux.co.jp>
Date: Thu Jun 17 15:15:45 2010 +0900
pci: fix pci_device_reset
Clear interrupt disable bit on reset, according to PCI spec.
Fix pci_device_reset() with 64bit BAR.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
diff --git a/hw/pci.c b/hw/pci.c
index 7787005..de33745 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -150,15 +150,24 @@ static void pci_device_reset(PCIDevice *dev)
dev->irq_state = 0;
pci_update_irq_status(dev);
- dev->config[PCI_COMMAND] &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
- PCI_COMMAND_MASTER);
+ /* Clear all writeable bits */
+ pci_set_word(dev->config + PCI_COMMAND,
+ pci_get_word(dev->config + PCI_COMMAND) &
+ ~pci_get_word(dev->wmask + PCI_COMMAND));
dev->config[PCI_CACHE_LINE_SIZE] = 0x0;
dev->config[PCI_INTERRUPT_LINE] = 0x0;
for (r = 0; r < PCI_NUM_REGIONS; ++r) {
- if (!dev->io_regions[r].size) {
+ PCIIORegion *region = &dev->io_regions[r];
+ if (!region->size) {
continue;
}
- pci_set_long(dev->config + pci_bar(dev, r), dev->io_regions[r].type);
+
+ if (!(region->type & PCI_BASE_ADDRESS_SPACE_IO) &&
+ region->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
+ pci_set_quad(dev->config + pci_bar(dev, r), region->type);
+ } else {
+ pci_set_long(dev->config + pci_bar(dev, r), region->type);
+ }
}
pci_update_mappings(dev);
}
next prev parent reply other threads:[~2010-06-17 11:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-17 6:15 [Qemu-devel] [PATCH 00/10] pci: pci to pci bridge clean up and enhancement Isaku Yamahata
2010-06-17 6:15 ` [Qemu-devel] [PATCH 01/10] pci_bridge: split out pci bridge code into pci_bridge.c from pci.c Isaku Yamahata
2010-06-17 6:15 ` [Qemu-devel] [PATCH 02/10] qdev: export qdev_reset() for later use Isaku Yamahata
2010-06-17 7:01 ` Markus Armbruster
2010-06-17 10:05 ` [Qemu-devel] " Michael S. Tsirkin
2010-06-17 6:15 ` [Qemu-devel] [PATCH 03/10] pci: fix pci_bus_reset() with 64bit BAR and several clean ups Isaku Yamahata
2010-06-17 10:58 ` Michael S. Tsirkin [this message]
2010-06-17 6:15 ` [Qemu-devel] [PATCH 04/10] pci_bridge: introduce pci bridge layer Isaku Yamahata
2010-06-17 9:52 ` [Qemu-devel] " Michael S. Tsirkin
2010-06-17 6:15 ` [Qemu-devel] [PATCH 05/10] pci bridge: add helper function for ssvid capability Isaku Yamahata
2010-06-17 10:01 ` [Qemu-devel] " Michael S. Tsirkin
2010-06-17 6:15 ` [Qemu-devel] [PATCH 06/10] pci: eliminate work around in pci_device_reset() Isaku Yamahata
2010-06-17 6:15 ` [Qemu-devel] [PATCH 07/10] pci: fix pci domain registering Isaku Yamahata
2010-06-17 6:15 ` [Qemu-devel] [PATCH 08/10] pci: remove PCIDeviceInfo::header_type Isaku Yamahata
2010-06-17 6:15 ` [Qemu-devel] [PATCH 09/10] pci: set PCI multi-function bit appropriately Isaku Yamahata
2010-06-17 9:37 ` [Qemu-devel] " Michael S. Tsirkin
2010-06-18 2:40 ` Isaku Yamahata
2010-06-18 12:44 ` Michael S. Tsirkin
2010-06-18 13:38 ` Isaku Yamahata
2010-06-18 14:59 ` Michael S. Tsirkin
2010-06-18 15:22 ` Jamie Lokier
2010-06-20 10:03 ` Michael S. Tsirkin
2010-06-17 6:15 ` [Qemu-devel] [PATCH 10/10] pci: don't overwrite multi functio bit in pci header type Isaku Yamahata
2010-06-17 9:41 ` [Qemu-devel] " Michael S. Tsirkin
2010-06-17 10:02 ` [Qemu-devel] Re: [PATCH 00/10] pci: pci to pci bridge clean up and enhancement Michael S. Tsirkin
2010-06-17 11:57 ` Michael S. Tsirkin
2010-06-18 3:26 ` Isaku Yamahata
2010-06-18 12:46 ` 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=20100617105843.GA10383@redhat.com \
--to=mst@redhat.com \
--cc=allen.m.kay@intel.com \
--cc=blauwirbel@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=jean.guyader@gmail.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.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).