linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCI: imx6: install the fault handler only if we are really running on a compatible device
@ 2023-03-09 16:56 H. Nikolaus Schaller
  2023-03-24 15:09 ` Lorenzo Pieralisi
  0 siblings, 1 reply; 2+ messages in thread
From: H. Nikolaus Schaller @ 2023-03-09 16:56 UTC (permalink / raw)
  To: Richard Zhu, Lucas Stach, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Bjorn Helgaas, Shawn Guo,
	Sascha Hauer
  Cc: Rob Herring, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, linux-pci, linux-arm-kernel, linux-kernel,
	letux-kernel, kernel, H. Nikolaus Schaller

commit bb38919ec56e ("PCI: imx6: Add support for i.MX6 PCIe controller")
added a fault hook to this driver in the probe function. So it was only
installed if needed.

commit bde4a5a00e76 ("PCI: imx6: Allow probe deferral by reset GPIO")
moved it from probe to driver init which installs the hook unconditionally
as soon as the driver is compiled into a kernel.

When this driver is compiled as a module, the hook is not registered
until after the driver has been matched with a .compatible and
loaded.

commit 415b6185c541 ("PCI: imx6: Fix config read timeout handling")
extended the fault handling code.

commit 2d8ed461dbc9 ("PCI: imx6: Add support for i.MX8MQ")
added some protection for non-ARM architectures, but this does not
protect non-i.MX ARM architectures.

Since fault handlers can be triggered on any architecture for different
reasons, there is no guarantee that they will be triggered only for the
assumed situation, leading to improper error handling (i.MX6-specific
imx6q_pcie_abort_handler) on foreign systems.

I had seen strange L3 imprecise external abort messages several times on
OMAP4 and OMAP5 devices and couldn't make sense of them until I realized
they were related to this unused imx6q driver because I had
CONFIG_PCI_IMX6=y.

Note that CONFIG_PCI_IMX6=y is useful for kernel binaries that are designed
to run on different ARM SoC and be differentiated only by device tree
binaries. So turning off CONFIG_PCI_IMX6 is not a solution.

Therefore we check the compatible in the init function before registering
the fault handler.

Fixes: bde4a5a00e76 ("PCI: imx6: Allow probe deferral by reset GPIO")
Fixes: 415b6185c541 ("PCI: imx6: Fix config read timeout handling")
Fixes: 2d8ed461dbc9 ("PCI: imx6: Add support for i.MX8MQ")

Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---

Notes:
    Changes since v1:
    
    - replace of_find_matching_node_and_match() by of_find_matching_node()
      (suggested by Bjorn Helgaas <helgaas@kernel.org>)
    
    - v1 was Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>

 drivers/pci/controller/dwc/pci-imx6.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 55a0405b921d6..52906f999f2bb 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -1566,6 +1566,13 @@ DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_SYNOPSYS, 0xabcd,
 static int __init imx6_pcie_init(void)
 {
 #ifdef CONFIG_ARM
+	struct device_node *np;
+
+	np = of_find_matching_node(NULL, imx6_pcie_of_match);
+	if (!np)
+		return -ENODEV;
+	of_node_put(np);
+
 	/*
 	 * Since probe() can be deferred we need to make sure that
 	 * hook_fault_code is not called after __init memory is freed
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] PCI: imx6: install the fault handler only if we are really running on a compatible device
  2023-03-09 16:56 [PATCH v2] PCI: imx6: install the fault handler only if we are really running on a compatible device H. Nikolaus Schaller
@ 2023-03-24 15:09 ` Lorenzo Pieralisi
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Pieralisi @ 2023-03-24 15:09 UTC (permalink / raw)
  To: Richard Zhu, Lucas Stach, Krzysztof Wilczyński,
	Bjorn Helgaas, Shawn Guo, Sascha Hauer, H. Nikolaus Schaller
  Cc: Lorenzo Pieralisi, Rob Herring, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, linux-pci, linux-arm-kernel,
	linux-kernel, letux-kernel, kernel

On Thu, 09 Mar 2023 17:56:31 +0100, H. Nikolaus Schaller wrote:
> commit bb38919ec56e ("PCI: imx6: Add support for i.MX6 PCIe controller")
> added a fault hook to this driver in the probe function. So it was only
> installed if needed.
> 
> commit bde4a5a00e76 ("PCI: imx6: Allow probe deferral by reset GPIO")
> moved it from probe to driver init which installs the hook unconditionally
> as soon as the driver is compiled into a kernel.
> 
> [...]

Applied to controller/dwc, thanks!

[1/1] PCI: imx6: install the fault handler only if we are really running on a compatible device
      https://git.kernel.org/pci/pci/c/5f5ac460dfe7

Thanks,
Lorenzo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-24 15:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 16:56 [PATCH v2] PCI: imx6: install the fault handler only if we are really running on a compatible device H. Nikolaus Schaller
2023-03-24 15:09 ` Lorenzo Pieralisi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).