On Thu, 13 Apr 2023 23:10:56 +0200
Pali Rohár <p...@kernel.org> wrote:

> Mapping between bootpart taken from EXT_CSD_EXTRACT_BOOT_PART() and
> Partition Access bits used by the mmc_switch_part() function may be quite
> misleading. So add extended comment describing why in sunxi case is this
> mapping just a simple identity. Because in generic case this mapping
> requires non-trivial mapping table.

Ah, indeed, many thanks for clearing this up! I missed the subtleties
of bootpart meaning slightly different things between
EXT_CSD_EXTRACT_BOOT_PART and mmc_switch_part(). It looks like we were
quite lucky as we only care about 1 and 2 here!

> Signed-off-by: Pali Rohár <p...@kernel.org>

Acked-by: Andre Przywara <andre.przyw...@arm.com>

Queued for sunxi/master.

Cheers,
Andre

> ---
>  arch/arm/mach-sunxi/board.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
> index 391a65a5495f..73519f6262ec 100644
> --- a/arch/arm/mach-sunxi/board.c
> +++ b/arch/arm/mach-sunxi/board.c
> @@ -381,7 +381,17 @@ static bool sunxi_valid_emmc_boot(struct mmc *mmc)
>           (mmc->ext_csd[EXT_CSD_BOOT_BUS_WIDTH] & 0x1b) != 0x09)
>               return false;
>  
> -     /* Partition 0 is the user data partition, bootpart must be 1 or 2. */
> +     /*
> +      * bootpart == 0 means that eMMC booting is disabled.
> +      * bootpart == 1 or 2 means to boot from Boot Partition 1 or 2.
> +      * bootpart == 7 means to boot from User Area.
> +      * Other bootpart values are reserved.
> +      * mmc_switch_part() takes partition access value which is:
> +      * 0 for User Area; 1-2 for Boot Partition 1-2; 3 for RPMB; 4-7 for GP 
> 1-4.
> +      * We allow booting only from Boot Partition 1 or 2 so
> +      * bootpart mapping between EXT_CSD_EXTRACT_BOOT_PART()
> +      * and mmc_switch_part() is straightforward identity.
> +      */
>       if (bootpart != 1 && bootpart != 2)
>               return false;
>  

Reply via email to