[PATCH v1 1/2] firmware: scmi: use PAGE_SIZE alignement for ARM64

Tom Rini trini at konsulko.com
Mon Oct 7 18:58:28 CEST 2024


On Sun, Oct 06, 2024 at 03:07:01PM +0800, alice.guo at oss.nxp.com wrote:
> From: Peng Fan <peng.fan at nxp.com>
> 
> For ARMv7, the alignment could be SECTION size. But for ARM64, use
> PAGE_SIZE.
> 
> Signed-off-by: Peng Fan <peng.fan at nxp.com>
> Signed-off-by: Alice Guo <alice.guo at nxp.com>
> Reviewed-by: Ye Li <ye.li at nxp.com>
> ---
>  drivers/firmware/scmi/smt.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/firmware/scmi/smt.c b/drivers/firmware/scmi/smt.c
> index 67d2f45002..e9d401f0da 100644
> --- a/drivers/firmware/scmi/smt.c
> +++ b/drivers/firmware/scmi/smt.c
> @@ -29,6 +29,7 @@ int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt)
>  	int ret;
>  	struct ofnode_phandle_args args;
>  	struct resource resource;
> +	u32 align_size __maybe_unused;
>  
>  	ret = dev_read_phandle_with_args(dev, "shmem", NULL, 0, 0, &args);
>  	if (ret)
> @@ -49,11 +50,15 @@ int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt)
>  		return -ENOMEM;
>  
>  #ifdef CONFIG_ARM
> -	if (dcache_status())
> -		mmu_set_region_dcache_behaviour(ALIGN_DOWN((uintptr_t)smt->buf, MMU_SECTION_SIZE),
> -						ALIGN(smt->size, MMU_SECTION_SIZE),
> -						DCACHE_OFF);
> -
> +	if (dcache_status()) {
> +		if (IS_ENABLED(CONFIG_ARM64))
> +			align_size = PAGE_SIZE;
> +		else
> +			align_size = MMU_SECTION_SIZE;
> +
> +		mmu_set_region_dcache_behaviour(ALIGN_DOWN((uintptr_t)smt->buf, align_size),
> +						ALIGN(smt->size, align_size), DCACHE_OFF);
> +	}
>  #endif
>  
>  	return 0;

You can move declaring align_size down to this stanza, no need to
__maybe_unused it.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20241007/a04b5a34/attachment.sig>


More information about the U-Boot mailing list