From: Siddharth Vadapalli <s-vadapalli@ti.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: <lpieralisi@kernel.org>, <kwilczynski@kernel.org>,
<robh@kernel.org>, <bhelgaas@google.com>, <jingoohan1@gmail.com>,
<christian.bruel@foss.st.com>, <krishna.chundru@oss.qualcomm.com>,
<qiang.yu@oss.qualcomm.com>, <shradha.t@samsung.com>,
<thippeswamy.havalige@amd.com>, <inochiama@gmail.com>,
<fan.ni@samsung.com>, <cassel@kernel.org>, <kishon@kernel.org>,
<18255117159@163.com>, <rongqianfeng@vivo.com>,
<jirislaby@kernel.org>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <srk@ti.com>,
<s-vadapalli@ti.com>
Subject: Re: [PATCH v5 4/4] PCI: keystone: Add support to build as a loadable module
Date: Thu, 6 Nov 2025 12:31:08 +0530 [thread overview]
Message-ID: <d65f44cac2d7fb6c4a139065b304cb4ab790acb3.camel@ti.com> (raw)
In-Reply-To: <fkzokskbjklt6atqrpwc46zsjr5ptpuynzhx4kvfurr4h37kae@rwcqljsjvzl6>
On Wed, 2025-11-05 at 22:53 +0530, Manivannan Sadhasivam wrote:
> On Wed, Oct 29, 2025 at 01:34:52PM +0530, Siddharth Vadapalli wrote:
> > The 'pci-keystone.c' driver is the application/glue/wrapper driver for the
> > Designware PCIe Controllers on TI SoCs. Now that all of the helper APIs
> > that the 'pci-keystone.c' driver depends upon have been exported for use,
> > enable support to build the driver as a loadable module.
> >
> > Additionally, the functions marked by the '__init' keyword may be invoked:
> > a) After a probe deferral
> > OR
> > b) During a delayed probe - Delay attributed to driver being built as a
> > loadable module
> >
> > In both of the cases mentioned above, the '__init' memory will be freed
> > before the functions are invoked. This results in an exception of the form:
> >
> > Unable to handle kernel paging request at virtual address ...
> > Mem abort info:
> > ...
> > pc : ks_pcie_host_init+0x0/0x540
> > lr : dw_pcie_host_init+0x170/0x498
> > ...
> > ks_pcie_host_init+0x0/0x540 (P)
> > ks_pcie_probe+0x728/0x84c
> > platform_probe+0x5c/0x98
> > really_probe+0xbc/0x29c
> > __driver_probe_device+0x78/0x12c
> > driver_probe_device+0xd8/0x15c
> > ...
> >
> > To address this, introduce a new function namely 'ks_pcie_init()' to
> > register the 'fault handler' while removing the '__init' keyword from
> > existing functions.
> >
> > Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> > ---
> >
> > v4:
> > https://lore.kernel.org/r/20251022095724.997218-5-s-vadapalli@ti.com/
> > Changes since v4:
> > - To fix the build error on ARM32 platforms as reported at:
> > https://lore.kernel.org/r/202510281008.jw19XuyP-lkp@intel.com/
> > patch 4 in the series has been updated by introducing a new config
> > named "PCI_KEYSTONE_TRISTATE" which allows building the driver as
> > a loadable module. Additionally, this newly introduced config can
> > be enabled only for non-ARM32 platforms. As a result, ARM32 platforms
> > continue using the existing PCI_KEYSTONE config which is a bool, while
> > ARM64 platforms can use PCI_KEYSTONE_TRISTATE which is a tristate, and
> > can optionally enabled loadable module support being enabled by this
> > series.
> >
> > Regards,
> > Siddharth.
> >
> > drivers/pci/controller/dwc/Kconfig | 15 +++--
> > drivers/pci/controller/dwc/Makefile | 3 +
> > drivers/pci/controller/dwc/pci-keystone.c | 78 +++++++++++++----------
> > 3 files changed, 59 insertions(+), 37 deletions(-)
> >
> > diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig
> > index 349d4657393c..c5bc2f0b1f39 100644
> > --- a/drivers/pci/controller/dwc/Kconfig
> > +++ b/drivers/pci/controller/dwc/Kconfig
> > @@ -482,15 +482,21 @@ config PCI_DRA7XX_EP
> > to enable device-specific features PCI_DRA7XX_EP must be selected.
> > This uses the DesignWare core.
> >
> > +# ARM32 platforms use hook_fault_code() and cannot support loadable module.
> > config PCI_KEYSTONE
> > bool
> >
> > +# On non-ARM32 platforms, loadable module can be supported.
> > +config PCI_KEYSTONE_TRISTATE
> > + tristate
> > +
> > config PCI_KEYSTONE_HOST
> > - bool "TI Keystone PCIe controller (host mode)"
> > + tristate "TI Keystone PCIe controller (host mode)"
> > depends on ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST
> > depends on PCI_MSI
> > select PCIE_DW_HOST
> > - select PCI_KEYSTONE
> > + select PCI_KEYSTONE if ARM
> > + select PCI_KEYSTONE_TRISTATE if !ARM
>
> Wouldn't below change work for you?
>
> diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig
> index 349d4657393c..b1219e7136c9 100644
> --- a/drivers/pci/controller/dwc/Kconfig
> +++ b/drivers/pci/controller/dwc/Kconfig
> @@ -486,8 +486,9 @@ config PCI_KEYSTONE
> bool
>
> config PCI_KEYSTONE_HOST
> - bool "TI Keystone PCIe controller (host mode)"
> + tristate "TI Keystone PCIe controller (host mode)"
This doesn't alter the build of the pci-keystone.c driver. From the
existing Makefile, we have:
obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone.o
implying that it is only CONFIG_PCI_KEYSTONE that determines whether the
pci-keystone.c driver is built as a loadable module or a built-in module.
> depends on ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST
> + default y if ARCH_KEYSTONE
The default flag only specifies what should be selected by default, but it
doesn't prevent the user from attempting to built it as a loadable module
using menuconfig. Building the pci-keystone.c driver as a loadable module
(CONFIG_PCI_KEYSTONE set to 'm') will cause build errors for ARM32
platforms due to the presence of hook_fault_code() which is __init code.
The Kconfig and Makefile changes made by the patch do the following:
1. Allow building the pci-keystone.c driver as a loadable module for non-
ARM32 platforms by introducing the PCI_KEYSTONE_TRISTATE config which is a
tristate unlike the existing PCI_KEYSTONE config which is a bool.
2. Associate PCI_KEYSTONE with ARM32 platforms and associate
PCI_KEYSTONE_TRISTATE with non-ARM32 platforms to prevent users from
building the pci-keystone.c driver as a loadable module for ARM32
platforms.
Regards,
Siddharth.
next prev parent reply other threads:[~2025-11-06 7:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 8:04 [PATCH v5 0/4] PCI: Keystone: Enable loadable module support Siddharth Vadapalli
2025-10-29 8:04 ` [PATCH v5 1/4] PCI: Export pci_get_host_bridge_device() for use by pci-keystone Siddharth Vadapalli
2025-10-29 8:04 ` [PATCH v5 2/4] PCI: dwc: Export dw_pcie_allocate_domains() and dw_pcie_ep_raise_msix_irq() Siddharth Vadapalli
2025-10-29 8:04 ` [PATCH v5 3/4] PCI: keystone: Exit ks_pcie_probe() for invalid mode Siddharth Vadapalli
2025-10-29 8:04 ` [PATCH v5 4/4] PCI: keystone: Add support to build as a loadable module Siddharth Vadapalli
2025-11-05 17:23 ` Manivannan Sadhasivam
2025-11-06 7:01 ` Siddharth Vadapalli [this message]
2025-11-06 8:00 ` Manivannan Sadhasivam
2025-11-13 18:13 ` Bjorn Helgaas
2025-11-13 18:35 ` Russell King (Oracle)
2025-11-13 18:48 ` Bjorn Helgaas
2025-11-06 8:10 ` [PATCH v5 0/4] PCI: Keystone: Enable loadable module support Manivannan Sadhasivam
2025-11-13 18:25 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d65f44cac2d7fb6c4a139065b304cb4ab790acb3.camel@ti.com \
--to=s-vadapalli@ti.com \
--cc=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=christian.bruel@foss.st.com \
--cc=fan.ni@samsung.com \
--cc=inochiama@gmail.com \
--cc=jingoohan1@gmail.com \
--cc=jirislaby@kernel.org \
--cc=kishon@kernel.org \
--cc=krishna.chundru@oss.qualcomm.com \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=qiang.yu@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=rongqianfeng@vivo.com \
--cc=shradha.t@samsung.com \
--cc=srk@ti.com \
--cc=thippeswamy.havalige@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox