From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
kvm-devel <kvm@vger.kernel.org>
Subject: Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
Date: Wed, 07 Oct 2009 10:20:19 +0200 [thread overview]
Message-ID: <4ACC4F43.1010906@redhat.com> (raw)
In-Reply-To: <200910051452.n95EphXY002170@d03av01.boulder.ibm.com>
On 10/05/2009 04:53 PM, Anthony Liguori wrote:
> From: Michael S. Tsirkin<mst@redhat.com>
>
> Reset BARs and a couple of other registers on bus reset, as per PCI
> spec.
>
This commit breaks Windows XP restart. After a restart Windows switches
from 800x600 cirrus logic vga to 640x480 standard vga. My guess is that
this is due to two mutually-cancelling bugs:
- the bios fails to initialize one of the registers touched below
- qemu sets up that register in the state the Windows expects the bios
to leave it in instead of the on-reset state
Once we perform the reset the register reverts to its correct reset
state, the bios fails to initialize it, and Windows ignores the device.
I reverted this commit from qemu-kvm.git.
> diff --git a/hw/pci.c b/hw/pci.c
> index 2dd7213..e2f88ff 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -92,7 +92,20 @@ static inline int pci_bar(int reg)
>
> static void pci_device_reset(PCIDevice *dev)
> {
> + int r;
> +
> memset(dev->irq_state, 0, sizeof dev->irq_state);
> + 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) {
> + continue;
> + }
> + pci_set_long(dev->config + pci_bar(r), dev->io_regions[r].type);
> + }
> + pci_update_mappings(dev);
> }
>
> static void pci_bus_reset(void *opaque)
>
>
>
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
WARNING: multiple messages have this Message-ID (diff)
From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
kvm-devel <kvm@vger.kernel.org>
Subject: [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
Date: Wed, 07 Oct 2009 10:20:19 +0200 [thread overview]
Message-ID: <4ACC4F43.1010906@redhat.com> (raw)
In-Reply-To: <200910051452.n95EphXY002170@d03av01.boulder.ibm.com>
On 10/05/2009 04:53 PM, Anthony Liguori wrote:
> From: Michael S. Tsirkin<mst@redhat.com>
>
> Reset BARs and a couple of other registers on bus reset, as per PCI
> spec.
>
This commit breaks Windows XP restart. After a restart Windows switches
from 800x600 cirrus logic vga to 640x480 standard vga. My guess is that
this is due to two mutually-cancelling bugs:
- the bios fails to initialize one of the registers touched below
- qemu sets up that register in the state the Windows expects the bios
to leave it in instead of the on-reset state
Once we perform the reset the register reverts to its correct reset
state, the bios fails to initialize it, and Windows ignores the device.
I reverted this commit from qemu-kvm.git.
> diff --git a/hw/pci.c b/hw/pci.c
> index 2dd7213..e2f88ff 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -92,7 +92,20 @@ static inline int pci_bar(int reg)
>
> static void pci_device_reset(PCIDevice *dev)
> {
> + int r;
> +
> memset(dev->irq_state, 0, sizeof dev->irq_state);
> + 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) {
> + continue;
> + }
> + pci_set_long(dev->config + pci_bar(r), dev->io_regions[r].type);
> + }
> + pci_update_mappings(dev);
> }
>
> static void pci_bus_reset(void *opaque)
>
>
>
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
next parent reply other threads:[~2009-10-07 8:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200910051452.n95EphXY002170@d03av01.boulder.ibm.com>
2009-10-07 8:20 ` Avi Kivity [this message]
2009-10-07 8:20 ` [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset Avi Kivity
2009-10-07 8:22 ` Michael S. Tsirkin
2009-10-07 8:22 ` [Qemu-devel] " Michael S. Tsirkin
2009-10-07 8:52 ` Michael S. Tsirkin
2009-10-07 8:52 ` [Qemu-devel] " Michael S. Tsirkin
2009-10-07 19:53 ` Michael S. Tsirkin
2009-10-07 19:53 ` [Qemu-devel] " Michael S. Tsirkin
2009-10-07 20:01 ` Avi Kivity
2009-10-07 20:01 ` [Qemu-devel] " Avi Kivity
2009-10-07 20:07 ` Michael S. Tsirkin
2009-10-07 20:07 ` [Qemu-devel] " Michael S. Tsirkin
2009-10-07 20:12 ` Avi Kivity
2009-10-07 20:12 ` [Qemu-devel] " Avi Kivity
2009-10-07 20:18 ` Michael S. Tsirkin
2009-10-07 20:18 ` [Qemu-devel] " 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=4ACC4F43.1010906@redhat.com \
--to=avi@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=kvm@vger.kernel.org \
--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 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.