Re: [PATCH v2 2/2] qcom_scm: hide Kconfig symbol
On Thu, Oct 7, 2021 at 8:10 AM Arnd Bergmann wrote: > > From: Arnd Bergmann > > Now that SCM can be a loadable module, we have to add another > dependency to avoid link failures when ipa or adreno-gpu are > built-in: > > aarch64-linux-ld: drivers/net/ipa/ipa_main.o: in function `ipa_probe': > ipa_main.c:(.text+0xfc4): undefined reference to `qcom_scm_is_available' > > ld.lld: error: undefined symbol: qcom_scm_is_available > >>> referenced by adreno_gpu.c > >>> gpu/drm/msm/adreno/adreno_gpu.o:(adreno_zap_shader_load) in > >>> archive drivers/built-in.a > > This can happen when CONFIG_ARCH_QCOM is disabled and we don't select > QCOM_MDT_LOADER, but some other module selects QCOM_SCM. Ideally we'd > use a similar dependency here to what we have for QCOM_RPROC_COMMON, > but that causes dependency loops from other things selecting QCOM_SCM. > > This appears to be an endless problem, so try something different this > time: > > - CONFIG_QCOM_SCM becomes a hidden symbol that nothing 'depends on' >but that is simply selected by all of its users > > - All the stubs in include/linux/qcom_scm.h can go away > > - arm-smccc.h needs to provide a stub for __arm_smccc_smc() to >allow compile-testing QCOM_SCM on all architectures. > > - To avoid a circular dependency chain involving RESET_CONTROLLER >and PINCTRL_SUNXI, drop the 'select RESET_CONTROLLER' statement. >According to my testing this still builds fine, and the QCOM >platform selects this symbol already. > > Acked-by: Kalle Valo > Acked-by: Alex Elder > Signed-off-by: Arnd Bergmann > --- > Changes in v2: > - fix the iommu dependencies Hey Arnd, Thanks again so much for working out these details. Also my apologies, as Bjorn asked for me to test this patch, but I wasn't able to get to it before it landed. Unfortunately I've hit an issue that is keeping the db845c from booting with this. > diff --git a/drivers/iommu/arm/arm-smmu/Makefile > b/drivers/iommu/arm/arm-smmu/Makefile > index e240a7bcf310..b0cc01aa20c9 100644 > --- a/drivers/iommu/arm/arm-smmu/Makefile > +++ b/drivers/iommu/arm/arm-smmu/Makefile > @@ -1,4 +1,5 @@ > # 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-qcom.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 > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c > b/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c > index 9f465e146799..2c25cce38060 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-impl.c > @@ -215,7 +215,8 @@ 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); > > - smmu = qcom_smmu_impl_init(smmu); > + if (IS_ENABLED(CONFIG_ARM_SMMU_QCOM)) > + smmu = qcom_smmu_impl_init(smmu); > > if (of_device_is_compatible(np, "marvell,ap806-smmu-500")) > smmu->impl = _mmu500_impl; The problem with these two chunks is that there is currently no CONFIG_ARM_SMMU_QCOM option. :) Was that something you intended to add in the patch? I'm working up a Kconfig patch to do so, so I'll send that out in a second here, but let me know if you already have that somewhere (I suspect you implemented it and just forgot to add the change to the commit), as I'm sure your Kconfig help text will be better than mine. :) Again, I'm so sorry I didn't get over to testing your patch before seeing this here! thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Wed, Jul 21, 2021 at 4:54 AM Greg Kroah-Hartman wrote: > > On Wed, Jul 07, 2021 at 04:53:20AM +, John Stultz wrote: > > Allow the qcom_scm driver to be loadable as a permenent module. > > This feels like a regression, it should be allowed to be a module. I'm sorry, I'm not sure I'm following you, Greg. This patch is trying to enable the driver to be able to be loaded as a module. > > This still uses the "depends on QCOM_SCM || !QCOM_SCM" bit to > > ensure that drivers that call into the qcom_scm driver are > > also built as modules. While not ideal in some cases its the > > only safe way I can find to avoid build errors without having > > those drivers select QCOM_SCM and have to force it on (as > > QCOM_SCM=n can be valid for those drivers). > > > > Reviving this now that Saravana's fw_devlink defaults to on, > > which should avoid loading troubles seen before. > > fw_devlink was supposed to resolve these issues and _allow_ code to be > built as modules and not forced to be built into the kernel. Right. I'm re-submitting this patch to enable a driver to work as a module, because earlier attempts to submit it ran into boot trouble because fw_devlink wasn't yet enabled. I worry something in my description made it seem otherwise, so let me know how you read it and I'll try to avoid such confusion in the future. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Fri, Jul 16, 2021 at 10:01 PM Bjorn Andersson wrote: > On Tue 06 Jul 23:53 CDT 2021, John Stultz wrote: > > Allow the qcom_scm driver to be loadable as a permenent module. > > > > This still uses the "depends on QCOM_SCM || !QCOM_SCM" bit to > > ensure that drivers that call into the qcom_scm driver are > > also built as modules. While not ideal in some cases its the > > only safe way I can find to avoid build errors without having > > those drivers select QCOM_SCM and have to force it on (as > > QCOM_SCM=n can be valid for those drivers). > > > > Reviving this now that Saravana's fw_devlink defaults to on, > > which should avoid loading troubles seen before. > > > > Are you (in this last paragraph) saying that all those who have been > burnt by fw_devlink during the last months and therefor run with it > disabled will have a less fun experience once this is merged? > I guess potentially. So way back when this was originally submitted, some folks had trouble booting if it was set as a module due to it loading due to the deferred_probe_timeout expiring. My attempts to change the default timeout value to be larger ran into trouble, but Saravana's fw_devlink does manage to resolve things properly for this case. But if folks are having issues w/ fw_devlink, and have it disabled, and set QCOM_SCM=m they could still trip over the issue with the timeout firing before it is loaded (especially if they are loading modules from late mounted storage rather than ramdisk). > (I'm picking this up, but I don't fancy the idea that some people are > turning the boot process into a lottery) Me neither, and I definitely think the deferred_probe_timeout logic is way too fragile, which is why I'm eager for fw_devlink as it's a much less racy approach to handling module loading dependencies. So if you want to hold on this, while any remaining fw_devlink issues get sorted, that's fine. But I'd also not cast too much ire at fw_devlink, as the global probe timeout approach for handling optional links isn't great, and we need a better solution. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v5 0/5] iommu/arm-smmu: adreno-smmu page fault handling
On Sun, Jul 4, 2021 at 11:16 AM Rob Clark wrote: > > I suspect you are getting a dpu fault, and need: > > https://lore.kernel.org/linux-arm-msm/CAF6AEGvTjTUQXqom-xhdh456tdLscbVFPQ+iud1H1gHc8A2=h...@mail.gmail.com/ > > I suppose Bjorn was expecting me to send that patch If it's helpful, I applied that and it got the db845c booting mainline again for me (along with some reverts for a separate ext4 shrinker crash). Tested-by: John Stultz thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
Allow the qcom_scm driver to be loadable as a permenent module. This still uses the "depends on QCOM_SCM || !QCOM_SCM" bit to ensure that drivers that call into the qcom_scm driver are also built as modules. While not ideal in some cases its the only safe way I can find to avoid build errors without having those drivers select QCOM_SCM and have to force it on (as QCOM_SCM=n can be valid for those drivers). Reviving this now that Saravana's fw_devlink defaults to on, which should avoid loading troubles seen before. Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Marc Zyngier Cc: Linus Walleij Cc: Vinod Koul Cc: Kalle Valo Cc: Maulik Shah Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Acked-by: Kalle Valo Acked-by: Greg Kroah-Hartman Acked-by: Will Deacon Reviewed-by: Bjorn Andersson Signed-off-by: John Stultz --- v3: * Fix __arm_smccc_smc build issue reported by kernel test robot v4: * Add "depends on QCOM_SCM || !QCOM_SCM" bit to ath10k config that requires it. v5: * Fix QCOM_QCM typo in Kconfig, it should be QCOM_SCM --- drivers/firmware/Kconfig| 2 +- drivers/firmware/Makefile | 3 ++- drivers/firmware/qcom_scm.c | 4 drivers/iommu/Kconfig | 2 ++ drivers/net/wireless/ath/ath10k/Kconfig | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index db0ea2d2d75a..af53778edc7e 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -235,7 +235,7 @@ config INTEL_STRATIX10_RSU Say Y here if you want Intel RSU support. config QCOM_SCM - bool + tristate "Qcom SCM driver" depends on ARM || ARM64 depends on HAVE_ARM_SMCCC select RESET_CONTROLLER diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 5e013b6a3692..523173cbff33 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -17,7 +17,8 @@ obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o -obj-$(CONFIG_QCOM_SCM) += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +obj-$(CONFIG_QCOM_SCM) += qcom-scm.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index ee9cb545e73b..bb9ce3f92931 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1296,6 +1296,7 @@ static const struct of_device_id qcom_scm_dt_match[] = { { .compatible = "qcom,scm" }, {} }; +MODULE_DEVICE_TABLE(of, qcom_scm_dt_match); static struct platform_driver qcom_scm_driver = { .driver = { @@ -1312,3 +1313,6 @@ static int __init qcom_scm_init(void) return platform_driver_register(_scm_driver); } subsys_initcall(qcom_scm_init); + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. SCM driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 07b7c25cbed8..f61516c17589 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -253,6 +253,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -382,6 +383,7 @@ config QCOM_IOMMU # Note: iommu drivers cannot (yet?) be built as modules bool "Qualcomm IOMMU Support" depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM=y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU diff --git a/drivers/net/wireless/ath/ath10k/Kconfig b/drivers/net/wireless/ath/ath10k/Kconfig index 40f91bc8514d..741289e385d5 100644 --- a/drivers/net/wireless/ath/ath10k/Kconfig +++ b/drivers/net/wireless/ath/ath10k/Kconfig @@ -44,6 +44,7 @@ config ATH10K_SNOC tristate "Qualcomm ath10k SNOC support" depends on ATH10K depends on ARCH_QCOM || COMPILE_TEST + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select QCOM_QMI_HELPERS help This module adds support for integrated WCN3990 chip connected -- 2.25.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 1/2] irqchip/qcom-pdc: Switch to IRQCHIP_PLATFORM_DRIVER and allow as a module
From: Saravana Kannan This patch revives changes from Saravana Kannan to switch the qcom-pdc driver to use IRQCHIP_PLATFORM_DRIVER helper macros, and allows qcom-pdc driver to be loaded as a permanent module. Earlier attempts at this ran into trouble with loading dependencies, but with Saravana's fw_devlink=on set by default now we should avoid those. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: Saravana Kannan [jstultz: Folded in with my changes to allow the driver to be loadable as a permenent module] Signed-off-by: John Stultz --- drivers/irqchip/Kconfig| 2 +- drivers/irqchip/qcom-pdc.c | 8 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index b90e825df7e14..d4a0b4964ccc5 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -415,7 +415,7 @@ config GOLDFISH_PIC for Goldfish based virtual platforms. config QCOM_PDC - bool "QCOM PDC" + tristate "QCOM PDC" depends on ARCH_QCOM select IRQ_DOMAIN_HIERARCHY help diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c index 5dc63c20b67ea..32d59202d408d 100644 --- a/drivers/irqchip/qcom-pdc.c +++ b/drivers/irqchip/qcom-pdc.c @@ -11,9 +11,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -459,4 +461,8 @@ static int qcom_pdc_init(struct device_node *node, struct device_node *parent) return ret; } -IRQCHIP_DECLARE(qcom_pdc, "qcom,pdc", qcom_pdc_init); +IRQCHIP_PLATFORM_DRIVER_BEGIN(qcom_pdc) +IRQCHIP_MATCH("qcom,pdc", qcom_pdc_init) +IRQCHIP_PLATFORM_DRIVER_END(qcom_pdc) +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Power Domain Controller"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH 2/2] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
Allow the qcom_scm driver to be loadable as a permenent module. This still uses the "depends on QCOM_SCM || !QCOM_SCM" bit to ensure that drivers that call into the qcom_scm driver are also built as modules. While not ideal in some cases its the only safe way I can find to avoid build errors without having those drivers select QCOM_SCM and have to force it on (as QCOM_SCM=n can be valid for those drivers). Reviving this now that Saravana's fw_devlink defaults to on, which should avoid loading troubles seen before. Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Vinod Koul Cc: Kalle Valo Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Acked-by: Kalle Valo Acked-by: Greg Kroah-Hartman Reviewed-by: Bjorn Andersson Signed-off-by: John Stultz --- v3: * Fix __arm_smccc_smc build issue reported by kernel test robot v4: * Add "depends on QCOM_SCM || !QCOM_SCM" bit to ath10k config that requires it. v5: * Fix QCOM_QCM typo in Kconfig, it should be QCOM_SCM --- drivers/firmware/Kconfig| 2 +- drivers/firmware/Makefile | 3 ++- drivers/firmware/qcom_scm.c | 4 drivers/iommu/Kconfig | 2 ++ drivers/net/wireless/ath/ath10k/Kconfig | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index db0ea2d2d75a2..af53778edc7e2 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -235,7 +235,7 @@ config INTEL_STRATIX10_RSU Say Y here if you want Intel RSU support. config QCOM_SCM - bool + tristate "Qcom SCM driver" depends on ARM || ARM64 depends on HAVE_ARM_SMCCC select RESET_CONTROLLER diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 5e013b6a3692e..523173cbff335 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -17,7 +17,8 @@ obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o -obj-$(CONFIG_QCOM_SCM) += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +obj-$(CONFIG_QCOM_SCM) += qcom-scm.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index ee9cb545e73b9..bb9ce3f92931a 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1296,6 +1296,7 @@ static const struct of_device_id qcom_scm_dt_match[] = { { .compatible = "qcom,scm" }, {} }; +MODULE_DEVICE_TABLE(of, qcom_scm_dt_match); static struct platform_driver qcom_scm_driver = { .driver = { @@ -1312,3 +1313,6 @@ static int __init qcom_scm_init(void) return platform_driver_register(_scm_driver); } subsys_initcall(qcom_scm_init); + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. SCM driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 1f111b399bcab..38f7b7a8e2843 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -253,6 +253,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -382,6 +383,7 @@ config QCOM_IOMMU # Note: iommu drivers cannot (yet?) be built as modules bool "Qualcomm IOMMU Support" depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM=y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU diff --git a/drivers/net/wireless/ath/ath10k/Kconfig b/drivers/net/wireless/ath/ath10k/Kconfig index 40f91bc8514d8..741289e385d59 100644 --- a/drivers/net/wireless/ath/ath10k/Kconfig +++ b/drivers/net/wireless/ath/ath10k/Kconfig @@ -44,6 +44,7 @@ config ATH10K_SNOC tristate "Qualcomm ath10k SNOC support" depends on ATH10K depends on ARCH_QCOM || COMPILE_TEST + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select QCOM_QMI_HELPERS help This module adds support for integrated WCN3990 chip connected -- 2.25.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH] Revert "firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module"
On Thu, Nov 19, 2020 at 9:41 AM Thierry Reding wrote: > > From: Thierry Reding > > Commit d0511b5496c0 ("firmware: QCOM_SCM: Allow qcom_scm driver to be > loadable as a permenent module") causes the ARM SMMU driver to be built > as a loadable module when using the Aarch64 default configuration. This > in turn causes problems because if the loadable module is not shipped > in an initial ramdisk, then the deferred probe timeout mechanism will > cause all SMMU masters to probe without SMMU support and fall back to > just plain DMA ops (not IOMMU-backed). > > Once the system has mounted the rootfs, the ARM SMMU driver will then > be loaded, but since the ARM SMMU driver faults by default, this causes > a slew of SMMU faults for the SMMU masters that have already been set > up with plain DMA ops and cause these devices to malfunction. > > Revert that commit to unbreak things while we look for an alternative > solution. > > Reported-by: Jon Hunter > Signed-off-by: Thierry Reding Acked-by: John Stultz Thanks for sending this Thierry, and sorry again for the troubles. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v6 3/3] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Mon, Nov 16, 2020 at 8:36 AM Will Deacon wrote: > On Mon, Nov 16, 2020 at 04:59:36PM +0100, Thierry Reding wrote: > > On Fri, Nov 06, 2020 at 04:27:10AM +0000, John Stultz wrote: > > Unfortunately, the ARM SMMU module will eventually end up being loaded > > once the root filesystem has been mounted (for example via SDHCI or > > Ethernet, both with using just plain, non-IOMMU-backed DMA API) and then > > initialize, configuring as "fault by default", which then results from a > > slew of SMMU faults from all the devices that have previously configured > > themselves without IOMMU support. > > I wonder if fw_devlink=on would help here? > > But either way, I'd be more inclined to revert this change if it's causing > problems for !QCOM devices. > > Linus -- please can you drop this one (patch 3/3) for now, given that it's > causing problems? Agreed. Apologies again for the trouble. I do feel like the probe timeout to handle optional links is causing a lot of the trouble here. I expect fw_devlink would solve this, but it may be awhile before it can be always enabled. I may see about pushing the default probe timeout value to be a little further out than init (I backed away from my last attempt as I didn't want to cause long (30 second) delays for cases like NFS root, but maybe 2-5 seconds would be enough to make things work better for everyone). thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v6 3/3] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Mon, Nov 16, 2020 at 7:59 AM Thierry Reding wrote: > > On Fri, Nov 06, 2020 at 04:27:10AM +, John Stultz wrote: > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > > index 04878caf6da49..c64d7a2b65134 100644 > > --- a/drivers/iommu/Kconfig > > +++ b/drivers/iommu/Kconfig > > @@ -248,6 +248,7 @@ config SPAPR_TCE_IOMMU > > config ARM_SMMU > > tristate "ARM Ltd. System MMU (SMMU) Support" > > depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) > > + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y > > select IOMMU_API > > select IOMMU_IO_PGTABLE_LPAE > > select ARM_DMA_USE_IOMMU if ARM > > This, in conjunction with deferred probe timeout, causes mayhem on > Tegra186. The problem, as far as I can tell, is that there are various > devices that are hooked up to the ARM SMMU, but if ARM SMMU ends up > being built as a loadable module, then those devices will initialize > without IOMMU support (because deferred probe will timeout before the > ARM SMMU module can be loaded from the root filesystem). > > Unfortunately, the ARM SMMU module will eventually end up being loaded > once the root filesystem has been mounted (for example via SDHCI or > Ethernet, both with using just plain, non-IOMMU-backed DMA API) and then > initialize, configuring as "fault by default", which then results from a > slew of SMMU faults from all the devices that have previously configured > themselves without IOMMU support. Oof. My apologies for the trouble. Thanks so much for the report. Out of curiosity, does booting with deferred_probe_timeout=30 avoid the issue for you? thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[RESEND][PATCH 1/2] arm-smmu-qcom: Ensure the qcom_scm driver has finished probing
Robin Murphy pointed out that if the arm-smmu driver probes before the qcom_scm driver, we may call qcom_scm_qsmmu500_wait_safe_toggle() before the __scm is initialized. Now, getting this to happen is a bit contrived, as in my efforts it required enabling asynchronous probing for both drivers, moving the firmware dts node to the end of the dtsi file, as well as forcing a long delay in the qcom_scm_probe function. With those tweaks we ran into the following crash: [2.631040] arm-smmu 1500.iommu: Stage-1: 48-bit VA -> 48-bit IPA [2.633372] Unable to handle kernel NULL pointer dereference at virtual address ... [2.633402] [] user address but active_mm is swapper [2.633409] Internal error: Oops: 9605 [#1] PREEMPT SMP [2.633415] Modules linked in: [2.633427] CPU: 5 PID: 117 Comm: kworker/u16:2 Tainted: GW 5.10.0-rc1-mainline-00025-g272a618fc36-dirty #3971 [2.633430] Hardware name: Thundercomm Dragonboard 845c (DT) [2.633448] Workqueue: events_unbound async_run_entry_fn [2.633456] pstate: 80c5 (Nzcv daif +PAN +UAO -TCO BTYPE=--) [2.633465] pc : qcom_scm_qsmmu500_wait_safe_toggle+0x78/0xb0 [2.633473] lr : qcom_smmu500_reset+0x58/0x78 [2.633476] sp : ffc0105a3b60 ... [2.633567] Call trace: [2.633572] qcom_scm_qsmmu500_wait_safe_toggle+0x78/0xb0 [2.633576] qcom_smmu500_reset+0x58/0x78 [2.633581] arm_smmu_device_reset+0x194/0x270 [2.633585] arm_smmu_device_probe+0xc94/0xeb8 [2.633592] platform_drv_probe+0x58/0xa8 [2.633597] really_probe+0xec/0x398 [2.633601] driver_probe_device+0x5c/0xb8 [2.633606] __driver_attach_async_helper+0x64/0x88 [2.633610] async_run_entry_fn+0x4c/0x118 [2.633617] process_one_work+0x20c/0x4b0 [2.633621] worker_thread+0x48/0x460 [2.633628] kthread+0x14c/0x158 [2.633634] ret_from_fork+0x10/0x18 [2.633642] Code: a9034fa0 d0007f73 29107fa0 91342273 (f9400020) To avoid this, this patch adds a check on qcom_scm_is_available() in the qcom_smmu_impl_init() function, returning -EPROBE_DEFER if its not ready. This allows the driver to try to probe again later after qcom_scm has finished probing. Cc: Robin Murphy Cc: Will Deacon Cc: Andy Gross Cc: Maulik Shah Cc: Bjorn Andersson Cc: Saravana Kannan Cc: Marc Zyngier Cc: Lina Iyer Cc: iommu@lists.linux-foundation.org Cc: linux-arm-msm Reported-by: Robin Murphy Signed-off-by: John Stultz --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 66ba4870659f4..ef37ccfa82562 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -159,6 +159,10 @@ struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu) { struct qcom_smmu *qsmmu; + /* Check to make sure qcom_scm has finished probing */ + if (!qcom_scm_is_available()) + return ERR_PTR(-EPROBE_DEFER); + qsmmu = devm_kzalloc(smmu->dev, sizeof(*qsmmu), GFP_KERNEL); if (!qsmmu) return ERR_PTR(-ENOMEM); -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[RESEND][PATCH 2/2] iommu: Avoid crash if iommu_group is null
In trying to handle a possible driver probe ordering issue brought up by Robin Murphy, I ran across a separate null pointer crash in the iommu core in iommu_group_remove_device(): [2.732803] dwc3-qcom a6f8800.usb: failed to get usb-ddr path: -517 [2.739281] Unable to handle kernel NULL pointer dereference at virtual address 00c0 ... [2.775619] [00c0] user address but active_mm is swapper [2.782039] Internal error: Oops: 9605 [#1] PREEMPT SMP [2.787670] Modules linked in: [2.790769] CPU: 6 PID: 1 Comm: swapper/0 Tainted: GW 5.10.0-rc1-mainline-00025-g272a618fc36-dirty #3973 [2.801719] Hardware name: Thundercomm Dragonboard 845c (DT) [2.807431] pstate: 00c5 (nzcv daif +PAN +UAO -TCO BTYPE=--) [2.813508] pc : iommu_group_remove_device+0x30/0x1b0 [2.818611] lr : iommu_release_device+0x4c/0x78 [2.823189] sp : ffc01005b950 ... [2.907082] Call trace: [2.909566] iommu_group_remove_device+0x30/0x1b0 [2.914323] iommu_release_device+0x4c/0x78 [2.918559] iommu_bus_notifier+0xe8/0x108 [2.922708] blocking_notifier_call_chain+0x78/0xb8 [2.927641] device_del+0x2ac/0x3d0 [2.931177] platform_device_del.part.9+0x20/0x98 [2.935933] platform_device_unregister+0x2c/0x40 [2.940694] of_platform_device_destroy+0xd8/0xe0 [2.945450] device_for_each_child_reverse+0x58/0xb0 [2.950471] of_platform_depopulate+0x4c/0x78 [2.954886] dwc3_qcom_probe+0x93c/0xcb8 [2.958858] platform_drv_probe+0x58/0xa8 [2.962917] really_probe+0xec/0x398 [2.966531] driver_probe_device+0x5c/0xb8 [2.970677] device_driver_attach+0x74/0x98 [2.974911] __driver_attach+0x60/0xe8 [2.978700] bus_for_each_dev+0x84/0xd8 [2.982581] driver_attach+0x30/0x40 [2.986194] bus_add_driver+0x160/0x208 [2.990076] driver_register+0x64/0x110 [2.993957] __platform_driver_register+0x58/0x68 [2.998716] dwc3_qcom_driver_init+0x20/0x28 [3.003041] do_one_initcall+0x6c/0x2d0 [3.006925] kernel_init_freeable+0x214/0x268 [3.011339] kernel_init+0x18/0x118 [3.014876] ret_from_fork+0x10/0x18 [3.018495] Code: d0006a21 f9417295 91130021 910162b6 (b940c2a2) In the case above, the arm-smmu driver fails to probe with EPROBE_DEFER, and I'm guessing I'm guessing that causes iommu_group_add_device() to fail and sets the dev->iommu_group = NULL, then somehow we hit iommu_group_remove_device() and trip over the null value? I'm not really sure... Anyway, adding the null check seems to avoid the issue and the system boots fine after the arm-smmu driver later reprobed. Feedback or better ideas for a solution would be appreciated! Cc: Robin Murphy Cc: Will Deacon Cc: Andy Gross Cc: Maulik Shah Cc: Bjorn Andersson Cc: Saravana Kannan Cc: Marc Zyngier Cc: Lina Iyer Cc: iommu@lists.linux-foundation.org Cc: linux-arm-msm Signed-off-by: John Stultz --- drivers/iommu/iommu.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index b53446bb8c6b4..28229f7ef7d5a 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -877,6 +877,10 @@ void iommu_group_remove_device(struct device *dev) struct iommu_group *group = dev->iommu_group; struct group_device *tmp_device, *device = NULL; + /* Avoid crash if iommu_group value is null */ + if (!group) + return; + dev_info(dev, "Removing from iommu group %d\n", group->id); /* Pre-notify listeners that a device is being removed. */ -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v6 3/3] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Thu, Nov 12, 2020 at 9:37 AM Will Deacon wrote: > On Tue, Nov 10, 2020 at 10:51:46AM -0800, John Stultz wrote: > > On Tue, Nov 10, 2020 at 5:35 AM Linus Walleij > > wrote: > > > On Fri, Nov 6, 2020 at 5:27 AM John Stultz wrote: > > > > > > > Allow the qcom_scm driver to be loadable as a permenent module. > > > > > > ... > > > I applied this patch to the pinctrl tree as well, I suppose > > > that was the intention. If someone gets upset I can always > > > pull it out. > > > > Will: You ok with this? > > We didn't come up with something better, so I can live with it. Ok, thanks! > Not sure > about the otehr issues that were reported by Robin though -- your RFC for > fixing those looked a bit more controversial ;) Huh, I hadn't heard anything back on that series and was going to resend it. Do let me know if you have more thoughts on that one. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v6 3/3] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Tue, Nov 10, 2020 at 5:35 AM Linus Walleij wrote: > On Fri, Nov 6, 2020 at 5:27 AM John Stultz wrote: > > > Allow the qcom_scm driver to be loadable as a permenent module. > > ... > I applied this patch to the pinctrl tree as well, I suppose > that was the intention. If someone gets upset I can always > pull it out. Will: You ok with this? thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v6 1/3] pinctrl: qcom: Kconfig: Rework PINCTRL_MSM to be a depenency rather then a selected config
This patch reworks PINCTRL_MSM to be a visible option, and instead of having the various SoC specific drivers select PINCTRL_MSM, this switches those configs to depend on PINCTRL_MSM. This is useful, as it will be needed in order to cleanly support having the qcom-scm driver, which pinctrl-msm calls into, configured as a module. Without this change, we would eventually have to add dependency lines to every config that selects PINCTRL_MSM, and that would becomes a maintenance headache. We also add PINCTRL_MSM to the arm64 defconfig to avoid surprises as otherwise PINCTRL_MSM/IPQ* options previously enabled, will be off. Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Vinod Koul Cc: Kalle Valo Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Reviewed-by: Bjorn Andersson Signed-off-by: John Stultz --- v6: * Split PINCTRL_MSM dependency bit out into its own patch --- arch/arm64/configs/defconfig | 1 + drivers/pinctrl/qcom/Kconfig | 48 ++-- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 5cfe3cf6f2acb..2ac53d8ae76a3 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -483,6 +483,7 @@ CONFIG_PINCTRL_IMX8MP=y CONFIG_PINCTRL_IMX8MQ=y CONFIG_PINCTRL_IMX8QXP=y CONFIG_PINCTRL_IMX8DXL=y +CONFIG_PINCTRL_MSM=y CONFIG_PINCTRL_IPQ8074=y CONFIG_PINCTRL_IPQ6018=y CONFIG_PINCTRL_MSM8916=y diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig index 5fe7b8aaf69d8..c9bb2d9e49d47 100644 --- a/drivers/pinctrl/qcom/Kconfig +++ b/drivers/pinctrl/qcom/Kconfig @@ -2,7 +2,7 @@ if (ARCH_QCOM || COMPILE_TEST) config PINCTRL_MSM - bool + bool "Qualcomm core pin controller driver" select PINMUX select PINCONF select GENERIC_PINCONF @@ -13,7 +13,7 @@ config PINCTRL_MSM config PINCTRL_APQ8064 tristate "Qualcomm APQ8064 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm APQ8064 platform. @@ -21,7 +21,7 @@ config PINCTRL_APQ8064 config PINCTRL_APQ8084 tristate "Qualcomm APQ8084 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm APQ8084 platform. @@ -29,7 +29,7 @@ config PINCTRL_APQ8084 config PINCTRL_IPQ4019 tristate "Qualcomm IPQ4019 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm IPQ4019 platform. @@ -37,7 +37,7 @@ config PINCTRL_IPQ4019 config PINCTRL_IPQ8064 tristate "Qualcomm IPQ8064 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm IPQ8064 platform. @@ -45,7 +45,7 @@ config PINCTRL_IPQ8064 config PINCTRL_IPQ8074 tristate "Qualcomm Technologies, Inc. IPQ8074 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm Technologies Inc. TLMM block found on the @@ -55,7 +55,7 @@ config PINCTRL_IPQ8074 config PINCTRL_IPQ6018 tristate "Qualcomm Technologies, Inc. IPQ6018 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm Technologies Inc. TLMM block found on the @@ -65,7 +65,7 @@ config PINCTRL_IPQ6018 config PINCTRL_MSM8226 tristate "Qualcomm 8226 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm Technologies Inc TLMM block found on the Qualcomm @@ -74,7 +74,7 @@ config PINCTRL_MSM8226 config PINCTRL_MSM8660 tristate "Qualcomm 8660 pin controller driver"
[PATCH v6 2/3] pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module
Tweaks to allow pinctrl-msm code to be loadable as a module. This is needed in order to support having the qcom-scm driver, which pinctrl-msm calls into, configured as a module. This requires that we tweak Kconfigs selecting PINCTRL_MSM to also depend on QCOM_SCM || QCOM_SCM=n so that we match the module setting of QCOM_SCM. Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Vinod Koul Cc: Kalle Valo Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Reviewed-by: Bjorn Andersson Signed-off-by: John Stultz --- v2: * Module description and whitespace fixes suggested by Bjorn * Added QCOM_SCM || QCOM_SCM=n bits on Kconfigs selecting PINCTRL_MSM. Reported by both Todd and Bjorn. v3: * Make sure the QCOM_SCM || QCOM_SCM=n trick is commented v4: * Rework "select PINCTRL_MSM" to "depends on PINCTRL_MSM" to consolidate the QCOM_SCM dependency. v5: * Add PINCTRL_MSM to arm64 defconfig v6: * Split PINCTRL_MSM dependency bit out into its own patch --- drivers/pinctrl/qcom/Kconfig | 3 ++- drivers/pinctrl/qcom/pinctrl-msm.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig index c9bb2d9e49d47..8bb786ed152dd 100644 --- a/drivers/pinctrl/qcom/Kconfig +++ b/drivers/pinctrl/qcom/Kconfig @@ -2,7 +2,8 @@ if (ARCH_QCOM || COMPILE_TEST) config PINCTRL_MSM - bool "Qualcomm core pin controller driver" + tristate "Qualcomm core pin controller driver" + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select PINMUX select PINCONF select GENERIC_PINCONF diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index c4bcda90aac4a..988343ac49b92 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -1443,3 +1443,5 @@ int msm_pinctrl_remove(struct platform_device *pdev) } EXPORT_SYMBOL(msm_pinctrl_remove); +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. TLMM driver"); +MODULE_LICENSE("GPL v2"); -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v6 3/3] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
Allow the qcom_scm driver to be loadable as a permenent module. This still uses the "depends on QCOM_SCM || !QCOM_SCM" bit to ensure that drivers that call into the qcom_scm driver are also built as modules. While not ideal in some cases its the only safe way I can find to avoid build errors without having those drivers select QCOM_SCM and have to force it on (as QCOM_SCM=n can be valid for those drivers). Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Vinod Koul Cc: Kalle Valo Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Acked-by: Kalle Valo Acked-by: Greg Kroah-Hartman Reviewed-by: Bjorn Andersson Signed-off-by: John Stultz --- v3: * Fix __arm_smccc_smc build issue reported by kernel test robot v4: * Add "depends on QCOM_SCM || !QCOM_SCM" bit to ath10k config that requires it. v5: * Fix QCOM_QCM typo in Kconfig, it should be QCOM_SCM --- drivers/firmware/Kconfig| 4 ++-- drivers/firmware/Makefile | 3 ++- drivers/firmware/qcom_scm.c | 4 drivers/iommu/Kconfig | 2 ++ drivers/net/wireless/ath/ath10k/Kconfig | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 3315e3c215864..5e369928bc567 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -235,8 +235,8 @@ config INTEL_STRATIX10_RSU Say Y here if you want Intel RSU support. config QCOM_SCM - bool - depends on ARM || ARM64 + tristate "Qcom SCM driver" + depends on (ARM && HAVE_ARM_SMCCC) || ARM64 select RESET_CONTROLLER config QCOM_SCM_DOWNLOAD_MODE_DEFAULT diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 5e013b6a3692e..523173cbff335 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -17,7 +17,8 @@ obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o -obj-$(CONFIG_QCOM_SCM) += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +obj-$(CONFIG_QCOM_SCM) += qcom-scm.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 7be48c1bec96d..6f431b73e617d 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1280,6 +1280,7 @@ static const struct of_device_id qcom_scm_dt_match[] = { { .compatible = "qcom,scm" }, {} }; +MODULE_DEVICE_TABLE(of, qcom_scm_dt_match); static struct platform_driver qcom_scm_driver = { .driver = { @@ -1295,3 +1296,6 @@ static int __init qcom_scm_init(void) return platform_driver_register(_scm_driver); } subsys_initcall(qcom_scm_init); + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. SCM driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 04878caf6da49..c64d7a2b65134 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -248,6 +248,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -375,6 +376,7 @@ config QCOM_IOMMU # Note: iommu drivers cannot (yet?) be built as modules bool "Qualcomm IOMMU Support" depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM=y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU diff --git a/drivers/net/wireless/ath/ath10k/Kconfig b/drivers/net/wireless/ath/ath10k/Kconfig index 40f91bc8514d8..741289e385d59 100644 --- a/drivers/net/wireless/ath/ath10k/Kconfig +++ b/drivers/net/wireless/ath/ath10k/Kconfig @@ -44,6 +44,7 @@ config ATH10K_SNOC tristate "Qualcomm ath10k SNOC support" depends on ATH10K depends on ARCH_QCOM || COMPILE_TEST + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select QCOM_QMI_HELPERS help This module adds support for integrated WCN3990 chip connected -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v5 1/2] pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module
On Thu, Nov 5, 2020 at 6:17 AM Linus Walleij wrote: > On Sat, Oct 31, 2020 at 1:38 AM John Stultz wrote: > > > Tweaks to allow pinctrl-msm code to be loadable as a module. > > > > This is needed in order to support having the qcom-scm driver, > > which pinctrl-msm calls into, configured as a module. > > > > This requires that we tweak Kconfigs selecting PINCTRL_MSM to > > also depend on QCOM_SCM || QCOM_SCM=n so that we match the > > module setting of QCOM_SCM. > > > > Unlike the previous revision of this patch: > > > > https://lore.kernel.org/lkml/20200625001039.56174-5-john.stu...@linaro.org/ > > this version reworks PINCTRL_MSM to be a visible option and > > instead of having the various SoC specific drivers select > > PINCTRL_MSM, this switches those configs to depend on > > PINCTRL_MSM. This avoids adding the oddish looking: > > "depend on QCOM_SCM || QCOM_SCM=n" > > to every SoC specific driver, as that becomes a maintenance > > headache. > > > > We also add PINCTRL_MSM to the arm64 defconfig to avoid > > surprises as otherwise PINCTRL_MSM/IPQ* options previously > > enabled, will be off. > > > > Cc: Catalin Marinas > > Cc: Will Deacon > > Cc: Andy Gross > > Cc: Bjorn Andersson > > Cc: Joerg Roedel > > Cc: Thomas Gleixner > > Cc: Jason Cooper > > Cc: Marc Zyngier > > Cc: Linus Walleij > > Cc: Vinod Koul > > Cc: Kalle Valo > > Cc: Maulik Shah > > Cc: Lina Iyer > > Cc: Saravana Kannan > > Cc: Todd Kjos > > Cc: Greg Kroah-Hartman > > Cc: linux-arm-...@vger.kernel.org > > Cc: iommu@lists.linux-foundation.org > > Cc: linux-g...@vger.kernel.org > > Signed-off-by: John Stultz > > --- > > v2: > > * Module description and whitespace fixes suggested by Bjorn > > * Added QCOM_SCM || QCOM_SCM=n bits on Kconfigs selecting > > PINCTRL_MSM. Reported by both Todd and Bjorn. > > v3: > > * Make sure the QCOM_SCM || QCOM_SCM=n trick is commented > > v4: > > * Rework "select PINCTRL_MSM" to "depends on PINCTRL_MSM" > > to consolidate the QCOM_SCM dependency. > > v5: > > * Add PINCTRL_MSM to arm64 defconfig > > Bjorn can you have a look at this series? > > BTW John I'm afraid I just merged a new QCOM subdriver so we might > need to respin this to cover all. > > It's an important patch so I'll help out in rebasing it if the only problem is > that my tree is moving under your feet. No worries. I'm mostly wanting to make sure there are no objections with switching PINCTRL_MSM from a selected config to a depended config. If that seems ok, I can redo it on whatever point you would like. I realize I can also split that change out separately from the module enablement bits as well if its helpful. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Fri, Oct 30, 2020 at 7:12 AM Robin Murphy wrote: > On 2020-10-30 01:02, John Stultz wrote: > > On Wed, Oct 28, 2020 at 7:51 AM Robin Murphy wrote: > >> Hmm, perhaps I'm missing something here, but even if the config options > >> *do* line up, what prevents arm-smmu probing before qcom-scm and > >> dereferencing NULL in qcom_scm_qsmmu500_wait_safe_toggle() before __scm > >> is initialised? > > > > Oh man, this spun me on a "wait, but how does it all work!" trip. :) > > > > So in the non-module case, the qcom_scm driver is a subsys_initcall > > and the arm-smmu is a module_platform_driver, so the ordering works > > out. > > > > In the module case, the arm-smmu code isn't loaded until the qcom_scm > > driver finishes probing due to the symbol dependency handling. > > My point is that module load != driver probe. AFAICS you could disable > drivers_autoprobe, load both modules, bind the SMMU to its driver first, > and boom! > > > To double check this, I added a big msleep at the top of the > > qcom_scm_probe to try to open the race window you described, but the > > arm_smmu_device_probe() doesn't run until after qcom_scm_probe > > completes. > > I don't think asynchronous probing is enabled by default, so indeed I > would expect that to still happen to work ;) > > > So at least as a built in / built in, or a module/module case its ok. > > And in the case where arm-smmu is a module and qcom_scm is built in > > that's ok too. > > In the built-in case, I'm sure it happens to work out similarly because > the order of nodes in the DTB tends to be the order in which devices are > autoprobed. Again, async probe might be enough to break things; manually > binding drivers definitely should; moving the firmware node to the end > of the DTB probably would as well. So, with modules, I turned on async probing for the two drivers, as well as moved the firmware node to the end of the dtb, and couldn't manage to trip it up even with a 6 second delay in the qcom_scm probe function. It was only when doing the same with everything built in that I did manage to trigger the issue. So yes, you're right! And it is an issue more easily tripped with everything built in statically (and not really connected to this patch series). > > Its just the case my patch is trying to prevent is where arm-smmu is > > built in, but qcom_scm is a module that it can't work (due to build > > errors in missing symbols, or if we tried to use function pointers to > > plug in the qcom_scm - the lack of initialization ordering). > > > > Hopefully that addresses your concern? Let me know if I'm still > > missing something. > > What I was dancing around is that the SCM API (and/or its users) appears > to need a general way to tell whether SCM is ready or not, because the > initialisation ordering problem is there anyway. Neither Kconfig nor the > module loader can solve that. Hrm... There is qcom_scm_is_available(). I tried adding a check for that in qcom_smmu_impl_init() and return EPROBE_DEFER if it fails, but I then hit a separate crash (tripping in iommu_group_remove_device on a null dev->iommu_group value). But after adding a check for that, it seems to be working... I'll try to spin up a separate patch here for that in a second. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v5 2/2] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
Allow the qcom_scm driver to be loadable as a permenent module. This still uses the "depends on QCOM_SCM || !QCOM_SCM" bit to ensure that drivers that call into the qcom_scm driver are also built as modules. While not ideal in some cases its the only safe way I can find to avoid build errors without having those drivers select QCOM_SCM and have to force it on (as QCOM_SCM=n can be valid for those drivers). Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Vinod Koul Cc: Kalle Valo Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Acked-by: Greg Kroah-Hartman Signed-off-by: John Stultz --- v3: * Fix __arm_smccc_smc build issue reported by kernel test robot v4: * Add "depends on QCOM_SCM || !QCOM_SCM" bit to ath10k config that requires it. v5: * Fix QCOM_QCM typo in Kconfig, it should be QCOM_SCM --- drivers/firmware/Kconfig| 4 ++-- drivers/firmware/Makefile | 3 ++- drivers/firmware/qcom_scm.c | 4 drivers/iommu/Kconfig | 2 ++ drivers/net/wireless/ath/ath10k/Kconfig | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 3315e3c215864..5e369928bc567 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -235,8 +235,8 @@ config INTEL_STRATIX10_RSU Say Y here if you want Intel RSU support. config QCOM_SCM - bool - depends on ARM || ARM64 + tristate "Qcom SCM driver" + depends on (ARM && HAVE_ARM_SMCCC) || ARM64 select RESET_CONTROLLER config QCOM_SCM_DOWNLOAD_MODE_DEFAULT diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 5e013b6a3692e..523173cbff335 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -17,7 +17,8 @@ obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o -obj-$(CONFIG_QCOM_SCM) += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +obj-$(CONFIG_QCOM_SCM) += qcom-scm.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 7be48c1bec96d..6f431b73e617d 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1280,6 +1280,7 @@ static const struct of_device_id qcom_scm_dt_match[] = { { .compatible = "qcom,scm" }, {} }; +MODULE_DEVICE_TABLE(of, qcom_scm_dt_match); static struct platform_driver qcom_scm_driver = { .driver = { @@ -1295,3 +1296,6 @@ static int __init qcom_scm_init(void) return platform_driver_register(_scm_driver); } subsys_initcall(qcom_scm_init); + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. SCM driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 04878caf6da49..c64d7a2b65134 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -248,6 +248,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -375,6 +376,7 @@ config QCOM_IOMMU # Note: iommu drivers cannot (yet?) be built as modules bool "Qualcomm IOMMU Support" depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM=y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU diff --git a/drivers/net/wireless/ath/ath10k/Kconfig b/drivers/net/wireless/ath/ath10k/Kconfig index 40f91bc8514d8..741289e385d59 100644 --- a/drivers/net/wireless/ath/ath10k/Kconfig +++ b/drivers/net/wireless/ath/ath10k/Kconfig @@ -44,6 +44,7 @@ config ATH10K_SNOC tristate "Qualcomm ath10k SNOC support" depends on ATH10K depends on ARCH_QCOM || COMPILE_TEST + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select QCOM_QMI_HELPERS help This module adds support for integrated WCN3990 chip connected -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v5 1/2] pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module
Tweaks to allow pinctrl-msm code to be loadable as a module. This is needed in order to support having the qcom-scm driver, which pinctrl-msm calls into, configured as a module. This requires that we tweak Kconfigs selecting PINCTRL_MSM to also depend on QCOM_SCM || QCOM_SCM=n so that we match the module setting of QCOM_SCM. Unlike the previous revision of this patch: https://lore.kernel.org/lkml/20200625001039.56174-5-john.stu...@linaro.org/ this version reworks PINCTRL_MSM to be a visible option and instead of having the various SoC specific drivers select PINCTRL_MSM, this switches those configs to depend on PINCTRL_MSM. This avoids adding the oddish looking: "depend on QCOM_SCM || QCOM_SCM=n" to every SoC specific driver, as that becomes a maintenance headache. We also add PINCTRL_MSM to the arm64 defconfig to avoid surprises as otherwise PINCTRL_MSM/IPQ* options previously enabled, will be off. Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Vinod Koul Cc: Kalle Valo Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- v2: * Module description and whitespace fixes suggested by Bjorn * Added QCOM_SCM || QCOM_SCM=n bits on Kconfigs selecting PINCTRL_MSM. Reported by both Todd and Bjorn. v3: * Make sure the QCOM_SCM || QCOM_SCM=n trick is commented v4: * Rework "select PINCTRL_MSM" to "depends on PINCTRL_MSM" to consolidate the QCOM_SCM dependency. v5: * Add PINCTRL_MSM to arm64 defconfig --- arch/arm64/configs/defconfig | 1 + drivers/pinctrl/qcom/Kconfig | 49 +++--- drivers/pinctrl/qcom/pinctrl-msm.c | 2 ++ 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 17a2df6a263e8..45768828fdb8e 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -483,6 +483,7 @@ CONFIG_PINCTRL_IMX8MP=y CONFIG_PINCTRL_IMX8MQ=y CONFIG_PINCTRL_IMX8QXP=y CONFIG_PINCTRL_IMX8DXL=y +CONFIG_PINCTRL_MSM=y CONFIG_PINCTRL_IPQ8074=y CONFIG_PINCTRL_IPQ6018=y CONFIG_PINCTRL_MSM8916=y diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig index 5fe7b8aaf69d8..8bb786ed152dd 100644 --- a/drivers/pinctrl/qcom/Kconfig +++ b/drivers/pinctrl/qcom/Kconfig @@ -2,7 +2,8 @@ if (ARCH_QCOM || COMPILE_TEST) config PINCTRL_MSM - bool + tristate "Qualcomm core pin controller driver" + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select PINMUX select PINCONF select GENERIC_PINCONF @@ -13,7 +14,7 @@ config PINCTRL_MSM config PINCTRL_APQ8064 tristate "Qualcomm APQ8064 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm APQ8064 platform. @@ -21,7 +22,7 @@ config PINCTRL_APQ8064 config PINCTRL_APQ8084 tristate "Qualcomm APQ8084 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm APQ8084 platform. @@ -29,7 +30,7 @@ config PINCTRL_APQ8084 config PINCTRL_IPQ4019 tristate "Qualcomm IPQ4019 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm IPQ4019 platform. @@ -37,7 +38,7 @@ config PINCTRL_IPQ4019 config PINCTRL_IPQ8064 tristate "Qualcomm IPQ8064 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm IPQ8064 platform. @@ -45,7 +46,7 @@ config PINCTRL_IPQ8064 config PINCTRL_IPQ8074 tristate "Qualcomm Technologies, Inc. IPQ8074 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm Technologies Inc. TLMM block found on the @@ -55,7 +56,7 @@ config PINCTRL_IPQ8074 config PINCTRL_IPQ6018 tristate "Qualcomm Technologies, Inc. IPQ6018 pin controller driver" depends on GPIOLIB &a
[RFC][PATCH 2/2] iommu: Avoid crash if iommu_group is null
In trying to handle a possible driver probe ordering issue brought up by Robin Murphy, I ran across a separate null pointer crash in the iommu core in iommu_group_remove_device(): [2.732803] dwc3-qcom a6f8800.usb: failed to get usb-ddr path: -517 [2.739281] Unable to handle kernel NULL pointer dereference at virtual address 00c0 ... [2.775619] [00c0] user address but active_mm is swapper [2.782039] Internal error: Oops: 9605 [#1] PREEMPT SMP [2.787670] Modules linked in: [2.790769] CPU: 6 PID: 1 Comm: swapper/0 Tainted: GW 5.10.0-rc1-mainline-00025-g272a618fc36-dirty #3973 [2.801719] Hardware name: Thundercomm Dragonboard 845c (DT) [2.807431] pstate: 00c5 (nzcv daif +PAN +UAO -TCO BTYPE=--) [2.813508] pc : iommu_group_remove_device+0x30/0x1b0 [2.818611] lr : iommu_release_device+0x4c/0x78 [2.823189] sp : ffc01005b950 ... [2.907082] Call trace: [2.909566] iommu_group_remove_device+0x30/0x1b0 [2.914323] iommu_release_device+0x4c/0x78 [2.918559] iommu_bus_notifier+0xe8/0x108 [2.922708] blocking_notifier_call_chain+0x78/0xb8 [2.927641] device_del+0x2ac/0x3d0 [2.931177] platform_device_del.part.9+0x20/0x98 [2.935933] platform_device_unregister+0x2c/0x40 [2.940694] of_platform_device_destroy+0xd8/0xe0 [2.945450] device_for_each_child_reverse+0x58/0xb0 [2.950471] of_platform_depopulate+0x4c/0x78 [2.954886] dwc3_qcom_probe+0x93c/0xcb8 [2.958858] platform_drv_probe+0x58/0xa8 [2.962917] really_probe+0xec/0x398 [2.966531] driver_probe_device+0x5c/0xb8 [2.970677] device_driver_attach+0x74/0x98 [2.974911] __driver_attach+0x60/0xe8 [2.978700] bus_for_each_dev+0x84/0xd8 [2.982581] driver_attach+0x30/0x40 [2.986194] bus_add_driver+0x160/0x208 [2.990076] driver_register+0x64/0x110 [2.993957] __platform_driver_register+0x58/0x68 [2.998716] dwc3_qcom_driver_init+0x20/0x28 [3.003041] do_one_initcall+0x6c/0x2d0 [3.006925] kernel_init_freeable+0x214/0x268 [3.011339] kernel_init+0x18/0x118 [3.014876] ret_from_fork+0x10/0x18 [3.018495] Code: d0006a21 f9417295 91130021 910162b6 (b940c2a2) In the case above, the arm-smmu driver fails to probe with EPROBE_DEFER, and I'm guessing I'm guessing that causes iommu_group_add_device() to fail and sets the dev->iommu_group = NULL, then somehow we hit iommu_group_remove_device() and trip over the null value? I'm not really sure... Anyway, adding the null check seems to avoid the issue and the system boots fine after the arm-smmu driver later reprobed. Feedback or better ideas for a solution would be appreciated! Cc: Robin Murphy Cc: Will Deacon Cc: Andy Gross Cc: Maulik Shah Cc: Bjorn Andersson Cc: Saravana Kannan Cc: Marc Zyngier Cc: Lina Iyer Cc: iommu@lists.linux-foundation.org Cc: linux-arm-msm Signed-off-by: John Stultz --- drivers/iommu/iommu.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 8c470f451a323..44639b88e77db 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -877,6 +877,10 @@ void iommu_group_remove_device(struct device *dev) struct iommu_group *group = dev->iommu_group; struct group_device *tmp_device, *device = NULL; + /* Avoid crash if iommu_group value is null */ + if (!group) + return; + dev_info(dev, "Removing from iommu group %d\n", group->id); /* Pre-notify listeners that a device is being removed. */ -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[RFC][PATCH 1/2] arm-smmu-qcom: Ensure the qcom_scm driver has finished probing
Robin Murphy pointed out that if the arm-smmu driver probes before the qcom_scm driver, we may call qcom_scm_qsmmu500_wait_safe_toggle() before the __scm is initialized. Now, getting this to happen is a bit contrived, as in my efforts it required enabling asynchronous probing for both drivers, moving the firmware dts node to the end of the dtsi file, as well as forcing a long delay in the qcom_scm_probe function. With those tweaks we ran into the following crash: [2.631040] arm-smmu 1500.iommu: Stage-1: 48-bit VA -> 48-bit IPA [2.633372] Unable to handle kernel NULL pointer dereference at virtual address ... [2.633402] [] user address but active_mm is swapper [2.633409] Internal error: Oops: 9605 [#1] PREEMPT SMP [2.633415] Modules linked in: [2.633427] CPU: 5 PID: 117 Comm: kworker/u16:2 Tainted: GW 5.10.0-rc1-mainline-00025-g272a618fc36-dirty #3971 [2.633430] Hardware name: Thundercomm Dragonboard 845c (DT) [2.633448] Workqueue: events_unbound async_run_entry_fn [2.633456] pstate: 80c5 (Nzcv daif +PAN +UAO -TCO BTYPE=--) [2.633465] pc : qcom_scm_qsmmu500_wait_safe_toggle+0x78/0xb0 [2.633473] lr : qcom_smmu500_reset+0x58/0x78 [2.633476] sp : ffc0105a3b60 ... [2.633567] Call trace: [2.633572] qcom_scm_qsmmu500_wait_safe_toggle+0x78/0xb0 [2.633576] qcom_smmu500_reset+0x58/0x78 [2.633581] arm_smmu_device_reset+0x194/0x270 [2.633585] arm_smmu_device_probe+0xc94/0xeb8 [2.633592] platform_drv_probe+0x58/0xa8 [2.633597] really_probe+0xec/0x398 [2.633601] driver_probe_device+0x5c/0xb8 [2.633606] __driver_attach_async_helper+0x64/0x88 [2.633610] async_run_entry_fn+0x4c/0x118 [2.633617] process_one_work+0x20c/0x4b0 [2.633621] worker_thread+0x48/0x460 [2.633628] kthread+0x14c/0x158 [2.633634] ret_from_fork+0x10/0x18 [2.633642] Code: a9034fa0 d0007f73 29107fa0 91342273 (f9400020) To avoid this, this patch adds a check on qcom_scm_is_available() in the qcom_smmu_impl_init() function, returning -EPROBE_DEFER if its not ready. This allows the driver to try to probe again later after qcom_scm has finished probing. Cc: Robin Murphy Cc: Will Deacon Cc: Andy Gross Cc: Maulik Shah Cc: Bjorn Andersson Cc: Saravana Kannan Cc: Marc Zyngier Cc: Lina Iyer Cc: iommu@lists.linux-foundation.org Cc: linux-arm-msm Reported-by: Robin Murphy Signed-off-by: John Stultz --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 66ba4870659f4..ef37ccfa82562 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -159,6 +159,10 @@ struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu) { struct qcom_smmu *qsmmu; + /* Check to make sure qcom_scm has finished probing */ + if (!qcom_scm_is_available()) + return ERR_PTR(-EPROBE_DEFER); + qsmmu = devm_kzalloc(smmu->dev, sizeof(*qsmmu), GFP_KERNEL); if (!qsmmu) return ERR_PTR(-ENOMEM); -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v4 2/2] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
> diff --git a/drivers/net/wireless/ath/ath10k/Kconfig > b/drivers/net/wireless/ath/ath10k/Kconfig > index 40f91bc8514d8..a490e78890017 100644 > --- a/drivers/net/wireless/ath/ath10k/Kconfig > +++ b/drivers/net/wireless/ath/ath10k/Kconfig > @@ -44,6 +44,7 @@ config ATH10K_SNOC > tristate "Qualcomm ath10k SNOC support" > depends on ATH10K > depends on ARCH_QCOM || COMPILE_TEST > + depends on QCOM_QCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y Doh. Apologies! I flubbed this line (SCM not QCM). I'll fix and resend tomorrow. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v4 1/2] pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module
Tweaks to allow pinctrl-msm code to be loadable as a module. This is needed in order to support having the qcom-scm driver, which pinctrl-msm calls into, configured as a module. This requires that we tweak Kconfigs selecting PINCTRL_MSM to also depend on QCOM_SCM || QCOM_SCM=n so that we match the module setting of QCOM_SCM. Unlike the previous revision of this patch: https://lore.kernel.org/lkml/20200625001039.56174-5-john.stu...@linaro.org/ this version reworks PINCTRL_MSM to be a visible option and instead of having the various SoC specific drivers select PINCTRL_MSM, this switches those configs to depend on PINCTRL_MSM. This avoids adding the oddish looking: "depend on QCOM_SCM || QCOM_SCM=n" to every SoC specific driver, as that becomes a maintenance headache. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- v2: * Module description and whitespace fixes suggested by Bjorn * Added QCOM_SCM || QCOM_SCM=n bits on Kconfigs selecting PINCTRL_MSM. Reported by both Todd and Bjorn. v3: * Make sure the QCOM_SCM || QCOM_SCM=n trick is commented v4: * Rework "select PINCTRL_MSM" to "depends on PINCTRL_MSM" to consolidate the QCOM_SCM dependency. --- drivers/pinctrl/qcom/Kconfig | 49 +++--- drivers/pinctrl/qcom/pinctrl-msm.c | 2 ++ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig index 5fe7b8aaf69d8..8bb786ed152dd 100644 --- a/drivers/pinctrl/qcom/Kconfig +++ b/drivers/pinctrl/qcom/Kconfig @@ -2,7 +2,8 @@ if (ARCH_QCOM || COMPILE_TEST) config PINCTRL_MSM - bool + tristate "Qualcomm core pin controller driver" + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select PINMUX select PINCONF select GENERIC_PINCONF @@ -13,7 +14,7 @@ config PINCTRL_MSM config PINCTRL_APQ8064 tristate "Qualcomm APQ8064 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm APQ8064 platform. @@ -21,7 +22,7 @@ config PINCTRL_APQ8064 config PINCTRL_APQ8084 tristate "Qualcomm APQ8084 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm APQ8084 platform. @@ -29,7 +30,7 @@ config PINCTRL_APQ8084 config PINCTRL_IPQ4019 tristate "Qualcomm IPQ4019 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm IPQ4019 platform. @@ -37,7 +38,7 @@ config PINCTRL_IPQ4019 config PINCTRL_IPQ8064 tristate "Qualcomm IPQ8064 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found in the Qualcomm IPQ8064 platform. @@ -45,7 +46,7 @@ config PINCTRL_IPQ8064 config PINCTRL_IPQ8074 tristate "Qualcomm Technologies, Inc. IPQ8074 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm Technologies Inc. TLMM block found on the @@ -55,7 +56,7 @@ config PINCTRL_IPQ8074 config PINCTRL_IPQ6018 tristate "Qualcomm Technologies, Inc. IPQ6018 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm Technologies Inc. TLMM block found on the @@ -65,7 +66,7 @@ config PINCTRL_IPQ6018 config PINCTRL_MSM8226 tristate "Qualcomm 8226 pin controller driver" depends on GPIOLIB && OF - select PINCTRL_MSM + depends on PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm Technologies Inc TLMM block found on the Qualcomm @@ -74,7 +75,7 @@ config PINCTRL_MSM8226 config PINCTRL_MSM8660 tristate "Qualcom
[PATCH v4 2/2] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
Allow the qcom_scm driver to be loadable as a permenent module. This still uses the "depends on QCOM_SCM || !QCOM_SCM" bit to ensure that drivers that call into the qcom_scm driver are also built as modules. While not ideal in some cases its the only safe way I can find to avoid build errors without having those drivers select QCOM_SCM and have to force it on (as QCOM_SCM=n can be valid for those drivers). Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Acked-by: Greg Kroah-Hartman Signed-off-by: John Stultz --- v3: Fix __arm_smccc_smc build issue reported by kernel test robot v4: Add "depends on QCOM_SCM || !QCOM_SCM" bit to ath10k config that requires it. --- drivers/firmware/Kconfig| 4 ++-- drivers/firmware/Makefile | 3 ++- drivers/firmware/qcom_scm.c | 4 drivers/iommu/Kconfig | 2 ++ drivers/net/wireless/ath/ath10k/Kconfig | 1 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 3315e3c215864..5e369928bc567 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -235,8 +235,8 @@ config INTEL_STRATIX10_RSU Say Y here if you want Intel RSU support. config QCOM_SCM - bool - depends on ARM || ARM64 + tristate "Qcom SCM driver" + depends on (ARM && HAVE_ARM_SMCCC) || ARM64 select RESET_CONTROLLER config QCOM_SCM_DOWNLOAD_MODE_DEFAULT diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 5e013b6a3692e..523173cbff335 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -17,7 +17,8 @@ obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o -obj-$(CONFIG_QCOM_SCM) += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +obj-$(CONFIG_QCOM_SCM) += qcom-scm.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 7be48c1bec96d..6f431b73e617d 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1280,6 +1280,7 @@ static const struct of_device_id qcom_scm_dt_match[] = { { .compatible = "qcom,scm" }, {} }; +MODULE_DEVICE_TABLE(of, qcom_scm_dt_match); static struct platform_driver qcom_scm_driver = { .driver = { @@ -1295,3 +1296,6 @@ static int __init qcom_scm_init(void) return platform_driver_register(_scm_driver); } subsys_initcall(qcom_scm_init); + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. SCM driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 04878caf6da49..c64d7a2b65134 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -248,6 +248,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -375,6 +376,7 @@ config QCOM_IOMMU # Note: iommu drivers cannot (yet?) be built as modules bool "Qualcomm IOMMU Support" depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM=y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU diff --git a/drivers/net/wireless/ath/ath10k/Kconfig b/drivers/net/wireless/ath/ath10k/Kconfig index 40f91bc8514d8..a490e78890017 100644 --- a/drivers/net/wireless/ath/ath10k/Kconfig +++ b/drivers/net/wireless/ath/ath10k/Kconfig @@ -44,6 +44,7 @@ config ATH10K_SNOC tristate "Qualcomm ath10k SNOC support" depends on ATH10K depends on ARCH_QCOM || COMPILE_TEST + depends on QCOM_QCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select QCOM_QMI_HELPERS help This module adds support for integrated WCN3990 chip connected -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Wed, Oct 28, 2020 at 6:51 AM Will Deacon wrote: > On Tue, Oct 27, 2020 at 10:53:47PM -0700, John Stultz wrote: > > Alternatively, I'm considering trying to switch the module dependency > > annotation so that the CONFIG_QCOM_SCM modularity depends on ARM_SMMU > > being a module. But that is sort of putting the restriction on the > > callee instead of the caller (sort of flipping the meaning of the > > depends), which feels prone to later trouble (and with multiple users > > of CONFIG_QCOM_SCM needing similar treatment, it would make it > > difficult to discover the right combination of configs needed to allow > > it to be a module). > > > > Anyway, I wanted to reach out to see if you had any further ideas > > here. Sorry for letting such a large time gap pass! > > Well we can always go with your original hack, if it helps? > > https://lore.kernel.org/linux-iommu/20200714075603.GE4277@willie-the-truck/ Yea. After trying a few more ideas that didn't pan out, I think I'm going to fall back to that. :( thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Wed, Oct 28, 2020 at 7:51 AM Robin Murphy wrote: > Hmm, perhaps I'm missing something here, but even if the config options > *do* line up, what prevents arm-smmu probing before qcom-scm and > dereferencing NULL in qcom_scm_qsmmu500_wait_safe_toggle() before __scm > is initialised? Oh man, this spun me on a "wait, but how does it all work!" trip. :) So in the non-module case, the qcom_scm driver is a subsys_initcall and the arm-smmu is a module_platform_driver, so the ordering works out. In the module case, the arm-smmu code isn't loaded until the qcom_scm driver finishes probing due to the symbol dependency handling. To double check this, I added a big msleep at the top of the qcom_scm_probe to try to open the race window you described, but the arm_smmu_device_probe() doesn't run until after qcom_scm_probe completes. So at least as a built in / built in, or a module/module case its ok. And in the case where arm-smmu is a module and qcom_scm is built in that's ok too. Its just the case my patch is trying to prevent is where arm-smmu is built in, but qcom_scm is a module that it can't work (due to build errors in missing symbols, or if we tried to use function pointers to plug in the qcom_scm - the lack of initialization ordering). Hopefully that addresses your concern? Let me know if I'm still missing something. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Mon, Jul 13, 2020 at 1:41 PM Will Deacon wrote: > On Fri, Jul 10, 2020 at 03:21:53PM -0700, John Stultz wrote: > > On Fri, Jul 10, 2020 at 12:54 AM Will Deacon wrote: > > > On Thu, Jul 09, 2020 at 08:28:45PM -0700, John Stultz wrote: > > > > On Thu, Jul 2, 2020 at 7:18 AM Will Deacon wrote: > > > > > On Thu, Jun 25, 2020 at 12:10:39AM +, John Stultz wrote: > > > > > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > > > > > > index b510f67dfa49..714893535dd2 100644 > > > > > > --- a/drivers/iommu/Kconfig > > > > > > +++ b/drivers/iommu/Kconfig > > > > > > @@ -381,6 +381,7 @@ config SPAPR_TCE_IOMMU > > > > > > config ARM_SMMU > > > > > > tristate "ARM Ltd. System MMU (SMMU) Support" > > > > > > depends on (ARM64 || ARM || (COMPILE_TEST && > > > > > > !GENERIC_ATOMIC64)) && MMU > > > > > > + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be > > > > > > =y > > > > > > select IOMMU_API > > > > > > select IOMMU_IO_PGTABLE_LPAE > > > > > > select ARM_DMA_USE_IOMMU if ARM > > > > > > > > > > This looks like a giant hack. Is there another way to handle this? > > > > > > > > Sorry for the slow response here. > > > > > > > > So, I agree the syntax looks strange (requiring a comment obviously > > > > isn't a good sign), but it's a fairly common way to ensure drivers > > > > don't get built in if they optionally depend on another driver that > > > > can be built as a module. > > > > See "RFKILL || !RFKILL", "EXTCON || !EXTCON", or "USB_GADGET || > > > > !USB_GADGET" in various Kconfig files. > > > > > > > > I'm open to using a different method, and in a different thread you > > > > suggested using something like symbol_get(). I need to look into it > > > > more, but that approach looks even more messy and prone to runtime > > > > failures. Blocking the unwanted case at build time seems a bit cleaner > > > > to me, even if the syntax is odd. > > > > > > Maybe just split it out then, so that the ARM_SMMU entry doesn't have > > > this, > > > as that driver _really_ doesn't care about SoC details like this. In other > > > words, add a new entry along the lines of: > > > > > > config ARM_SMMU_QCOM_IMPL > > > default y > > > #if QCOM_SCM=m this can't be =y > > > depends on ARM_SMMU & (QCOM_SCM || !QCOM_SCM) > > > > > > and then have arm-smmu.h provide a static inline qcom_smmu_impl_init() > > > which returns -ENODEV if CONFIG_ARM_SMMU_QCOM_IMPL=n and hack the Makefile > > > so that we don't bother to compile arm-smmu-qcom.o in that case. > > > > > > Would that work? > > > > I think this proposal still has problems with the directionality of the > > call. > > > > The arm-smmu-impl.o calls to arm-smmu-qcom.o which calls qcom_scm.o > > So if qcom_scm.o is part of a module, the calling code in > > arm-smmu-qcom.o also needs to be a module, which means CONFIG_ARM_SMMU > > needs to be a module. > > > > I know you said the arm-smmu driver doesn't care about SoC details, > > but the trouble is that currently the arm-smmu driver does directly > > call the qcom-scm code. So it is a real dependency. However, if > > QCOM_SCM is not configured, it calls stubs and that's ok. In that > > way, the "depends on QCOM_SCM || !QCOM_SCM" line actually makes sense. > > It looks terrible because we're used to boolean logic, but it's > > ternary. > > Yes, it looks ugly, but the part I really have issues with is that building > QCOM_SCM=m and ARM_SMMU=y is perfectly fine if you don't run on an SoC > with the qcom implementation. I don't see why we need to enforce things > here beyond making sure that all selectable permutations _build_ and > fail gracefully at runtime on the qcom SoC if SCM isn't available. Hey Will, Sorry to dredge up this old thread. I've been off busy with other things and didn't get around to trying to rework this until now. Unfortunately I'm still having some trouble coming up with a better solution. Initially I figured I'd rework the qcom_scm driver to, so that we have the various qcom_scm_* as inline functions, which call out to function pointers that the qcom_scm driver would register wh
[PATCH] irqchip/qcom-pdc: Allow QCOM_PDC to be loadable as a permanent module
Allows qcom-pdc driver to be loaded as a permanent module. An earlier version of this patch was merged in a larger patchset but was reverted entirely when issues were found with other drivers, so now that Marc has provided a better solution in his Hybrid probing patch set, I wanted to re-submit this change. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- drivers/irqchip/Kconfig| 2 +- drivers/irqchip/qcom-pdc.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index bfc9719dbcdc..bb70b7177f94 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -425,7 +425,7 @@ config GOLDFISH_PIC for Goldfish based virtual platforms. config QCOM_PDC - bool "QCOM PDC" + tristate "QCOM PDC" depends on ARCH_QCOM select IRQ_DOMAIN_HIERARCHY help diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c index 8543fa23da10..59eb3c8473b0 100644 --- a/drivers/irqchip/qcom-pdc.c +++ b/drivers/irqchip/qcom-pdc.c @@ -433,3 +433,5 @@ static int qcom_pdc_init(struct device_node *node, struct device_node *parent) IRQCHIP_HYBRID_DRIVER_BEGIN(qcom_pdc) IRQCHIP_MATCH("qcom,pdc", qcom_pdc_init) IRQCHIP_HYBRID_DRIVER_END(qcom_pdc) +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Power Domain Controller"); +MODULE_LICENSE("GPL v2"); -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 0/8] iommu/arm-smmu: Support maintaining bootloader mappings
On Fri, Sep 4, 2020 at 8:56 AM Bjorn Andersson wrote: > > Based on previous attempts and discussions this is the latest attempt at > inheriting stream mappings set up by the bootloader, for e.g. boot splash or > efifb. > > Per Will's request this builds on the work by Jordan and Rob for the Adreno > SMMU support. It applies cleanly ontop of v16 of their series, which can be > found at > https://lore.kernel.org/linux-arm-msm/20200901164707.2645413-1-robdcl...@gmail.com/ > Apologies, I just found this today. I've pulled your patches and Rob's into my own tree here: https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/db845c-mainline-WIP And they all work fine on the db845c. So for your whole series: Tested-by: John Stultz thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 00/16] IOMMU driver for Kirin 960/970
On Tue, Aug 18, 2020 at 9:26 AM Robin Murphy wrote: > On 2020-08-18 16:29, Mauro Carvalho Chehab wrote: > > Em Tue, 18 Aug 2020 15:47:55 +0100 > > Basically, the DT binding has this, for IOMMU: > > > > > > smmu_lpae { > > compatible = "hisilicon,smmu-lpae"; > > }; > > > > ... > > dpe: dpe@e860 { > > compatible = "hisilicon,kirin970-dpe"; > > memory-region = <_dma_reserved>; > > ... > > iommu_info { > > start-addr = <0x8000>; > > size = <0xbfff8000>; > > }; > > } > > > > This is used by kirin9xx_drm_dss.c in order to enable and use > > the iommu: > > > > > > static int dss_enable_iommu(struct platform_device *pdev, struct > > dss_hw_ctx *ctx) > > { > > struct device *dev = NULL; > > > > dev = >dev; > > > > /* create iommu domain */ > > ctx->mmu_domain = iommu_domain_alloc(dev->bus); > > if (!ctx->mmu_domain) { > > pr_err("iommu_domain_alloc failed!\n"); > > return -EINVAL; > > } > > > > iommu_attach_device(ctx->mmu_domain, dev); > > > > return 0; > > } > > > > The only place where the IOMMU domain is used is on this part of the > > code(error part simplified here) [1]: > > > > void hisi_dss_smmu_on(struct dss_hw_ctx *ctx) > > { > > uint64_t fama_phy_pgd_base; > > uint32_t phy_pgd_base; > > ... > > fama_phy_pgd_base = iommu_iova_to_phys(ctx->mmu_domain, 0); > > phy_pgd_base = (uint32_t)fama_phy_pgd_base; > > if (WARN_ON(!phy_pgd_base)) > > return; > > > > set_reg(smmu_base + SMMU_CB_TTBR0, phy_pgd_base, 32, 0); > > } > > > > [1] > > https://github.com/mchehab/linux/commit/36da105e719b47bbe9d6cb7e5619b30c7f3eb1bd > > > > In other words, the driver needs to get the physical address of the frame > > buffer (mapped via iommu) in order to set some DRM-specific register. > > > > Yeah, the above code is somewhat hackish. I would love to replace > > this part by a more standard approach. > > OK, so from a quick look at that, my impression is that your display > controller has its own MMU and you don't need to pretend to use the > IOMMU API at all. Just have the DRM driver use io-pgtable directly to > run its own set of ARM_32_LPAE_S1 pagetables - see Panfrost for an > example (but try to ignore the wacky "Mali LPAE" format). Yea. For the HiKey960, there was originally a similar patch series but it was refactored out and the (still out of tree) DRM driver I'm carrying doesn't seem to need it (though looking we still have the iommu_info subnode in the dts that maybe needs to be cleaned up). thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Mon, Jul 13, 2020 at 1:41 PM Will Deacon wrote: > > On Fri, Jul 10, 2020 at 03:21:53PM -0700, John Stultz wrote: > > On Fri, Jul 10, 2020 at 12:54 AM Will Deacon wrote: > > > On Thu, Jul 09, 2020 at 08:28:45PM -0700, John Stultz wrote: > > > > On Thu, Jul 2, 2020 at 7:18 AM Will Deacon wrote: > > > > > On Thu, Jun 25, 2020 at 12:10:39AM +, John Stultz wrote: > > > > > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > > > > > > index b510f67dfa49..714893535dd2 100644 > > > > > > --- a/drivers/iommu/Kconfig > > > > > > +++ b/drivers/iommu/Kconfig > > > > > > @@ -381,6 +381,7 @@ config SPAPR_TCE_IOMMU > > > > > > config ARM_SMMU > > > > > > tristate "ARM Ltd. System MMU (SMMU) Support" > > > > > > depends on (ARM64 || ARM || (COMPILE_TEST && > > > > > > !GENERIC_ATOMIC64)) && MMU > > > > > > + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be > > > > > > =y > > > > > > select IOMMU_API > > > > > > select IOMMU_IO_PGTABLE_LPAE > > > > > > select ARM_DMA_USE_IOMMU if ARM > > > > > > > > > > This looks like a giant hack. Is there another way to handle this? > > > > > > > > Sorry for the slow response here. > > > > > > > > So, I agree the syntax looks strange (requiring a comment obviously > > > > isn't a good sign), but it's a fairly common way to ensure drivers > > > > don't get built in if they optionally depend on another driver that > > > > can be built as a module. > > > > See "RFKILL || !RFKILL", "EXTCON || !EXTCON", or "USB_GADGET || > > > > !USB_GADGET" in various Kconfig files. > > > > > > > > I'm open to using a different method, and in a different thread you > > > > suggested using something like symbol_get(). I need to look into it > > > > more, but that approach looks even more messy and prone to runtime > > > > failures. Blocking the unwanted case at build time seems a bit cleaner > > > > to me, even if the syntax is odd. > > > > > > Maybe just split it out then, so that the ARM_SMMU entry doesn't have > > > this, > > > as that driver _really_ doesn't care about SoC details like this. In other > > > words, add a new entry along the lines of: > > > > > > config ARM_SMMU_QCOM_IMPL > > > default y > > > #if QCOM_SCM=m this can't be =y > > > depends on ARM_SMMU & (QCOM_SCM || !QCOM_SCM) > > > > > > and then have arm-smmu.h provide a static inline qcom_smmu_impl_init() > > > which returns -ENODEV if CONFIG_ARM_SMMU_QCOM_IMPL=n and hack the Makefile > > > so that we don't bother to compile arm-smmu-qcom.o in that case. > > > > > > Would that work? > > > > I think this proposal still has problems with the directionality of the > > call. > > > > The arm-smmu-impl.o calls to arm-smmu-qcom.o which calls qcom_scm.o > > So if qcom_scm.o is part of a module, the calling code in > > arm-smmu-qcom.o also needs to be a module, which means CONFIG_ARM_SMMU > > needs to be a module. > > > > I know you said the arm-smmu driver doesn't care about SoC details, > > but the trouble is that currently the arm-smmu driver does directly > > call the qcom-scm code. So it is a real dependency. However, if > > QCOM_SCM is not configured, it calls stubs and that's ok. In that > > way, the "depends on QCOM_SCM || !QCOM_SCM" line actually makes sense. > > It looks terrible because we're used to boolean logic, but it's > > ternary. > > Yes, it looks ugly, but the part I really have issues with is that building > QCOM_SCM=m and ARM_SMMU=y is perfectly fine if you don't run on an SoC > with the qcom implementation. I don't see why we need to enforce things > here beyond making sure that all selectable permutations _build_ and > fail gracefully at runtime on the qcom SoC if SCM isn't available. Ok. Thanks, that context/rationale makes sense to me now! I'll dig in and see if I can figure out the runtime get_symbol handling you suggested for the scm callout. Thanks again for the feedback! -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v3 3/3] irqchip: Allow QCOM_PDC to be loadable as a permanent module
Allows qcom-pdc driver to be loaded as a permanent module Also, due to the fact that IRQCHIP_DECLARE becomes a no-op when building as a module, we have to replace it with platform driver hooks explicitly. Thanks to Saravana for his help on pointing out the IRQCHIP_DECLARE issue and guidance on a solution. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- v2: Fix spelling, include order and set suppress_bind_attrs suggested by Maulik Shah v3: Drop conditional usage of IRQCHIP_DECLARE as suggested by Stephen Boyd and Marc Zyngier --- drivers/irqchip/Kconfig| 2 +- drivers/irqchip/qcom-pdc.c | 28 +++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 216b3b8392b5..cc285c1a54c1 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -425,7 +425,7 @@ config GOLDFISH_PIC for Goldfish based virtual platforms. config QCOM_PDC - bool "QCOM PDC" + tristate "QCOM PDC" depends on ARCH_QCOM select IRQ_DOMAIN_HIERARCHY help diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c index 6ae9e1f0819d..5b624e3295e4 100644 --- a/drivers/irqchip/qcom-pdc.c +++ b/drivers/irqchip/qcom-pdc.c @@ -11,9 +11,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -430,4 +432,28 @@ static int qcom_pdc_init(struct device_node *node, struct device_node *parent) return ret; } -IRQCHIP_DECLARE(qcom_pdc, "qcom,pdc", qcom_pdc_init); +static int qcom_pdc_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device_node *parent = of_irq_find_parent(np); + + return qcom_pdc_init(np, parent); +} + +static const struct of_device_id qcom_pdc_match_table[] = { + { .compatible = "qcom,pdc" }, + {} +}; +MODULE_DEVICE_TABLE(of, qcom_pdc_match_table); + +static struct platform_driver qcom_pdc_driver = { + .probe = qcom_pdc_probe, + .driver = { + .name = "qcom-pdc", + .of_match_table = qcom_pdc_match_table, + .suppress_bind_attrs = true, + }, +}; +module_platform_driver(qcom_pdc_driver); +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Power Domain Controller"); +MODULE_LICENSE("GPL v2"); -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v3 1/3] irq: irqdomain: Export irq_domain_update_bus_token
Add export for irq_domain_update_bus_token() so that we can allow drivers like the qcom-pdc driver to be loadable as a module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- kernel/irq/irqdomain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index a4c2c915511d..ca974d965fda 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -281,6 +281,7 @@ void irq_domain_update_bus_token(struct irq_domain *domain, mutex_unlock(_domain_mutex); } +EXPORT_SYMBOL_GPL(irq_domain_update_bus_token); /** * irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v3 2/3] irq: irqchip: Export irq_chip_retrigger_hierarchy and irq_chip_set_vcpu_affinity_parent
Add EXPORT_SYMBOL_GPL entries for irq_chip_retrigger_hierarchy() and irq_chip_set_vcpu_affinity_parent() so that we can allow drivers like the qcom-pdc driver to be loadable as a module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- kernel/irq/chip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 41e7e37a0928..ba6ce66d7ed6 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1478,6 +1478,7 @@ int irq_chip_retrigger_hierarchy(struct irq_data *data) return 0; } +EXPORT_SYMBOL_GPL(irq_chip_retrigger_hierarchy); /** * irq_chip_set_vcpu_affinity_parent - Set vcpu affinity on the parent interrupt @@ -1492,7 +1493,7 @@ int irq_chip_set_vcpu_affinity_parent(struct irq_data *data, void *vcpu_info) return -ENOSYS; } - +EXPORT_SYMBOL_GPL(irq_chip_set_vcpu_affinity_parent); /** * irq_chip_set_wake_parent - Set/reset wake-up on the parent interrupt * @data: Pointer to interrupt specific data -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v3 0/3] Allow for qcom-pdc to be loadable as a module
This patch series provides exports and config tweaks to allow the qcom-pdc driver to be able to be configured as a permement modules (particularlly useful for the Android Generic Kernel Image efforts). This was part of a larger patch series, to enable qcom_scm driver to be a module as well, but I've split it out as there are some outstanding objections I still need to address with the follow-on patches, and wanted to see if progress could be made on this subset of the series in the meantime. New in v3: * Drop conditional usage of IRQCHIP_DECLARE as suggested by Stephen Boyd and Marc Zyngier thanks -john Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Lina Iyer Cc: Maulik Shah Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org John Stultz (3): irq: irqdomain: Export irq_domain_update_bus_token irq: irqchip: Export irq_chip_retrigger_hierarchy and irq_chip_set_vcpu_affinity_parent irqchip: Allow QCOM_PDC to be loadable as a permanent module drivers/irqchip/Kconfig| 2 +- drivers/irqchip/qcom-pdc.c | 28 +++- kernel/irq/chip.c | 3 ++- kernel/irq/irqdomain.c | 1 + 4 files changed, 31 insertions(+), 3 deletions(-) -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 3/5] irqchip: Allow QCOM_PDC to be loadable as a permanent module
On Thu, Jul 9, 2020 at 11:02 PM Stephen Boyd wrote: > Quoting Marc Zyngier (2020-06-27 02:37:47) > > On Sat, 27 Jun 2020 02:34:25 +0100, > > John Stultz wrote: > > > > > > On Fri, Jun 26, 2020 at 12:42 AM Stephen Boyd wrote: > > > > > > > > > > > > Is there any reason to use IRQCHIP_DECLARE if this can work as a > > > > platform device driver? > > > > > > > > > > Hey! Thanks so much for the review! > > > > > > Mostly it was done this way to minimize the change in the non-module > > > case. But if you'd rather avoid the #ifdefery I'll respin it without. > > > > That would certainly be my own preference. In general, IRQCHIP_DECLARE > > and platform drivers should be mutually exclusive in the same driver: > > if you can delay the probing and have it as a proper platform device, > > then this should be the one true way. > > > > Does it work? I haven't looked in detail but I worry that the child > irqdomain (i.e. pinctrl-msm) would need to delay probing until this > parent irqdomain is registered. Or has the hierarchical irqdomain code > been updated to handle the parent child relationship and wait for things > to probe or be loaded? So I can't say I know the underlying hardware particularly well, but I've been using this successfully on the Dragonboard 845c with both static builds as well as module enabled builds. And the same patch has been in the android-mainline and android-5.4 kernels for a while without objections from QCOM. As to the probe ordering question, Saravana can maybe speak in more detail if it's involved in this case but the fw_devlink code has addressed many of these sorts of ordering issues. However, I'm not sure if I'm lucking into the right probe order, as we have been able to boot android-mainline w/ both fw_devlink=on and fw_devlink=off (though in the =off case, we need deferred_probe_timeout=30 to give us a bit more time for modules to load after init starts). thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Fri, Jul 10, 2020 at 12:54 AM Will Deacon wrote: > On Thu, Jul 09, 2020 at 08:28:45PM -0700, John Stultz wrote: > > On Thu, Jul 2, 2020 at 7:18 AM Will Deacon wrote: > > > On Thu, Jun 25, 2020 at 12:10:39AM +, John Stultz wrote: > > > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > > > > index b510f67dfa49..714893535dd2 100644 > > > > --- a/drivers/iommu/Kconfig > > > > +++ b/drivers/iommu/Kconfig > > > > @@ -381,6 +381,7 @@ config SPAPR_TCE_IOMMU > > > > config ARM_SMMU > > > > tristate "ARM Ltd. System MMU (SMMU) Support" > > > > depends on (ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64)) > > > > && MMU > > > > + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y > > > > select IOMMU_API > > > > select IOMMU_IO_PGTABLE_LPAE > > > > select ARM_DMA_USE_IOMMU if ARM > > > > > > This looks like a giant hack. Is there another way to handle this? > > > > Sorry for the slow response here. > > > > So, I agree the syntax looks strange (requiring a comment obviously > > isn't a good sign), but it's a fairly common way to ensure drivers > > don't get built in if they optionally depend on another driver that > > can be built as a module. > > See "RFKILL || !RFKILL", "EXTCON || !EXTCON", or "USB_GADGET || > > !USB_GADGET" in various Kconfig files. > > > > I'm open to using a different method, and in a different thread you > > suggested using something like symbol_get(). I need to look into it > > more, but that approach looks even more messy and prone to runtime > > failures. Blocking the unwanted case at build time seems a bit cleaner > > to me, even if the syntax is odd. > > Maybe just split it out then, so that the ARM_SMMU entry doesn't have this, > as that driver _really_ doesn't care about SoC details like this. In other > words, add a new entry along the lines of: > > config ARM_SMMU_QCOM_IMPL > default y > #if QCOM_SCM=m this can't be =y > depends on ARM_SMMU & (QCOM_SCM || !QCOM_SCM) > > and then have arm-smmu.h provide a static inline qcom_smmu_impl_init() > which returns -ENODEV if CONFIG_ARM_SMMU_QCOM_IMPL=n and hack the Makefile > so that we don't bother to compile arm-smmu-qcom.o in that case. > > Would that work? I think this proposal still has problems with the directionality of the call. The arm-smmu-impl.o calls to arm-smmu-qcom.o which calls qcom_scm.o So if qcom_scm.o is part of a module, the calling code in arm-smmu-qcom.o also needs to be a module, which means CONFIG_ARM_SMMU needs to be a module. I know you said the arm-smmu driver doesn't care about SoC details, but the trouble is that currently the arm-smmu driver does directly call the qcom-scm code. So it is a real dependency. However, if QCOM_SCM is not configured, it calls stubs and that's ok. In that way, the "depends on QCOM_SCM || !QCOM_SCM" line actually makes sense. It looks terrible because we're used to boolean logic, but it's ternary. Maybe can have the ARM_SMMU_QCOM_IMPL approach you suggest above, but that just holds the issue out at arms length, because we're still going to need to have: depends on ARM_SMMU_QCOM_IMPL || !ARM_SMMU_QCOM_IMPL in the ARM_SMMU definition, which I suspect you're wanting to avoid. Otherwise the only thing I can think of is a deeper reworking of the arm-smmu-impl code so that the arm-smmu-qcom code probes itself and registers its hooks with the arm-smmu core. That way the arm-smmu driver would not directly call any SoC specific code (and thus have no dependencies outward). But it's probably a fair amount of churn vs the extra depends string. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 0/5] iommu/arm-smmu: Support maintaining bootloader mappings
On Wed, Jul 8, 2020 at 10:02 PM Bjorn Andersson wrote: > > Based on previous attempts and discussions this is the latest attempt at > inheriting stream mappings set up by the bootloader, for e.g. boot splash or > efifb. > > The first patch is an implementation of Robin's suggestion that we should just > mark the relevant stream mappings as BYPASS. Relying on something else to set > up the stream mappings wanted - e.g. by reading it back in platform specific > implementation code. > > The series then tackles the problem seen in most versions of Qualcomm > firmware, > that the hypervisor intercepts BYPASS writes and turn them into FAULTs. It > does > this by allocating context banks for identity domains as well, with > translation > disabled. > > Lastly it amends the stream mapping initialization code to allocate a specific > identity domain that is used for any mappings inherited from the bootloader, > if > above Qualcomm quirk is required. > > > The series has been tested and shown to allow booting SDM845, SDM850, SM8150, > SM8250 with boot splash screen setup by the bootloader. Specifically it also > allows the Lenovo Yoga C630 to boot with SMMU and efifb enabled. This series allows the db845c to boot successfully! (Without it we crash!) It would be really great to have this upstream! For the series: Tested-by: John Stultz Thanks so much! -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
On Thu, Jul 2, 2020 at 7:18 AM Will Deacon wrote: > On Thu, Jun 25, 2020 at 12:10:39AM +0000, John Stultz wrote: > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > > index b510f67dfa49..714893535dd2 100644 > > --- a/drivers/iommu/Kconfig > > +++ b/drivers/iommu/Kconfig > > @@ -381,6 +381,7 @@ config SPAPR_TCE_IOMMU > > config ARM_SMMU > > tristate "ARM Ltd. System MMU (SMMU) Support" > > depends on (ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64)) && > > MMU > > + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y > > select IOMMU_API > > select IOMMU_IO_PGTABLE_LPAE > > select ARM_DMA_USE_IOMMU if ARM > > This looks like a giant hack. Is there another way to handle this? Sorry for the slow response here. So, I agree the syntax looks strange (requiring a comment obviously isn't a good sign), but it's a fairly common way to ensure drivers don't get built in if they optionally depend on another driver that can be built as a module. See "RFKILL || !RFKILL", "EXTCON || !EXTCON", or "USB_GADGET || !USB_GADGET" in various Kconfig files. I'm open to using a different method, and in a different thread you suggested using something like symbol_get(). I need to look into it more, but that approach looks even more messy and prone to runtime failures. Blocking the unwanted case at build time seems a bit cleaner to me, even if the syntax is odd. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 3/5] irqchip: Allow QCOM_PDC to be loadable as a permanent module
On Fri, Jun 26, 2020 at 12:42 AM Stephen Boyd wrote: > > Quoting John Stultz (2020-06-24 17:10:37) > > diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c > > index 6ae9e1f0819d..3fee8b655da1 100644 > > --- a/drivers/irqchip/qcom-pdc.c > > +++ b/drivers/irqchip/qcom-pdc.c > > @@ -430,4 +432,33 @@ static int qcom_pdc_init(struct device_node *node, > > struct device_node *parent) > > return ret; > > } > > > > +#ifdef MODULE > > +static int qcom_pdc_probe(struct platform_device *pdev) > > +{ > > + struct device_node *np = pdev->dev.of_node; > > + struct device_node *parent = of_irq_find_parent(np); > > + > > + return qcom_pdc_init(np, parent); > > +} > > + > > +static const struct of_device_id qcom_pdc_match_table[] = { > > + { .compatible = "qcom,pdc" }, > > + {} > > +}; > > +MODULE_DEVICE_TABLE(of, qcom_pdc_match_table); > > + > > +static struct platform_driver qcom_pdc_driver = { > > + .probe = qcom_pdc_probe, > > + .driver = { > > + .name = "qcom-pdc", > > + .of_match_table = qcom_pdc_match_table, > > + .suppress_bind_attrs = true, > > + }, > > +}; > > +module_platform_driver(qcom_pdc_driver); > > +#else > > IRQCHIP_DECLARE(qcom_pdc, "qcom,pdc", qcom_pdc_init); > > Is there any reason to use IRQCHIP_DECLARE if this can work as a > platform device driver? > Hey! Thanks so much for the review! Mostly it was done this way to minimize the change in the non-module case. But if you'd rather avoid the #ifdefery I'll respin it without. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v2 3/5] irqchip: Allow QCOM_PDC to be loadable as a permanent module
Allows qcom-pdc driver to be loaded as a permanent module Also, due to the fact that IRQCHIP_DECLARE becomes a no-op when building as a module, we have to add the platform driver hooks explicitly. Thanks to Saravana for his help on pointing out the IRQCHIP_DECLARE issue and guidance on a solution. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- v2: Fix spelling, include order and set suppress_bind_attrs suggested by Maulik Shah --- drivers/irqchip/Kconfig| 2 +- drivers/irqchip/qcom-pdc.c | 31 +++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 29fead208cad..12765bed08f9 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -425,7 +425,7 @@ config GOLDFISH_PIC for Goldfish based virtual platforms. config QCOM_PDC - bool "QCOM PDC" + tristate "QCOM PDC" depends on ARCH_QCOM select IRQ_DOMAIN_HIERARCHY help diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c index 6ae9e1f0819d..3fee8b655da1 100644 --- a/drivers/irqchip/qcom-pdc.c +++ b/drivers/irqchip/qcom-pdc.c @@ -11,9 +11,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -430,4 +432,33 @@ static int qcom_pdc_init(struct device_node *node, struct device_node *parent) return ret; } +#ifdef MODULE +static int qcom_pdc_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device_node *parent = of_irq_find_parent(np); + + return qcom_pdc_init(np, parent); +} + +static const struct of_device_id qcom_pdc_match_table[] = { + { .compatible = "qcom,pdc" }, + {} +}; +MODULE_DEVICE_TABLE(of, qcom_pdc_match_table); + +static struct platform_driver qcom_pdc_driver = { + .probe = qcom_pdc_probe, + .driver = { + .name = "qcom-pdc", + .of_match_table = qcom_pdc_match_table, + .suppress_bind_attrs = true, + }, +}; +module_platform_driver(qcom_pdc_driver); +#else IRQCHIP_DECLARE(qcom_pdc, "qcom,pdc", qcom_pdc_init); +#endif + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Power Domain Controller"); +MODULE_LICENSE("GPL v2"); -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v2 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
Allow the qcom_scm driver to be loadable as a permenent module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- drivers/firmware/Kconfig| 2 +- drivers/firmware/Makefile | 3 ++- drivers/firmware/qcom_scm.c | 4 drivers/iommu/Kconfig | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index fbd785dd0513..9e533a462bf4 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -236,7 +236,7 @@ config INTEL_STRATIX10_RSU Say Y here if you want Intel RSU support. config QCOM_SCM - bool + tristate "Qcom SCM driver" depends on ARM || ARM64 select RESET_CONTROLLER diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 99510be9f5ed..cf24d674216b 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -17,7 +17,8 @@ obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o -obj-$(CONFIG_QCOM_SCM) += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +obj-$(CONFIG_QCOM_SCM) += qcom-scm.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 0e7233a20f34..b5e88bf66975 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1155,6 +1155,7 @@ static const struct of_device_id qcom_scm_dt_match[] = { { .compatible = "qcom,scm" }, {} }; +MODULE_DEVICE_TABLE(of, qcom_scm_dt_match); static struct platform_driver qcom_scm_driver = { .driver = { @@ -1170,3 +1171,6 @@ static int __init qcom_scm_init(void) return platform_driver_register(_scm_driver); } subsys_initcall(qcom_scm_init); + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. SCM driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index b510f67dfa49..714893535dd2 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -381,6 +381,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on (ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64)) && MMU + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -500,6 +501,7 @@ config QCOM_IOMMU # Note: iommu drivers cannot (yet?) be built as modules bool "Qualcomm IOMMU Support" depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM=y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v2 1/5] irq: irqdomain: Export irq_domain_update_bus_token
Add export for irq_domain_update_bus_token() so that we can allow drivers like the qcom-pdc driver to be loadable as a module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- kernel/irq/irqdomain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index a4c2c915511d..ca974d965fda 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -281,6 +281,7 @@ void irq_domain_update_bus_token(struct irq_domain *domain, mutex_unlock(_domain_mutex); } +EXPORT_SYMBOL_GPL(irq_domain_update_bus_token); /** * irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v2 4/5] pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module
Tweaks to allow pinctrl-msm code to be loadable as a module. This is needed in order to support having the qcom-scm driver, which pinctrl-msm calls into, configured as a module. This requires that we tweak Kconfigs selecting PINCTRL_MSM to also depend on QCOM_SCM || QCOM_SCM=n so that we match the module setting of QCOM_SCM. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- v2: * Module description and whitespace fixes suggested by Bjorn * Added QCOM_SCM || QCOM_SCM=n bits on Kconfigs selecting PINCTRL_MSM. Reported by both Todd and Bjorn. --- drivers/pinctrl/qcom/Kconfig | 24 +++- drivers/pinctrl/qcom/pinctrl-msm.c | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig index ff1ee159dca2..11228ae3d826 100644 --- a/drivers/pinctrl/qcom/Kconfig +++ b/drivers/pinctrl/qcom/Kconfig @@ -2,7 +2,7 @@ if (ARCH_QCOM || COMPILE_TEST) config PINCTRL_MSM - bool + tristate select PINMUX select PINCONF select GENERIC_PINCONF @@ -11,6 +11,7 @@ config PINCTRL_MSM config PINCTRL_APQ8064 tristate "Qualcomm APQ8064 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the @@ -19,6 +20,7 @@ config PINCTRL_APQ8064 config PINCTRL_APQ8084 tristate "Qualcomm APQ8084 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the @@ -27,6 +29,7 @@ config PINCTRL_APQ8084 config PINCTRL_IPQ4019 tristate "Qualcomm IPQ4019 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the @@ -35,6 +38,7 @@ config PINCTRL_IPQ4019 config PINCTRL_IPQ8064 tristate "Qualcomm IPQ8064 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the @@ -43,6 +47,7 @@ config PINCTRL_IPQ8064 config PINCTRL_IPQ8074 tristate "Qualcomm Technologies, Inc. IPQ8074 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for @@ -53,6 +58,7 @@ config PINCTRL_IPQ8074 config PINCTRL_IPQ6018 tristate "Qualcomm Technologies, Inc. IPQ6018 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for @@ -63,6 +69,7 @@ config PINCTRL_IPQ6018 config PINCTRL_MSM8660 tristate "Qualcomm 8660 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the @@ -71,6 +78,7 @@ config PINCTRL_MSM8660 config PINCTRL_MSM8960 tristate "Qualcomm 8960 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the @@ -79,6 +87,7 @@ config PINCTRL_MSM8960 config PINCTRL_MDM9615 tristate "Qualcomm 9615 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the @@ -87,6 +96,7 @@ config PINCTRL_MDM9615 config PINCTRL_MSM8X74 tristate "Qualcomm 8x74 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the @@ -95,6 +105,7 @@ config PINCTRL_MSM8X74 config PINCTRL_MSM8916 tristate "Qualcomm 8916 pin controller driver" depends on GPIOLIB && OF + depends on QCOM_SCM || !QCOM_SCM select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib
[PATCH v2 2/5] irq: irqchip: Export irq_chip_retrigger_hierarchy and irq_chip_set_vcpu_affinity_parent
Add EXPORT_SYMBOL_GPL entries for irq_chip_retrigger_hierarchy() and irq_chip_set_vcpu_affinity_parent() so that we can allow drivers like the qcom-pdc driver to be loadable as a module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- kernel/irq/chip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 41e7e37a0928..ba6ce66d7ed6 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1478,6 +1478,7 @@ int irq_chip_retrigger_hierarchy(struct irq_data *data) return 0; } +EXPORT_SYMBOL_GPL(irq_chip_retrigger_hierarchy); /** * irq_chip_set_vcpu_affinity_parent - Set vcpu affinity on the parent interrupt @@ -1492,7 +1493,7 @@ int irq_chip_set_vcpu_affinity_parent(struct irq_data *data, void *vcpu_info) return -ENOSYS; } - +EXPORT_SYMBOL_GPL(irq_chip_set_vcpu_affinity_parent); /** * irq_chip_set_wake_parent - Set/reset wake-up on the parent interrupt * @data: Pointer to interrupt specific data -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v2 0/5] Allow for qcom-pdc, pinctrl-msm and qcom-scm drivers to be loadable as modules
This patch series provides exports and config tweaks to allow the qcom-pdc, pinctrl-msm and qcom-scm drivers to be able to be configured as permement modules (particularlly useful for the Android Generic Kernel Image efforts). Feedback would be appreciated! New in v2: * Fix up MSM_PINCTRL Kconfig dependency logic so we match QCOM_SCM. * Minor tweaks and corrections suggested by Bjorn and Maulik thanks -john Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Lina Iyer Cc: Maulik Shah Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org John Stultz (5): irq: irqdomain: Export irq_domain_update_bus_token irq: irqchip: Export irq_chip_retrigger_hierarchy and irq_chip_set_vcpu_affinity_parent irqchip: Allow QCOM_PDC to be loadable as a permanent module pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module drivers/firmware/Kconfig | 2 +- drivers/firmware/Makefile | 3 ++- drivers/firmware/qcom_scm.c| 4 drivers/iommu/Kconfig | 2 ++ drivers/irqchip/Kconfig| 2 +- drivers/irqchip/qcom-pdc.c | 31 ++ drivers/pinctrl/qcom/Kconfig | 24 ++- drivers/pinctrl/qcom/pinctrl-msm.c | 2 ++ kernel/irq/chip.c | 3 ++- kernel/irq/irqdomain.c | 1 + 10 files changed, 69 insertions(+), 5 deletions(-) -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [RFC][PATCH 4/5] pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module
On Sat, Jun 20, 2020 at 11:03 PM Bjorn Andersson wrote: > > On Mon 15 Jun 23:13 PDT 2020, John Stultz wrote: > > > Tweaks to allow pinctrl-msm code to be loadable as a module. > > This is needed in order to support having the qcom-scm driver, > > which pinctrl-msm calls into, configured as a module. > > > > This means that we need a "depends on QCOM_SCM || QCOM_SCM=n" on all > entries in the Kconfig that selects PINCTRL_MSM, or switch PINCTRL_MSM > to be user selectable and make all the others depend on it. Oh, good point! I already had to fix that in a different tree, but forgot to move the fix over to my upstreaming tree. > > > > +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. pinctrl-msm driver"); > > It's the "Qualcomm Technologies, Inc. TLMM driver" > > > +MODULE_LICENSE("GPL v2"); > > + > > Please don't retain my empty line at the end of this file :) Done and done. Thanks so much for the review! -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [RFC][PATCH 3/5] irqchip: Allow QCOM_PDC to be loadable as a perment module
On Tue, Jun 16, 2020 at 4:30 AM Maulik Shah wrote: > > Hi, > > On 6/16/2020 11:43 AM, John Stultz wrote: > > Allows qcom-pdc driver to be loaded as a permenent module > > typo: permanent > > > Also, due to the fact that IRQCHIP_DECLARE becomes a no-op when > > building as a module, we have to add the platform driver hooks > > explicitly. > > > > Thanks to Saravana for his help on pointing out the > > IRQCHIP_DECLARE issue and guidance on a solution. > > > > Cc: Andy Gross > > Cc: Bjorn Andersson > > Cc: Joerg Roedel > > Cc: Thomas Gleixner > > Cc: Jason Cooper > > Cc: Marc Zyngier > > Cc: Linus Walleij > > Cc: Lina Iyer > > Cc: Saravana Kannan > > Cc: Todd Kjos > > Cc: Greg Kroah-Hartman > > Cc: linux-arm-...@vger.kernel.org > > Cc: iommu@lists.linux-foundation.org > > Cc: linux-g...@vger.kernel.org > > Signed-off-by: John Stultz > > --- > > drivers/irqchip/Kconfig| 2 +- > > drivers/irqchip/qcom-pdc.c | 30 ++ > > 2 files changed, 31 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig > > index 29fead208cad..12765bed08f9 100644 > > --- a/drivers/irqchip/Kconfig > > +++ b/drivers/irqchip/Kconfig > > @@ -425,7 +425,7 @@ config GOLDFISH_PIC > >for Goldfish based virtual platforms. > > > > config QCOM_PDC > > - bool "QCOM PDC" > > + tristate "QCOM PDC" > > depends on ARCH_QCOM > > select IRQ_DOMAIN_HIERARCHY > > help > > diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c > > index 6ae9e1f0819d..98d74160afcd 100644 > > --- a/drivers/irqchip/qcom-pdc.c > > +++ b/drivers/irqchip/qcom-pdc.c > > @@ -11,7 +11,9 @@ > > #include > > #include > > #include > > +#include > > #include > > +#include > please move this include in order after of_device.h > > #include > > #include > > #include > > @@ -430,4 +432,32 @@ static int qcom_pdc_init(struct device_node *node, > > struct device_node *parent) > > return ret; > > } > > > > +#ifdef MODULE > > +static int qcom_pdc_probe(struct platform_device *pdev) > > +{ > > + struct device_node *np = pdev->dev.of_node; > > + struct device_node *parent = of_irq_find_parent(np); > > + > > + return qcom_pdc_init(np, parent); > > +} > > + > > +static const struct of_device_id qcom_pdc_match_table[] = { > > + { .compatible = "qcom,pdc" }, > > + {} > > +}; > > +MODULE_DEVICE_TABLE(of, qcom_pdc_match_table); > > + > > +static struct platform_driver qcom_pdc_driver = { > > + .probe = qcom_pdc_probe, > > + .driver = { > > + .name = "qcom-pdc", > > + .of_match_table = qcom_pdc_match_table, > > can you please set .suppress_bind_attrs = true, > > This is to prevent bind/unbind using sysfs. Once irqchip driver module > is loaded, it shouldn't get unbind at runtime. Thanks, I really appreciate the review! I've made these changes on my side and they'll be included in v2. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[RFC][PATCH 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module
Allow the qcom_scm driver to be loadable as a permenent module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- drivers/firmware/Kconfig| 2 +- drivers/firmware/Makefile | 3 ++- drivers/firmware/qcom_scm.c | 4 drivers/iommu/Kconfig | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index fbd785dd0513..9e533a462bf4 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -236,7 +236,7 @@ config INTEL_STRATIX10_RSU Say Y here if you want Intel RSU support. config QCOM_SCM - bool + tristate "Qcom SCM driver" depends on ARM || ARM64 select RESET_CONTROLLER diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 99510be9f5ed..cf24d674216b 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -17,7 +17,8 @@ obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o -obj-$(CONFIG_QCOM_SCM) += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o +obj-$(CONFIG_QCOM_SCM) += qcom-scm.o +qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 0e7233a20f34..b5e88bf66975 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1155,6 +1155,7 @@ static const struct of_device_id qcom_scm_dt_match[] = { { .compatible = "qcom,scm" }, {} }; +MODULE_DEVICE_TABLE(of, qcom_scm_dt_match); static struct platform_driver qcom_scm_driver = { .driver = { @@ -1170,3 +1171,6 @@ static int __init qcom_scm_init(void) return platform_driver_register(_scm_driver); } subsys_initcall(qcom_scm_init); + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. SCM driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index b510f67dfa49..714893535dd2 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -381,6 +381,7 @@ config SPAPR_TCE_IOMMU config ARM_SMMU tristate "ARM Ltd. System MMU (SMMU) Support" depends on (ARM64 || ARM || (COMPILE_TEST && !GENERIC_ATOMIC64)) && MMU + depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU if ARM @@ -500,6 +501,7 @@ config QCOM_IOMMU # Note: iommu drivers cannot (yet?) be built as modules bool "Qualcomm IOMMU Support" depends on ARCH_QCOM || (COMPILE_TEST && !GENERIC_ATOMIC64) + depends on QCOM_SCM=y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE select ARM_DMA_USE_IOMMU -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[RFC][PATCH 2/5] irq: irqchip: Export irq_chip_retrigger_hierarchy and irq_chip_set_vcpu_affinity_parent
Add EXPORT_SYMBOL_GPL entries for irq_chip_retrigger_hierarchy() and irq_chip_set_vcpu_affinity_parent() so that we can allow drivers like the qcom-pdc driver to be loadable as a module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- kernel/irq/chip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 41e7e37a0928..ba6ce66d7ed6 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1478,6 +1478,7 @@ int irq_chip_retrigger_hierarchy(struct irq_data *data) return 0; } +EXPORT_SYMBOL_GPL(irq_chip_retrigger_hierarchy); /** * irq_chip_set_vcpu_affinity_parent - Set vcpu affinity on the parent interrupt @@ -1492,7 +1493,7 @@ int irq_chip_set_vcpu_affinity_parent(struct irq_data *data, void *vcpu_info) return -ENOSYS; } - +EXPORT_SYMBOL_GPL(irq_chip_set_vcpu_affinity_parent); /** * irq_chip_set_wake_parent - Set/reset wake-up on the parent interrupt * @data: Pointer to interrupt specific data -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[RFC][PATCH 0/5] Allow for qcom-pdc, pinctrl-msm and qcom-scm drivers to be loadable as modules
This patch series provides exports and config tweaks to allow the qcom-pdc, pinctrl-msm and qcom-scm drivers to be able to be configured as permement modules (particularlly useful for the Android Generic Kernel Image efforts). Feedback would be appreciated! thanks -john Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org John Stultz (5): irq: irqdomain: Export irq_domain_update_bus_token irq: irqchip: Export irq_chip_retrigger_hierarchy and irq_chip_set_vcpu_affinity_parent irqchip: Allow QCOM_PDC to be loadable as a perment module pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module drivers/firmware/Kconfig | 2 +- drivers/firmware/Makefile | 3 ++- drivers/firmware/qcom_scm.c| 4 drivers/iommu/Kconfig | 2 ++ drivers/irqchip/Kconfig| 2 +- drivers/irqchip/qcom-pdc.c | 30 ++ drivers/pinctrl/qcom/Kconfig | 2 +- drivers/pinctrl/qcom/pinctrl-msm.c | 3 +++ kernel/irq/chip.c | 3 ++- kernel/irq/irqdomain.c | 1 + 10 files changed, 47 insertions(+), 5 deletions(-) -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[RFC][PATCH 1/5] irq: irqdomain: Export irq_domain_update_bus_token
Add export for irq_domain_update_bus_token() so that we can allow drivers like the qcom-pdc driver to be loadable as a module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- kernel/irq/irqdomain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index a4c2c915511d..ca974d965fda 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -281,6 +281,7 @@ void irq_domain_update_bus_token(struct irq_domain *domain, mutex_unlock(_domain_mutex); } +EXPORT_SYMBOL_GPL(irq_domain_update_bus_token); /** * irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[RFC][PATCH 4/5] pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module
Tweaks to allow pinctrl-msm code to be loadable as a module. This is needed in order to support having the qcom-scm driver, which pinctrl-msm calls into, configured as a module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- drivers/pinctrl/qcom/Kconfig | 2 +- drivers/pinctrl/qcom/pinctrl-msm.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/qcom/Kconfig b/drivers/pinctrl/qcom/Kconfig index ff1ee159dca2..5a7e1bc621e6 100644 --- a/drivers/pinctrl/qcom/Kconfig +++ b/drivers/pinctrl/qcom/Kconfig @@ -2,7 +2,7 @@ if (ARCH_QCOM || COMPILE_TEST) config PINCTRL_MSM - bool + tristate select PINMUX select PINCONF select GENERIC_PINCONF diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index 83b7d64bc4c1..54a226f682e9 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -1355,3 +1355,6 @@ int msm_pinctrl_remove(struct platform_device *pdev) } EXPORT_SYMBOL(msm_pinctrl_remove); +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. pinctrl-msm driver"); +MODULE_LICENSE("GPL v2"); + -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[RFC][PATCH 3/5] irqchip: Allow QCOM_PDC to be loadable as a perment module
Allows qcom-pdc driver to be loaded as a permenent module Also, due to the fact that IRQCHIP_DECLARE becomes a no-op when building as a module, we have to add the platform driver hooks explicitly. Thanks to Saravana for his help on pointing out the IRQCHIP_DECLARE issue and guidance on a solution. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc: linux-arm-...@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-g...@vger.kernel.org Signed-off-by: John Stultz --- drivers/irqchip/Kconfig| 2 +- drivers/irqchip/qcom-pdc.c | 30 ++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 29fead208cad..12765bed08f9 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -425,7 +425,7 @@ config GOLDFISH_PIC for Goldfish based virtual platforms. config QCOM_PDC - bool "QCOM PDC" + tristate "QCOM PDC" depends on ARCH_QCOM select IRQ_DOMAIN_HIERARCHY help diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c index 6ae9e1f0819d..98d74160afcd 100644 --- a/drivers/irqchip/qcom-pdc.c +++ b/drivers/irqchip/qcom-pdc.c @@ -11,7 +11,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -430,4 +432,32 @@ static int qcom_pdc_init(struct device_node *node, struct device_node *parent) return ret; } +#ifdef MODULE +static int qcom_pdc_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device_node *parent = of_irq_find_parent(np); + + return qcom_pdc_init(np, parent); +} + +static const struct of_device_id qcom_pdc_match_table[] = { + { .compatible = "qcom,pdc" }, + {} +}; +MODULE_DEVICE_TABLE(of, qcom_pdc_match_table); + +static struct platform_driver qcom_pdc_driver = { + .probe = qcom_pdc_probe, + .driver = { + .name = "qcom-pdc", + .of_match_table = qcom_pdc_match_table, + }, +}; +module_platform_driver(qcom_pdc_driver); +#else IRQCHIP_DECLARE(qcom_pdc, "qcom,pdc", qcom_pdc_init); +#endif + +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Power Domain Controller"); +MODULE_LICENSE("GPL v2"); -- 2.17.1 ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [RFC 0/2] iommu: arm-smmu: Add support for early direct mappings
On Thu, May 14, 2020 at 12:34 PM wrote: > > On Thu 27 Feb 18:57 PST 2020, Bjorn Andersson wrote: > > Rob, Will, we're reaching the point where upstream has enough > functionality that this is becoming a critical issue for us. > > E.g. Lenovo Yoga C630 is lacking this and a single dts patch to boot > mainline with display, GPU, WiFi and audio working and the story is > similar on several devboards. > > As previously described, the only thing I want is the stream mapping > related to the display controller in place, either with the CB with > translation disabled or possibly with a way to specify the framebuffer > region (although this turns out to mess things up in the display > driver...) > > I did pick this up again recently and concluded that by omitting the > streams for the USB controllers causes an instability issue seen on one > of the controller to disappear. So I would prefer if we somehow could > have a mechanism to only pick the display streams and the context > allocation for this. > > > Can you please share some pointers/insights/wishes for how we can > conclude on this subject? Ping? I just wanted to follow up on this discussion as this small series is crucial for booting mainline on the Dragonboard 845c devboard. It would be really valuable to be able to get some solution upstream so we can test mainline w/o adding additional patches. The rest of the db845c series has been moving forward smoothly, but this set seems to be very stuck with no visible progress since Dec. Are there any pointers for what folks would prefer to see? thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: How to fix WARN from drivers/base/dd.c in next-20200401 if CONFIG_MODULES=y?
On Fri, Apr 3, 2020 at 4:47 AM Geert Uytterhoeven wrote: > On Thu, Apr 2, 2020 at 7:27 PM John Stultz wrote: > > On Thu, Apr 2, 2020 at 3:17 AM Yoshihiro Shimoda > > wrote: > > > > > > I found an issue after applied the following patches: > > > --- > > > 64c775f driver core: Rename deferred_probe_timeout and make it global > > > 0e9f8d0 driver core: Remove driver_deferred_probe_check_state_continue() > > > bec6c0e pinctrl: Remove use of > > > driver_deferred_probe_check_state_continue() > > > e2cec7d driver core: Set deferred_probe_timeout to a longer default if > > > CONFIG_MODULES is set > > Note that just setting deferred_probe_timeout = -1 like for the > CONFIG_MODULES=n case doesn't help. Yea. I can see why in that case, as we're checking !IS_ENABLED(CONFIG_MODULES) directly in driver_deferred_probe_check_state. I guess we could switch that to checking (driver_deferred_probe_timeout == -1) which would have the same logic and at least make it consistent if someone specifies -1 on the command line (since now it will effectively have it EPROBE_DEFER forever in that case). But also having a timeout=infinity could be useful if folks don't want the deferring to time out. Maybe in the !modules case setting it to =0 would be the most clear. But that's sort of a further cleanup. I'm still more worried about the NFS failure below. > > Hey, > > Terribly sorry for the trouble. So as Robin mentioned I have a patch > > to remove the WARN messages, but I'm a bit more concerned about why > > after the 30 second delay, the ethernet driver loads: > > [ 36.218666] ravb e680.ethernet eth0: Base address at > > 0xe680, 2e:09:0a:02:eb:2d, IRQ 117. > > but NFS fails. > > > > Is it just that the 30 second delay is too long and NFS gives up? > > I added some debug code to mount_nfs_root(), which shows that the first > 3 tries happen before ravb is instantiated, and the last 3 tries happen > after. So NFS root should work, if the network works. > > However, it seems the Ethernet PHY is never initialized, hence the link > never becomes ready. Dmesg before/after: > > ravb e680.ethernet eth0: Base address at 0xe680, > 2e:09:0a:02:ea:ff, IRQ 108. > > Good. > > ... > -gpio_rcar e6052000.gpio: sense irq = 11, type = 8 > > This is the GPIO the PHY IRQ is connected to. > Note that that GPIO controller has been instantiated before. > > ... > -Micrel KSZ9031 Gigabit PHY e680.ethernet-:00: > attached PHY driver [Micrel KSZ9031 Gigabit PHY] > (mii_bus:phy_addr=e680.ethernet-:00, irq=197) > ... > -ravb e680.ethernet eth0: Link is Up - 1Gbps/Full - flow control off > > Oops. > > -Sending DHCP requests .., OK > -IP-Config: Got DHCP answer from ... > ... > +VFS: Unable to mount root fs via NFS, trying floppy. > +VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6 > > > Does booting with deferred_probe_timeout=0 work? > > It does, as now everything using optional links (DMA and IOMMU) is now > instantiated on first try. Thanks so much for helping clarify this! So it's at least good to hear that booting with deferred_probe_timeout=0 is working! But I'm bummed the NFS (or as you pointed out in your later mail, ip_auto_config) falls over because the network isn't immediately there. Looking a little closer at the ip_auto_config() code, I think the issue may be that wait_for_device_probe() is effectively returning too early, since the probe_defer_timeout is still active? I need to dig a bit more on that code, on Monday, as I don't fully understand it yet. If I can't find a way to address that, I think the best course will be to set the driver_deferred_probe_timeout value to default to 0 regardless of the value of CONFIG_MODULES, so we don't cause any apparent regression from previous behavior. That will also sort out the less intuitive = -1 initialization in the non-modules case. In any case, I'll try to have a patch to send out on Monday. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: How to fix WARN from drivers/base/dd.c in next-20200401 if CONFIG_MODULES=y?
On Thu, Apr 2, 2020 at 3:17 AM Yoshihiro Shimoda wrote: > > I found an issue after applied the following patches: > --- > 64c775f driver core: Rename deferred_probe_timeout and make it global > 0e9f8d0 driver core: Remove driver_deferred_probe_check_state_continue() > bec6c0e pinctrl: Remove use of driver_deferred_probe_check_state_continue() > e2cec7d driver core: Set deferred_probe_timeout to a longer default if > CONFIG_MODULES is set > c8c43ce driver core: Fix driver_deferred_probe_check_state() logic > --- > > Before these patches, on my environment [1], some device drivers > which has iommus property output the following message when probing: > > [3.05] ravb e680.ethernet: ignoring dependency for device, > assuming no driver > [3.257174] ravb e680.ethernet eth0: Base address at 0xe680, > 2e:09:0a:02:eb:2d, IRQ 117. > > So, since ravb driver is probed within 4 seconds, we can use NFS rootfs > correctly. > > However, after these patches are applied, since the patches are always > waiting for 30 seconds > for of_iommu_configure() when IOMMU hardware is disabled, drivers/base/dd.c > output WARN. > Also, since ravb cannot be probed for 30 seconds, we cannot use NFS rootfs > anymore. > JFYI, I copied the kernel log to the end of this email. Hey, Terribly sorry for the trouble. So as Robin mentioned I have a patch to remove the WARN messages, but I'm a bit more concerned about why after the 30 second delay, the ethernet driver loads: [ 36.218666] ravb e680.ethernet eth0: Base address at 0xe680, 2e:09:0a:02:eb:2d, IRQ 117. but NFS fails. Is it just that the 30 second delay is too long and NFS gives up? Does booting with deferred_probe_timeout=0 work? thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 0/2] SWIOTLB fixes for 4.20
On Tue, Nov 20, 2018 at 6:10 AM Robin Murphy wrote: > > This is what I have so far, which at least resolves the most ovbious > problems. I still haven't got very far with the USB corruption issue > I see on Juno with -rc1, but I'm yet to confirm whether that's actually > attributable to the SWIOTLB changes or something else entirely. > > Robin. > > Robin Murphy (2): > swiotlb: Make DIRECT_MAPPING_ERROR viable > swiotlb: Skip cache maintenance on map error > > include/linux/dma-direct.h | 2 +- > kernel/dma/swiotlb.c | 3 ++- > 2 files changed, 3 insertions(+), 2 deletions(-) Thanks so much for chasing this down! Unfortunately AOSP is giving me grief this week, so I've not been able to test the full environment, but I don't seem to be hitting the io hangs I was seeing earlier with this patch set. For both: Tested-by: John Stultz thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 06/10] swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs
On Wed, Nov 14, 2018 at 8:12 AM Christoph Hellwig wrote: > > On Wed, Nov 14, 2018 at 03:13:11PM +0100, Christoph Hellwig wrote: > > Does the patch below make a difference for you? Assigning an > > address to the S/G list is the only functional difference I could > > spot. Drivers really should never look at the S/G list on an > > error return, but.. > > And that was obviously just the second half of the patch, so here > is the full one: > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > index 5731daa09a32..a896f46d0c31 100644 > --- a/kernel/dma/swiotlb.c > +++ b/kernel/dma/swiotlb.c > @@ -786,10 +786,13 @@ swiotlb_map_sg_attrs(struct device *dev, struct > scatterlist *sgl, int nelems, > int i; > > for_each_sg(sgl, sg, nelems, i) { > - sg->dma_address = swiotlb_map_page(dev, sg_page(sg), > sg->offset, > + dma_addr_t dma_addr; > + > + dma_addr = swiotlb_map_page(dev, sg_page(sg), sg->offset, > sg->length, dir, attrs); > - if (sg->dma_address == DIRECT_MAPPING_ERROR) > + if (dma_addr == DIRECT_MAPPING_ERROR) > goto out_error; > + sg->dma_address = dma_addr; > sg_dma_len(sg) = sg->length; > } I know Robin has already replied with more detailed info, but just to close the loop as I'm finally home, applying this patch didn't seem to help with the IO hangs I'm seeing w/ HiKey960. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 06/10] swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs
On Mon, Nov 12, 2018 at 4:07 PM, John Stultz wrote: > On Thu, Nov 8, 2018 at 11:49 PM, Christoph Hellwig wrote: >> On Tue, Nov 06, 2018 at 05:27:14PM -0800, John Stultz wrote: >>> But at that point if I just re-apply "swiotlb: use swiotlb_map_page in >>> swiotlb_map_sg_attrs", I reproduce the hangs. >>> >>> Any suggestions for how to further debug what might be going wrong >>> would be appreciated! >> >> Very odd. In the end map_sg and map_page are defined to do the same >> things to start with. The only real issue we had in this area was: >> >> "[PATCH v2] of/device: Really only set bus DMA mask when appropriate" >> >> so with current mainline + that you still see a problem, and if you >> rever the commit we are replying to it still goes away? > > Just to confirm, as of 4.20-rc2 (which includes the of/device patch > above), I'm still seeing this issue, but it isn't as reliable to > reproduce as before. > > With "swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs" reverted > (along with the dependent swiotlb patches) it doesn't seem to trigger > (no matter what I try). But re-applying that patch it tends to > trigger by itself at boot up, but sometimes I have to run "find /" to > trigger the io hang/stall. Also, I wanted to mention I've not seen this issue on the original hikey board. So far only on the hikey960, which might mean this is tied to something in the hisi UFS driver? thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 06/10] swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs
On Thu, Nov 8, 2018 at 11:49 PM, Christoph Hellwig wrote: > On Tue, Nov 06, 2018 at 05:27:14PM -0800, John Stultz wrote: >> But at that point if I just re-apply "swiotlb: use swiotlb_map_page in >> swiotlb_map_sg_attrs", I reproduce the hangs. >> >> Any suggestions for how to further debug what might be going wrong >> would be appreciated! > > Very odd. In the end map_sg and map_page are defined to do the same > things to start with. The only real issue we had in this area was: > > "[PATCH v2] of/device: Really only set bus DMA mask when appropriate" > > so with current mainline + that you still see a problem, and if you > rever the commit we are replying to it still goes away? Just to confirm, as of 4.20-rc2 (which includes the of/device patch above), I'm still seeing this issue, but it isn't as reliable to reproduce as before. With "swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs" reverted (along with the dependent swiotlb patches) it doesn't seem to trigger (no matter what I try). But re-applying that patch it tends to trigger by itself at boot up, but sometimes I have to run "find /" to trigger the io hang/stall. thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 06/10] swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs
On Mon, Oct 8, 2018 at 1:04 AM Christoph Hellwig wrote: > > No need to duplicate the code - map_sg is equivalent to map_page > for each page in the scatterlist. > > Signed-off-by: Christoph Hellwig > --- > kernel/dma/swiotlb.c | 34 -- > 1 file changed, 12 insertions(+), 22 deletions(-) Hey all, So, I've found this patch seems to break userspace booting on the HiKey960 board. Initially I thought this was an issue with the mali drivers, and have worked w/ the mali team to try to find a solution, but I've since found that booting just the upstream kernel (with no graphics support) will see userland hang/block unless this patch is reverted. When I see the hangs, it seems like the filesystems are stuck or something, as kernel messages still show up and sometimes I can get to a shell, but commands that I run in that shell (like ls) just hang. I don't see any other error messages. Reverting this patch then gets it work. In order to cleanly revert the patch, I have to revert the following set: "arm64: use the generic swiotlb_dma_ops" "swiotlb: add support for non-coherent DMA" "swiotlb: don't dip into swiotlb pool for coherent allocations" "swiotlb: refactor swiotlb_map_page" "swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs" But at that point if I just re-apply "swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs", I reproduce the hangs. Any suggestions for how to further debug what might be going wrong would be appreciated! thanks -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH] of/device: Really only set bus DMA mask when appropriate
On Tue, Nov 6, 2018 at 3:54 AM, Robin Murphy wrote: > of_dma_configure() was *supposed* to be following the same logic as > acpi_dma_configure() and only setting bus_dma_mask if some range was > specified by the firmware. However, it seems that subtlety got lost in > the process of fitting it into the differently-shaped control flow, and > as a result the force_dma==true case ends up always setting the bus mask > to the 32-bit default, which is not what anyone wants. > > Make sure we only touch it if the DT actually said so. > > Fixes: 6c2fb2ea7636 ("of/device: Set bus DMA mask as appropriate") > Reported-by: Aaro Koskinen > Reported-by: Jean-Philippe Brucker > Signed-off-by: Robin Murphy > --- > > Sorry about that... I guess I only have test setups that either have > dma-ranges or where a 32-bit bus mask goes unnoticed :( > > The Octeon and SMMU issues sound like they're purely down to this, and > it's probably related to at least one of John's Hikey woes. Yep! This does seem to resolve the mali bifrost dma address warn-ons I was seeing, and makes the board seem to function more consistently, so that's great! Tested-by: John Stultz Though I still find I have to revert "swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs" still to boot to UI successfully with AOSP. Still not sure whats going on there (its sort of soft hangs where some userland runs ok, but other bits seem to jam up, even console commands sometimes hang - almost seems like io stalls). Anyway, thanks so much again for this one! -john ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu