qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/1] serial: fix multi-pci card error cleanup.
@ 2015-05-19 10:54 Gerd Hoffmann
  2015-05-19 10:54 ` [Qemu-devel] [PULL 1/1] " Gerd Hoffmann
  2015-05-19 14:13 ` [Qemu-devel] [PULL 0/1] " Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2015-05-19 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Error handling fix for the multiport pci-serial cards.

please pull,
  Gerd

The following changes since commit faa261a7fb254866bdd5b6a25ad94677945f21b4:

  Merge remote-tracking branch 'remotes/pmaydell/tags/pull-cocoa-20150519' into staging (2015-05-19 10:25:59 +0100)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-serial-20150519-1

for you to fetch changes up to a48da7b5bc1f0c98e7a124337140efd47049066c:

  serial: fix multi-pci card error cleanup. (2015-05-19 12:47:08 +0200)

----------------------------------------------------------------
serial: fix multi-pci card error cleanup.

----------------------------------------------------------------
Gerd Hoffmann (1):
      serial: fix multi-pci card error cleanup.

 hw/char/serial-pci.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

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

* [Qemu-devel] [PULL 1/1] serial: fix multi-pci card error cleanup.
  2015-05-19 10:54 [Qemu-devel] [PULL 0/1] serial: fix multi-pci card error cleanup Gerd Hoffmann
@ 2015-05-19 10:54 ` Gerd Hoffmann
  2015-05-19 14:13 ` [Qemu-devel] [PULL 0/1] " Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2015-05-19 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Put the number of serial ports into a local variable in
multi_serial_pci_realize, then increment the port count
(pci->ports) as we initialize the serial port cores.

Now pci->ports always holds the number of successfully
initialized ports and we can use multi_serial_pci_exit
to properly cleanup the already initialized bits in case
of a init failure.

https://bugzilla.redhat.com/show_bug.cgi?id=970551

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/char/serial-pci.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index 467c3b4..653064f 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -48,6 +48,8 @@ typedef struct PCIMultiSerialState {
     uint8_t      prog_if;
 } PCIMultiSerialState;
 
+static void multi_serial_pci_exit(PCIDevice *dev);
+
 static void serial_pci_realize(PCIDevice *dev, Error **errp)
 {
     PCISerialState *pci = DO_UPCAST(PCISerialState, dev, dev);
@@ -89,32 +91,33 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
     PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev);
     SerialState *s;
     Error *err = NULL;
-    int i;
+    int i, nr_ports = 0;
 
     switch (pc->device_id) {
     case 0x0003:
-        pci->ports = 2;
+        nr_ports = 2;
         break;
     case 0x0004:
-        pci->ports = 4;
+        nr_ports = 4;
         break;
     }
-    assert(pci->ports > 0);
-    assert(pci->ports <= PCI_SERIAL_MAX_PORTS);
+    assert(nr_ports > 0);
+    assert(nr_ports <= PCI_SERIAL_MAX_PORTS);
 
     pci->dev.config[PCI_CLASS_PROG] = pci->prog_if;
     pci->dev.config[PCI_INTERRUPT_PIN] = 0x01;
-    memory_region_init(&pci->iobar, OBJECT(pci), "multiserial", 8 * pci->ports);
+    memory_region_init(&pci->iobar, OBJECT(pci), "multiserial", 8 * nr_ports);
     pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->iobar);
     pci->irqs = qemu_allocate_irqs(multi_serial_irq_mux, pci,
-                                   pci->ports);
+                                   nr_ports);
 
-    for (i = 0; i < pci->ports; i++) {
+    for (i = 0; i < nr_ports; i++) {
         s = pci->state + i;
         s->baudbase = 115200;
         serial_realize_core(s, &err);
         if (err != NULL) {
             error_propagate(errp, err);
+            multi_serial_pci_exit(dev);
             return;
         }
         s->irq = pci->irqs[i];
@@ -122,6 +125,7 @@ static void multi_serial_pci_realize(PCIDevice *dev, Error **errp)
         memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s,
                               pci->name[i], 8);
         memory_region_add_subregion(&pci->iobar, 8 * i, &s->io);
+        pci->ports++;
     }
 }
 
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PULL 0/1] serial: fix multi-pci card error cleanup.
  2015-05-19 10:54 [Qemu-devel] [PULL 0/1] serial: fix multi-pci card error cleanup Gerd Hoffmann
  2015-05-19 10:54 ` [Qemu-devel] [PULL 1/1] " Gerd Hoffmann
@ 2015-05-19 14:13 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2015-05-19 14:13 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 19 May 2015 at 11:54, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> Error handling fix for the multiport pci-serial cards.
>
> please pull,
>   Gerd
>
> The following changes since commit faa261a7fb254866bdd5b6a25ad94677945f21b4:
>
>   Merge remote-tracking branch 'remotes/pmaydell/tags/pull-cocoa-20150519' into staging (2015-05-19 10:25:59 +0100)
>
> are available in the git repository at:
>
>
>   git://git.kraxel.org/qemu tags/pull-serial-20150519-1
>
> for you to fetch changes up to a48da7b5bc1f0c98e7a124337140efd47049066c:
>
>   serial: fix multi-pci card error cleanup. (2015-05-19 12:47:08 +0200)
>
> ----------------------------------------------------------------
> serial: fix multi-pci card error cleanup.

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2015-05-19 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-19 10:54 [Qemu-devel] [PULL 0/1] serial: fix multi-pci card error cleanup Gerd Hoffmann
2015-05-19 10:54 ` [Qemu-devel] [PULL 1/1] " Gerd Hoffmann
2015-05-19 14:13 ` [Qemu-devel] [PULL 0/1] " Peter Maydell

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