Re: [PATCH] PCI: dwc: Provide deinit callback for i.MX

From: Fabio Estevam
Date: Tue Jul 04 2023 - 07:50:34 EST


Hi Mark,

On Mon, Jul 3, 2023 at 1:30 PM Mark Brown <broonie@xxxxxxxxxx> wrote:
>
> The i.MX integration for the DesignWare PCI controller has a _host_exit()
> operation which undoes everything that the _host_init() operation does but
> does not wire this up as the host_deinit callback for the core, or call it
> in any path other than suspend. This means that if we ever unwind the
> initial probe of the device, for example because it fails, the regulator
> core complains that the regulators for the device were left enabled:
>
> imx6q-pcie 33800000.pcie: iATU: unroll T, 4 ob, 4 ib, align 64K, limit 16G
> imx6q-pcie 33800000.pcie: Phy link never came up
> imx6q-pcie 33800000.pcie: Phy link never came up
> imx6q-pcie: probe of 33800000.pcie failed with error -110
> ------------[ cut here ]------------
> WARNING: CPU: 2 PID: 46 at drivers/regulator/core.c:2396 _regulator_put+0x110/0x128

Your change looks good, but I have a more basic question.

I recall seeing this regulator warning before:
f81f095e8771 ("PCI: imx6: Allow to probe when dw_pcie_wait_for_link() fails")

I think the real issue is why does the probe fail when the link is not up?

It should not fail to probe. At least, this was the original intention
with Rob's commit:

886a9c134755 ("PCI: dwc: Move link handling into common code")

Should we do something like this?

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c
b/drivers/pci/controller/dwc/pcie-designware-host.c
index cf61733bf78d..6bd6ffef900d 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -509,6 +509,7 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)

err_stop_link:
dw_pcie_stop_link(pci);
+ return 0;

err_remove_edma:
dw_pcie_edma_remove(pci);