Add pci_bus_reset() function.
PATCH 1/3 Add pci_bus_reset() function.
To reset internal irq handling data structures.
--- hw/pci.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
hw/pci.c +16 -0
@@ -87,6 +87,21 @@ static int pcibus_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } +static void pci_bus_reset (void *opaque) +{ +PCIBus *bus = (PCIBus *)opaque; +int i; + +for (i =0 ; i < bus->nirq; i++) { + bus->irq_count[i] =0 ; + } +for (i =0 ; i <256 ; i++) { +if (bus->devices[i]) +memset (bus->devices[i]->irq_state,0 , +sizeof (bus->devices[i]->irq_state)); + } +} +PCIBus *pci_register_bus (DeviceState *parent,const char *name,pci_set_irq_fn set_irq,pci_map_irq_fn map_irq,qemu_irq *pic,int devfn_min,int nirq)
@@ -105,6 +120,7 @@ PCIBus *pci_register_bus(DeviceState *parent, const char *name, bus->next = first_bus; first_bus = bus;register_savevm ("PCIBUS" , nbus++,1 , pcibus_save, pcibus_load, bus); +qemu_register_reset (pci_bus_reset,0 , bus);return bus; }
Signature · 1 line
1.6.2.1
PATCH 2/3 Call piix3_reset() on system reset.
Also zero pci_irq_levels on reset to avoid stuck irq after reset.
--- hw/piix_pci.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
hw/piix_pci.c +5 -1
@@ -232,8 +232,9 @@ static void piix3_set_irq(qemu_irq *pic, int irq_num, int level) } } -static void piix3_reset (PCIDevice *d) +static void piix3_reset (void *opaque) { +PCIDevice *d = opaque;uint8_t *pci_conf = d->config; pci_conf[0x04 ] =0x07 ;// master, memory and I/O
@@ -267,6 +268,8 @@ static void piix3_reset(PCIDevice *d) pci_conf[0xab ] =0x00 ; pci_conf[0xac ] =0x00 ; pci_conf[0xae ] =0x00 ; + +memset (pci_irq_levels,0 ,sizeof (pci_irq_levels)); }static void piix4_reset (PCIDevice *d)
@@ -339,6 +342,7 @@ int piix3_init(PCIBus *bus, int devfn)PCI_HEADER_TYPE_NORMAL |PCI_HEADER_TYPE_MULTI_FUNCTION ;// header_type = PCI_multifunction, generic piix3_reset (d); +qemu_register_reset (piix3_reset,0 , d);return d->devfn; }
Signature · 1 line
1.6.2.1
Blue Swirl
AppliedRe: [Qemu-devel] [PATCH 2/3] Call piix3_reset() on system reset.
Quoted 4 lines · Gleb Natapov
Also zero
pci_irq_levelson reset to avoid stuck irq after reset.Signed-off-by Gleb Natapov <[email protected]>Signed-off-by Yaniv Kamay <[email protected]>
Thanks, applied.
Re: [Qemu-devel] [PATCH 2/3] Call piix3_reset() on system reset.
Quoted 7 lines · Blue Swirl
Quoted 4 lines · Gleb Natapov
Also zero
pci_irq_levelson reset to avoid stuck irq after reset.Signed-off-by Gleb Natapov <[email protected]>Signed-off-by Yaniv Kamay <[email protected]>Thanks, applied.
Thanks, but without 1/3 reset is still buggy. Look at hw/pci.c:pci_set_irq() If pci_dev->irq_state[irq_num] == 1 at reset time it will stay 1 after reset too. When device will try to race IRQ line after reset it will fail to do so. And if bus->irq_count[] is not zeroed you have another set of problems. If you don't like that pci_bus_reset() reset per device state (why?) it is possible to create pci_device_reset(), but then we will have to fix 25 devices to call it. Complication for no good reason. IMHO pci_device_save/load should be handled in hw/pci.c too. What are the disadvantages?
--
Gleb.
PATCH 3/3 Register usb-uhci reset function.
In reply to Gleb NatapovThe device is not reset on system reset currently. Without this patch RHEL4.8 hangs after reboot if -usbdevice table is in use.
--- hw/usb-uhci.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
hw/usb-uhci.c +4 -1
@@ -319,8 +319,9 @@ static void uhci_update_irq(UHCIState *s)qemu_set_irq (s->dev.irq[3 ], level); } -static void uhci_reset (UHCIState *s) +static void uhci_reset (void *opaque) { +UHCIState *s = opaque;uint8_t *pci_conf;int i;UHCIPort *port;
@@ -1093,6 +1094,7 @@ void usb_uhci_piix3_init(PCIBus *bus, int devfn) } s->frame_timer =qemu_new_timer (vm_clock, uhci_frame_timer, s); +qemu_register_reset (uhci_reset,0 , s);uhci_reset (s);/* Use region 4 for consistency with real hardware. BSD guests seem
@@ -1127,6 +1129,7 @@ void usb_uhci_piix4_init(PCIBus *bus, int devfn) } s->frame_timer =qemu_new_timer (vm_clock, uhci_frame_timer, s); +qemu_register_reset (uhci_reset,0 , s);uhci_reset (s);/* Use region 4 for consistency with real hardware. BSD guests seem
Signature · 1 line
1.6.2.1
Blue Swirl
AppliedRe: [Qemu-devel] [PATCH 3/3] Register usb-uhci reset function.
Quoted 5 lines · Gleb Natapov
The device is not reset on system reset currently.
Without this patch RHEL4.8 hangs after reboot if -usbdevice table is in use.Signed-off-by Gleb Natapov <[email protected]>
Thanks, applied.