Skip to contentSkip to conversation

soc: qcom: ubwc: Fix link error

PATCH Superseded Daniel Baluta 4 participants 10 messages Aug 12 – Aug 14

Subsystems (8)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover soc: qcom: ubwc: Fix link error

Fix link error caused by the fact that drivers/soc/qcom/ubwc_config.c enabled via QCOM_UBWC_CONFIG uses unconditionally symbols from drivers/soc/qcom/smem.c enabled via CONFIG_QCOM_SMEM.

Changes since v3:
- fix issues pointed by sashiko https://sashiko.dev/#/patchset/20260812130421.670527-1-daniel.baluta%40nxp.com
- add new patches 2/3 in order to fix unmet dependcy for VIDEO_QCOM_IRIS
- Use IS_REACHABLE instead of IS_ENABLED to avoid the situation we use
some symbols in builtin kernel but their definitions sits in a
module.

Remark for Dmitry, at this point I think v1 would have been a better option.
Link to v1:
- https://lore.kernel.org/imx/[email protected]/T/#t

Daniel Baluta (3):
soc: qcom: ubwc: Fix link error when QCOM_SMEM=n
media: iris: Fix unmet dependency when QCOM_SMEM=n
soc: qcom: ubwc: Use IS_REACHABLE() instead of IS_ENABLED()

 drivers/gpu/drm/msm/Kconfig              | 2 +-
 drivers/media/platform/qcom/iris/Kconfig | 2 +-
 drivers/soc/qcom/Kconfig                 | 1 +
 include/linux/soc/qcom/ubwc.h            | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH v4 1/3 soc: qcom: ubwc: Fix link error when QCOM_SMEM=n

DRM_MSM unconditionally selects QCOM_UBWC_CONFIG, which calls SMEM APIs, causing a link error on non-Qcom platforms (e.g. SOC_IMX5):

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'

Make QCOM_UBWC_CONFIG depend on QCOM_SMEM to make the requirement explicit, and guard the select in DRM_MSM with ARCH_QCOM && QCOM_SMEM so it is only selected when its dependency is met.

Fixes 1b445022d1d0 ("soc: qcom: ubwc: Get HBB from SMEM")
---
 drivers/gpu/drm/msm/Kconfig | 2 +-
 drivers/soc/qcom/Kconfig    | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/Kconfig +1 -1
index 09469d56513b0..1670dbc9464c6 100644
@@ -22,7 +22,7 @@ config DRM_MSM
 	select TMPFS
 	select QCOM_SCM
 	select QCOM_PAS
-	select QCOM_UBWC_CONFIG
+	select QCOM_UBWC_CONFIG if ARCH_QCOM && QCOM_SMEM
 	select WANT_DEV_COREDUMP
 	select SND_SOC_HDMI_CODEC if SND_SOC
 	select SYNC_FILE
drivers/soc/qcom/Kconfig +1 -0
index fd4d4ecd2df0f..e0629e9328c87 100644
@@ -321,6 +321,7 @@ config QCOM_QMI_HELPERS
 
 config QCOM_UBWC_CONFIG
 	tristate
+	depends on QCOM_SMEM
 	help
 	  Most Qualcomm SoCs feature a number of Universal Bandwidth Compression
 	  (UBWC) engines across various IP blocks, which need to be initialized
Signature · 1 line
2.45.2
#2 lore raw

Re: [PATCH v4 1/3] soc: qcom: ubwc: Fix link error when QCOM_SMEM=n

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The patch adds `depends on QCOM_SMEM` to `QCOM_UBWC_CONFIG` but misses that `VIDEO_QCOM_IRIS`…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The patch adds depends on QCOM_SMEM to QCOM_UBWC_CONFIG but misses that VIDEO_QCOM_IRIS unconditionally selects it, causing an unmet dependency warning and leaving the original linker error unfixed.
- [High] The conditional select in DRM_MSM creates a configuration where a built-in driver calls a function from a module, resulting in a linker error.
--

--- Patch [1]: [PATCH v4 1/3] soc: qcom: ubwc: Fix link error when QCOM_SMEM=n --- commit a54f8c4ddffc0b9c1fbde97cc8f98242588a42bf
Author: Daniel Baluta <[email protected]>

soc: qcom: ubwc: Fix link error when QCOM_SMEM=n

DRM_MSM unconditionally selects QCOM_UBWC_CONFIG, which calls SMEM APIs, causing a link error on non-Qcom platforms (e.g. SOC_IMX5). Make QCOM_UBWC_CONFIG depend on QCOM_SMEM to make the requirement explicit, and guard the select in DRM_MSM with ARCH_QCOM && QCOM_SMEM.

drivers/gpu/drm/msm/Kconfig config DRM_MSM · line 25

Quoted 10 lines
drivers/gpu/drm/msm/Kconfig +1 -1
index 09469d56513b0..1670dbc9464c6 100644
@@ -22,7 +22,7 @@ config DRM_MSM
 	select TMPFS
 	select QCOM_SCM
 	select QCOM_PAS
-	select QCOM_UBWC_CONFIG
+	select QCOM_UBWC_CONFIG if ARCH_QCOM && QCOM_SMEM

[Severity: High]
Can this conditional select create a new configuration where a built-in driver fails to link against a module?

If we compile with CONFIG_DRM_MSM=y, CONFIG_ARCH_QCOM=y, and CONFIG_QCOM_SMEM=m, the select evaluates to 'm', forcing CONFIG_QCOM_UBWC_CONFIG=m.

Because IS_ENABLED(CONFIG_QCOM_UBWC_CONFIG) evaluates to true for both 'y' and 'm', built-in code like msm_mdss_init() in drivers/gpu/drm/msm/msm_mdss.c will attempt to call the external qcom_ubwc_config_get_data() function:

include/linux/soc/qcom/ubwc.h:
#if IS_ENABLED(CONFIG_QCOM_UBWC_CONFIG)
const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void);
...

At link time, vmlinux will fail to resolve this function because it resides in the ubwc_config module.

Quoted 3 lines
drivers/gpu/drm/msm/Kconfig +0 -0
 	select WANT_DEV_COREDUMP
 	select SND_SOC_HDMI_CODEC if SND_SOC
 	select SYNC_FILE

[ ... ]

drivers/soc/qcom/Kconfig config QCOM_QMI_HELPERS · line 324

Quoted 9 lines
drivers/soc/qcom/Kconfig +1 -0
index fd4d4ecd2df0f..e0629e9328c87 100644
@@ -321,6 +321,7 @@ config QCOM_QMI_HELPERS
 
 config QCOM_UBWC_CONFIG
 	tristate
+	depends on QCOM_SMEM

[Severity: High]
Does this leave the linker error unfixed when CONFIG_VIDEO_QCOM_IRIS=y?

Looking at drivers/media/platform/qcom/iris/Kconfig, it unconditionally selects QCOM_UBWC_CONFIG:

config VIDEO_QCOM_IRIS

    ...
    select QCOM_UBWC_CONFIG

If we compile with CONFIG_COMPILE_TEST=y, CONFIG_VIDEO_QCOM_IRIS=y, and CONFIG_QCOM_SMEM=n, the unconditional select will force QCOM_UBWC_CONFIG to y despite the new dependency.

This produces an unmet dependency warning and attempts to link ubwc_config.c, which fails with the exact undefined reference to 'qcom_smem_*' APIs that this patch intended to fix.

Quoted 3 lines
drivers/soc/qcom/Kconfig +0 -0
 	help
 	  Most Qualcomm SoCs feature a number of Universal Bandwidth Compression
 	  (UBWC) engines across various IP blocks, which need to be initialized
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

Re: [PATCH v4 1/3] soc: qcom: ubwc: Fix link error when QCOM_SMEM=n

Quoted 3 lines · On 8/12/26 18:50, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The patch adds depends on QCOM_SMEM to QCOM_UBWC_CONFIG but misses that VIDEO_QCOM_IRIS unconditionally selects it, causing an unmet dependency warning and leaving the original linker error unfixed.
- [High] The conditional select in DRM_MSM creates a configuration where a built-in driver calls a function from a module, resulting in a linker error.

these two are addressed in patches 2/3 and 3/3.

#4 lore raw

PATCH v4 2/3 media: iris: Fix unmet dependency when QCOM_SMEM=n

In reply to Daniel Baluta

VIDEO_QCOM_IRIS unconditionally selects QCOM_UBWC_CONFIG, violating the Kconfig rule that a selecting symbol must carry all dependencies of the selected one. QCOM_UBWC_CONFIG now depends on QCOM_SMEM, so with COMPILE_TEST and QCOM_SMEM=n Kconfig forces QCOM_UBWC_CONFIG=y and the build fails with an undefined reference to qcom_smem_is_available.

Guard the select the same way DRM_MSM already does.

Fixes c43207553867 ("media: iris: retrieve UBWC platform configuration")
---
 drivers/media/platform/qcom/iris/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/iris/Kconfig +1 -1
index 388c9bbc81365..04a4440a2dd51 100644
@@ -6,7 +6,7 @@ config VIDEO_QCOM_IRIS
 	select QCOM_MDT_LOADER
 	select QCOM_SCM
 	select QCOM_PAS
-	select QCOM_UBWC_CONFIG
+	select QCOM_UBWC_CONFIG if ARCH_QCOM && QCOM_SMEM
 	select VIDEOBUF2_DMA_CONTIG
 	help
 	  This is a V4L2 driver for Qualcomm iris video accelerator
Signature · 1 line
2.45.2
#5 lore raw

PATCH v4 3/3 soc: qcom: ubwc: Use IS_REACHABLE() instead of IS_ENABLED()

In reply to Daniel Baluta

When DRM_MSM=y and QCOM_SMEM=m, the conditional select evaluates to 'm' so QCOM_UBWC_CONFIG=m. IS_ENABLED() is true for both =y and =m, so the real qcom_ubwc_config_get_data() declaration is exposed to built-in callers, which cannot resolve it at vmlinux link time.

IS_REACHABLE() is false when the caller is built-in and the dependency is only a module, causing the inline stub to be used instead.

Fixes 1b445022d1d0 ("soc: qcom: ubwc: Get HBB from SMEM")
---
 include/linux/soc/qcom/ubwc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/soc/qcom/ubwc.h +1 -1
index a7372d9c25fbc..1a61238f6d4d5 100644
@@ -36,7 +36,7 @@ struct qcom_ubwc_cfg_data {
 #define UBWC_5_0 0x50000000
 #define UBWC_6_0 0x60000000
 
-#if IS_ENABLED(CONFIG_QCOM_UBWC_CONFIG)
+#if IS_REACHABLE(CONFIG_QCOM_UBWC_CONFIG)
 const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void);
 #else
 static inline const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void)
Signature · 1 line
2.45.2
#6 lore raw

Re: [PATCH v4 3/3] soc: qcom: ubwc: Use IS_REACHABLE() instead of IS_ENABLED()

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Using IS_REACHABLE() masks a Kconfig dependency mismatch, causing guaranteed runtime probe failures for built-in drivers when the dependency is built as a module.

Pre-existing issues:
- [Medium] Missing resource cleanup in a5xx_gpu_init() when qcom_ubwc_config_get_data() fails. --

--- Patch [3]: [PATCH v4 3/3] soc: qcom: ubwc: Use IS_REACHABLE() instead of IS_ENABLED() --- commit 27da698f8aa42c85fe3250533a0ac637d13515f3
Author: Daniel Baluta <[email protected]>

soc: qcom: ubwc: Use IS_REACHABLE() instead of IS_ENABLED()

This commit changes the conditional check for QCOM_UBWC_CONFIG from IS_ENABLED to IS_REACHABLE. This aims to resolve a link error when built-in callers try to use the function while the dependency is built as a module.

Quoted 4 lines
include/linux/soc/qcom/ubwc.h +0 -0
index a7372d9c25fbc..1a61238f6d4d5 100644

[ ... ]

include/linux/soc/qcom/ubwc.h struct qcom_ubwc_cfg_data { · line 39

Quoted 6 lines
include/linux/soc/qcom/ubwc.h +1 -1
@@ -36,7 +36,7 @@ struct qcom_ubwc_cfg_data {
 #define UBWC_5_0 0x50000000
 #define UBWC_6_0 0x60000000
 
-#if IS_ENABLED(CONFIG_QCOM_UBWC_CONFIG)
+#if IS_REACHABLE(CONFIG_QCOM_UBWC_CONFIG)

[Severity: High]
Does using IS_REACHABLE() here mask a Kconfig dependency mismatch?

If a user configures DRM_MSM=y and QCOM_SMEM=m, IS_REACHABLE() evaluates to false and provides the inline stub to the built-in driver. Since the callers abort on error rather than treating the configuration as optional, won't this cause guaranteed runtime probe failures for built-in drivers instead of catching the unmet dependency at build time?

include/linux/soc/qcom/ubwc.h struct qcom_ubwc_cfg_data { · line 42

Quoted 3 lines
include/linux/soc/qcom/ubwc.h +0 -0
 const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void);
 #else
 static inline const struct qcom_ubwc_cfg_data *qcom_ubwc_config_get_data(void)

[Severity: Medium]
This is a pre-existing issue, but does falling back to this stub cause a resource leak during device probe?

Looking at a5xx_gpu_init(), if the stub is used and returns an error pointer, the function returns early without cleaning up resources allocated by adreno_gpu_init():

drivers/gpu/drm/msm/adreno/a5xx_gpu.c:a5xx_gpu_init() {
    ...
    adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, 1);
    ...
    adreno_gpu->ubwc_config = qcom_ubwc_config_get_data();
    if (IS_ERR(adreno_gpu->ubwc_config))
        return ERR_CAST(adreno_gpu->ubwc_config);
    ...
}

Will this leak memory and GPU resources like ringbuffers and the a5xx_gpu structure itself if it fails to call a5xx_destroy() on the error path?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#7 lore raw
In reply to Daniel Baluta

Hi Daniel,

Quoted 18 lines · Daniel Baluta

Fix link error caused by the fact that drivers/soc/qcom/ubwc_config.c enabled via QCOM_UBWC_CONFIG uses unconditionally symbols from drivers/soc/qcom/smem.c enabled via CONFIG_QCOM_SMEM.

Changes since v3:
- fix issues pointed by sashiko https://sashiko.dev/#/patchset/20260812130421.670527-1-daniel.baluta%40nxp.com
- add new patches 2/3 in order to fix unmet dependcy for VIDEO_QCOM_IRIS
- Use IS_REACHABLE instead of IS_ENABLED to avoid the situation we use
some symbols in builtin kernel but their definitions sits in a
module.

Remark for Dmitry, at this point I think v1 would have been a better option.
Link to v1:

(quoted diff) +0 -1
-	https://lore.kernel.org/imx/[email protected]/T/#t
Quoted 3 lines

Daniel Baluta (3):
soc: qcom: ubwc: Fix link error when QCOM_SMEM=n
media: iris: Fix unmet dependency when QCOM_SMEM=n

I think this patch should come first since you introduce the QCOM_SMEM dependency that requires this change in the first patch, which could mess with bisects. I would personally add the 'if' condition to the 'select QCOM_UBWC_CONFIG' statements in one patch then add the QCOM_SMEM dependency to QCOM_UBWC_CONFIG in a separate patch.

Quoted 1 line

soc: qcom: ubwc: Use IS_REACHABLE() instead of IS_ENABLED()

Even with this series applied, I see

  $ cat allno.config
  CONFIG_ARCH_MULTI_V7=y
  CONFIG_ARCH_QCOM=y
  CONFIG_DRM=y
  CONFIG_DRM_MSM=y
  CONFIG_DRM_MSM_DPU=y
  CONFIG_IOMMU_SUPPORT=y
  CONFIG_MAILBOX=y
  CONFIG_MMU=y
  CONFIG_PM=y
  CONFIG_QCOM_AOSS_QMP=y
  CONFIG_QCOM_LLCC=y
  CONFIG_QCOM_OCMEM=y
  $ make -skj"$(nproc)" ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- KCONFIG_ALLCONFIG=1 allnoconfig drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.o
  In file included from drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c:7:
  include/linux/soc/qcom/ubwc.h: In function 'qcom_ubwc_config_get_data':
  include/linux/soc/qcom/ubwc.h:45:16: error: implicit declaration of function 'ERR_PTR' [-Wimplicit-function-declaration]
     45 |         return ERR_PTR(-EOPNOTSUPP);
        |                ^~~~~~~
  include/linux/soc/qcom/ubwc.h:45:25: error: 'EOPNOTSUPP' undeclared (first use in this function)
     45 |         return ERR_PTR(-EOPNOTSUPP);
        |                         ^~~~~~~~~~
  include/linux/soc/qcom/ubwc.h:45:25: note: each undeclared identifier is reported only once for each function it appears in
  In file included from include/linux/cleanup.h:6,
                   from include/linux/irqflags.h:17,
                   from arch/arm/include/asm/bitops.h:28,
                   from include/linux/bitops.h:67,
                   from include/linux/kernel.h:23,
                   from drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h:10,
                   from drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h:8,
                   from drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c:9:
  include/linux/err.h: At top level:
  include/linux/err.h:39:44: error: conflicting types for 'ERR_PTR'; have 'void *(long int)'
     39 | static __always_inline void * __must_check ERR_PTR(long error)
        |                                            ^~~~~~~
  include/linux/soc/qcom/ubwc.h:45:16: note: previous implicit declaration of 'ERR_PTR' with type 'int()'
     45 |         return ERR_PTR(-EOPNOTSUPP);
        |                ^~~~~~~

Adding '#include <linux/err.h>' to include/linux/soc/qcom/ubwc.h appears to resolve that for me.

Signature · 2 lines
Cheers,
Nathan
#8 lore raw
Quoted 51 lines · Nathan Chancellor

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Hi Daniel,

Quoted 18 lines · Daniel Baluta

Fix link error caused by the fact that drivers/soc/qcom/ubwc_config.c enabled via QCOM_UBWC_CONFIG uses unconditionally symbols from drivers/soc/qcom/smem.c enabled via CONFIG_QCOM_SMEM.

Changes since v3:
- fix issues pointed by sashiko https://sashiko.dev/#/patchset/20260812130421.670527-1-daniel.baluta%40nxp.com
- add new patches 2/3 in order to fix unmet dependcy for VIDEO_QCOM_IRIS
- Use IS_REACHABLE instead of IS_ENABLED to avoid the situation we use
some symbols in builtin kernel but their definitions sits in a
module.

Remark for Dmitry, at this point I think v1 would have been a better option.
Link to v1:
- https://lore.kernel.org/imx/[email protected]/T/#t

Quoted 3 lines

Daniel Baluta (3):
soc: qcom: ubwc: Fix link error when QCOM_SMEM=n
media: iris: Fix unmet dependency when QCOM_SMEM=n

I think this patch should come first since you introduce the QCOM_SMEM dependency that requires this change in the first patch, which could mess with bisects. I would personally add the 'if' condition to the 'select QCOM_UBWC_CONFIG' statements in one patch then add the QCOM_SMEM dependency to QCOM_UBWC_CONFIG in a separate patch.

Quoted 1 line

soc: qcom: ubwc: Use IS_REACHABLE() instead of IS_ENABLED()

Even with this series applied, I see

  $ cat allno.config
  CONFIG_ARCH_MULTI_V7=y
  CONFIG_ARCH_QCOM=y
  CONFIG_DRM=y
  CONFIG_DRM_MSM=y
  CONFIG_DRM_MSM_DPU=y
  CONFIG_IOMMU_SUPPORT=y
  CONFIG_MAILBOX=y
  CONFIG_MMU=y
  CONFIG_PM=y
  CONFIG_QCOM_AOSS_QMP=y
  CONFIG_QCOM_LLCC=y
  CONFIG_QCOM_OCMEM=y
Quoted 7 lines
  $ make -skj"$(nproc)" ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- KCONFIG_ALLCONFIG=1 allnoconfig drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.o
  In file included from drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c:7:
  include/linux/soc/qcom/ubwc.h: In function 'qcom_ubwc_config_get_data':
  include/linux/soc/qcom/ubwc.h:45:16: error: implicit declaration of function 'ERR_PTR' [-Wimplicit-function-declaration]
     45 |         return ERR_PTR(-EOPNOTSUPP);
        |                ^~~~~~~
  include/linux/soc/qcom/ubwc.h:45:25: error: 'EOPNOTSUPP' undeclared (first use in this function)

Hi Nathan,

This issue is pre-existing and I've sent a separate fix for it:

https://lore.kernel.org/all/5fy7l6o5nfzclsmhsqys562xwoilbo4xv3af65kcqugtitgltd@3fw2w443pw2g/#r

#9 lore raw
Quoted 8 lines · Daniel Baluta
Quoted 6 lines · Nathan Chancellor

In file included from drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp_v13.c:7:
include/linux/soc/qcom/ubwc.h: In function 'qcom_ubwc_config_get_data':
include/linux/soc/qcom/ubwc.h:45:16: error: implicit declaration of function 'ERR_PTR' [-Wimplicit-function-declaration]

     45 |         return ERR_PTR(-EOPNOTSUPP);
        |                ^~~~~~~

include/linux/soc/qcom/ubwc.h:45:25: error: 'EOPNOTSUPP' undeclared (first use in this function)

Quoted 5 lines

Hi Nathan,

This issue is pre-existing and I've sent a separate fix for it:

https://lore.kernel.org/all/5fy7l6o5nfzclsmhsqys562xwoilbo4xv3af65kcqugtitgltd@3fw2w443pw2g/#r

Sure, it is a pre-existing issue but it is only exposed by making CONFIG_QCOM_UBWC_CONFIG an optional selection for these drivers, so I think that patch should be a part of this series. Otherwise, I don't see how you could actually trigger such an error.

Signature · 2 lines
Cheers,
Nathan