linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware: smccc: Fix Arm SMCCC SOC_ID name call
@ 2025-09-02 17:20 Andre Przywara
  2025-09-03 14:23 ` Sudeep Holla
  0 siblings, 1 reply; 4+ messages in thread
From: Andre Przywara @ 2025-09-02 17:20 UTC (permalink / raw)
  To: Mark Rutland, Lorenzo Pieralisi, Sudeep Holla
  Cc: Paul Benoit, linux-arm-kernel, linux-kernel

Commit 5f9c23abc477 ("firmware: smccc: Support optional Arm SMCCC SOC_ID
name") introduced the SOC_ID name string call, which reports a human
readable string describing the SoC, as returned by firmware.
The SMCCC spec v1.6 describes this feature as AArch64 only, since we rely
on 8 characters to be transmitted per register. Consequently the SMCCC
call must use the AArch64 calling convention, which requires bit 30 of
the FID to be set. The spec is a bit confusing here, since it mentions
that in the parameter description ("2: SoC name (optionally implemented for
SMC64 calls, ..."), but still prints the FID explicitly as 0x80000002.
But as this FID is using the SMC32 calling convention (correct for the
other two calls), it will not match what mainline TF-A is expecting, so
any call would return NOT_SUPPORTED.

Add a 64-bit version of the ARCH_SOC_ID FID macro, and use that for the
SoC name version of the call.

Fixes: 5f9c23abc477 ("firmware: smccc: Support optional Arm SMCCC SOC_ID name")
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
Hi,

as somewhat expected, this now fails on an Ampere machine, which
reported a string in /sys/devices/soc0/machine before, but is now missing
this file.
Any idea what's the best way to handle this? Let the code try the 32-bit
FID, when the 64-bit one fails? Or handle this as some kind of erratum?

Cheers,
Andre

 drivers/firmware/smccc/soc_id.c | 2 +-
 include/linux/arm-smccc.h       | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/smccc/soc_id.c b/drivers/firmware/smccc/soc_id.c
index c24b3fca1cfe3..8f556df34fc42 100644
--- a/drivers/firmware/smccc/soc_id.c
+++ b/drivers/firmware/smccc/soc_id.c
@@ -60,7 +60,7 @@ static char __init *smccc_soc_name_init(void)
 	 * to the ARM_SMCCC_ARCH_SOC_ID function.  Fetch it if
 	 * available.
 	 */
-	args.a0 = ARM_SMCCC_ARCH_SOC_ID;
+	args.a0 = ARM_SMCCC_ARCH_SOC_ID64;
 	args.a1 = 2;    /* SOC_ID name */
 	arm_smccc_1_2_invoke(&args, &res);
 
diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
index 50b47eba7d015..976c5f8001ff2 100644
--- a/include/linux/arm-smccc.h
+++ b/include/linux/arm-smccc.h
@@ -90,6 +90,11 @@
 			   ARM_SMCCC_SMC_32,				\
 			   0, 2)
 
+#define ARM_SMCCC_ARCH_SOC_ID64						\
+	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
+			   ARM_SMCCC_SMC_64,				\
+			   0, 2)
+
 #define ARM_SMCCC_ARCH_WORKAROUND_1					\
 	ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,				\
 			   ARM_SMCCC_SMC_32,				\
-- 
2.25.1


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

* Re: [PATCH] firmware: smccc: Fix Arm SMCCC SOC_ID name call
  2025-09-02 17:20 [PATCH] firmware: smccc: Fix Arm SMCCC SOC_ID name call Andre Przywara
@ 2025-09-03 14:23 ` Sudeep Holla
  2025-09-03 14:49   ` Sudeep Holla
  0 siblings, 1 reply; 4+ messages in thread
From: Sudeep Holla @ 2025-09-03 14:23 UTC (permalink / raw)
  To: Andre Przywara
  Cc: Mark Rutland, Sudeep Holla, Lorenzo Pieralisi, Paul Benoit,
	linux-arm-kernel, linux-kernel

On Tue, Sep 02, 2025 at 06:20:53PM +0100, Andre Przywara wrote:
> Commit 5f9c23abc477 ("firmware: smccc: Support optional Arm SMCCC SOC_ID
> name") introduced the SOC_ID name string call, which reports a human
> readable string describing the SoC, as returned by firmware.
> The SMCCC spec v1.6 describes this feature as AArch64 only, since we rely
> on 8 characters to be transmitted per register. Consequently the SMCCC
> call must use the AArch64 calling convention, which requires bit 30 of
> the FID to be set. The spec is a bit confusing here, since it mentions
> that in the parameter description ("2: SoC name (optionally implemented for
> SMC64 calls, ..."), but still prints the FID explicitly as 0x80000002.
> But as this FID is using the SMC32 calling convention (correct for the
> other two calls), it will not match what mainline TF-A is expecting, so
> any call would return NOT_SUPPORTED.
> 

Good catch and I must admit I completely missed it inspite of discussing
32b vs 64b FID around the same time this was introduced.

> Add a 64-bit version of the ARCH_SOC_ID FID macro, and use that for the
> SoC name version of the call.
> 
> Fixes: 5f9c23abc477 ("firmware: smccc: Support optional Arm SMCCC SOC_ID name")
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
> Hi,
> 
> as somewhat expected, this now fails on an Ampere machine, which
> reported a string in /sys/devices/soc0/machine before, but is now missing
> this file.
> Any idea what's the best way to handle this? Let the code try the 32-bit
> FID, when the 64-bit one fails? Or handle this as some kind of erratum?
> 

Not sure about it yet. Erratum seems good option so that we can avoid
others getting it wrong too as they might just run the kernel and be happy
if the machine sysfs shows up as we decided to do fallback to 32b FID.

I will start a discussion to get the spec updated and pushed out and see
how that goes.

The change itself looks good and happy to get it merged once we know
what is the best approach(erratum vs fallback).

-- 
Regards,
Sudeep

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

* Re: [PATCH] firmware: smccc: Fix Arm SMCCC SOC_ID name call
  2025-09-03 14:23 ` Sudeep Holla
@ 2025-09-03 14:49   ` Sudeep Holla
  2025-09-03 21:38     ` Paul Benoit
  0 siblings, 1 reply; 4+ messages in thread
From: Sudeep Holla @ 2025-09-03 14:49 UTC (permalink / raw)
  To: Andre Przywara, Paul Benoit
  Cc: Mark Rutland, Sudeep Holla, Lorenzo Pieralisi, linux-arm-kernel,
	linux-kernel

On Wed, Sep 03, 2025 at 03:23:58PM +0100, Sudeep Holla wrote:
> On Tue, Sep 02, 2025 at 06:20:53PM +0100, Andre Przywara wrote:
> > Commit 5f9c23abc477 ("firmware: smccc: Support optional Arm SMCCC SOC_ID
> > name") introduced the SOC_ID name string call, which reports a human
> > readable string describing the SoC, as returned by firmware.
> > The SMCCC spec v1.6 describes this feature as AArch64 only, since we rely
> > on 8 characters to be transmitted per register. Consequently the SMCCC
> > call must use the AArch64 calling convention, which requires bit 30 of
> > the FID to be set. The spec is a bit confusing here, since it mentions
> > that in the parameter description ("2: SoC name (optionally implemented for
> > SMC64 calls, ..."), but still prints the FID explicitly as 0x80000002.
> > But as this FID is using the SMC32 calling convention (correct for the
> > other two calls), it will not match what mainline TF-A is expecting, so
> > any call would return NOT_SUPPORTED.
> > 
> 
> Good catch and I must admit I completely missed it inspite of discussing
> 32b vs 64b FID around the same time this was introduced.
> 
> > Add a 64-bit version of the ARCH_SOC_ID FID macro, and use that for the
> > SoC name version of the call.
> > 
> > Fixes: 5f9c23abc477 ("firmware: smccc: Support optional Arm SMCCC SOC_ID name")
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > ---
> > Hi,
> > 
> > as somewhat expected, this now fails on an Ampere machine, which
> > reported a string in /sys/devices/soc0/machine before, but is now missing
> > this file.
> > Any idea what's the best way to handle this? Let the code try the 32-bit
> > FID, when the 64-bit one fails? Or handle this as some kind of erratum?
> > 
> 
> Not sure about it yet. Erratum seems good option so that we can avoid
> others getting it wrong too as they might just run the kernel and be happy
> if the machine sysfs shows up as we decided to do fallback to 32b FID.
> 
> I will start a discussion to get the spec updated and pushed out and see
> how that goes.
> 
> The change itself looks good and happy to get it merged once we know
> what is the best approach(erratum vs fallback).
> 

Looking at the SMCCC spec(DEN0028 v1.6 G Edition) ->
Section 7.4.6 Implementation responsibilities

If implemented, the firmware:
...
• must not implement SoC_ID_type == 2 for SMC32.
• can optionally implement SoC_ID_type == 2 for SMC64 (Function ID 0xC000_0002),
...

So Ampere is not spec conformant here and hence I prefer to handle it as
erratum. Hopefully we can use SOC_ID version and revision to keep the scope
of erratum confined to smallest set of platforms.

Paul,

Thoughts ?

-- 
Regards,
Sudeep

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

* Re: [PATCH] firmware: smccc: Fix Arm SMCCC SOC_ID name call
  2025-09-03 14:49   ` Sudeep Holla
@ 2025-09-03 21:38     ` Paul Benoit
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Benoit @ 2025-09-03 21:38 UTC (permalink / raw)
  To: Sudeep Holla, Andre Przywara
  Cc: Mark Rutland, Lorenzo Pieralisi, linux-arm-kernel, linux-kernel

On 9/3/2025 10:49 AM, Sudeep Holla wrote:
> On Wed, Sep 03, 2025 at 03:23:58PM +0100, Sudeep Holla wrote:
>> On Tue, Sep 02, 2025 at 06:20:53PM +0100, Andre Przywara wrote:
>>> Commit 5f9c23abc477 ("firmware: smccc: Support optional Arm SMCCC SOC_ID
>>> name") introduced the SOC_ID name string call, which reports a human
>>> readable string describing the SoC, as returned by firmware.
>>> The SMCCC spec v1.6 describes this feature as AArch64 only, since we rely
>>> on 8 characters to be transmitted per register. Consequently the SMCCC
>>> call must use the AArch64 calling convention, which requires bit 30 of
>>> the FID to be set. The spec is a bit confusing here, since it mentions
>>> that in the parameter description ("2: SoC name (optionally implemented for
>>> SMC64 calls, ..."), but still prints the FID explicitly as 0x80000002.
>>> But as this FID is using the SMC32 calling convention (correct for the
>>> other two calls), it will not match what mainline TF-A is expecting, so
>>> any call would return NOT_SUPPORTED.
>>>
>>
>> Good catch and I must admit I completely missed it inspite of discussing
>> 32b vs 64b FID around the same time this was introduced.
>>
>>> Add a 64-bit version of the ARCH_SOC_ID FID macro, and use that for the
>>> SoC name version of the call.
>>>
>>> Fixes: 5f9c23abc477 ("firmware: smccc: Support optional Arm SMCCC SOC_ID name")
>>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>> ---
>>> Hi,
>>>
>>> as somewhat expected, this now fails on an Ampere machine, which
>>> reported a string in /sys/devices/soc0/machine before, but is now missing
>>> this file.
>>> Any idea what's the best way to handle this? Let the code try the 32-bit
>>> FID, when the 64-bit one fails? Or handle this as some kind of erratum?
>>>
>>
>> Not sure about it yet. Erratum seems good option so that we can avoid
>> others getting it wrong too as they might just run the kernel and be happy
>> if the machine sysfs shows up as we decided to do fallback to 32b FID.
>>
>> I will start a discussion to get the spec updated and pushed out and see
>> how that goes.
>>
>> The change itself looks good and happy to get it merged once we know
>> what is the best approach(erratum vs fallback).
>>
> 
> Looking at the SMCCC spec(DEN0028 v1.6 G Edition) ->
> Section 7.4.6 Implementation responsibilities
> 
> If implemented, the firmware:
> ...
> • must not implement SoC_ID_type == 2 for SMC32.
> • can optionally implement SoC_ID_type == 2 for SMC64 (Function ID 0xC000_0002),
> ...
> 
> So Ampere is not spec conformant here and hence I prefer to handle it as
> erratum. Hopefully we can use SOC_ID version and revision to keep the scope
> of erratum confined to smallest set of platforms.
> 
> Paul,
> 
> Thoughts ?
>

Am I correctly understanding that, if the SMC64 SOC_ID Name call fails,
rather than an unconditional fallback to the SMC32 call, the SMC32
fallback would only be occurring under the proposed erratum?

I brought this issue up at a weekly team meeting today, and I'll also be
communicating with the Ampere Computing firmware team regarding this
issue.

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

end of thread, other threads:[~2025-09-03 21:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-02 17:20 [PATCH] firmware: smccc: Fix Arm SMCCC SOC_ID name call Andre Przywara
2025-09-03 14:23 ` Sudeep Holla
2025-09-03 14:49   ` Sudeep Holla
2025-09-03 21:38     ` Paul Benoit

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