iommu: fix ARM_SMMU vs QCOM_SCM compilation
Subsystems (3)
PATCH 1/1 iommu: fix ARM_SMMU vs QCOM_SCM compilation
After commit 424953cf3c66 ("qcom_scm: hide Kconfig symbol") arm-smmu got qcom_smmu_impl_init() call guarded by IS_ENABLED(CONFIG_ARM_SMMU_QCOM). However the CONFIG_ARM_SMMU_QCOM Kconfig entry does not exist, so the qcom_smmu_impl_init() is never called.
So, let's fix this by always calling qcom_smmu_impl_init(). It does not touch the smmu passed unless the device is a non-Qualcomm one. Make ARM_SMMU select QCOM_SCM for ARCH_QCOM.
--- drivers/iommu/Kconfig | 1 + drivers/iommu/arm/arm-smmu/Makefile | 3 +-- drivers/iommu/arm/arm-smmu/arm-smmu-impl.c | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-)
drivers/iommu/Kconfig +1 -0
@@ -309,6 +309,7 @@ config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) select IOMMU_API + select QCOM_SCM select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM help
drivers/iommu/arm/arm-smmu/Makefile +1 -2
@@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_QCOM_IOMMU) += qcom_iommu.o obj-$(CONFIG_ARM_SMMU) += arm_smmu.o -arm_smmu-objs += arm-smmu.o arm-smmu-impl.o arm-smmu-nvidia.o -arm_smmu-$(CONFIG_ARM_SMMU_QCOM) += arm-smmu-qcom.o +arm_smmu-objs += arm-smmu.o arm-smmu-impl.o arm-smmu-nvidia.o arm-smmu-qcom.o
drivers/iommu/arm/arm-smmu/arm-smmu-impl.c +7 -2
@@ -215,8 +215,13 @@ struct arm_smmu_device *arm_smmu_impl_init(struct arm_smmu_device *smmu) of_device_is_compatible(np, "nvidia,tegra186-smmu"))return nvidia_smmu_impl_init (smmu); -if (IS_ENABLED (CONFIG_ARM_SMMU_QCOM )) - smmu =qcom_smmu_impl_init (smmu); +/* +* qcom_smmu_impl_init() will not touch smmu if the device is not +* a Qualcomm one. +*/ + smmu =qcom_smmu_impl_init (smmu); +if (IS_ERR (smmu)) +return smmu;if (of_device_is_compatible (np,"marvell,ap806-smmu-500" )) smmu->impl = &mrvl_mmu500_impl;
Signature · 1 line
2.30.2
Quoted 9 lines · Dmitry Baryshkov
After commit
424953cf3c66("qcom_scm: hideKconfigsymbol") arm-smmu gotqcom_smmu_impl_init()call guarded byIS_ENABLED(CONFIG_ARM_SMMU_QCOM). However theCONFIG_ARM_SMMU_QCOMKconfigentry does not exist, so theqcom_smmu_impl_init()is never called.So, let's fix this by always calling
qcom_smmu_impl_init(). It does not touch the smmu passed unless the device is a non-Qualcomm one. MakeARM_SMMUselectQCOM_SCMforARCH_QCOM.
Arnd's intention was to not force QCOM_SCM to be built on non-Qualcomm devices. But as Daniel experienced, attempting to boot most Qualcomm boards without this results in a instant reboot.
I think it's okay if we tinker with CONFIG_ARM_SMMU_QCOM for v5.16, but we're getting late in v5.15 so I would prefer if we make sure this works out of the box.
Regards,
Bjorn
Quoted 56 lines
Fixes 424953cf3c66 ("qcom_scm: hide Kconfig symbol")Cc Arnd Bergmann <[email protected]>Reported-by Daniel Lezcano <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/iommu/Kconfig | 1 + drivers/iommu/arm/arm-smmu/Makefile | 3 +-- drivers/iommu/arm/arm-smmu/arm-smmu-impl.c | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-)drivers/iommu/Kconfig +1
-0@@ -309,6 +309,7 @@ config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) select IOMMU_API + select QCOM_SCM select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM helpdrivers/iommu/arm/arm-smmu/Makefile +1
-2@@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_QCOM_IOMMU) += qcom_iommu.o obj-$(CONFIG_ARM_SMMU) += arm_smmu.o -arm_smmu-objs += arm-smmu.o arm-smmu-impl.o arm-smmu-nvidia.o -arm_smmu-$(CONFIG_ARM_SMMU_QCOM) += arm-smmu-qcom.o +arm_smmu-objs += arm-smmu.o arm-smmu-impl.o arm-smmu-nvidia.o arm-smmu-qcom.odrivers/iommu/arm/arm-smmu/arm-smmu-impl.c +7
-2@@ -215,8 +215,13 @@ struct arm_smmu_device *arm_smmu_impl_init(struct arm_smmu_device *smmu) of_device_is_compatible(np, "nvidia,tegra186-smmu"))return nvidia_smmu_impl_init (smmu); -if (IS_ENABLED (CONFIG_ARM_SMMU_QCOM )) - smmu =qcom_smmu_impl_init (smmu); +/* +* qcom_smmu_impl_init() will not touch smmu if the device is not +* a Qualcomm one. +*/ + smmu =qcom_smmu_impl_init (smmu); +if (IS_ERR (smmu)) +return smmu;if (of_device_is_compatible (np,"marvell,ap806-smmu-500" )) smmu->impl = &mrvl_mmu500_impl;Signature · 1 line
2.30.2
Quoted 11 lines · Bjorn Andersson
Quoted 8 lines · Dmitry Baryshkov
After commit
424953cf3c66("qcom_scm: hideKconfigsymbol") arm-smmu gotqcom_smmu_impl_init()call guarded byIS_ENABLED(CONFIG_ARM_SMMU_QCOM). However theCONFIG_ARM_SMMU_QCOMKconfigentry does not exist, so theqcom_smmu_impl_init()is never called.So, let's fix this by always calling
qcom_smmu_impl_init(). It does not touch the smmu passed unless the device is a non-Qualcomm one. MakeARM_SMMUselectQCOM_SCMforARCH_QCOM.
Sorry about this bug. I was sure I had it working, but I lost part of the commit during a rebase, and my randconfig builds still succeeded without it, so I sent a wrong version.
Quoted 7 lines
Arnd's intention was to not force
QCOM_SCMto be built on non-Qualcomm devices. But as Daniel experienced, attempting to boot most Qualcomm boards without this results in a instant reboot.I think it's okay if we tinker with
CONFIG_ARM_SMMU_QCOMfor v5.16, but we're getting late in v5.15 so I would prefer if we make sure this works out of the box.
Yes, makes sense. For reference, see below for how I would fix this properly, this is what I had intended to have in the patch. Feel free to pick either version
as the immediate bugfix. I'll give the below a little more randconfig testing overnight though. The pasted version of the patch is probably whitespace-damaged,
let me know if you would like me to send it as a proper patch.
Arnd
8<-----
Subject: iommu: fix ARM_SMMU_QCOM compilation
My previous bugfix ended up making things worse for the QCOM IOMMU driver when it forgot to add the Kconfig symbol that is getting used to control the compilation of the SMMU implementation specific code for Qualcomm.
----
drivers/iommu/Kconfig +8 -0
@@ -311,6 +311,7 @@ config ARM_SMMU select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM + select QCOM_SCM if ARM_SMMU_QCOM help Support for implementations of the ARM System MMU architecture versions 1 and 2.
@@ -355,6 +356,13 @@ config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT 'arm-smmu.disable_bypass' will continue to override this config. +config ARM_SMMU_QCOM + def_bool y + depends on ARM_SMMU && ARCH_QCOM + help + When running on a Qualcomm platform that has the custom variant + of the ARM SMMU, this needs to be built into the SMMU driver. + config ARM_SMMU_V3 tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support" depends on ARM64
Quoted 62 lines · Arnd Bergmann
Quoted 10 lines · Bjorn Andersson
Quoted 8 lines · Dmitry Baryshkov
After commit
424953cf3c66("qcom_scm: hideKconfigsymbol") arm-smmu gotqcom_smmu_impl_init()call guarded byIS_ENABLED(CONFIG_ARM_SMMU_QCOM). However theCONFIG_ARM_SMMU_QCOMKconfigentry does not exist, so theqcom_smmu_impl_init()is never called.So, let's fix this by always calling
qcom_smmu_impl_init(). It does not touch the smmu passed unless the device is a non-Qualcomm one. MakeARM_SMMUselectQCOM_SCMforARCH_QCOM.Sorry about this bug. I was sure I had it working, but I lost part of the commit during a rebase, and my randconfig builds still succeeded without it, so I sent a wrong version.
Quoted 7 lines
Arnd's intention was to not force
QCOM_SCMto be built on non-Qualcomm devices. But as Daniel experienced, attempting to boot most Qualcomm boards without this results in a instant reboot.I think it's okay if we tinker with
CONFIG_ARM_SMMU_QCOMfor v5.16, but we're getting late in v5.15 so I would prefer if we make sure this works out of the box.Yes, makes sense. For reference, see below for how I would fix this properly, this is what I had intended to have in the patch. Feel free to pick either version
as the immediate bugfix. I'll give the below a little more randconfig testing overnight though. The pasted version of the patch is probably whitespace-damaged,
let me know if you would like me to send it as a proper patch.Arnd
8<-----
Subject: iommu: fixARM_SMMU_QCOMcompilationMy previous bugfix ended up making things worse for the QCOM IOMMU driver when it forgot to add the
Kconfigsymbol that is getting used to control the compilation of the SMMU implementation specific code for Qualcomm.Fixes 424953cf3c66 ("qcom_scm: hide Kconfig symbol")Reported-by Daniel Lezcano <[email protected]>Reported-by Dmitry Baryshkov <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>----
drivers/iommu/Kconfig +1
-0@@ -311,6 +311,7 @@ config ARM_SMMU select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM + select QCOM_SCM if ARM_SMMU_QCOM help Support for implementations of the ARM System MMU architecture versions 1 and 2.@@ -355,6 +356,13 @@ config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT 'arm-smmu.disable_bypass' will continue to override this config.
drivers/iommu/Kconfig config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT · line 368
Quoted 10 lines
drivers/iommu/Kconfig +7
-0+config ARM_SMMU_QCOM + def_bool y + depends on ARM_SMMU && ARCH_QCOM + help + When running on a Qualcomm platform that has the custom variant + of the ARM SMMU, this needs to be built into the SMMU driver. + config ARM_SMMU_V3 tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support" depends on ARM64
FWIW, I tested this patch on the Lenovo Yoga C630 with Dmitry's patch backed out, and this does the right thing as well.
So if we go this route instead of the other patch, Tested-By: Steev Klimaszewski <[email protected]>
Quoted 66 lines · Arnd Bergmann
Quoted 11 lines · Bjorn Andersson
Quoted 8 lines · Dmitry Baryshkov
After commit
424953cf3c66("qcom_scm: hideKconfigsymbol") arm-smmu gotqcom_smmu_impl_init()call guarded byIS_ENABLED(CONFIG_ARM_SMMU_QCOM). However theCONFIG_ARM_SMMU_QCOMKconfigentry does not exist, so theqcom_smmu_impl_init()is never called.So, let's fix this by always calling
qcom_smmu_impl_init(). It does not touch the smmu passed unless the device is a non-Qualcomm one. MakeARM_SMMUselectQCOM_SCMforARCH_QCOM.Sorry about this bug. I was sure I had it working, but I lost part of the commit during a rebase, and my randconfig builds still succeeded without it, so I sent a wrong version.
Quoted 7 lines
Arnd's intention was to not force
QCOM_SCMto be built on non-Qualcomm devices. But as Daniel experienced, attempting to boot most Qualcomm boards without this results in a instant reboot.I think it's okay if we tinker with
CONFIG_ARM_SMMU_QCOMfor v5.16, but we're getting late in v5.15 so I would prefer if we make sure this works out of the box.Yes, makes sense. For reference, see below for how I would fix this properly, this is what I had intended to have in the patch. Feel free to pick either version
as the immediate bugfix. I'll give the below a little more randconfig testing overnight though. The pasted version of the patch is probably whitespace-damaged,
let me know if you would like me to send it as a proper patch.Arnd
8<-----
Subject: iommu: fixARM_SMMU_QCOMcompilationMy previous bugfix ended up making things worse for the QCOM IOMMU driver when it forgot to add the
Kconfigsymbol that is getting used to control the compilation of the SMMU implementation specific code for Qualcomm.Fixes 424953cf3c66 ("qcom_scm: hide Kconfig symbol")Reported-by Daniel Lezcano <[email protected]>Reported-by Dmitry Baryshkov <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>----
drivers/iommu/Kconfig +1
-0@@ -311,6 +311,7 @@ config ARM_SMMU select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM + select QCOM_SCM if ARM_SMMU_QCOM help Support for implementations of the ARM System MMU architecture versions 1 and 2.@@ -355,6 +356,13 @@ config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT 'arm-smmu.disable_bypass' will continue to override this config.
drivers/iommu/Kconfig config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT · line 368
Quoted 10 lines
drivers/iommu/Kconfig +7
-0+config ARM_SMMU_QCOM + def_bool y + depends on ARM_SMMU && ARCH_QCOM + help + When running on a Qualcomm platform that has the custom variant + of the ARM SMMU, this needs to be built into the SMMU driver. + config ARM_SMMU_V3 tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support" depends on ARM64
The patch seems correct, but it becomes overcomplicated. What about:
- restoring QCOM_SCM stubs
- making ARM_SMMU select QCOM_SCM if ARM_SMMU_QCOM
This would have almost the same result as with your patch, but without extra ARM_SMMU_QCOM Kconfig symbol.
Signature · 2 lines
With best wishes Dmitry
Quoted 4 lines · Dmitry Baryshkov
On Sun, 10 Oct 2021 at 20:42, Arnd Bergmann <[email protected]> wrote:
The patch seems correct, but it becomes overcomplicated. What about:
- restoringQCOM_SCMstubs
The stubs are what has led to the previous bugs in this area to often go unnoticed for too long, as illustrated by your suggestion
Quoted 1 line
- making
ARM_SMMUselectQCOM_SCMifARM_SMMU_QCOM
I assume you meant "select QCOM_SCM if ARCH_QCOM", after we stop using ARM_SMMU_QCOM?
Quoted 2 lines
This would have almost the same result as with your patch, but without extra
ARM_SMMU_QCOMKconfigsymbol.
The "almost" is the problem: consider the case of
CONFIG_ARM=yCONFIG_COMPILE_TEST=yCONFIG_ARCH_QCOM=nCONFIG_ARM_SMMU=yCONFIG_DRM_MSM=mCONFIG_QCOM_SCM=m (selected by DRM_MSM)
The stubs here lead to ARM_SMMU linking against the QCOM_SCM driver from built-in code, which fails because QCOM_SCM itself is a loadable module.
We can move the "select QCOM_SCM" in the ARM_SMMU_QCOM symbol if we make that a tristate though, if you want to separate it a little more.
Arnd
Quoted 28 lines · Arnd Bergmann
Quoted 4 lines · Dmitry Baryshkov
On Sun, 10 Oct 2021 at 20:42, Arnd Bergmann <[email protected]> wrote:
The patch seems correct, but it becomes overcomplicated. What about:
- restoringQCOM_SCMstubsThe stubs are what has led to the previous bugs in this area to often go unnoticed for too long, as illustrated by your suggestion
Quoted 1 line
- making
ARM_SMMUselectQCOM_SCMifARM_SMMU_QCOMI assume you meant "select
QCOM_SCMifARCH_QCOM", after we stop usingARM_SMMU_QCOM?Quoted 2 lines
This would have almost the same result as with your patch, but without extra
ARM_SMMU_QCOMKconfigsymbol.The "almost" is the problem: consider the case of
CONFIG_ARM=yCONFIG_COMPILE_TEST=yCONFIG_ARCH_QCOM=nCONFIG_ARM_SMMU=yCONFIG_DRM_MSM=mCONFIG_QCOM_SCM=m(selected byDRM_MSM)
Quoted 3 lines
The stubs here lead to
ARM_SMMUlinking against theQCOM_SCMdriver from built-in code, which fails becauseQCOM_SCMitself is a loadable module.
I see. The idealist in me wishes to change my suggestion to 'select QCOM_SCM if ARCH_QCOM || COMPILE_TEST'
but I have the subtle feeling that this also might fail somehow.
Quoted 4 lines
We can move the "select
QCOM_SCM" in theARM_SMMU_QCOMsymbol if we make that a tristate though, if you want to separate it a little more.
This would complicate things a bit, as we would no longer be able to use 'arm-smmu-$(CONFIG_ARM_SMMU_QCOM) +=' construct.
Signature · 2 lines
With best wishes Dmitry
Quoted 30 lines · Dmitry Baryshkov
Quoted 28 lines · Arnd Bergmann
Quoted 4 lines · Dmitry Baryshkov
On Sun, 10 Oct 2021 at 20:42, Arnd Bergmann <[email protected]> wrote:
The patch seems correct, but it becomes overcomplicated. What about:
- restoringQCOM_SCMstubsThe stubs are what has led to the previous bugs in this area to often go unnoticed for too long, as illustrated by your suggestion
Quoted 1 line
- making
ARM_SMMUselectQCOM_SCMifARM_SMMU_QCOMI assume you meant "select
QCOM_SCMifARCH_QCOM", after we stop usingARM_SMMU_QCOM?Quoted 2 lines
This would have almost the same result as with your patch, but without extra
ARM_SMMU_QCOMKconfigsymbol.The "almost" is the problem: consider the case of
CONFIG_ARM=yCONFIG_COMPILE_TEST=yCONFIG_ARCH_QCOM=nCONFIG_ARM_SMMU=yCONFIG_DRM_MSM=mCONFIG_QCOM_SCM=m(selected byDRM_MSM)
Quoted 7 lines
Quoted 3 lines
The stubs here lead to
ARM_SMMUlinking against theQCOM_SCMdriver from built-in code, which fails becauseQCOM_SCMitself is a loadable module.I see. The idealist in me wishes to change my suggestion to 'select
QCOM_SCMifARCH_QCOM||COMPILE_TEST'
but I have the subtle feeling that this also might fail somehow.
I think that would actually work, but it has the nasty side-effect that simply flipping 'CONFIG_COMPILE_TEST' changes what the kernel does, rather than just hiding or unhiding additional options.
Quoted 6 lines
Quoted 3 lines
We can move the "select
QCOM_SCM" in theARM_SMMU_QCOMsymbol if we make that a tristate though, if you want to separate it a little more.This would complicate things a bit, as we would no longer be able to use 'arm-smmu-$(CONFIG_ARM_SMMU_QCOM) +=' construct.
I'm fairly sure we could still use that, Kbuild is smart enough to include both 'file-m +=' and 'file-y += ' in 'file.ko', see scripts/Makefile.lib:
# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
multi-obj-y := $(call multi-search, $(obj-y), .o, -objs -y) multi-obj-m := $(call multi-search, $(obj-m), .o, -objs -y -m) multi-obj-ym := $(multi-obj-y) $(multi-obj-m)
# Replace multi-part objects by their individual parts,
# including built-in.a from subdirectories real-obj-y := $(call real-search, $(obj-y), .o, -objs -y) real-obj-m := $(call real-search, $(obj-m), .o, -objs -y -m)
What doesn't work is having a built-in driver in a directory that is guarded with a =m symbol, or including a =m object into a =y module.
Arnd
Quoted 63 lines · Arnd Bergmann
Quoted 30 lines · Dmitry Baryshkov
Quoted 28 lines · Arnd Bergmann
Quoted 4 lines · Dmitry Baryshkov
On Sun, 10 Oct 2021 at 20:42, Arnd Bergmann <[email protected]> wrote:
The patch seems correct, but it becomes overcomplicated. What about:
- restoringQCOM_SCMstubsThe stubs are what has led to the previous bugs in this area to often go unnoticed for too long, as illustrated by your suggestion
Quoted 1 line
- making
ARM_SMMUselectQCOM_SCMifARM_SMMU_QCOMI assume you meant "select
QCOM_SCMifARCH_QCOM", after we stop usingARM_SMMU_QCOM?Quoted 2 lines
This would have almost the same result as with your patch, but without extra
ARM_SMMU_QCOMKconfigsymbol.The "almost" is the problem: consider the case of
CONFIG_ARM=yCONFIG_COMPILE_TEST=yCONFIG_ARCH_QCOM=nCONFIG_ARM_SMMU=yCONFIG_DRM_MSM=mCONFIG_QCOM_SCM=m(selected byDRM_MSM)Quoted 7 lines
Quoted 3 lines
The stubs here lead to
ARM_SMMUlinking against theQCOM_SCMdriver from built-in code, which fails becauseQCOM_SCMitself is a loadable module.I see. The idealist in me wishes to change my suggestion to 'select
QCOM_SCMifARCH_QCOM||COMPILE_TEST'
but I have the subtle feeling that this also might fail somehow.I think that would actually work, but it has the nasty side-effect that simply flipping '
CONFIG_COMPILE_TEST' changes what the kernel does, rather than just hiding or unhiding additional options.Quoted 6 lines
Quoted 3 lines
We can move the "select
QCOM_SCM" in theARM_SMMU_QCOMsymbol if we make that a tristate though, if you want to separate it a little more.This would complicate things a bit, as we would no longer be able to use 'arm-smmu-$(CONFIG_ARM_SMMU_QCOM) +=' construct.
I'm fairly sure we could still use that,
Kbuildis smart enough to include both 'file-m +=' and 'file-y += ' in 'file.ko', seescripts/Makefile.lib:# If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
multi-obj-y := $(call multi-search, $(obj-y), .o, -objs -y) multi-obj-m := $(call multi-search, $(obj-m), .o, -objs -y -m) multi-obj-ym := $(multi-obj-y) $(multi-obj-m)
Quoted 4 lines
# Replace multi-part objects by their individual parts,
# including built-in.a from subdirectories real-obj-y := $(call real-search, $(obj-y), .o, -objs -y) real-obj-m := $(call real-search, $(obj-m), .o, -objs -y -m)
Ah, I thought Kbuild would accept only foo-y, please excuse me.
Quoted 6 lines
What doesn't work is having a built-in driver in a directory that is guarded with a =m symbol, or including a =m object into a =y module.
Arnd
Signature · 2 lines
With best wishes Dmitry
Dmitry Baryshkov
Reviewed-byQuoted 45 lines · Arnd Bergmann
Quoted 11 lines · Bjorn Andersson
Quoted 8 lines · Dmitry Baryshkov
After commit
424953cf3c66("qcom_scm: hideKconfigsymbol") arm-smmu gotqcom_smmu_impl_init()call guarded byIS_ENABLED(CONFIG_ARM_SMMU_QCOM). However theCONFIG_ARM_SMMU_QCOMKconfigentry does not exist, so theqcom_smmu_impl_init()is never called.So, let's fix this by always calling
qcom_smmu_impl_init(). It does not touch the smmu passed unless the device is a non-Qualcomm one. MakeARM_SMMUselectQCOM_SCMforARCH_QCOM.Sorry about this bug. I was sure I had it working, but I lost part of the commit during a rebase, and my randconfig builds still succeeded without it, so I sent a wrong version.
Quoted 7 lines
Arnd's intention was to not force
QCOM_SCMto be built on non-Qualcomm devices. But as Daniel experienced, attempting to boot most Qualcomm boards without this results in a instant reboot.I think it's okay if we tinker with
CONFIG_ARM_SMMU_QCOMfor v5.16, but we're getting late in v5.15 so I would prefer if we make sure this works out of the box.Yes, makes sense. For reference, see below for how I would fix this properly, this is what I had intended to have in the patch. Feel free to pick either version
as the immediate bugfix. I'll give the below a little more randconfig testing overnight though. The pasted version of the patch is probably whitespace-damaged,
let me know if you would like me to send it as a proper patch.Arnd
8<-----
Subject: iommu: fixARM_SMMU_QCOMcompilationMy previous bugfix ended up making things worse for the QCOM IOMMU driver when it forgot to add the
Kconfigsymbol that is getting used to control the compilation of the SMMU implementation specific code for Qualcomm.
Quoted 4 lines
Fixes 424953cf3c66 ("qcom_scm: hide Kconfig symbol")Reported-by Daniel Lezcano <[email protected]>Reported-by Dmitry Baryshkov <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>
Let's get either of them in.
Quoted 27 lines
----
drivers/iommu/Kconfig +8
-0@@ -311,6 +311,7 @@ config ARM_SMMU select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM + select QCOM_SCM if ARM_SMMU_QCOM help Support for implementations of the ARM System MMU architecture versions 1 and 2.@@ -355,6 +356,13 @@ config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT 'arm-smmu.disable_bypass' will continue to override this config. +config ARM_SMMU_QCOM + def_bool y + depends on ARM_SMMU && ARCH_QCOM + help + When running on a Qualcomm platform that has the custom variant + of the ARM SMMU, this needs to be built into the SMMU driver. + config ARM_SMMU_V3 tristate "ARM Ltd. System MMU Version 3 (SMMUv3) Support" depends on ARM64
Signature · 2 lines
With best wishes Dmitry
Quoted 52 lines · Dmitry Baryshkov
After commit
424953cf3c66("qcom_scm: hideKconfigsymbol") arm-smmu gotqcom_smmu_impl_init()call guarded byIS_ENABLED(CONFIG_ARM_SMMU_QCOM). However theCONFIG_ARM_SMMU_QCOMKconfigentry does not exist, so theqcom_smmu_impl_init()is never called.So, let's fix this by always calling
qcom_smmu_impl_init(). It does not touch the smmu passed unless the device is a non-Qualcomm one. MakeARM_SMMUselectQCOM_SCMforARCH_QCOM.Fixes 424953cf3c66 ("qcom_scm: hide Kconfig symbol")Cc Arnd Bergmann <[email protected]>Reported-by Daniel Lezcano <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/iommu/Kconfig | 1 + drivers/iommu/arm/arm-smmu/Makefile | 3 +-- drivers/iommu/arm/arm-smmu/arm-smmu-impl.c | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-)drivers/iommu/Kconfig +1
-0@@ -309,6 +309,7 @@ config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) select IOMMU_API + select QCOM_SCM select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM helpdrivers/iommu/arm/arm-smmu/Makefile +1
-2@@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_QCOM_IOMMU) += qcom_iommu.o obj-$(CONFIG_ARM_SMMU) += arm_smmu.o -arm_smmu-objs += arm-smmu.o arm-smmu-impl.o arm-smmu-nvidia.o -arm_smmu-$(CONFIG_ARM_SMMU_QCOM) += arm-smmu-qcom.o +arm_smmu-objs += arm-smmu.o arm-smmu-impl.o arm-smmu-nvidia.o arm-smmu-qcom.odrivers/iommu/arm/arm-smmu/arm-smmu-impl.c +0
-2@@ -215,8 +215,13 @@ struct arm_smmu_device *arm_smmu_impl_init(struct arm_smmu_device *smmu) of_device_is_compatible(np, "nvidia,tegra186-smmu"))return nvidia_smmu_impl_init (smmu); -if (IS_ENABLED (CONFIG_ARM_SMMU_QCOM )) - smmu =qcom_smmu_impl_init (smmu);
drivers/iommu/arm/arm-smmu/arm-smmu-impl.c struct arm_smmu_device *arm_smmu_impl_init(struct arm_smmu_device *smmu) · line 227
Quoted 10 lines
drivers/iommu/arm/arm-smmu/arm-smmu-impl.c +7
-0+/* +* qcom_smmu_impl_init() will not touch smmu if the device is not +* a Qualcomm one. +*/ + smmu =qcom_smmu_impl_init (smmu); +if (IS_ERR (smmu)) +return smmu;if (of_device_is_compatible (np,"marvell,ap806-smmu-500" )) smmu->impl = &mrvl_mmu500_impl;
Without this applied, my Lenovo Yoga C630 just boot loops with 424953cf3c66 applied when it gets to the smmu. This fixes it.