[PATCH v2] firmware: meson: sm: add stub functions when CONFIG_MESON_SM is disabled

Ronald Claveau via B4 Relay posted 1 patch 1 week ago
include/linux/firmware/meson/meson_sm.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
[PATCH v2] firmware: meson: sm: add stub functions when CONFIG_MESON_SM is disabled
Posted by Ronald Claveau via B4 Relay 1 week ago
From: Ronald Claveau <linux-kernel-dev@aliel.fr>

After merging the thermal tree, linux-next build (arm_multi_v7
defconfig) failed like this:

arm-linux-gnueabihf-ld: drivers/thermal/amlogic_thermal.o: in function `amlogic_thermal_probe_sm':
/tmp/next/build/drivers/thermal/amlogic_thermal.c:196:(.text+0x2f4): undefined reference to `meson_sm_get'
arm-linux-gnueabihf-ld: /tmp/next/build/drivers/thermal/amlogic_thermal.c:205:(.text+0x320): undefined reference to `meson_sm_get_thermal_calib'

Add inline stub implementations of meson_sm_get() and
meson_sm_get_thermal_calib() behind an #else guard so that drivers
including this header can be compiled without CONFIG_MESON_SM .

Fixes: b21d88de6918 ("thermal/drivers/amlogic: Add support for secure monitor calibration readout")
Closes: https://lore.kernel.org/oe-kbuild-all/202605291530.en7aGn7w-lkp@intel.com/
Reported-by: Mark Brown <broonie@kernel.org>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ronald Claveau <linux-kernel-dev@aliel.fr>
---
Changes in v2:
- Replace #ifdef CONFIG_MESON_SM by #if IS_ENABLED(CONFIG_MESON_SM)
  to cover builtin and module in config.
- Add missing trailers for kernel test robot.
- Link to v1: https://lore.kernel.org/r/20260530-fix-missing-meson_sm-symbol-v1-1-3fb672b989d4@aliel.fr
---
 include/linux/firmware/meson/meson_sm.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/linux/firmware/meson/meson_sm.h b/include/linux/firmware/meson/meson_sm.h
index 3ebc2bd9a9760..baecdaf263f41 100644
--- a/include/linux/firmware/meson/meson_sm.h
+++ b/include/linux/firmware/meson/meson_sm.h
@@ -27,8 +27,25 @@ int meson_sm_call_write(struct meson_sm_firmware *fw, void *buffer,
 int meson_sm_call_read(struct meson_sm_firmware *fw, void *buffer,
 		       unsigned int bsize, unsigned int cmd_index, u32 arg0,
 		       u32 arg1, u32 arg2, u32 arg3, u32 arg4);
+
+#if IS_ENABLED(CONFIG_MESON_SM)
+
 struct meson_sm_firmware *meson_sm_get(struct device_node *firmware_node);
 int meson_sm_get_thermal_calib(struct meson_sm_firmware *fw, u32 *trim_info,
 			       u32 tsensor_id);
 
+#else
+
+static inline struct meson_sm_firmware *meson_sm_get(struct device_node *firmware_node)
+{
+	return NULL;
+}
+static inline int meson_sm_get_thermal_calib(struct meson_sm_firmware *fw,
+					     u32 *trim_info, u32 tsensor_id)
+{
+	return -EINVAL;
+}
+
+#endif
+
 #endif /* _MESON_SM_FW_H_ */

---
base-commit: 3929405c64376a8a54c794e8a4485023b108a97e
change-id: 20260529-fix-missing-meson_sm-symbol-7776d0d9d760

Best regards,
-- 
Ronald Claveau <linux-kernel-dev@aliel.fr>
Re: [PATCH v2] firmware: meson: sm: add stub functions when CONFIG_MESON_SM is disabled
Posted by Daniel Lezcano 1 week ago
On 5/31/26 09:51, Ronald Claveau via B4 Relay wrote:
> From: Ronald Claveau <linux-kernel-dev@aliel.fr>
>
> After merging the thermal tree, linux-next build (arm_multi_v7
> defconfig) failed like this:
>
> arm-linux-gnueabihf-ld: drivers/thermal/amlogic_thermal.o: in function `amlogic_thermal_probe_sm':
> /tmp/next/build/drivers/thermal/amlogic_thermal.c:196:(.text+0x2f4): undefined reference to `meson_sm_get'
> arm-linux-gnueabihf-ld: /tmp/next/build/drivers/thermal/amlogic_thermal.c:205:(.text+0x320): undefined reference to `meson_sm_get_thermal_calib'
>
> Add inline stub implementations of meson_sm_get() and
> meson_sm_get_thermal_calib() behind an #else guard so that drivers
> including this header can be compiled without CONFIG_MESON_SM .
>
> Fixes: b21d88de6918 ("thermal/drivers/amlogic: Add support for secure monitor calibration readout")
> Closes: https://lore.kernel.org/oe-kbuild-all/202605291530.en7aGn7w-lkp@intel.com/
> Reported-by: Mark Brown <broonie@kernel.org>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Ronald Claveau <linux-kernel-dev@aliel.fr>
> ---
> Changes in v2:
> - Replace #ifdef CONFIG_MESON_SM by #if IS_ENABLED(CONFIG_MESON_SM)
>    to cover builtin and module in config.
> - Add missing trailers for kernel test robot.
> - Link to v1: https://lore.kernel.org/r/20260530-fix-missing-meson_sm-symbol-v1-1-3fb672b989d4@aliel.fr
> ---
>   include/linux/firmware/meson/meson_sm.h | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
>
> diff --git a/include/linux/firmware/meson/meson_sm.h b/include/linux/firmware/meson/meson_sm.h
> index 3ebc2bd9a9760..baecdaf263f41 100644
> --- a/include/linux/firmware/meson/meson_sm.h
> +++ b/include/linux/firmware/meson/meson_sm.h
> @@ -27,8 +27,25 @@ int meson_sm_call_write(struct meson_sm_firmware *fw, void *buffer,
>   int meson_sm_call_read(struct meson_sm_firmware *fw, void *buffer,
>   		       unsigned int bsize, unsigned int cmd_index, u32 arg0,
>   		       u32 arg1, u32 arg2, u32 arg3, u32 arg4);
> +
> +#if IS_ENABLED(CONFIG_MESON_SM)
> +
>   struct meson_sm_firmware *meson_sm_get(struct device_node *firmware_node);
>   int meson_sm_get_thermal_calib(struct meson_sm_firmware *fw, u32 *trim_info,
>   			       u32 tsensor_id);

Do you really want to compile meson_sm as a module ?
Re: [PATCH v2] firmware: meson: sm: add stub functions when CONFIG_MESON_SM is disabled
Posted by Ronald Claveau 1 week ago
On 5/31/26 10:41 AM, Daniel Lezcano wrote:
> On 5/31/26 09:51, Ronald Claveau via B4 Relay wrote:
>> From: Ronald Claveau <linux-kernel-dev@aliel.fr>
>>
>> After merging the thermal tree, linux-next build (arm_multi_v7
>> defconfig) failed like this:
>>
>> arm-linux-gnueabihf-ld: drivers/thermal/amlogic_thermal.o: in function
>> `amlogic_thermal_probe_sm':
>> /tmp/next/build/drivers/thermal/amlogic_thermal.c:196:(.text+0x2f4):
>> undefined reference to `meson_sm_get'
>> arm-linux-gnueabihf-ld: /tmp/next/build/drivers/thermal/
>> amlogic_thermal.c:205:(.text+0x320): undefined reference to
>> `meson_sm_get_thermal_calib'
>>
>> Add inline stub implementations of meson_sm_get() and
>> meson_sm_get_thermal_calib() behind an #else guard so that drivers
>> including this header can be compiled without CONFIG_MESON_SM .
>>
>> Fixes: b21d88de6918 ("thermal/drivers/amlogic: Add support for secure
>> monitor calibration readout")
>> Closes: https://lore.kernel.org/oe-kbuild-all/202605291530.en7aGn7w-
>> lkp@intel.com/
>> Reported-by: Mark Brown <broonie@kernel.org>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Signed-off-by: Ronald Claveau <linux-kernel-dev@aliel.fr>
>> ---
>> Changes in v2:
>> - Replace #ifdef CONFIG_MESON_SM by #if IS_ENABLED(CONFIG_MESON_SM)
>>    to cover builtin and module in config.
>> - Add missing trailers for kernel test robot.
>> - Link to v1: https://lore.kernel.org/r/20260530-fix-missing-meson_sm-
>> symbol-v1-1-3fb672b989d4@aliel.fr
>> ---
>>   include/linux/firmware/meson/meson_sm.h | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/include/linux/firmware/meson/meson_sm.h b/include/linux/
>> firmware/meson/meson_sm.h
>> index 3ebc2bd9a9760..baecdaf263f41 100644
>> --- a/include/linux/firmware/meson/meson_sm.h
>> +++ b/include/linux/firmware/meson/meson_sm.h
>> @@ -27,8 +27,25 @@ int meson_sm_call_write(struct meson_sm_firmware
>> *fw, void *buffer,
>>   int meson_sm_call_read(struct meson_sm_firmware *fw, void *buffer,
>>                  unsigned int bsize, unsigned int cmd_index, u32 arg0,
>>                  u32 arg1, u32 arg2, u32 arg3, u32 arg4);
>> +
>> +#if IS_ENABLED(CONFIG_MESON_SM)
>> +
>>   struct meson_sm_firmware *meson_sm_get(struct device_node
>> *firmware_node);
>>   int meson_sm_get_thermal_calib(struct meson_sm_firmware *fw, u32
>> *trim_info,
>>                      u32 tsensor_id);
> 
> Do you really want to compile meson_sm as a module ?
> 
> 
> 

I don't want, but if I send a patch to change tristate to bool, it will
raise a warning because 'm' is not valid.
If it is accepted to ignore this warning, I can send another patch.

-- 
Best regards,
Ronald
Re: [PATCH v2] firmware: meson: sm: add stub functions when CONFIG_MESON_SM is disabled
Posted by Daniel Lezcano 1 week ago
On 5/31/26 19:49, Ronald Claveau wrote:
> On 5/31/26 10:41 AM, Daniel Lezcano wrote:
>> On 5/31/26 09:51, Ronald Claveau via B4 Relay wrote:
>>> From: Ronald Claveau <linux-kernel-dev@aliel.fr>

[ ... ]

>>> +#if IS_ENABLED(CONFIG_MESON_SM)
>>> +
>>>    struct meson_sm_firmware *meson_sm_get(struct device_node
>>> *firmware_node);
>>>    int meson_sm_get_thermal_calib(struct meson_sm_firmware *fw, u32
>>> *trim_info,
>>>                       u32 tsensor_id);
>>
>> Do you really want to compile meson_sm as a module ?
>>
>>
>>
> 
> I don't want, but if I send a patch to change tristate to bool, it will
> raise a warning because 'm' is not valid.
> If it is accepted to ignore this warning, I can send another patch.


Sorry, I don't get your point :/

'm' is a config option, make menuconfig should set it to yes or not set.

Compiling the firmware as a module means it must be loaded before the 
amlogic thermal driver, right ? Where is the dependency declared in the 
module ?

If the sm_meson is in the platform, it should be selected as part of the 
platform's component. No need to have an option for that, no ?


Re: [PATCH v2] firmware: meson: sm: add stub functions when CONFIG_MESON_SM is disabled
Posted by Daniel Lezcano 5 days, 21 hours ago
On 5/31/26 21:58, Daniel Lezcano wrote:
> On 5/31/26 19:49, Ronald Claveau wrote:
>> On 5/31/26 10:41 AM, Daniel Lezcano wrote:
>>> On 5/31/26 09:51, Ronald Claveau via B4 Relay wrote:
>>>> From: Ronald Claveau <linux-kernel-dev@aliel.fr>
> 
> [ ... ]
> 
>>>> +#if IS_ENABLED(CONFIG_MESON_SM)
>>>> +
>>>>    struct meson_sm_firmware *meson_sm_get(struct device_node
>>>> *firmware_node);
>>>>    int meson_sm_get_thermal_calib(struct meson_sm_firmware *fw, u32
>>>> *trim_info,
>>>>                       u32 tsensor_id);
>>>
>>> Do you really want to compile meson_sm as a module ?
>>>
>>>
>>>
>>
>> I don't want, but if I send a patch to change tristate to bool, it will
>> raise a warning because 'm' is not valid.
>> If it is accepted to ignore this warning, I can send another patch.
> 

[ ... ]

> Compiling the firmware as a module means it must be loaded before the 
> amlogic thermal driver, right ? Where is the dependency declared in the 
> module ?
> 
> If the sm_meson is in the platform, it should be selected as part of the 
> platform's component. No need to have an option for that, no ?

The questions remain and PR is approaching ...
Re: [PATCH v2] firmware: meson: sm: add stub functions when CONFIG_MESON_SM is disabled
Posted by Ronald Claveau 5 days, 19 hours ago
On 6/2/26 11:57 AM, Daniel Lezcano wrote:
> On 5/31/26 21:58, Daniel Lezcano wrote:
>> On 5/31/26 19:49, Ronald Claveau wrote:
>>> On 5/31/26 10:41 AM, Daniel Lezcano wrote:
>>>> On 5/31/26 09:51, Ronald Claveau via B4 Relay wrote:
>>>>> From: Ronald Claveau <linux-kernel-dev@aliel.fr>
>>
>> [ ... ]
>>
>>>>> +#if IS_ENABLED(CONFIG_MESON_SM)
>>>>> +
>>>>>    struct meson_sm_firmware *meson_sm_get(struct device_node
>>>>> *firmware_node);
>>>>>    int meson_sm_get_thermal_calib(struct meson_sm_firmware *fw, u32
>>>>> *trim_info,
>>>>>                       u32 tsensor_id);
>>>>
>>>> Do you really want to compile meson_sm as a module ?
>>>>
>>>>
>>>>
>>>
>>> I don't want, but if I send a patch to change tristate to bool, it will
>>> raise a warning because 'm' is not valid.
>>> If it is accepted to ignore this warning, I can send another patch.
>>
> 
> [ ... ]
> 
>> Compiling the firmware as a module means it must be loaded before the
>> amlogic thermal driver, right ? Where is the dependency declared in
>> the module ?
>>
>> If the sm_meson is in the platform, it should be selected as part of
>> the platform's component. No need to have an option for that, no ?
> 
> The questions remain and PR is approaching ...

Sorry for the delay.
The module issue was raised by the test robot here
https://lore.kernel.org/oe-kbuild-all/202605310154.bmdMBZHJ-lkp@intel.com/

If I understand correctly we can drop this stub change and only use a
"depends on MESON_SM" for the "AMLOGIC_THERMAL" config, is it correct ?

-- 
Best regards,
Ronald
Re: [PATCH v2] firmware: meson: sm: add stub functions when CONFIG_MESON_SM is disabled
Posted by Daniel Lezcano 5 days, 19 hours ago
On 6/2/26 13:58, Ronald Claveau wrote:
> On 6/2/26 11:57 AM, Daniel Lezcano wrote:
>> On 5/31/26 21:58, Daniel Lezcano wrote:
>>> On 5/31/26 19:49, Ronald Claveau wrote:
>>>> On 5/31/26 10:41 AM, Daniel Lezcano wrote:
>>>>> On 5/31/26 09:51, Ronald Claveau via B4 Relay wrote:
>>>>>> From: Ronald Claveau <linux-kernel-dev@aliel.fr>
>>>
>>> [ ... ]

[ ... ]

> Sorry for the delay.
> The module issue was raised by the test robot here
> https://lore.kernel.org/oe-kbuild-all/202605310154.bmdMBZHJ-lkp@intel.com/
> 
> If I understand correctly we can drop this stub change and only use a
> "depends on MESON_SM" for the "AMLOGIC_THERMAL" config, is it correct ?

Yes, that is the simplest solution for now

Indirectly related, where is the mod dependency telling meson_sm must be 
loaded before the amlogic thermal driver ?
Re: [PATCH v2] firmware: meson: sm: add stub functions when CONFIG_MESON_SM is disabled
Posted by Ronald Claveau 5 days, 18 hours ago
On 6/2/26 2:15 PM, Daniel Lezcano wrote:
> On 6/2/26 13:58, Ronald Claveau wrote:
>> On 6/2/26 11:57 AM, Daniel Lezcano wrote:
>>> On 5/31/26 21:58, Daniel Lezcano wrote:
>>>> On 5/31/26 19:49, Ronald Claveau wrote:
>>>>> On 5/31/26 10:41 AM, Daniel Lezcano wrote:
>>>>>> On 5/31/26 09:51, Ronald Claveau via B4 Relay wrote:
>>>>>>> From: Ronald Claveau <linux-kernel-dev@aliel.fr>
>>>>
>>>> [ ... ]
> 
> [ ... ]
> 
>> Sorry for the delay.
>> The module issue was raised by the test robot here
>> https://lore.kernel.org/oe-kbuild-all/202605310154.bmdMBZHJ-
>> lkp@intel.com/
>>
>> If I understand correctly we can drop this stub change and only use a
>> "depends on MESON_SM" for the "AMLOGIC_THERMAL" config, is it correct ?
> 
> Yes, that is the simplest solution for now
> 
> Indirectly related, where is the mod dependency telling meson_sm must be
> loaded before the amlogic thermal driver ?

I think depmod should detect the symbol usage and add it to the
modules.dep file to give the correct order. Do you think it would not
work here ?

-- 
Best regards,
Ronald