Skip to contentSkip to conversation

hw/arm/bcm2836: Mark the bcm2836 / bcm2837 devices with user_creatable = false

PATCH In review Thomas Huth 3 participants 6 messages Jul 12, 2018 – Jul 16, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/bcm2836: Mark the bcm2836 / bcm2837 devices with user_creatable = false

These devices are currently causing some problems when a user is trying to hot-plug or introspect them during runtime. Since these devices can not be instantiated by the user at all (they need to be wired up in code instead), we should mark them with user_creatable = false anyway, then we avoid at least the crashes with the hot-plugging. The introspection problem will be handled by a separate patch.

---
 hw/arm/bcm2836.c | 2 ++
 1 file changed, 2 insertions(+)
hw/arm/bcm2836.c +2 -0
index 6805a7d..45d9e40 100644
@@ -185,6 +185,8 @@ static void bcm283x_class_init(ObjectClass *oc, void *data)
     bc->info = data;
     dc->realize = bcm2836_realize;
     dc->props = bcm2836_props;
+    /* Reason: Must be wired up in code (see raspi_init() function) */
+    dc->user_creatable = false;
 }
 
 static const TypeInfo bcm283x_type_info = {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 9 lines · Thomas Huth

These devices are currently causing some problems when a user is trying to hot-plug or introspect them during runtime. Since these devices can not be instantiated by the user at all (they need to be wired up in code instead), we should mark them with user_creatable = false anyway, then we avoid at least the crashes with the hot-plugging. The introspection problem will be handled by a separate patch.

---

I thought we'd changed things so all sysbus devices defaulted to not-user-createable? Am I confusing that with something else? (The set of user-creatable sysbus devices must be very small...)

thanks
-- PMM

#2 lore raw
Quoted 11 lines · Peter Maydell
Quoted 6 lines · Thomas Huth

These devices are currently causing some problems when a user is trying to hot-plug or introspect them during runtime. Since these devices can not be instantiated by the user at all (they need to be wired up in code instead), we should mark them with user_creatable = false anyway, then we avoid at least the crashes with the hot-plugging. The introspection problem will be handled by a separate patch.

I thought we'd changed things so all sysbus devices defaulted to not-user-createable? Am I confusing that with something else? (The set of user-creatable sysbus devices must be very small...)

You remember it right, but TYPE_BCM283X is not a sysbus device, it is declared with ".parent = TYPE_DEVICE" instead.

Thomas

Reviewed-by
#3 lore raw
Quoted 9 lines · Thomas Huth
Quoted 8 lines · Peter Maydell
Quoted 6 lines · Thomas Huth

These devices are currently causing some problems when a user is trying to hot-plug or introspect them during runtime. Since these devices can not be instantiated by the user at all (they need to be wired up in code instead), we should mark them with user_creatable = false anyway, then we avoid at least the crashes with the hot-plugging. The introspection problem will be handled by a separate patch.

Quoted 6 lines
Quoted 3 lines

I thought we'd changed things so all sysbus devices defaulted to not-user-createable? Am I confusing that with something else? (The set of user-creatable sysbus devices must be very small...)

You remember it right, but TYPE_BCM283X is not a sysbus device, it is declared with ".parent = TYPE_DEVICE" instead.

So it is. (Which sort of makes sense I suppose, though we're not entirely consistent about whether SoC containers are sysbus or plain device.)

and I'll apply this to target-arm.next for 3.0.

thanks
-- PMM

Reviewed-by on v1 1/1
#4 lore raw
In reply to Thomas Huth
Quoted 17 lines · Thomas Huth

These devices are currently causing some problems when a user is trying to hot-plug or introspect them during runtime. Since these devices can not be instantiated by the user at all (they need to be wired up in code instead), we should mark them with user_creatable = false anyway, then we avoid at least the crashes with the hot-plugging. The introspection problem will be handled by a separate patch.

---
 hw/arm/bcm2836.c | 2 ++
 1 file changed, 2 insertions(+)
hw/arm/bcm2836.c +0 -0
index 6805a7d..45d9e40 100644

hw/arm/bcm2836.c static void bcm283x_class_init(ObjectClass *oc, void *data) · line 192

Quoted 8 lines
hw/arm/bcm2836.c +2 -0
@@ -185,6 +185,8 @@ static void bcm283x_class_init(ObjectClass *oc, void *data)
     bc->info = data;
     dc->realize = bcm2836_realize;
     dc->props = bcm2836_props;
+    /* Reason: Must be wired up in code (see raspi_init() function) */
+    dc->user_creatable = false;
 }
 
 static const TypeInfo bcm283x_type_info = {

A more common way to phrase this is

       /* Reason: needs to be wired-up by raspi_init() */

If you you expect other functions to wire this one up in the future, insert ", e.g." before "by".

I like consistency in such things, but it's matter of taste, thus:

#5 lore raw
Quoted 26 lines · Markus Armbruster
Quoted 24 lines · Thomas Huth

These devices are currently causing some problems when a user is trying to hot-plug or introspect them during runtime. Since these devices can not be instantiated by the user at all (they need to be wired up in code instead), we should mark them with user_creatable = false anyway, then we avoid at least the crashes with the hot-plugging. The introspection problem will be handled by a separate patch.

---
 hw/arm/bcm2836.c | 2 ++
 1 file changed, 2 insertions(+)
hw/arm/bcm2836.c +2 -0
index 6805a7d..45d9e40 100644
@@ -185,6 +185,8 @@ static void bcm283x_class_init(ObjectClass *oc, void *data)
     bc->info = data;
     dc->realize = bcm2836_realize;
     dc->props = bcm2836_props;
+    /* Reason: Must be wired up in code (see raspi_init() function) */
+    dc->user_creatable = false;
 }
 
Quoted 8 lines

hw/arm/bcm2836.c static void bcm283x_class_init(ObjectClass *oc, void *data) · line 192

Quoted 1 line
hw/arm/bcm2836.c +0 -0
 static const TypeInfo bcm283x_type_info = {

A more common way to phrase this is

       /* Reason: needs to be wired-up by raspi_init() */

If you you expect other functions to wire this one up in the future, insert ", e.g." before "by".

$ grep -r Reason.*wire hw/
hw/acpi/piix4.c:     * Reason: part of PIIX4 southbridge, needs to be wired up,
hw/core/or-irq.c:    /* Reason: Needs to be wired up to work, e.g. see stm32f205_soc.c */
hw/core/register.c:    /* Reason: needs to be wired up to work */
hw/core/split-irq.c:    /* Reason: Needs to be wired up to work */
hw/dma/i8257.c:    /* Reason: needs to be wired up by isa_bus_dma() to work */
hw/i2c/smbus_ich9.c:     * Reason: part of ICH9 southbridge, needs to be wired up by
hw/ide/microdrive.c:    /* Reason: Needs to be wired-up in code, see dscm1xxxx_init() */
hw/intc/apic_common.c:     * Reason: APIC and CPU need to be wired up by
hw/intc/nios2_iic.c:    /* Reason: needs to be wired up, e.g. by nios2_10m50_ghrd_init() */
hw/isa/piix4.c:     * Reason: part of PIIX4 southbridge, needs to be wired up,
hw/isa/vt82c686.c:     * Reason: part of VIA VT82C686 southbridge, needs to be wired up,
hw/isa/lpc_ich9.c:     * Reason: part of ICH9 southbridge, needs to be wired up by
hw/pci-host/piix.c:     * Reason: part of PIIX3 southbridge, needs to be wired up by
hw/pci-host/piix.c:    /* Reason: needs to be wired up by pc_init1 */
hw/pci-host/q35.c:    /* Reason: needs to be wired up by pc_q35_init */
hw/timer/mc146818rtc.c:    /* Reason: needs to be wired up by rtc_init() */

... does not look very consistent to me.

But if Peter feels like it should be changed, too, please feel free to modify the comment when picking up the patch (I won't resend it again just because of this).

Quoted 2 lines

I like consistency in such things, but it's matter of taste, thus:

Thanks,
Thomas