Message ID | 20200616061338.109499-6-john.stultz@linaro.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Allow for qcom-pdc, pinctrl-msm and qcom-scm drivers to be loadable as modules | expand |
Hi John, +Will for the SMMU part. On 2020-06-16 07:13, John Stultz wrote: > Allow the qcom_scm driver to be loadable as a > permenent module. > > Cc: Andy Gross <agross@kernel.org> > Cc: Bjorn Andersson <bjorn.andersson@linaro.org> > Cc: Joerg Roedel <joro@8bytes.org> > Cc: Thomas Gleixner <tglx@linutronix.de> > Cc: Jason Cooper <jason@lakedaemon.net> > Cc: Marc Zyngier <maz@kernel.org> > Cc: Linus Walleij <linus.walleij@linaro.org> > Cc: Lina Iyer <ilina@codeaurora.org> > Cc: Saravana Kannan <saravanak@google.com> > Cc: Todd Kjos <tkjos@google.com> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: linux-arm-msm@vger.kernel.org > Cc: iommu@lists.linux-foundation.org > Cc: linux-gpio@vger.kernel.org > Signed-off-by: John Stultz <john.stultz@linaro.org> > --- > 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(&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 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 This looks a bit ugly. Could you explain why we need this at the SMMU level? I'd have expected the dependency to flow the other way around... > 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 Thanks, M.
On Tue, Jun 16, 2020 at 12:55 AM Marc Zyngier <maz@kernel.org> wrote: > On 2020-06-16 07:13, 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 > > This looks a bit ugly. Could you explain why we need this at the SMMU > level? I'd have expected the dependency to flow the other way around... Yea, so the arm-smmu-qcom.c file calls directly into the qcom-scm code via qcom_scm_qsmmu500_wait_safe_toggle() https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iommu/arm-smmu-qcom.c?h=v5.8-rc1#n44 So if ARM_SMMU=y and QCOM_SCM=m we get: drivers/iommu/arm-smmu-qcom.o: In function `qcom_smmu500_reset': arm-smmu-qcom.c:(.text+0xb4): undefined reference to `qcom_scm_qsmmu500_wait_safe_toggle' Do you have a suggestion for an alternative approach? thanks -john
On Tue, Jun 16, 2020 at 01:52:32PM -0700, John Stultz wrote: > On Tue, Jun 16, 2020 at 12:55 AM Marc Zyngier <maz@kernel.org> wrote: > > On 2020-06-16 07:13, 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 > > > > This looks a bit ugly. Could you explain why we need this at the SMMU > > level? I'd have expected the dependency to flow the other way around... > > Yea, so the arm-smmu-qcom.c file calls directly into the qcom-scm code > via qcom_scm_qsmmu500_wait_safe_toggle() > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iommu/arm-smmu-qcom.c?h=v5.8-rc1#n44 > > So if ARM_SMMU=y and QCOM_SCM=m we get: > drivers/iommu/arm-smmu-qcom.o: In function `qcom_smmu500_reset': > arm-smmu-qcom.c:(.text+0xb4): undefined reference to > `qcom_scm_qsmmu500_wait_safe_toggle' > > Do you have a suggestion for an alternative approach? Can you use symbol_get() or something like that? How are module dependencies handled by other drivers? Will
On 03-07-20, 13:23, Will Deacon wrote: > On Tue, Jun 16, 2020 at 01:52:32PM -0700, John Stultz wrote: > > On Tue, Jun 16, 2020 at 12:55 AM Marc Zyngier <maz@kernel.org> wrote: > > > On 2020-06-16 07:13, 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 > > > > > > This looks a bit ugly. Could you explain why we need this at the SMMU > > > level? I'd have expected the dependency to flow the other way around... > > > > Yea, so the arm-smmu-qcom.c file calls directly into the qcom-scm code > > via qcom_scm_qsmmu500_wait_safe_toggle() > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iommu/arm-smmu-qcom.c?h=v5.8-rc1#n44 > > > > So if ARM_SMMU=y and QCOM_SCM=m we get: > > drivers/iommu/arm-smmu-qcom.o: In function `qcom_smmu500_reset': > > arm-smmu-qcom.c:(.text+0xb4): undefined reference to > > `qcom_scm_qsmmu500_wait_safe_toggle' > > > > Do you have a suggestion for an alternative approach? > > Can you use symbol_get() or something like that? How are module dependencies > handled by other drivers? So drivers deal with this by making rules in Kconfig which will prohibit this case. QCOM_SCM depends on ARM_SMMU with the caveat that if ARM_SMMU is a module, QCOM_SCM cant be inbuilt. This can be done by adding below line in Kconfig for QCOM_SCM: depends on ARM_SMMU || !ARM_SMMU This is quite prevalent is drivers to ensure dependency like this Thanks
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(&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 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
Allow the qcom_scm driver to be loadable as a permenent module. Cc: Andy Gross <agross@kernel.org> Cc: Bjorn Andersson <bjorn.andersson@linaro.org> Cc: Joerg Roedel <joro@8bytes.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jason Cooper <jason@lakedaemon.net> Cc: Marc Zyngier <maz@kernel.org> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Lina Iyer <ilina@codeaurora.org> Cc: Saravana Kannan <saravanak@google.com> Cc: Todd Kjos <tkjos@google.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-arm-msm@vger.kernel.org Cc: iommu@lists.linux-foundation.org Cc: linux-gpio@vger.kernel.org Signed-off-by: John Stultz <john.stultz@linaro.org> --- 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(-)