[PATCH v2 1/9] hw/sd/pxa2xx: Realize sysbus device before accessing it

Philippe Mathieu-Daudé posted 9 patches 1 year, 1 month ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>
There is a newer version of this series
[PATCH v2 1/9] hw/sd/pxa2xx: Realize sysbus device before accessing it
Posted by Philippe Mathieu-Daudé 1 year, 1 month ago
sysbus_mmio_map() and sysbus_connect_irq() should not be
called on unrealized device.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/sd/pxa2xx_mmci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c
index 124fbf8bbd..9f7a880bac 100644
--- a/hw/sd/pxa2xx_mmci.c
+++ b/hw/sd/pxa2xx_mmci.c
@@ -483,11 +483,11 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
 
     dev = qdev_new(TYPE_PXA2XX_MMCI);
     sbd = SYS_BUS_DEVICE(dev);
+    sysbus_realize_and_unref(sbd, &error_fatal);
     sysbus_mmio_map(sbd, 0, base);
     sysbus_connect_irq(sbd, 0, irq);
     qdev_connect_gpio_out_named(dev, "rx-dma", 0, rx_dma);
     qdev_connect_gpio_out_named(dev, "tx-dma", 0, tx_dma);
-    sysbus_realize_and_unref(sbd, &error_fatal);
 
     return PXA2XX_MMCI(dev);
 }
-- 
2.41.0


Re: [PATCH v2 1/9] hw/sd/pxa2xx: Realize sysbus device before accessing it
Posted by Thomas Huth 1 year, 1 month ago
On 19/10/2023 15.09, Philippe Mathieu-Daudé wrote:
> sysbus_mmio_map() and sysbus_connect_irq() should not be
> called on unrealized device.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/sd/pxa2xx_mmci.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c
> index 124fbf8bbd..9f7a880bac 100644
> --- a/hw/sd/pxa2xx_mmci.c
> +++ b/hw/sd/pxa2xx_mmci.c
> @@ -483,11 +483,11 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
>   
>       dev = qdev_new(TYPE_PXA2XX_MMCI);
>       sbd = SYS_BUS_DEVICE(dev);
> +    sysbus_realize_and_unref(sbd, &error_fatal);
>       sysbus_mmio_map(sbd, 0, base);
>       sysbus_connect_irq(sbd, 0, irq);
>       qdev_connect_gpio_out_named(dev, "rx-dma", 0, rx_dma);
>       qdev_connect_gpio_out_named(dev, "tx-dma", 0, tx_dma);
> -    sysbus_realize_and_unref(sbd, &error_fatal);
>   
>       return PXA2XX_MMCI(dev);
>   }

Signed-off-by: Thomas Huth <thuth@redhat.com>


Re: [PATCH v2 1/9] hw/sd/pxa2xx: Realize sysbus device before accessing it
Posted by Thomas Huth 1 year, 1 month ago
On 19/10/2023 18.00, Thomas Huth wrote:
> On 19/10/2023 15.09, Philippe Mathieu-Daudé wrote:
>> sysbus_mmio_map() and sysbus_connect_irq() should not be
>> called on unrealized device.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   hw/sd/pxa2xx_mmci.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c
>> index 124fbf8bbd..9f7a880bac 100644
>> --- a/hw/sd/pxa2xx_mmci.c
>> +++ b/hw/sd/pxa2xx_mmci.c
>> @@ -483,11 +483,11 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
>>       dev = qdev_new(TYPE_PXA2XX_MMCI);
>>       sbd = SYS_BUS_DEVICE(dev);
>> +    sysbus_realize_and_unref(sbd, &error_fatal);
>>       sysbus_mmio_map(sbd, 0, base);
>>       sysbus_connect_irq(sbd, 0, irq);
>>       qdev_connect_gpio_out_named(dev, "rx-dma", 0, rx_dma);
>>       qdev_connect_gpio_out_named(dev, "tx-dma", 0, tx_dma);
>> -    sysbus_realize_and_unref(sbd, &error_fatal);
>>       return PXA2XX_MMCI(dev);
>>   }
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Drat, copy-n-paste failure. That should be:

Reviewed-by: Thomas Huth <thuth@redhat.com>