qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
       [not found] <200910051452.n95EphXY002170@d03av01.boulder.ibm.com>
@ 2009-10-07  8:20 ` Avi Kivity
  2009-10-07  8:22   ` Michael S. Tsirkin
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Avi Kivity @ 2009-10-07  8:20 UTC (permalink / raw)
  To: Anthony Liguori, Michael S. Tsirkin; +Cc: qemu-devel@nongnu.org, kvm-devel

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
  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:52   ` Michael S. Tsirkin
  2009-10-07 19:53   ` Michael S. Tsirkin
  2 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2009-10-07  8:22 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Anthony Liguori, qemu-devel@nongnu.org, kvm-devel

On Wed, Oct 07, 2009 at 10:20:19AM +0200, Avi Kivity wrote:
> 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.

I'll look into this.

> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
  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:52   ` Michael S. Tsirkin
  2009-10-07 19:53   ` Michael S. Tsirkin
  2 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2009-10-07  8:52 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Anthony Liguori, qemu-devel@nongnu.org, kvm-devel

On Wed, Oct 07, 2009 at 10:20:19AM +0200, Avi Kivity wrote:
> 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

Yes, cirrus does this on init:
     pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS;
Trying to understand what's the right thing to do is.

> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
  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:52   ` Michael S. Tsirkin
@ 2009-10-07 19:53   ` Michael S. Tsirkin
  2009-10-07 20:01     ` Avi Kivity
  2 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2009-10-07 19:53 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Anthony Liguori, qemu-devel@nongnu.org, kvm-devel

On Wed, Oct 07, 2009 at 10:20:19AM +0200, Avi Kivity wrote:
> 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:

Could you please tell me how to reproduce the problem exactly?
I tried several configurations but in all of them windows
seems to keep 800x600 across restarts, and shows display adapter
as cirrus vga.

-- 
MST

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
  2009-10-07 19:53   ` Michael S. Tsirkin
@ 2009-10-07 20:01     ` Avi Kivity
  2009-10-07 20:07       ` Michael S. Tsirkin
  0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-10-07 20:01 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Anthony Liguori, qemu-devel@nongnu.org, kvm-devel

On 10/07/2009 09:53 PM, Michael S. Tsirkin wrote:
> On Wed, Oct 07, 2009 at 10:20:19AM +0200, Avi Kivity wrote:
>    
>> 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:
>>      
> Could you please tell me how to reproduce the problem exactly?
> I tried several configurations but in all of them windows
> seems to keep 800x600 across restarts, and shows display adapter
> as cirrus vga.
>    

Clean Windows XP install (-smp 2), boot, reboot.

After restart it also loses S3 (so Standby is gr[ae]yed out in the 
shutdown menu).

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
  2009-10-07 20:01     ` Avi Kivity
@ 2009-10-07 20:07       ` Michael S. Tsirkin
  2009-10-07 20:12         ` Avi Kivity
  0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2009-10-07 20:07 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Anthony Liguori, qemu-devel@nongnu.org, kvm-devel

On Wed, Oct 07, 2009 at 10:01:19PM +0200, Avi Kivity wrote:
> On 10/07/2009 09:53 PM, Michael S. Tsirkin wrote:
>> On Wed, Oct 07, 2009 at 10:20:19AM +0200, Avi Kivity wrote:
>>    
>>> 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:
>>>      
>> Could you please tell me how to reproduce the problem exactly?
>> I tried several configurations but in all of them windows
>> seems to keep 800x600 across restarts, and shows display adapter
>> as cirrus vga.
>>    
>
> Clean Windows XP install (-smp 2), boot, reboot.
>
> After restart it also loses S3 (so Standby is gr[ae]yed out in the  
> shutdown menu).

OK, see it now, finally. I'll work on it.

> -- 
> Do not meddle in the internals of kernels, for they are subtle and quick to panic.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
  2009-10-07 20:07       ` Michael S. Tsirkin
@ 2009-10-07 20:12         ` Avi Kivity
  2009-10-07 20:18           ` Michael S. Tsirkin
  0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-10-07 20:12 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Anthony Liguori, qemu-devel@nongnu.org, kvm-devel

On 10/07/2009 10:07 PM, Michael S. Tsirkin wrote:
>> Clean Windows XP install (-smp 2), boot, reboot.
>>
>> After restart it also loses S3 (so Standby is gr[ae]yed out in the
>> shutdown menu).
>>      
> OK, see it now, finally. I'll work on it.
>    

What changed?  -smp 2?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] Re: [Qemu-commits] [COMMIT c0b1905] qemu/pci: reset device registers on bus reset
  2009-10-07 20:12         ` Avi Kivity
@ 2009-10-07 20:18           ` Michael S. Tsirkin
  0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2009-10-07 20:18 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Anthony Liguori, qemu-devel@nongnu.org, kvm-devel

On Wed, Oct 07, 2009 at 10:12:59PM +0200, Avi Kivity wrote:
> On 10/07/2009 10:07 PM, Michael S. Tsirkin wrote:
>>> Clean Windows XP install (-smp 2), boot, reboot.
>>>
>>> After restart it also loses S3 (so Standby is gr[ae]yed out in the
>>> shutdown menu).
>>>      
>> OK, see it now, finally. I'll work on it.
>>    
>
> What changed?  -smp 2?

/me stopped being silly.

> -- 
> Do not meddle in the internals of kernels, for they are subtle and quick to panic.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-10-07 20:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200910051452.n95EphXY002170@d03av01.boulder.ibm.com>
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:52   ` Michael S. Tsirkin
2009-10-07 19:53   ` Michael S. Tsirkin
2009-10-07 20:01     ` Avi Kivity
2009-10-07 20:07       ` Michael S. Tsirkin
2009-10-07 20:12         ` Avi Kivity
2009-10-07 20:18           ` Michael S. Tsirkin

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).