qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] aspeed: Don't set always boot properties of the emmc device
@ 2024-11-02 14:39 Cédric Le Goater
  2024-11-02 15:36 ` Guenter Roeck
  2024-11-04  8:50 ` Jan Lübbe
  0 siblings, 2 replies; 4+ messages in thread
From: Cédric Le Goater @ 2024-11-02 14:39 UTC (permalink / raw)
  To: qemu-devel, qemu-arm
  Cc: Peter Maydell, Steven Lee, Troy Lee, Jamin Lin, Andrew Jeffery,
	Joel Stanley, Philippe Mathieu-Daudé, Cédric Le Goater,
	Jan Luebbe, Guenter Roeck

Commit e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
HW strapping") added support to boot from an eMMC device by setting
the boot properties of the eMMC device. This change made the
assumption that the device always has boot areas.

However, if the machine boots from the flash device (or -kernel) and
uses an eMMC device without boot areas, support would be broken. This
impacts the ast2600-evb machine which can choose to boot from flash or
eMMC using the "boot-emmc" machine option.

To provide some flexibility for Aspeed machine users to use different
flavors of eMMC devices (with or without boot areas), do not set the
eMMC device boot properties when the machine is not configured to boot
from eMMC. However, this approach makes another assumption about eMMC
devices, namely that eMMC devices from which the machine does not boot
do not have boot areas.

A preferable alternative would be to add support for user creatable
eMMC devices and define the device boot properties on the QEMU command
line :

  -blockdev node-name=emmc0,driver=file,filename=mmc-ast2600-evb.raw \
  -device emmc,bus=sdhci-bus.2,drive=emmc0,boot-partition-size=1048576,boot-config=8

This is a global change requiring more thinking. Nevertheless, in the
case of the ast2600-evb machine booting from an eMMC device and when
default devices are created, the proposed change still makes sense
since the device is required to have boot areas.

Cc: Jan Luebbe <jlu@pengutronix.de>
Fixes: e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
HW strapping")
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
---
 hw/arm/aspeed.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index e161e6b1c582..ac6d8dde71b3 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -338,7 +338,18 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc,
             return;
         }
         card = qdev_new(emmc ? TYPE_EMMC : TYPE_SD_CARD);
-        if (emmc) {
+
+        /*
+         * Force the boot properties of the eMMC device only when the
+         * machine is strapped to boot from eMMC. Without these
+         * settings, the machine would not boot.
+         *
+         * This also allows the machine to use an eMMC device without
+         * boot areas when booting from the flash device (or -kernel)
+         * Ideally, the device and its properties should be defined on
+         * the command line.
+         */
+        if (emmc && boot_emmc) {
             qdev_prop_set_uint64(card, "boot-partition-size", 1 * MiB);
             qdev_prop_set_uint8(card, "boot-config",
                                 boot_emmc ? 0x1 << 3 : 0x0);
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] aspeed: Don't set always boot properties of the emmc device
  2024-11-02 14:39 [PATCH] aspeed: Don't set always boot properties of the emmc device Cédric Le Goater
@ 2024-11-02 15:36 ` Guenter Roeck
  2024-11-04  8:50 ` Jan Lübbe
  1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2024-11-02 15:36 UTC (permalink / raw)
  To: Cédric Le Goater, qemu-devel, qemu-arm
  Cc: Peter Maydell, Steven Lee, Troy Lee, Jamin Lin, Andrew Jeffery,
	Joel Stanley, Philippe Mathieu-Daudé, Jan Luebbe

On 11/2/24 07:39, Cédric Le Goater wrote:
> Commit e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
> HW strapping") added support to boot from an eMMC device by setting
> the boot properties of the eMMC device. This change made the
> assumption that the device always has boot areas.
> 
> However, if the machine boots from the flash device (or -kernel) and
> uses an eMMC device without boot areas, support would be broken. This
> impacts the ast2600-evb machine which can choose to boot from flash or
> eMMC using the "boot-emmc" machine option.
> 
> To provide some flexibility for Aspeed machine users to use different
> flavors of eMMC devices (with or without boot areas), do not set the
> eMMC device boot properties when the machine is not configured to boot
> from eMMC. However, this approach makes another assumption about eMMC
> devices, namely that eMMC devices from which the machine does not boot
> do not have boot areas.
> 
> A preferable alternative would be to add support for user creatable
> eMMC devices and define the device boot properties on the QEMU command
> line :
> 
>    -blockdev node-name=emmc0,driver=file,filename=mmc-ast2600-evb.raw \
>    -device emmc,bus=sdhci-bus.2,drive=emmc0,boot-partition-size=1048576,boot-config=8
> 
> This is a global change requiring more thinking. Nevertheless, in the
> case of the ast2600-evb machine booting from an eMMC device and when
> default devices are created, the proposed change still makes sense
> since the device is required to have boot areas.
> 
> Cc: Jan Luebbe <jlu@pengutronix.de>
> Fixes: e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
> HW strapping")
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> Tested-by: Guenter Roeck <linux@roeck-us.net>
> ---
>   hw/arm/aspeed.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index e161e6b1c582..ac6d8dde71b3 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -338,7 +338,18 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc,
>               return;
>           }
>           card = qdev_new(emmc ? TYPE_EMMC : TYPE_SD_CARD);
> -        if (emmc) {
> +
> +        /*
> +         * Force the boot properties of the eMMC device only when the
> +         * machine is strapped to boot from eMMC. Without these
> +         * settings, the machine would not boot.
> +         *
> +         * This also allows the machine to use an eMMC device without
> +         * boot areas when booting from the flash device (or -kernel)
> +         * Ideally, the device and its properties should be defined on
> +         * the command line.
> +         */
> +        if (emmc && boot_emmc) {
>               qdev_prop_set_uint64(card, "boot-partition-size", 1 * MiB);
>               qdev_prop_set_uint8(card, "boot-config",
>                                   boot_emmc ? 0x1 << 3 : 0x0);

That second boot_emmc check is no longer necessary, so this could be
simplified to
		qdev_prop_set_uint8(card, "boot-config", 0x1 << 3);

Thanks,
Guenter



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] aspeed: Don't set always boot properties of the emmc device
  2024-11-02 14:39 [PATCH] aspeed: Don't set always boot properties of the emmc device Cédric Le Goater
  2024-11-02 15:36 ` Guenter Roeck
@ 2024-11-04  8:50 ` Jan Lübbe
  2024-11-04  8:56   ` Cédric Le Goater
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Lübbe @ 2024-11-04  8:50 UTC (permalink / raw)
  To: Cédric Le Goater, qemu-devel, qemu-arm
  Cc: Peter Maydell, Steven Lee, Troy Lee, Jamin Lin, Andrew Jeffery,
	Joel Stanley, Philippe Mathieu-Daudé, Guenter Roeck

On Sat, 2024-11-02 at 15:39 +0100, Cédric Le Goater wrote:
> Commit e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
> HW strapping") added support to boot from an eMMC device by setting
> the boot properties of the eMMC device. This change made the
> assumption that the device always has boot areas.
> 
> However, if the machine boots from the flash device (or -kernel) and
> uses an eMMC device without boot areas, support would be broken. This
> impacts the ast2600-evb machine which can choose to boot from flash or
> eMMC using the "boot-emmc" machine option.
> 
> To provide some flexibility for Aspeed machine users to use different
> flavors of eMMC devices (with or without boot areas), do not set the
> eMMC device boot properties when the machine is not configured to boot
> from eMMC. However, this approach makes another assumption about eMMC
> devices, namely that eMMC devices from which the machine does not boot
> do not have boot areas.
> 
> A preferable alternative would be to add support for user creatable
> eMMC devices and define the device boot properties on the QEMU command
> line :
> 
>   -blockdev node-name=emmc0,driver=file,filename=mmc-ast2600-evb.raw \
>   -device emmc,bus=sdhci-bus.2,drive=emmc0,boot-partition-size=1048576,boot-config=8
> 
> This is a global change requiring more thinking. Nevertheless, in the
> case of the ast2600-evb machine booting from an eMMC device and when
> default devices are created, the proposed change still makes sense
> since the device is required to have boot areas.
> 
> Cc: Jan Luebbe <jlu@pengutronix.de>
> Fixes: e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
> HW strapping")
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> Tested-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  hw/arm/aspeed.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index e161e6b1c582..ac6d8dde71b3 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -338,7 +338,18 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc,
>              return;
>          }
>          card = qdev_new(emmc ? TYPE_EMMC : TYPE_SD_CARD);
> -        if (emmc) {
> +
> +        /*
> +         * Force the boot properties of the eMMC device only when the
> +         * machine is strapped to boot from eMMC. Without these
> +         * settings, the machine would not boot.
> +         *
> +         * This also allows the machine to use an eMMC device without
> +         * boot areas when booting from the flash device (or -kernel)
> +         * Ideally, the device and its properties should be defined on
> +         * the command line.
> +         */
> +        if (emmc && boot_emmc) {
>              qdev_prop_set_uint64(card, "boot-partition-size", 1 * MiB);
>              qdev_prop_set_uint8(card, "boot-config",
>                                  boot_emmc ? 0x1 << 3 : 0x0);

With the change proposed by Guenter, this looks good to me.

Thanks,
Jan
-- 
Pengutronix e.K.                        |                             |
Steuerwalder Str. 21                    | https://www.pengutronix.de/ |
31137 Hildesheim, Germany               | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686        | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] aspeed: Don't set always boot properties of the emmc device
  2024-11-04  8:50 ` Jan Lübbe
@ 2024-11-04  8:56   ` Cédric Le Goater
  0 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2024-11-04  8:56 UTC (permalink / raw)
  To: Jan Lübbe, qemu-devel, qemu-arm
  Cc: Peter Maydell, Steven Lee, Troy Lee, Jamin Lin, Andrew Jeffery,
	Joel Stanley, Philippe Mathieu-Daudé, Guenter Roeck

On 11/4/24 09:50, Jan Lübbe wrote:
> On Sat, 2024-11-02 at 15:39 +0100, Cédric Le Goater wrote:
>> Commit e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
>> HW strapping") added support to boot from an eMMC device by setting
>> the boot properties of the eMMC device. This change made the
>> assumption that the device always has boot areas.
>>
>> However, if the machine boots from the flash device (or -kernel) and
>> uses an eMMC device without boot areas, support would be broken. This
>> impacts the ast2600-evb machine which can choose to boot from flash or
>> eMMC using the "boot-emmc" machine option.
>>
>> To provide some flexibility for Aspeed machine users to use different
>> flavors of eMMC devices (with or without boot areas), do not set the
>> eMMC device boot properties when the machine is not configured to boot
>> from eMMC. However, this approach makes another assumption about eMMC
>> devices, namely that eMMC devices from which the machine does not boot
>> do not have boot areas.
>>
>> A preferable alternative would be to add support for user creatable
>> eMMC devices and define the device boot properties on the QEMU command
>> line :
>>
>>    -blockdev node-name=emmc0,driver=file,filename=mmc-ast2600-evb.raw \
>>    -device emmc,bus=sdhci-bus.2,drive=emmc0,boot-partition-size=1048576,boot-config=8
>>
>> This is a global change requiring more thinking. Nevertheless, in the
>> case of the ast2600-evb machine booting from an eMMC device and when
>> default devices are created, the proposed change still makes sense
>> since the device is required to have boot areas.
>>
>> Cc: Jan Luebbe <jlu@pengutronix.de>
>> Fixes: e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
>> HW strapping")
>> Signed-off-by: Cédric Le Goater <clg@redhat.com>
>> Tested-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>   hw/arm/aspeed.c | 13 ++++++++++++-
>>   1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
>> index e161e6b1c582..ac6d8dde71b3 100644
>> --- a/hw/arm/aspeed.c
>> +++ b/hw/arm/aspeed.c
>> @@ -338,7 +338,18 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc,
>>               return;
>>           }
>>           card = qdev_new(emmc ? TYPE_EMMC : TYPE_SD_CARD);
>> -        if (emmc) {
>> +
>> +        /*
>> +         * Force the boot properties of the eMMC device only when the
>> +         * machine is strapped to boot from eMMC. Without these
>> +         * settings, the machine would not boot.
>> +         *
>> +         * This also allows the machine to use an eMMC device without
>> +         * boot areas when booting from the flash device (or -kernel)
>> +         * Ideally, the device and its properties should be defined on
>> +         * the command line.
>> +         */
>> +        if (emmc && boot_emmc) {
>>               qdev_prop_set_uint64(card, "boot-partition-size", 1 * MiB);
>>               qdev_prop_set_uint8(card, "boot-config",
>>                                   boot_emmc ? 0x1 << 3 : 0x0);
> 
> With the change proposed by Guenter, this looks good to me.

yes. Could you please review v2 them ?

Thanks,

C.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-04  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-02 14:39 [PATCH] aspeed: Don't set always boot properties of the emmc device Cédric Le Goater
2024-11-02 15:36 ` Guenter Roeck
2024-11-04  8:50 ` Jan Lübbe
2024-11-04  8:56   ` Cédric Le Goater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).