hw/i2c/allwinner-i2c: Fix subclassing of TYPE_AW_I2C_SUN6I
In commit 8461bfdca9c we added the TYPE_AW_I2C_SUN6I, which is a minor variant of the TYPE_AW_I2C device. However, we didn't quite get the class hierarchy right. We made the new TYPE_AW_I2C_SUN6I a subclass of TYPE_SYS_BUS_DEVICE, which means that you can't validly use a pointer to this object via the AW_I2C() cast macro, which insists on having something that is an instance of TYPE_AW_I2C or some subclass of that type.
This only causes a problem if QOM cast macro debugging is enabled; that is supposed to be on by default, but a mistake in the meson conversion in commit c55cf6ab03f4c meant that it ended up disabled by default, and we didn't catch this bug.
Fix the problem by arranging the classes in the same way we do for TYPE_PL011 and TYPE_PL011_LUMINARY in hw/char/pl011.c -- make the variant class be a subclass of the "normal" version of the device.
This was reported in
https://gitlab.com/qemu-project/qemu/-/issues/1586 but this fix alone isn't sufficient, as there is a separate cast-related issue in the CXL code in pci_expander_bridge.c.
--- hw/i2c/allwinner-i2c.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/i2c/allwinner-i2c.c +1 -3
@@ -466,10 +466,8 @@ static void allwinner_i2c_sun6i_init(Object *obj)static const TypeInfo allwinner_i2c_sun6i_type_info = { .name =TYPE_AW_I2C_SUN6I , - .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (AWI2CState), + .parent =TYPE_AW_I2C , .instance_init = allwinner_i2c_sun6i_init, - .class_init = allwinner_i2c_class_init, };static void allwinner_i2c_register_types (void )
Signature · 1 line
2.34.1
Thomas Huth
Reviewed-byQuoted 33 lines · Peter Maydell
In commit
8461bfdca9cwe added theTYPE_AW_I2C_SUN6I, which is a minor variant of theTYPE_AW_I2Cdevice. However, we didn't quite get the class hierarchy right. We made the newTYPE_AW_I2C_SUN6Ia subclass ofTYPE_SYS_BUS_DEVICE, which means that you can't validly use a pointer to this object via theAW_I2C()cast macro, which insists on having something that is an instance ofTYPE_AW_I2Cor some subclass of that type.This only causes a problem if QOM cast macro debugging is enabled; that is supposed to be on by default, but a mistake in the meson conversion in commit
c55cf6ab03f4cmeant that it ended up disabled by default, and we didn't catch this bug.Fix the problem by arranging the classes in the same way we do for
TYPE_PL011andTYPE_PL011_LUMINARYinhw/char/pl011.c-- make the variant class be a subclass of the "normal" version of the device.This was reported in
https://gitlab.com/qemu-project/qemu/-/issues/1586 but this fix alone isn't sufficient, as there is a separate cast-related issue in the CXL code inpci_expander_bridge.c.Signed-off-by Peter Maydell <[email protected]>--- hw/i2c/allwinner-i2c.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/i2c/allwinner-i2c.c +0
-0@@ -466,10 +466,8 @@ static void allwinner_i2c_sun6i_init(Object *obj)
hw/i2c/allwinner-i2c.c static void allwinner_i2c_sun6i_init(Object *obj) · line 473
Quoted 10 lines
hw/i2c/allwinner-i2c.c +1
-3static const TypeInfo allwinner_i2c_sun6i_type_info = { .name =TYPE_AW_I2C_SUN6I , - .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (AWI2CState), + .parent =TYPE_AW_I2C , .instance_init = allwinner_i2c_sun6i_init, - .class_init = allwinner_i2c_class_init, };static void allwinner_i2c_register_types (void )
Alex Bennée
Reviewed-byQuoted 17 lines · Peter Maydell
In commit
8461bfdca9cwe added theTYPE_AW_I2C_SUN6I, which is a minor variant of theTYPE_AW_I2Cdevice. However, we didn't quite get the class hierarchy right. We made the newTYPE_AW_I2C_SUN6Ia subclass ofTYPE_SYS_BUS_DEVICE, which means that you can't validly use a pointer to this object via theAW_I2C()cast macro, which insists on having something that is an instance ofTYPE_AW_I2Cor some subclass of that type.This only causes a problem if QOM cast macro debugging is enabled; that is supposed to be on by default, but a mistake in the meson conversion in commit
c55cf6ab03f4cmeant that it ended up disabled by default, and we didn't catch this bug.Fix the problem by arranging the classes in the same way we do for
TYPE_PL011andTYPE_PL011_LUMINARYinhw/char/pl011.c-- make the variant class be a subclass of the "normal" version of the device.
Quoted 6 lines
This was reported in
https://gitlab.com/qemu-project/qemu/-/issues/1586 but this fix alone isn't sufficient, as there is a separate cast-related issue in the CXL code inpci_expander_bridge.c.Signed-off-by Peter Maydell <[email protected]>
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Corey Minyard
Reviewed-byQuoted 17 lines · Peter Maydell
In commit
8461bfdca9cwe added theTYPE_AW_I2C_SUN6I, which is a minor variant of theTYPE_AW_I2Cdevice. However, we didn't quite get the class hierarchy right. We made the newTYPE_AW_I2C_SUN6Ia subclass ofTYPE_SYS_BUS_DEVICE, which means that you can't validly use a pointer to this object via theAW_I2C()cast macro, which insists on having something that is an instance ofTYPE_AW_I2Cor some subclass of that type.This only causes a problem if QOM cast macro debugging is enabled; that is supposed to be on by default, but a mistake in the meson conversion in commit
c55cf6ab03f4cmeant that it ended up disabled by default, and we didn't catch this bug.Fix the problem by arranging the classes in the same way we do for
TYPE_PL011andTYPE_PL011_LUMINARYinhw/char/pl011.c-- make the variant class be a subclass of the "normal" version of the device.
Quoted 6 lines
This was reported in
https://gitlab.com/qemu-project/qemu/-/issues/1586 but this fix alone isn't sufficient, as there is a separate cast-related issue in the CXL code inpci_expander_bridge.c.Signed-off-by Peter Maydell <[email protected]>
Looks correct ot me.
Quoted 24 lines
--- hw/i2c/allwinner-i2c.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/i2c/allwinner-i2c.c +1
-3@@ -466,10 +466,8 @@ static void allwinner_i2c_sun6i_init(Object *obj)static const TypeInfo allwinner_i2c_sun6i_type_info = { .name =TYPE_AW_I2C_SUN6I , - .parent =TYPE_SYS_BUS_DEVICE , - .instance_size =sizeof (AWI2CState), + .parent =TYPE_AW_I2C , .instance_init = allwinner_i2c_sun6i_init, - .class_init = allwinner_i2c_class_init, };static void allwinner_i2c_register_types (void )Signature · 1 line
2.34.1
Philippe Mathieu-Daudé
Reviewed-byQuoted 22 lines · Peter Maydell
In commit
8461bfdca9cwe added theTYPE_AW_I2C_SUN6I, which is a minor variant of theTYPE_AW_I2Cdevice. However, we didn't quite get the class hierarchy right. We made the newTYPE_AW_I2C_SUN6Ia subclass ofTYPE_SYS_BUS_DEVICE, which means that you can't validly use a pointer to this object via theAW_I2C()cast macro, which insists on having something that is an instance ofTYPE_AW_I2Cor some subclass of that type.This only causes a problem if QOM cast macro debugging is enabled; that is supposed to be on by default, but a mistake in the meson conversion in commit
c55cf6ab03f4cmeant that it ended up disabled by default, and we didn't catch this bug.Fix the problem by arranging the classes in the same way we do for
TYPE_PL011andTYPE_PL011_LUMINARYinhw/char/pl011.c-- make the variant class be a subclass of the "normal" version of the device.This was reported in
https://gitlab.com/qemu-project/qemu/-/issues/1586 but this fix alone isn't sufficient, as there is a separate cast-related issue in the CXL code inpci_expander_bridge.c.
Quoted 4 lines
Signed-off-by Peter Maydell <[email protected]>--- hw/i2c/allwinner-i2c.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)