[PATCH v2] PCI: rcar-host: Add static assertion to check !PCI_LOCKLESS_CONFIG

Marek Vasut posted 1 patch 1 week, 1 day ago
drivers/pci/controller/Kconfig          | 1 +
drivers/pci/controller/pcie-rcar-host.c | 8 ++++++++
2 files changed, 9 insertions(+)
[PATCH v2] PCI: rcar-host: Add static assertion to check !PCI_LOCKLESS_CONFIG
Posted by Marek Vasut 1 week, 1 day ago
This driver can not function correctly without PCIe subsystem level
config space access serialization. In case PCI_LOCKLESS_CONFIG is
ever enabled on ARM, complain loudly so the driver can be updated
accordingly.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: "Krzysztof Wilczyński" <kwilczynski@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
---
V2: Add depends on !PCI_LOCKLESS_CONFIG into Kconfig file, to prevent
    this from being built when PCI_LOCKLESS_CONFIG is not set at all
---
 drivers/pci/controller/Kconfig          | 1 +
 drivers/pci/controller/pcie-rcar-host.c | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 41748d083b933..3f489bed289fb 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -244,6 +244,7 @@ config PCIE_RCAR_HOST
 	bool "Renesas R-Car PCIe controller (host mode)"
 	depends on ARCH_RENESAS || COMPILE_TEST
 	depends on PCI_MSI
+	depends on !PCI_LOCKLESS_CONFIG
 	select IRQ_MSI_LIB
 	help
 	  Say Y here if you want PCIe controller support on R-Car SoCs in host
diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c
index 213028052aa58..29e13f7ff7ff1 100644
--- a/drivers/pci/controller/pcie-rcar-host.c
+++ b/drivers/pci/controller/pcie-rcar-host.c
@@ -35,6 +35,14 @@
 
 #include "pcie-rcar.h"
 
+/*
+ * This driver can not function correctly without PCIe subsystem level
+ * config space access serialization. In case PCI_LOCKLESS_CONFIG is
+ * ever enabled on ARM, complain loudly so the driver can be updated
+ * accordingly.
+ */
+static_assert(!IS_ENABLED(CONFIG_PCI_LOCKLESS_CONFIG));
+
 struct rcar_msi {
 	DECLARE_BITMAP(used, INT_PCI_MSI_NR);
 	struct irq_domain *domain;
-- 
2.51.0

Re: [PATCH v2] PCI: rcar-host: Add static assertion to check !PCI_LOCKLESS_CONFIG
Posted by Manivannan Sadhasivam 1 week ago
On Wed, Sep 24, 2025 at 01:46:18AM +0200, Marek Vasut wrote:
> This driver can not function correctly without PCIe subsystem level
> config space access serialization. In case PCI_LOCKLESS_CONFIG is
> ever enabled on ARM, complain loudly so the driver can be updated
> accordingly.
> 

This limitation applies to almost all host controller drivers except those used
on Intel platforms like VMD and Hyper-V. So this would require adding the
Kconfig dependency for all those, not just for RCAR.

We could also add the dependency to the arch Kconfig, but there is still a
possibility that if the driver is used on a platform selecting
PCI_LOCKLESS_CONFIG, it would be broken silently. So adding the dependency to
the individual drivers that suffer from the limitation seems to be the right
thing to do.

Also, I'm not in favor of adding static_assert with Kconfig dependency in place.

- Mani

> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Cc: "Krzysztof Wilczyński" <kwilczynski@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Manivannan Sadhasivam <mani@kernel.org>
> Cc: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-pci@vger.kernel.org
> Cc: linux-renesas-soc@vger.kernel.org
> ---
> V2: Add depends on !PCI_LOCKLESS_CONFIG into Kconfig file, to prevent
>     this from being built when PCI_LOCKLESS_CONFIG is not set at all
> ---
>  drivers/pci/controller/Kconfig          | 1 +
>  drivers/pci/controller/pcie-rcar-host.c | 8 ++++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> index 41748d083b933..3f489bed289fb 100644
> --- a/drivers/pci/controller/Kconfig
> +++ b/drivers/pci/controller/Kconfig
> @@ -244,6 +244,7 @@ config PCIE_RCAR_HOST
>  	bool "Renesas R-Car PCIe controller (host mode)"
>  	depends on ARCH_RENESAS || COMPILE_TEST
>  	depends on PCI_MSI
> +	depends on !PCI_LOCKLESS_CONFIG
>  	select IRQ_MSI_LIB
>  	help
>  	  Say Y here if you want PCIe controller support on R-Car SoCs in host
> diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c
> index 213028052aa58..29e13f7ff7ff1 100644
> --- a/drivers/pci/controller/pcie-rcar-host.c
> +++ b/drivers/pci/controller/pcie-rcar-host.c
> @@ -35,6 +35,14 @@
>  
>  #include "pcie-rcar.h"
>  
> +/*
> + * This driver can not function correctly without PCIe subsystem level
> + * config space access serialization. In case PCI_LOCKLESS_CONFIG is
> + * ever enabled on ARM, complain loudly so the driver can be updated
> + * accordingly.
> + */
> +static_assert(!IS_ENABLED(CONFIG_PCI_LOCKLESS_CONFIG));
> +
>  struct rcar_msi {
>  	DECLARE_BITMAP(used, INT_PCI_MSI_NR);
>  	struct irq_domain *domain;
> -- 
> 2.51.0
> 

-- 
மணிவண்ணன் சதாசிவம்
Re: [PATCH v2] PCI: rcar-host: Add static assertion to check !PCI_LOCKLESS_CONFIG
Posted by Marek Vasut 1 week ago
Hello Manivannan,

On 9/24/25 5:25 AM, Manivannan Sadhasivam wrote:
> On Wed, Sep 24, 2025 at 01:46:18AM +0200, Marek Vasut wrote:
>> This driver can not function correctly without PCIe subsystem level
>> config space access serialization. In case PCI_LOCKLESS_CONFIG is
>> ever enabled on ARM, complain loudly so the driver can be updated
>> accordingly.
>>
> 
> This limitation applies to almost all host controller drivers except those used
> on Intel platforms like VMD and Hyper-V. So this would require adding the
> Kconfig dependency for all those, not just for RCAR.

Correct.

> We could also add the dependency to the arch Kconfig, but there is still a
> possibility that if the driver is used on a platform selecting
> PCI_LOCKLESS_CONFIG, it would be broken silently. So adding the dependency to
> the individual drivers that suffer from the limitation seems to be the right
> thing to do.

Would you like me to send a few more patches which add 
!PCI_LOCKLESS_CONFIG into per-driver Kconfig entries, at least for 
drivers where I am sure they suffer from this currently hypothetical 
issue ...

> Also, I'm not in favor of adding static_assert with Kconfig dependency in place.
... and drop the static assert ?

Then the drivers would at least be marked accordingly.
Re: [PATCH v2] PCI: rcar-host: Add static assertion to check !PCI_LOCKLESS_CONFIG
Posted by Manivannan Sadhasivam 1 week ago
On Wed, Sep 24, 2025 at 05:34:55AM +0200, Marek Vasut wrote:
> Hello Manivannan,
> 
> On 9/24/25 5:25 AM, Manivannan Sadhasivam wrote:
> > On Wed, Sep 24, 2025 at 01:46:18AM +0200, Marek Vasut wrote:
> > > This driver can not function correctly without PCIe subsystem level
> > > config space access serialization. In case PCI_LOCKLESS_CONFIG is
> > > ever enabled on ARM, complain loudly so the driver can be updated
> > > accordingly.
> > > 
> > 
> > This limitation applies to almost all host controller drivers except those used
> > on Intel platforms like VMD and Hyper-V. So this would require adding the
> > Kconfig dependency for all those, not just for RCAR.
> 
> Correct.
> 
> > We could also add the dependency to the arch Kconfig, but there is still a
> > possibility that if the driver is used on a platform selecting
> > PCI_LOCKLESS_CONFIG, it would be broken silently. So adding the dependency to
> > the individual drivers that suffer from the limitation seems to be the right
> > thing to do.
> 
> Would you like me to send a few more patches which add !PCI_LOCKLESS_CONFIG
> into per-driver Kconfig entries, at least for drivers where I am sure they
> suffer from this currently hypothetical issue ...
> 

Sure.

> > Also, I'm not in favor of adding static_assert with Kconfig dependency in place.
> ... and drop the static assert ?
> 
> Then the drivers would at least be marked accordingly.

Yes. Better than what we have currently.

- Mani

-- 
மணிவண்ணன் சதாசிவம்
Re: [PATCH v2] PCI: rcar-host: Add static assertion to check !PCI_LOCKLESS_CONFIG
Posted by Marek Vasut 6 days, 10 hours ago
On 9/24/25 6:00 AM, Manivannan Sadhasivam wrote:
> On Wed, Sep 24, 2025 at 05:34:55AM +0200, Marek Vasut wrote:
>> Hello Manivannan,
>>
>> On 9/24/25 5:25 AM, Manivannan Sadhasivam wrote:
>>> On Wed, Sep 24, 2025 at 01:46:18AM +0200, Marek Vasut wrote:
>>>> This driver can not function correctly without PCIe subsystem level
>>>> config space access serialization. In case PCI_LOCKLESS_CONFIG is
>>>> ever enabled on ARM, complain loudly so the driver can be updated
>>>> accordingly.
>>>>
>>>
>>> This limitation applies to almost all host controller drivers except those used
>>> on Intel platforms like VMD and Hyper-V. So this would require adding the
>>> Kconfig dependency for all those, not just for RCAR.
>>
>> Correct.
>>
>>> We could also add the dependency to the arch Kconfig, but there is still a
>>> possibility that if the driver is used on a platform selecting
>>> PCI_LOCKLESS_CONFIG, it would be broken silently. So adding the dependency to
>>> the individual drivers that suffer from the limitation seems to be the right
>>> thing to do.
>>
>> Would you like me to send a few more patches which add !PCI_LOCKLESS_CONFIG
>> into per-driver Kconfig entries, at least for drivers where I am sure they
>> suffer from this currently hypothetical issue ...
>>
> 
> Sure.
> 
>>> Also, I'm not in favor of adding static_assert with Kconfig dependency in place.
>> ... and drop the static assert ?
>>
>> Then the drivers would at least be marked accordingly.
> 
> Yes. Better than what we have currently.
This is now done in

[PATCH] PCI: controller: Mark controllers which cannot do lockless 
config access with !PCI_LOCKLESS_CONFIG

I hope I got all of them.