linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware: qcom_scm: use the SCM_CONVENTION based on ARM / ARM64
@ 2023-05-22  4:45 Kathiravan T
  2023-05-22  6:33 ` Bhupesh Sharma
  0 siblings, 1 reply; 4+ messages in thread
From: Kathiravan T @ 2023-05-22  4:45 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel
  Cc: quic_eberman, Kathiravan T

During SCM probe, to identify the SCM convention, scm call is made with
SMC_CONVENTION_ARM_64 followed by SMC_CONVENTION_ARM_32. Based on the
result what convention to be used is decided.

IPQ chipsets starting from IPQ807x, supports both 32bit and 64bit kernel
variants, however TZ firmware runs in 64bit mode. When running on 32bit
kernel, scm call is made with SMC_CONVENTION_ARM_64 is causing the
system crash, due to the difference in the register sets between ARM and
AARCH64, which is accessed by the TZ.

To avoid this, use SMC_CONVENTION_ARM_64 only on ARM64 builds.

Signed-off-by: Kathiravan T <quic_kathirav@quicinc.com>
---
 drivers/firmware/qcom_scm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index fde33acd46b7..db6754db48a0 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -171,6 +171,7 @@ static enum qcom_scm_convention __get_convention(void)
 	if (likely(qcom_scm_convention != SMC_CONVENTION_UNKNOWN))
 		return qcom_scm_convention;
 
+#if IS_ENABLED(CONFIG_ARM64)
 	/*
 	 * Device isn't required as there is only one argument - no device
 	 * needed to dma_map_single to secure world
@@ -191,6 +192,7 @@ static enum qcom_scm_convention __get_convention(void)
 		forced = true;
 		goto found;
 	}
+#endif
 
 	probed_convention = SMC_CONVENTION_ARM_32;
 	ret = __scm_smc_call(NULL, &desc, probed_convention, &res, true);
-- 
2.17.1


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

* Re: [PATCH] firmware: qcom_scm: use the SCM_CONVENTION based on ARM / ARM64
  2023-05-22  4:45 [PATCH] firmware: qcom_scm: use the SCM_CONVENTION based on ARM / ARM64 Kathiravan T
@ 2023-05-22  6:33 ` Bhupesh Sharma
  2023-05-23  8:34   ` Kathiravan T
  2023-05-23  9:46   ` Mukesh Ojha
  0 siblings, 2 replies; 4+ messages in thread
From: Bhupesh Sharma @ 2023-05-22  6:33 UTC (permalink / raw)
  To: Kathiravan T
  Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, linux-arm-msm,
	linux-kernel, quic_eberman

Hi,

On Mon, 22 May 2023 at 10:15, Kathiravan T <quic_kathirav@quicinc.com> wrote:
>
> During SCM probe, to identify the SCM convention, scm call is made with
> SMC_CONVENTION_ARM_64 followed by SMC_CONVENTION_ARM_32. Based on the
> result what convention to be used is decided.
>
> IPQ chipsets starting from IPQ807x, supports both 32bit and 64bit kernel
> variants, however TZ firmware runs in 64bit mode. When running on 32bit
> kernel, scm call is made with SMC_CONVENTION_ARM_64 is causing the
> system crash, due to the difference in the register sets between ARM and
> AARCH64, which is accessed by the TZ.

If a crash is being fixed, should we use a Fixes tag as well?

> To avoid this, use SMC_CONVENTION_ARM_64 only on ARM64 builds.
>
> Signed-off-by: Kathiravan T <quic_kathirav@quicinc.com>
> ---
>  drivers/firmware/qcom_scm.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index fde33acd46b7..db6754db48a0 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -171,6 +171,7 @@ static enum qcom_scm_convention __get_convention(void)
>         if (likely(qcom_scm_convention != SMC_CONVENTION_UNKNOWN))
>                 return qcom_scm_convention;
>
> +#if IS_ENABLED(CONFIG_ARM64)
>         /*
>          * Device isn't required as there is only one argument - no device
>          * needed to dma_map_single to secure world
> @@ -191,6 +192,7 @@ static enum qcom_scm_convention __get_convention(void)
>                 forced = true;
>                 goto found;
>         }
> +#endif

If we are already inside a 'CONFIG_ARM64' define here ^^^, do we even
need the following snippet now:

/*
     * Some SC7180 firmwares didn't implement the
     * QCOM_SCM_INFO_IS_CALL_AVAIL call, so we fallback to forcing ARM_64
     * calling conventions on these firmwares. Luckily we don't make any
     * early calls into the firmware on these SoCs so the device pointer
     * will be valid here to check if the compatible matches.
     */
    if (of_device_is_compatible(__scm ? __scm->dev->of_node : NULL,
"qcom,scm-sc7180")) {
        forced = true;
        goto found;
    }

'forced' will always be 'true' now that we are inside the CONFIG_ARM64
check above, right?
So, maybe you can clean-up that path as well.

Thanks,
Bhupesh

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

* Re: [PATCH] firmware: qcom_scm: use the SCM_CONVENTION based on ARM / ARM64
  2023-05-22  6:33 ` Bhupesh Sharma
@ 2023-05-23  8:34   ` Kathiravan T
  2023-05-23  9:46   ` Mukesh Ojha
  1 sibling, 0 replies; 4+ messages in thread
From: Kathiravan T @ 2023-05-23  8:34 UTC (permalink / raw)
  To: Bhupesh Sharma
  Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, linux-arm-msm,
	linux-kernel, quic_eberman


On 5/22/2023 12:03 PM, Bhupesh Sharma wrote:
> Hi,
>
> On Mon, 22 May 2023 at 10:15, Kathiravan T <quic_kathirav@quicinc.com> wrote:
>> During SCM probe, to identify the SCM convention, scm call is made with
>> SMC_CONVENTION_ARM_64 followed by SMC_CONVENTION_ARM_32. Based on the
>> result what convention to be used is decided.
>>
>> IPQ chipsets starting from IPQ807x, supports both 32bit and 64bit kernel
>> variants, however TZ firmware runs in 64bit mode. When running on 32bit
>> kernel, scm call is made with SMC_CONVENTION_ARM_64 is causing the
>> system crash, due to the difference in the register sets between ARM and
>> AARCH64, which is accessed by the TZ.
> If a crash is being fixed, should we use a Fixes tag as well?


Ack. Will add it in next spin.


>
>> To avoid this, use SMC_CONVENTION_ARM_64 only on ARM64 builds.
>>
>> Signed-off-by: Kathiravan T <quic_kathirav@quicinc.com>
>> ---
>>   drivers/firmware/qcom_scm.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
>> index fde33acd46b7..db6754db48a0 100644
>> --- a/drivers/firmware/qcom_scm.c
>> +++ b/drivers/firmware/qcom_scm.c
>> @@ -171,6 +171,7 @@ static enum qcom_scm_convention __get_convention(void)
>>          if (likely(qcom_scm_convention != SMC_CONVENTION_UNKNOWN))
>>                  return qcom_scm_convention;
>>
>> +#if IS_ENABLED(CONFIG_ARM64)
>>          /*
>>           * Device isn't required as there is only one argument - no device
>>           * needed to dma_map_single to secure world
>> @@ -191,6 +192,7 @@ static enum qcom_scm_convention __get_convention(void)
>>                  forced = true;
>>                  goto found;
>>          }
>> +#endif
> If we are already inside a 'CONFIG_ARM64' define here ^^^, do we even
> need the following snippet now:
>
> /*
>       * Some SC7180 firmwares didn't implement the
>       * QCOM_SCM_INFO_IS_CALL_AVAIL call, so we fallback to forcing ARM_64
>       * calling conventions on these firmwares. Luckily we don't make any
>       * early calls into the firmware on these SoCs so the device pointer
>       * will be valid here to check if the compatible matches.
>       */
>      if (of_device_is_compatible(__scm ? __scm->dev->of_node : NULL,
> "qcom,scm-sc7180")) {
>          forced = true;
>          goto found;
>      }
>
> 'forced' will always be 'true' now that we are inside the CONFIG_ARM64
> check above, right?
> So, maybe you can clean-up that path as well.


You want to remove the of_device_is_compatible check and by default set 
the 'forced' to true, if the SCM call fails? Currently it clearly states 
why we are forcing the convention. If we remove it, we may not able to 
identify which target FW lacks this scm call support and why we are 
forcing it...


Thanks,

>
> Thanks,
> Bhupesh

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

* Re: [PATCH] firmware: qcom_scm: use the SCM_CONVENTION based on ARM / ARM64
  2023-05-22  6:33 ` Bhupesh Sharma
  2023-05-23  8:34   ` Kathiravan T
@ 2023-05-23  9:46   ` Mukesh Ojha
  1 sibling, 0 replies; 4+ messages in thread
From: Mukesh Ojha @ 2023-05-23  9:46 UTC (permalink / raw)
  To: Bhupesh Sharma, Kathiravan T
  Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, linux-arm-msm,
	linux-kernel, quic_eberman



On 5/22/2023 12:03 PM, Bhupesh Sharma wrote:
> Hi,
> 
> On Mon, 22 May 2023 at 10:15, Kathiravan T <quic_kathirav@quicinc.com> wrote:
>>
>> During SCM probe, to identify the SCM convention, scm call is made with
>> SMC_CONVENTION_ARM_64 followed by SMC_CONVENTION_ARM_32. Based on the
>> result what convention to be used is decided.
>>
>> IPQ chipsets starting from IPQ807x, supports both 32bit and 64bit kernel
>> variants, however TZ firmware runs in 64bit mode. When running on 32bit
>> kernel, scm call is made with SMC_CONVENTION_ARM_64 is causing the
>> system crash, due to the difference in the register sets between ARM and
>> AARCH64, which is accessed by the TZ.
> 
> If a crash is being fixed, should we use a Fixes tag as well?
> 
>> To avoid this, use SMC_CONVENTION_ARM_64 only on ARM64 builds.
>>
>> Signed-off-by: Kathiravan T <quic_kathirav@quicinc.com>
>> ---
>>   drivers/firmware/qcom_scm.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
>> index fde33acd46b7..db6754db48a0 100644
>> --- a/drivers/firmware/qcom_scm.c
>> +++ b/drivers/firmware/qcom_scm.c
>> @@ -171,6 +171,7 @@ static enum qcom_scm_convention __get_convention(void)
>>          if (likely(qcom_scm_convention != SMC_CONVENTION_UNKNOWN))
>>                  return qcom_scm_convention;
>>
>> +#if IS_ENABLED(CONFIG_ARM64)
>>          /*
>>           * Device isn't required as there is only one argument - no device
>>           * needed to dma_map_single to secure world
>> @@ -191,6 +192,7 @@ static enum qcom_scm_convention __get_convention(void)
>>                  forced = true;
>>                  goto found;
>>          }
>> +#endif
> 
> If we are already inside a 'CONFIG_ARM64' define here ^^^, do we even
> need the following snippet now:
> 
> /*
>       * Some SC7180 firmwares didn't implement the
>       * QCOM_SCM_INFO_IS_CALL_AVAIL call, so we fallback to forcing ARM_64
>       * calling conventions on these firmwares. Luckily we don't make any
>       * early calls into the firmware on these SoCs so the device pointer
>       * will be valid here to check if the compatible matches.
>       */
>      if (of_device_is_compatible(__scm ? __scm->dev->of_node : NULL,
> "qcom,scm-sc7180")) {
>          forced = true;
>          goto found;
>      }
> 
> 'forced' will always be 'true' now that we are inside the CONFIG_ARM64
> check above, right?

Well, i think you can't get rid off the variable here as main purpose
of the variable seems to be print the mode is being forced here
(kind of workaround for a firmware) here and not natural.

is not that ?

-- Mukesh

> So, maybe you can clean-up that path as well.
> 
> Thanks,
> Bhupesh

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

end of thread, other threads:[~2023-05-23  9:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22  4:45 [PATCH] firmware: qcom_scm: use the SCM_CONVENTION based on ARM / ARM64 Kathiravan T
2023-05-22  6:33 ` Bhupesh Sharma
2023-05-23  8:34   ` Kathiravan T
2023-05-23  9:46   ` Mukesh Ojha

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).