soc: qcom: ubwc: Fix link error when QCOM_SMEM=n
Subsystems (8)
v6 cover soc: qcom: ubwc: Fix link error when QCOM_SMEM=n
DRM_MSM and VIDEO_QCOM_IRIS select QCOM_UBWC_CONFIG, whose ubwc_config.c calls QCOM_SMEM APIs unconditionally. On configs without QCOM_SMEM this fails to link, e.g. on SOC_IMX5:
arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x2c): undefined
reference to 'qcom_smem_is_available'
Fix it by making the QCOM_SMEM requirement explicit in Kconfig.
Changes since v5:
* added patch 4/4 to this series, which was initially sent as a standalone patch (addresses review from Nathan)
* no other change to the series.
* picked up all R-b and Acked-by tags.
Link to v5: https://lore.kernel.org/imx/[email protected]/T/#t
Daniel Baluta (4):
drm/msm: Guard the QCOM_UBWC_CONFIG select with QCOM_SMEM
media: iris: Guard the QCOM_UBWC_CONFIG select with QCOM_SMEM
soc: qcom: ubwc: Fix link error when QCOM_SMEM=n
soc: qcom: ubwc: Fix missing include
drivers/gpu/drm/msm/Kconfig | 3 ++- drivers/media/platform/qcom/iris/Kconfig | 3 ++- drivers/soc/qcom/Kconfig | 1 + include/linux/soc/qcom/ubwc.h | 1 + 4 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.45.2
PATCH v6 1/4 drm/msm: Guard the QCOM_UBWC_CONFIG select with QCOM_SMEM
QCOM_UBWC_CONFIG is about to depend on QCOM_SMEM. Guard the DRM_MSM select with 'if ARCH_QCOM && QCOM_SMEM', and add 'depends on QCOM_SMEM || QCOM_SMEM=n' so a built-in driver is never selected against a missing or modular SMEM.
--- drivers/gpu/drm/msm/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/Kconfig +2 -1
@@ -11,6 +11,7 @@ config DRM_MSM depends on QCOM_OCMEM || QCOM_OCMEM=n depends on QCOM_LLCC || QCOM_LLCC=n depends on QCOM_COMMAND_DB || QCOM_COMMAND_DB=n + depends on QCOM_SMEM || QCOM_SMEM=n depends on PM select IOMMU_IO_PGTABLE select QCOM_MDT_LOADER if ARCH_QCOM
@@ -22,7 +23,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
Signature · 1 line
2.45.2
[email protected]
AI reviewRe: [PATCH v6 1/4] drm/msm: Guard the QCOM_UBWC_CONFIG select with QCOM_SMEM
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Conditionally selecting QCOM_UBWC_CONFIG without adding `depends on QCOM_UBWC_CONFIG ||…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Conditionally selecting QCOM_UBWC_CONFIG without adding depends on QCOM_UBWC_CONFIG || QCOM_UBWC_CONFIG=n causes an undefined reference linker error when DRM_MSM is built-in (=y) and QCOM_UBWC_CONFIG is a module (=m). --
--- Patch [1]: [PATCH v6 1/4] drm/msm: Guard the QCOM_UBWC_CONFIG select with QCOM_SMEM --- commit 353149f56be7035f090eb09914820d684b1f59f4
Author: Daniel Baluta <[email protected]>
drm/msm: Guard the QCOM_UBWC_CONFIG select with QCOM_SMEM
This commit guards the DRM_MSM select of QCOM_UBWC_CONFIG with an architecture and SMEM check. It also adds a dependency to ensure a built-in driver is never selected against a modular SMEM.
Quoted 4 lines
drivers/gpu/drm/msm/Kconfig +0
-0
[ ... ]
drivers/gpu/drm/msm/Kconfig config DRM_MSM · line 26
Quoted 6 lines
drivers/gpu/drm/msm/Kconfig +1
-1@@ -22,7 +23,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: Low]
Does this conditional select cause an undefined reference linker error when DRM_MSM is built-in (=y) and QCOM_UBWC_CONFIG is built as a module (=m)?
If the kernel is configured with CONFIG_DRM_MSM=y, CONFIG_COMPILE_TEST=y, and CONFIG_ARCH_QCOM=n, this conditional select is bypassed.
If another driver (such as VIDEO_QCOM_IRIS) then selects QCOM_UBWC_CONFIG as a module, the built-in DRM_MSM driver will fail to link. This happens because include/linux/soc/qcom/ubwc.h uses IS_ENABLED(CONFIG_QCOM_UBWC_CONFIG) instead of IS_REACHABLE(), so the header provides an external declaration rather than a static inline stub.
Should this config also include "depends on QCOM_UBWC_CONFIG || QCOM_UBWC_CONFIG=n" to prevent the built-in driver from being selected against a missing or modular UBWC dependency?
Quoted 3 lines
drivers/gpu/drm/msm/Kconfig +0
-0select WANT_DEV_COREDUMP select SND_SOC_HDMI_CODEC if SND_SOC select SYNC_FILE
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v6 2/4 media: iris: Guard the QCOM_UBWC_CONFIG select with QCOM_SMEM
In reply to Daniel BalutaQCOM_UBWC_CONFIG is about to depend on QCOM_SMEM. Guard the VIDEO_QCOM_IRIS select with 'if ARCH_QCOM && QCOM_SMEM', and add 'depends on QCOM_SMEM || QCOM_SMEM=n' so a built-in driver is never selected against a missing or modular SMEM.
--- drivers/media/platform/qcom/iris/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/iris/Kconfig +2 -1
@@ -2,11 +2,12 @@ config VIDEO_QCOM_IRIS tristate "Qualcomm iris V4L2 decoder driver" depends on VIDEO_DEV depends on ARCH_QCOM || COMPILE_TEST + depends on QCOM_SMEM || QCOM_SMEM=n select V4L2_MEM2MEM_DEV 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
Re: [PATCH v6 2/4] media: iris: Guard the QCOM_UBWC_CONFIG select with QCOM_SMEM
Quoted 5 lines · Daniel Baluta
QCOM_UBWC_CONFIGis about to depend onQCOM_SMEM. Guard theVIDEO_QCOM_IRISselect with 'ifARCH_QCOM&&QCOM_SMEM', and add 'depends onQCOM_SMEM|| QCOM_SMEM=n' so a built-in driver is never selected against a missing or modular SMEM.
Quoted 7 lines
Fixes c43207553867 ("media: iris: retrieve UBWC platform configuration")Reviewed-by Konrad Dybcio <[email protected]>Signed-off-by Daniel Baluta <[email protected]>--- drivers/media/platform/qcom/iris/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v6 2/4] media: iris: Guard the QCOM_UBWC_CONFIG select with QCOM_SMEM
In reply to Daniel BalutaQuoted 12 lines · Daniel Baluta
QCOM_UBWC_CONFIGis about to depend onQCOM_SMEM. Guard theVIDEO_QCOM_IRISselect with 'ifARCH_QCOM&&QCOM_SMEM', and add 'depends onQCOM_SMEM|| QCOM_SMEM=n' so a built-in driver is never selected against a missing or modular SMEM.Fixes c43207553867 ("media: iris: retrieve UBWC platform configuration")Reviewed-by Konrad Dybcio <[email protected]>Signed-off-by Daniel Baluta <[email protected]>--- drivers/media/platform/qcom/iris/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 2 lines
With best wishes Dmitry
PATCH v6 3/4 soc: qcom: ubwc: Fix link error when QCOM_SMEM=n
In reply to Daniel Balutaubwc_config.c calls qcom_smem_is_available() and qcom_smem_dram_get_hbb() unconditionally, so QCOM_UBWC_CONFIG=y with QCOM_SMEM=n fails to link:
arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x2c): undefined
reference to 'qcom_smem_is_available'
Add the missing 'depends on QCOM_SMEM'.
--- drivers/soc/qcom/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/soc/qcom/Kconfig +1 -0
@@ -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
Quoted 6 lines · Daniel Baluta
ubwc_config.ccallsqcom_smem_is_available()andqcom_smem_dram_get_hbb()unconditionally, so QCOM_UBWC_CONFIG=y with QCOM_SMEM=n fails to link:arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x2c): undefined
reference to 'qcom_smem_is_available'
Quoted 9 lines
Add the missing 'depends on
QCOM_SMEM'.Fixes 1b445022d1d0 ("soc: qcom: ubwc: Get HBB from SMEM")Reviewed-by Konrad Dybcio <[email protected]>Signed-off-by Daniel Baluta <[email protected]>--- drivers/soc/qcom/Kconfig | 1 + 1 file changed, 1 insertion(+)
Signature · 2 lines
With best wishes Dmitry
PATCH v6 4/4 soc: qcom: ubwc: Fix missing include
In reply to Daniel BalutaWhen CONFIG_QCOM_UBWC_CONFIG=n, compiler needs to know the definition of ERR_PTR otherwise there will be a compilation error:
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]
Fix this by including <linux/err.h>
--- include/linux/soc/qcom/ubwc.h | 1 + 1 file changed, 1 insertion(+)
include/linux/soc/qcom/ubwc.h +1 -0
@@ -8,6 +8,7 @@#define __QCOM_UBWC_H__#include <linux/bits.h> +#include <linux/err.h> #include <linux/printk.h> #include <linux/types.h>
Signature · 1 line
2.45.2
[email protected]
AI reviewRe: [PATCH v6 4/4] soc: qcom: ubwc: Fix missing include
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing cleanup in a5xx_gpu_init() when qcom_ubwc_config_get_data() returns an error, leading to a memory and resource leak. --
--- Patch [4]: [PATCH v6 4/4] soc: qcom: ubwc: Fix missing include --- commit 8a6d2fb79b4edaad79d216dc3cc985d7cf39e314
Author: Daniel Baluta <[email protected]>
soc: qcom: ubwc: Fix missing include
This commit adds the <linux/err.h> include to ubwc.h to resolve a compilation error regarding the implicit declaration of ERR_PTR when CONFIG_QCOM_UBWC_CONFIG=n.
include/linux/soc/qcom/ubwc.h line 11
Quoted 9 lines
include/linux/soc/qcom/ubwc.h +1
-0@@ -8,6 +8,7 @@#define __QCOM_UBWC_H__#include <linux/bits.h> +#include <linux/err.h>
[Severity: High]
This isn't a bug introduced by this patch, but it brings attention to a potential memory and resource leak in a5xx_gpu_init() when it calls qcom_ubwc_config_get_data().
If qcom_ubwc_config_get_data() returns -EPROBE_DEFER (when SMEM is unavailable) or -EOPNOTSUPP (when CONFIG_QCOM_UBWC_CONFIG=n), the function returns the error directly without tearing down the initialized GPU resources via a5xx_destroy():
drivers/gpu/drm/msm/adreno/a5xx_gpu.c:a5xx_gpu_init() {
...
/* Inherit the common config and make some necessary fixups */
adreno_gpu->ubwc_config = qcom_ubwc_config_get_data();
if (IS_ERR(adreno_gpu->ubwc_config))
return ERR_CAST(adreno_gpu->ubwc_config);
...
}Because qcom_ubwc_config_get_data() actively returns -EPROBE_DEFER when SMEM isn't ready, this error path will be taken during standard boot sequences where SMEM probes after the GPU.
Does this code leak the a5xx_gpu structure and ringbuffers initialized by adreno_gpu_init() on each deferral?
Quoted 3 lines
include/linux/soc/qcom/ubwc.h +0
-0#include <linux/printk.h> #include <linux/types.h>
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Hi Daniel,
Quoted 23 lines · Daniel Baluta
DRM_MSMandVIDEO_QCOM_IRISselectQCOM_UBWC_CONFIG, whoseubwc_config.ccallsQCOM_SMEMAPIs unconditionally. On configs withoutQCOM_SMEMthis fails to link, e.g. onSOC_IMX5:arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x2c): undefined
reference to 'qcom_smem_is_available'Fix it by making the
QCOM_SMEMrequirement explicit inKconfig.Changes since v5:
* added patch 4/4 to this series, which was initially sent as a standalone patch (addresses review from Nathan)
* no other change to the series.
* picked up all R-b and Acked-by tags.Link to v5: https://lore.kernel.org/imx/[email protected]/T/#t
Daniel Baluta (4):
drm/msm: Guard theQCOM_UBWC_CONFIGselect withQCOM_SMEM
media: iris: Guard theQCOM_UBWC_CONFIGselect withQCOM_SMEM
soc: qcom: ubwc: Fix link error when QCOM_SMEM=n
soc: qcom: ubwc: Fix missing include
Quoted 5 lines
drivers/gpu/drm/msm/Kconfig | 3 ++- drivers/media/platform/qcom/iris/Kconfig | 3 ++- drivers/soc/qcom/Kconfig | 1 + include/linux/soc/qcom/ubwc.h | 1 + 4 files changed, 6 insertions(+), 2 deletions(-)
Thanks, this resolves the build errors that I noticed.
Signature · 2 lines
Cheers, Nathan
Quoted 9 lines · Daniel Baluta
DRM_MSMandVIDEO_QCOM_IRISselectQCOM_UBWC_CONFIG, whoseubwc_config.ccallsQCOM_SMEMAPIs unconditionally. On configs withoutQCOM_SMEMthis fails to link, e.g. onSOC_IMX5:arm-linux-gnueabihf-ld: ubwc_config.c:(.text+0x2c): undefined
reference to 'qcom_smem_is_available'Fix it by making the
QCOM_SMEMrequirement explicit inKconfig.
Quoted 8 lines
Changes since v5:
* added patch 4/4 to this series, which was initially sent as a standalone patch (addresses review from Nathan)
* no other change to the series.
* picked up all R-b and Acked-by tags.Link to v5:
https://lore.kernel.org/imx/[email protected]/T/#t
Krzysztof pointed me to this series when I ran into the same problem during my last minute regression test for the coming merge window.
I've included the four patches as fixups in the soc/drivers branch now and plan to send this to Linus later today when the regression tests finish.
Let me know if anyone feels that the patches should go a different way.
Arnd