Subject: Re: [RESEND PATCH 1/2] firmware: arm_scpi: Add compatibility checks for shmem node

From: Cristian Marussi <[email-masked]>
Date: Thu, 3 Jun 2021 13:52:49 +0100

Reviewed-by: Cristian Marussi <[email-masked]>
Tested-by: Cristian Marussi <[email-masked]>

Cristian

On Wed, Jun 02, 2021 at 08:38:50AM +0100, Sudeep Holla wrote:
> The shared memory node used for communication between the firmware and
> the OS should be compatible with one of the following:
> 	- amlogic,meson-gxbb-scp-shmem
> 	- amlogic,meson-axg-scp-shmem
> 	- arm,juno-scp-shmem
> 	- arm,scp-shmem
> Add the check for the same while parsing the node before fetching the memory
> regions.
> 
> Cc: Rob Herring <[email-masked]>
> Cc: Kevin Hilman <[email-masked]>
> Cc: Neil Armstrong <[email-masked]>
> Cc: Jerome Brunet <[email-masked]>
> Signed-off-by: Sudeep Holla <[email-masked]>
> ---
>  drivers/firmware/arm_scpi.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
> index d0dee37ad522..7b827258e163 100644
> --- a/drivers/firmware/arm_scpi.c
> +++ b/drivers/firmware/arm_scpi.c
> @@ -897,6 +897,13 @@ static const struct of_device_id legacy_scpi_of_match[] = {
>  	{},
>  };
>  
> +static const struct of_device_id shmem_of_match[] = {
> +	{ .compatible = "amlogic,meson-gxbb-scp-shmem", },
> +	{ .compatible = "amlogic,meson-axg-scp-shmem", },
> +	{ .compatible = "arm,juno-scp-shmem", },
> +	{ .compatible = "arm,scp-shmem", },
> +	{ }
> +};
>  static int scpi_probe(struct platform_device *pdev)
>  {
>  	int count, idx, ret;
> @@ -933,6 +940,9 @@ static int scpi_probe(struct platform_device *pdev)
>  		struct mbox_client *cl = &pchan->cl;
>  		struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
>  
> +		if (!of_match_node(shmem_of_match, shmem))
> +			return -ENXIO;
> +
>  		ret = of_address_to_resource(shmem, 0, &res);
>  		of_node_put(shmem);
>  		if (ret) {
> -- 
> 2.25.1
> 

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel