From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1giAqO-0001UQ-I2 for barebox@lists.infradead.org; Sat, 12 Jan 2019 04:24:26 +0000 Received: by mail-wm1-x343.google.com with SMTP id d15so4153503wmb.3 for ; Fri, 11 Jan 2019 20:24:23 -0800 (PST) MIME-Version: 1.0 References: <20190109071210.18896-1-andrew.smirnov@gmail.com> <20190109071210.18896-17-andrew.smirnov@gmail.com> <20190110080519.plzbkseqs3ndn3s6@pengutronix.de> In-Reply-To: <20190110080519.plzbkseqs3ndn3s6@pengutronix.de> From: Andrey Smirnov Date: Fri, 11 Jan 2019 20:24:10 -0800 Message-ID: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [PATCH 16/21] PCI: imx6: Allow probe deferral by reset GPIO To: Sascha Hauer Cc: Barebox List On Thu, Jan 10, 2019 at 12:05 AM Sascha Hauer wrote: > > On Tue, Jan 08, 2019 at 11:12:05PM -0800, Andrey Smirnov wrote: > > Port of a Linux commit bde4a5a00e761f55be92f62378cf5024ced79ee3 > > > > Some designs implement reset GPIO via a GPIO expander connected to a > > peripheral bus. One such example would be i.MX7 Sabre board where said > > GPIO is provided by SPI shift register connected to a bitbanged SPI bus. > > To support such designs, allow reset GPIO request to defer probing of the > > driver. > > > > Signed-off-by: Andrey Smirnov > > Signed-off-by: Bjorn Helgaas > > Reviewed-by: Lucas Stach > > Cc: yurovsky@gmail.com > > Cc: Fabio Estevam > > Cc: Dong Aisheng > > Cc: linux-arm-kernel@lists.infradead.org > > > > Signed-off-by: Andrey Smirnov > > --- > > drivers/pci/pci-imx6.c | 9 ++++++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/pci/pci-imx6.c b/drivers/pci/pci-imx6.c > > index 6471f95b6..517c6bef8 100644 > > --- a/drivers/pci/pci-imx6.c > > +++ b/drivers/pci/pci-imx6.c > > @@ -562,8 +562,8 @@ static const struct dw_pcie_host_ops imx6_pcie_host_ops = { > > .host_init = imx6_pcie_host_init, > > }; > > > > -static int __init imx6_add_pcie_port(struct imx6_pcie *imx6_pcie, > > - struct device_d *dev) > > +static int imx6_add_pcie_port(struct imx6_pcie *imx6_pcie, > > + struct device_d *dev) > > { > > struct dw_pcie *pci = imx6_pcie->pci; > > struct pcie_port *pp = &pci->pp; > > @@ -581,7 +581,7 @@ static int __init imx6_add_pcie_port(struct imx6_pcie *imx6_pcie, > > return 0; > > } > > > > -static int __init imx6_pcie_probe(struct device_d *dev) > > +static int imx6_pcie_probe(struct device_d *dev) > > { > > struct resource *iores; > > struct dw_pcie *pci; > > @@ -606,6 +606,9 @@ static int __init imx6_pcie_probe(struct device_d *dev) > > > > /* Fetch GPIOs */ > > imx6_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); > > + if (imx6_pcie->reset_gpio == -EPROBE_DEFER) > > + return imx6_pcie->reset_gpio; > > Normally probe function run only once in barebox and in that case I do > not care about loosing memory. When doing probe deferral here we loose a > private data struct with each deferred probe here. > > Before returning -EPROBE_DEFER Here we already claimed a iomem resource using > dev_request_mem_resource() which will fail during next probe, so I > believe this patch doesn't work. > Yeah, it just happens to be that in Barebox 74164 GPIO driver gets probed before PCIe, so this patch isn't strictly needed on i.MX7 (unlike on Linux). The simplest solution, I think, would be to move GPIO request before dev_request_mem_resource(), which is my plan for v2. If you'd rather this patch be dropped, since, technically things are working without it, let me know. Thanks, Andrey Smirnov _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox