All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@kernel.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Helge Deller <deller@gmx.de>
Subject: Re: [PULL 2/6] hw/hppa: Wire up Diva GSP card
Date: Fri, 6 Mar 2026 19:12:57 +0100	[thread overview]
Message-ID: <aasZKZ1FQY5ytrb2@p100> (raw)
In-Reply-To: <CAFEAcA_VWSYYE+GdDRwxpWzOX6qVYptjYOe--azOzo4_pre_+A@mail.gmail.com>

* Peter Maydell <peter.maydell@linaro.org>:
> On Fri, 7 Feb 2025 at 21:08, <deller@kernel.org> wrote:
> >
> > From: Helge Deller <deller@gmx.de>
> >
> > Until now we used a standard serial-pci device to emulate a HP serial
> > console.  This worked nicely with 32-bit Linux and 32-bit HP-UX, but
> > 64-bit HP-UX crashes with it and expects either a Diva GSP card, or a real
> > 64-bit capable PCI graphic card (which we don't have yet).
> > In order to continue with 64-bit HP-UX, switch over to the recently
> > added Diva GSP card emulation.
> >
> > Signed-off-by: Helge Deller <deller@gmx.de>
> 
> Hi; I've been looking at memory leaks reported by the clang
> address-sanitizer, and it flags one up introduced by this change
> from last year:
> 
> 
> > @@ -383,26 +383,17 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
> 
> > +    /* BMC board: HP Diva GSP */
> > +    dev = qdev_new("diva-gsp");
> 
> Here we create a new diva-gsp device...
> 
> > +    if (!object_property_get_bool(OBJECT(dev), "disable", NULL)) {
> 
> ...but then after looking at the "disable" property on it we
> do nothing else with it, and instead...
> 
> > +        pci_dev = pci_new_multifunction(PCI_DEVFN(2, 0), "diva-gsp");
> 
> ...create a second instance of it via pci_new_multifunction().
> So now there are two copies of this device, one half-initialized
> and leaked, and the second one which we actually use.
 
Nice catch!

> What is the intention here? The value of the "disable" property
> on the device is presumably just going to be its default "false"
> value all the time, so can we drop that check entirely and
> create the device via pci_new_multifunction() unconditionally?

Yes.

Background: During development of the various machines it was
easier for me to just disable/enable the Diva card from the command
line via the "disable" property.
Commit 16786eb7bf86 ("hw/hppa: Add BMC on 64-bit machines only") now
simply disables diva on B160L, and for the C3700, although it never
had Diva boards, we will use Diva until we get SuperIO implemented.

The patch below should address this.
Maybe you can review?

Thanks!
Helge


From: Helge Deller <deller@gmx.de>
Subject: [PATCH] hw/hppa: Avoid leaking a diva-gsp device

Create a Diva-gsp unconditionally on all 64-bit PCI machines.
The A400 usually comes with a Diva card. The C3700 has a built-in
SUPERIO chip, which we haven't implemented yet, so running with an
emulated Diva is the best we can do for now.

Signed-off-by: Helge Deller <deller@gmx.de>
Noticed-by: Peter Maydell <peter.maydell@linaro.org>

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index f55e84529f..50ace81528 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -380,18 +380,15 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,
 
     if (pci_bus && hppa_is_pa20(&cpu[0]->env)) {
         /* BMC board: HP Diva GSP PCI card */
-        dev = qdev_new("diva-gsp");
-        if (dev && !object_property_get_bool(OBJECT(dev), "disable", NULL)) {
-            pci_dev = pci_new_multifunction(PCI_DEVFN(2, 0), "diva-gsp");
-            if (!lasi_dev) {
-                /* bind default keyboard/serial to Diva card */
-                qdev_prop_set_chr(DEVICE(pci_dev), "chardev1", serial_hd(0));
-                qdev_prop_set_chr(DEVICE(pci_dev), "chardev2", serial_hd(1));
-                qdev_prop_set_chr(DEVICE(pci_dev), "chardev3", serial_hd(2));
-                qdev_prop_set_chr(DEVICE(pci_dev), "chardev4", serial_hd(3));
-            }
-            pci_realize_and_unref(pci_dev, pci_bus, &error_fatal);
+        pci_dev = pci_new_multifunction(PCI_DEVFN(2, 0), "diva-gsp");
+        if (!lasi_dev) {
+            /* bind default keyboard/serial to Diva card */
+            qdev_prop_set_chr(DEVICE(pci_dev), "chardev1", serial_hd(0));
+            qdev_prop_set_chr(DEVICE(pci_dev), "chardev2", serial_hd(1));
+            qdev_prop_set_chr(DEVICE(pci_dev), "chardev3", serial_hd(2));
+            qdev_prop_set_chr(DEVICE(pci_dev), "chardev4", serial_hd(3));
         }
+        pci_realize_and_unref(pci_dev, pci_bus, &error_fatal);
     }
 
     /* create USB OHCI controller for USB keyboard & mouse on Astro machines */


  reply	other threads:[~2026-03-06 18:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-07 21:05 [PULL 0/6] Hppa system for v10 diva artist patches deller
2025-02-07 21:05 ` [PULL 1/6] hw/char: Add emulation of Diva GSP PCI management boards deller
2025-02-07 21:05 ` [PULL 2/6] hw/hppa: Wire up Diva GSP card deller
2026-03-06 17:22   ` Peter Maydell
2026-03-06 18:12     ` Helge Deller [this message]
2026-03-06 18:19       ` Peter Maydell
2026-03-06 18:33         ` Helge Deller
2026-03-06 18:56           ` Peter Maydell
2026-03-06 20:40             ` Helge Deller
2026-03-06 21:15               ` BALATON Zoltan
2026-03-06 21:17                 ` Helge Deller
2026-03-07 10:46               ` Peter Maydell
2026-03-07 11:41                 ` Helge Deller
2026-03-07 11:57                   ` Peter Maydell
2025-02-07 21:05 ` [PULL 3/6] artist: Allow disabling artist on command line deller
2025-02-07 21:05 ` [PULL 4/6] hw/hppa: Avoid creation of artist if disabled " deller
2025-02-07 21:05 ` [PULL 5/6] hw/pci-host/astro: Add LMMIO range support deller
2025-02-07 21:05 ` [PULL 6/6] target/hppa: Update SeaBIOS-hppa deller
2025-02-08 16:08 ` [PULL 0/6] Hppa system for v10 diva artist patches Stefan Hajnoczi

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=aasZKZ1FQY5ytrb2@p100 \
    --to=deller@kernel.org \
    --cc=deller@gmx.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@redhat.com \
    /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.