qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

why the below code can't attach alias bus


From: 夏磊杰
Subject: why the below code can't attach alias bus
Date: Sun, 31 Jul 2022 23:07:37 +0800

Hi All,

In sabrelite, all 4 sd controller bus name is sd-bus, in order to attach a specific sd controller, I have already tested below two ways in v6.0.0, I want to understand why alias is not working in this case:
1. overwrite bus name in fsl-imx6.c, this is working, so I can attach a specific sd controller by passing such parameters  "bus=sd-bus2“ to qemu, also from "info qtree", I can see the bus name was been overwrote.
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 00dafe3f62..b68212b5a9 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -314,6 +314,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
             { FSL_IMX6_uSDHC3_ADDR, FSL_IMX6_uSDHC3_IRQ },
             { FSL_IMX6_uSDHC4_ADDR, FSL_IMX6_uSDHC4_IRQ },
         };
+       //g_autofree char *bus_name = NULL;
+       BusState *bus = NULL;

         /* UHS-I SDIO3.0 SDR104 1.8V ADMA */
         object_property_set_uint(OBJECT(&s->esdhc[i]), "sd-spec-version", 3,
@@ -329,6 +331,15 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->esdhc[i]), 0,
                            qdev_get_gpio_in(DEVICE(&s->a9mpcore),
                                             esdhc_table[i].irq));
+
+       /* give unique name with index for all 4 sd controller bus, simply overwrite origin name */
+       bus = qdev_get_child_bus(DEVICE(&s->esdhc[i]), "sd-bus");
+       bus->name = g_strdup_printf("sd-bus%d", i);
+
+        /* Alias controller SD bus to the SoC itself */
+       //bus_name = g_strdup_printf("sd-bus%d", i);
+       //object_property_add_alias(OBJECT(s), bus_name,
+                                 //OBJECT(&s->esdhc[i]), "sd-bus");

2. as suggested in some related thread, by create an alias for bus name, this is not working, when I checked "info qtree", I didn't even find my alias bus. I debugged a little, seems the alias property waas been created, but the type is link<sdhci-bus>, not child<sdhci-bus>.

diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 00dafe3f62..1d631583e5 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -314,6 +314,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
             { FSL_IMX6_uSDHC3_ADDR, FSL_IMX6_uSDHC3_IRQ },
             { FSL_IMX6_uSDHC4_ADDR, FSL_IMX6_uSDHC4_IRQ },
         };
+       g_autofree char *bus_name = NULL;
+       //BusState *bus = NULL;

         /* UHS-I SDIO3.0 SDR104 1.8V ADMA */
         object_property_set_uint(OBJECT(&s->esdhc[i]), "sd-spec-version", 3,
@@ -329,6 +331,15 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->esdhc[i]), 0,
                            qdev_get_gpio_in(DEVICE(&s->a9mpcore),
                                             esdhc_table[i].irq));
+
+       /* give unique name with index for all 4 sd controller bus, simply overwrite origin name */
+       //bus = qdev_get_child_bus(DEVICE(&s->esdhc[i]), "sd-bus");
+       //bus->name = g_strdup_printf("sd-bus%d", i);
+
+        /* Alias controller SD bus to the SoC itself */
+       bus_name = g_strdup_printf("sd-bus%d", i);
+       object_property_add_alias(OBJECT(s), bus_name,
+                                 OBJECT(&s->esdhc[i]), "sd-bus");

So I want to understand why the second way is not working, I understand read the implementation of object_property_add_alias can answer this question,
but here just want to get some comments from you. Thanks in advance

reply via email to

[Prev in Thread] Current Thread [Next in Thread]