All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/3] Add pci_bus_reset() function.
@ 2009-06-17 16:32 Gleb Natapov
  2009-06-17 16:32 ` [Qemu-devel] [PATCH 2/3] Call piix3_reset() on system reset Gleb Natapov
  2009-06-17 16:32 ` [Qemu-devel] [PATCH 3/3] Register usb-uhci reset function Gleb Natapov
  0 siblings, 2 replies; 6+ messages in thread
From: Gleb Natapov @ 2009-06-17 16:32 UTC (permalink / raw)
  To: qemu-devel

To reset internal irq handling data structures.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Yaniv Kamay <ykamay@redhat.com>
---
 hw/pci.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 0a738db..140cdba 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -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;
 }
 
-- 
1.6.2.1

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

* [Qemu-devel] [PATCH 2/3] Call piix3_reset() on system reset.
  2009-06-17 16:32 [Qemu-devel] [PATCH 1/3] Add pci_bus_reset() function Gleb Natapov
@ 2009-06-17 16:32 ` Gleb Natapov
  2009-06-17 17:10   ` Blue Swirl
  2009-06-17 16:32 ` [Qemu-devel] [PATCH 3/3] Register usb-uhci reset function Gleb Natapov
  1 sibling, 1 reply; 6+ messages in thread
From: Gleb Natapov @ 2009-06-17 16:32 UTC (permalink / raw)
  To: qemu-devel

Also zero pci_irq_levels on reset to avoid stuck irq after reset.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Yaniv Kamay <ykamay@redhat.com>
---
 hw/piix_pci.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 914a65a..ff2cbde 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -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;
 }
 
-- 
1.6.2.1

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

* [Qemu-devel] [PATCH 3/3] Register usb-uhci reset function.
  2009-06-17 16:32 [Qemu-devel] [PATCH 1/3] Add pci_bus_reset() function Gleb Natapov
  2009-06-17 16:32 ` [Qemu-devel] [PATCH 2/3] Call piix3_reset() on system reset Gleb Natapov
@ 2009-06-17 16:32 ` Gleb Natapov
  2009-06-17 17:11   ` Blue Swirl
  1 sibling, 1 reply; 6+ messages in thread
From: Gleb Natapov @ 2009-06-17 16:32 UTC (permalink / raw)
  To: qemu-devel

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 <gleb@redhat.com>
---
 hw/usb-uhci.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 00e740b..ea83bdc 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -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
-- 
1.6.2.1

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

* Re: [Qemu-devel] [PATCH 2/3] Call piix3_reset() on system reset.
  2009-06-17 16:32 ` [Qemu-devel] [PATCH 2/3] Call piix3_reset() on system reset Gleb Natapov
@ 2009-06-17 17:10   ` Blue Swirl
  2009-06-18  6:02     ` Gleb Natapov
  0 siblings, 1 reply; 6+ messages in thread
From: Blue Swirl @ 2009-06-17 17:10 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: qemu-devel

On 6/17/09, Gleb Natapov <gleb@redhat.com> wrote:
> Also zero pci_irq_levels on reset to avoid stuck irq after reset.
>
>  Signed-off-by: Gleb Natapov <gleb@redhat.com>
>  Signed-off-by: Yaniv Kamay <ykamay@redhat.com>

Thanks, applied.

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

* Re: [Qemu-devel] [PATCH 3/3] Register usb-uhci reset function.
  2009-06-17 16:32 ` [Qemu-devel] [PATCH 3/3] Register usb-uhci reset function Gleb Natapov
@ 2009-06-17 17:11   ` Blue Swirl
  0 siblings, 0 replies; 6+ messages in thread
From: Blue Swirl @ 2009-06-17 17:11 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: qemu-devel

On 6/17/09, Gleb Natapov <gleb@redhat.com> wrote:
> 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 <gleb@redhat.com>

Thanks, applied.

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

* Re: [Qemu-devel] [PATCH 2/3] Call piix3_reset() on system reset.
  2009-06-17 17:10   ` Blue Swirl
@ 2009-06-18  6:02     ` Gleb Natapov
  0 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2009-06-18  6:02 UTC (permalink / raw)
  To: Blue Swirl; +Cc: qemu-devel

On Wed, Jun 17, 2009 at 08:10:23PM +0300, Blue Swirl wrote:
> On 6/17/09, Gleb Natapov <gleb@redhat.com> wrote:
> > Also zero pci_irq_levels on reset to avoid stuck irq after reset.
> >
> >  Signed-off-by: Gleb Natapov <gleb@redhat.com>
> >  Signed-off-by: Yaniv Kamay <ykamay@redhat.com>
> 
> 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.

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

end of thread, other threads:[~2009-06-18  6:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-17 16:32 [Qemu-devel] [PATCH 1/3] Add pci_bus_reset() function Gleb Natapov
2009-06-17 16:32 ` [Qemu-devel] [PATCH 2/3] Call piix3_reset() on system reset Gleb Natapov
2009-06-17 17:10   ` Blue Swirl
2009-06-18  6:02     ` Gleb Natapov
2009-06-17 16:32 ` [Qemu-devel] [PATCH 3/3] Register usb-uhci reset function Gleb Natapov
2009-06-17 17:11   ` Blue Swirl

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.