On Fri, Nov 06, 2020 at 04:27:10AM +0000, 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). > > Cc: Catalin Marinas <catalin.marinas@xxxxxxx> > Cc: Will Deacon <will@xxxxxxxxxx> > Cc: Andy Gross <agross@xxxxxxxxxx> > Cc: Bjorn Andersson <bjorn.andersson@xxxxxxxxxx> > Cc: Joerg Roedel <joro@xxxxxxxxxx> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > Cc: Jason Cooper <jason@xxxxxxxxxxxxxx> > Cc: Marc Zyngier <maz@xxxxxxxxxx> > Cc: Linus Walleij <linus.walleij@xxxxxxxxxx> > Cc: Vinod Koul <vkoul@xxxxxxxxxx> > Cc: Kalle Valo <kvalo@xxxxxxxxxxxxxx> > Cc: Maulik Shah <mkshah@xxxxxxxxxxxxxx> > Cc: Lina Iyer <ilina@xxxxxxxxxxxxxx> > Cc: Saravana Kannan <saravanak@xxxxxxxxxx> > Cc: Todd Kjos <tkjos@xxxxxxxxxx> > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > Cc: linux-arm-msm@xxxxxxxxxxxxxxx > Cc: iommu@xxxxxxxxxxxxxxxxxxxxxxxxxx > Cc: linux-gpio@xxxxxxxxxxxxxxx > Acked-by: Kalle Valo <kvalo@xxxxxxxxxxxxxx> > Acked-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > Reviewed-by: Bjorn Andersson <bjorn.andersson@xxxxxxxxxx> > Signed-off-by: John Stultz <john.stultz@xxxxxxxxxx> > --- > v3: > * Fix __arm_smccc_smc build issue reported by > kernel test robot <lkp@xxxxxxxxx> > 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(&qcom_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 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. One way to work around this is to just disable all QCOM-related drivers for the build so that ARM SMMU will be built-in again. I'm going to guess that distributions aren't going to be too happy about having to make that kind of choice. Another way would be for the ARM SMMU module to be included in the initial ramdisk, which /should/ solve this as well, though I haven't actually tested that yet. That's not ideal, because it means that users will have to use an initial ramdisk in order to make this work, and not all of them may want to. Perhaps a better solution for now would be to make QCOM_SCM always built-in, so that ARM SMMU can also always be built-in? I suspect that this will be a problem not only on Tegra but on any platform that uses an ARM SMMU. I think this is also not directly related to the QCOM_SCM code because this would also happen if ARM SMMU were built as a module for a kernel that doesn't have any QCOM drivers enabled. So in general any configuration that builds ARM SMMU as a module seems like it would currently be broken (if it also keeps the "fault by default" default). Is this something that people have extensively tested? I can't see how that would currently work, since there's no way for an ARM SMMU master to somehow recover and switch to IOMMU-backed DMA API dynamically once the ARM SMMU becomes available. I guess yet another possibility would be for the ARM SMMU driver to detect whether it was loaded after all of its consumers and switch to "bypass by default" automatically in such a situation. That should allow any driver probed after the ARM SMMU to still take advantage of IOVA translation, but will not impact the devices probed before the ARM SMMU. Thierry
Attachment:
signature.asc
Description: PGP signature