[PATCH] soc: qcom: smem: Add stubs for CONFIG_QCOM_SMEM=n

Daniel Baluta posted 1 patch 1 month, 2 weeks ago
include/linux/soc/qcom/smem.h | 51 +++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
[PATCH] soc: qcom: smem: Add stubs for CONFIG_QCOM_SMEM=n
Posted by Daniel Baluta 1 month, 2 weeks ago
drivers/soc/qcom/ubwc_config.c calls qcom_smem_is_available() and
qcom_smem_dram_get_hbb() unconditionally. These symbols are provided
by the QCOM_SMEM module, but QCOM_UBWC_CONFIG can be selected by
DRM_MSM even on non-Qcom platforms (e.g. with SOC_IMX5) thus resulting
in the following link error:

  arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x2c): undefined
      reference to 'qcom_smem_is_available'
  arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x4c): undefined
      reference to 'qcom_smem_dram_get_hbb'

Add static inline stub definitions for the !CONFIG_QCOM_SMEM case for
all `qcom_smem_` functions in order to fix the issue above.

Fixes: 1b445022d1d0 ("soc: qcom: ubwc: Get HBB from SMEM")
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 include/linux/soc/qcom/smem.h | 51 +++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/include/linux/soc/qcom/smem.h b/include/linux/soc/qcom/smem.h
index 3249cbd2016b5..d35ab5d248054 100644
--- a/include/linux/soc/qcom/smem.h
+++ b/include/linux/soc/qcom/smem.h
@@ -4,6 +4,8 @@
 
 #define QCOM_SMEM_HOST_ANY -1
 
+#if IS_ENABLED(CONFIG_QCOM_SMEM)
+
 bool qcom_smem_is_available(void);
 int qcom_smem_alloc(unsigned host, unsigned item, size_t size);
 void *qcom_smem_get(unsigned host, unsigned item, size_t *size);
@@ -19,4 +21,53 @@ int qcom_smem_bust_hwspin_lock_by_host(unsigned int host);
 
 int qcom_smem_dram_get_hbb(void);
 
+#else
+
+static inline bool qcom_smem_is_available(void)
+{
+	return false;
+}
+
+static inline int qcom_smem_alloc(unsigned int host, unsigned int item, size_t size)
+{
+	return -ENODEV;
+}
+
+static inline void *qcom_smem_get(unsigned int host, unsigned int item, size_t *size)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline int qcom_smem_get_free_space(unsigned int host)
+{
+	return -ENODEV;
+}
+
+static inline phys_addr_t qcom_smem_virt_to_phys(void *p)
+{
+	return 0;
+}
+
+static inline int qcom_smem_get_soc_id(u32 *id)
+{
+	return -ENODEV;
+}
+
+static inline int qcom_smem_get_feature_code(u32 *code)
+{
+	return -ENODEV;
+}
+
+static inline int qcom_smem_bust_hwspin_lock_by_host(unsigned int host)
+{
+	return -ENODEV;
+}
+
+static inline int qcom_smem_dram_get_hbb(void)
+{
+	return -ENODATA;
+}
+
+#endif /* CONFIG_QCOM_SMEM */
+
 #endif
-- 
2.45.2
Re: [PATCH] soc: qcom: smem: Add stubs for CONFIG_QCOM_SMEM=n
Posted by Dmitry Baryshkov 1 month, 2 weeks ago
On Tue, Aug 11, 2026 at 03:31:03PM +0300, Daniel Baluta wrote:
> drivers/soc/qcom/ubwc_config.c calls qcom_smem_is_available() and
> qcom_smem_dram_get_hbb() unconditionally. These symbols are provided
> by the QCOM_SMEM module, but QCOM_UBWC_CONFIG can be selected by
> DRM_MSM even on non-Qcom platforms (e.g. with SOC_IMX5) thus resulting
> in the following link error:
> 
>   arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x2c): undefined
>       reference to 'qcom_smem_is_available'
>   arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x4c): undefined
>       reference to 'qcom_smem_dram_get_hbb'
> 
> Add static inline stub definitions for the !CONFIG_QCOM_SMEM case for
> all `qcom_smem_` functions in order to fix the issue above.
> 
> Fixes: 1b445022d1d0 ("soc: qcom: ubwc: Get HBB from SMEM")
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
>  include/linux/soc/qcom/smem.h | 51 +++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)

I think a proper fix would be to relax drm/msm dependency on UBWC_CONFIG
(limiting it to ARM64 && ARCH_QCOM) and letting UBWC_CONFIG have strict
dependency on QCOM_SMEM. WDYT?

-- 
With best wishes
Dmitry
Re: [PATCH] soc: qcom: smem: Add stubs for CONFIG_QCOM_SMEM=n
Posted by Daniel Baluta 1 month, 2 weeks ago
On 8/11/26 16:53, Dmitry Baryshkov wrote:
> On Tue, Aug 11, 2026 at 03:31:03PM +0300, Daniel Baluta wrote:
>> drivers/soc/qcom/ubwc_config.c calls qcom_smem_is_available() and
>> qcom_smem_dram_get_hbb() unconditionally. These symbols are provided
>> by the QCOM_SMEM module, but QCOM_UBWC_CONFIG can be selected by
>> DRM_MSM even on non-Qcom platforms (e.g. with SOC_IMX5) thus resulting
>> in the following link error:
>>
>>   arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x2c): undefined
>>       reference to 'qcom_smem_is_available'
>>   arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x4c): undefined
>>       reference to 'qcom_smem_dram_get_hbb'
>>
>> Add static inline stub definitions for the !CONFIG_QCOM_SMEM case for
>> all `qcom_smem_` functions in order to fix the issue above.
>>
>> Fixes: 1b445022d1d0 ("soc: qcom: ubwc: Get HBB from SMEM")
>> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
>> ---
>>  include/linux/soc/qcom/smem.h | 51 +++++++++++++++++++++++++++++++++++
>>  1 file changed, 51 insertions(+)
> 
> I think a proper fix would be to relax drm/msm dependency on UBWC_CONFIG
> (limiting it to ARM64 && ARCH_QCOM) and letting UBWC_CONFIG have strict
> dependency on QCOM_SMEM. WDYT?
> 

Yes, that would work.