From: Frank Li <Frank.li@nxp.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: Sherry Sun <sherry.sun@nxp.com>,
hongxing.zhu@nxp.com, l.stach@pengutronix.de,
bhelgaas@google.com, lpieralisi@kernel.org,
kwilczynski@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com,
imx@lists.linux.dev, kernel@pengutronix.de,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3 02/10] PCI: imx6: Add support for parsing the reset property in new Root Port binding
Date: Wed, 4 Feb 2026 10:25:28 -0500 [thread overview]
Message-ID: <aYNk6C_W_oSFVqbH@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <pz5zmte5dbb23ccwvc2xkl4grptr35bmcwd6ohlzo2arjopgkw@t3euzojtsoyf>
On Wed, Feb 04, 2026 at 05:58:33PM +0530, Manivannan Sadhasivam wrote:
> On Tue, Feb 03, 2026 at 12:43:17PM -0500, Frank Li wrote:
> > On Tue, Feb 03, 2026 at 06:38:18PM +0530, Manivannan Sadhasivam wrote:
> > > On Tue, Feb 03, 2026 at 09:56:06AM +0800, Sherry Sun wrote:
> > > > DT binding allows specifying 'reset' property in both host bridge and
> > > > Root Port nodes, but specifying in the host bridge node is marked as
> > > > deprecated. So add support for parsing the new binding that uses
> > > > 'reset-gpios' property for PERST#.
> > > >
> > > > The initial idea is to add the PCIe M.2 KeyE connector support and PCI
> > > > power control framework to the pcie-imx6 driver. Since the new
> > > > M.2/pwrctrl model is implemented based on Root Ports and requires the
> > > > pwrctrl driver to bind to a Root Port device, we need to introduce a
> > > > Root Port child node on i.MX boards that provide an M.2 connector.
> > > >
> > > > To follow a more standardized DT structure, it also makes sense to move
> > > > the reset-gpios and wake-gpios properties into the Root Port node. These
> > > > signals logically belong to the Root Port rather than the host bridge,
> > > > and placing them there aligns with the new M.2/pwrctrl model.
> > > >
> > > > To maintain DT backwards compatibility, fallback to the legacy method of
> > > > parsing the host bridge node if the reset property is not present in the
> > > > Root Port node.
> > > >
> > > > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > > > ---
> > > > drivers/pci/controller/dwc/pci-imx6.c | 123 +++++++++++++++++++++++---
> > > > 1 file changed, 109 insertions(+), 14 deletions(-)
> > > >
> > > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> > > > index a5b8d0b71677..e3ba68976bee 100644
> > > > --- a/drivers/pci/controller/dwc/pci-imx6.c
> > > > +++ b/drivers/pci/controller/dwc/pci-imx6.c
> > > > @@ -148,10 +148,15 @@ struct imx_lut_data {
> > > > u32 data2;
> > > > };
> > > >
> > > > +struct imx_pcie_port {
> > > > + struct list_head list;
> > > > + struct gpio_desc *reset;
> > > > +};
> > > > +
> > >
> > > I'd love to abstract the Root Port properties in a generic struct so that we can
> > > introduce generic APIs to parse the ports. But I'm not asking you to implement
> > > it :)
> > >
> >
> > good idea, where is good place to put it?
> >
>
> drivers/pci/controller/pci-host-common.c
>
> > > >
> > > > @@ -1688,12 +1771,24 @@ static int imx_pcie_probe(struct platform_device *pdev)
> > > > return PTR_ERR(imx_pcie->phy_base);
> > > > }
> > > >
> > > > - /* Fetch GPIOs */
> > > > - imx_pcie->reset_gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> > > > - if (IS_ERR(imx_pcie->reset_gpiod))
> > > > - return dev_err_probe(dev, PTR_ERR(imx_pcie->reset_gpiod),
> > > > - "unable to get reset gpio\n");
> > > > - gpiod_set_consumer_name(imx_pcie->reset_gpiod, "PCIe reset");
> > > > + ret = imx_pcie_parse_ports(imx_pcie);
> > > > + if (ret) {
> > > > + if (ret != -ENOENT)
> > > > + return dev_err_probe(dev, ret, "Failed to parse Root Port: %d\n", ret);
> > > > +
> > > > + /*
> > > > + * In the case of properties not populated in Root Port node,
> > > > + * fallback to the legacy method of parsing the Host Bridge
> > > > + * node. This is to maintain DT backwards compatibility.
> > > > + */
> > > > + ret = imx_pcie_parse_legacy_binding(imx_pcie);
> > > > + if (ret)
> > > > + return dev_err_probe(dev, ret, "Unable to get reset gpio: %d\n", ret);
> > > > + }
> > > > +
> > > > + ret = devm_add_action_or_reset(dev, imx_pcie_delete_ports, imx_pcie);
> > > > + if (ret)
> > > > + return ret;
> > >
> > > I'd prefer to do it in err labels.
> >
> > we just removed err label and module remove.
> >
>
> This driver is always built-in. So the only way 'struct dev' will get freed is
> when probe fails. The usual pattern within the host controller drivers is to use
> err label to do the cleanup not devm_add_action_or_reset() (there are some
> exceptions though).
>
> It just helps us to keep uniformity across the drivers.
Thanks, but err label is quite easy to make mistake. More and more function
support devm_*. I think if well design common API at pci-host-common.c,
goto can be avoid.
Frank
>
> - Mani
>
> --
> மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2026-02-04 15:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 1:56 [PATCH V3 00/10] pci-imx6: Add support for parsing the reset property in new Root Port binding Sherry Sun
2026-02-03 1:56 ` [PATCH V3 01/10] dt-bindings: PCI: fsl,imx6q-pcie: Add reset GPIO in Root Port node Sherry Sun
2026-02-03 1:56 ` [PATCH V3 02/10] PCI: imx6: Add support for parsing the reset property in new Root Port binding Sherry Sun
2026-02-03 13:08 ` Manivannan Sadhasivam
2026-02-03 17:43 ` Frank Li
2026-02-04 12:28 ` Manivannan Sadhasivam
2026-02-04 15:25 ` Frank Li [this message]
2026-02-05 5:11 ` Manivannan Sadhasivam
2026-02-04 6:33 ` Sherry Sun
2026-02-03 1:56 ` [PATCH V3 03/10] arm: dts: imx6qdl: Add Root Port node and PERST property Sherry Sun
2026-02-03 13:09 ` Manivannan Sadhasivam
2026-02-04 6:44 ` Sherry Sun
2026-02-04 12:33 ` Manivannan Sadhasivam
2026-02-04 15:21 ` Frank Li
2026-02-05 5:16 ` Manivannan Sadhasivam
2026-02-05 15:30 ` Frank Li
2026-02-03 1:56 ` [PATCH V3 04/10] arm: dts: imx6sx: " Sherry Sun
2026-02-03 1:56 ` [PATCH V3 05/10] arm: dts: imx7d: " Sherry Sun
2026-02-03 1:56 ` [PATCH V3 06/10] arm64: dts: imx8mm: " Sherry Sun
2026-02-03 1:56 ` [PATCH V3 07/10] arm64: dts: imx8mp: " Sherry Sun
2026-02-03 1:56 ` [PATCH V3 08/10] arm64: dts: imx8mq: " Sherry Sun
2026-02-03 1:56 ` [PATCH V3 09/10] arm64: dts: imx8dxl/qm/qxp: " Sherry Sun
2026-02-03 1:56 ` [PATCH V3 10/10] arm64: dts: imx95: " Sherry Sun
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=aYNk6C_W_oSFVqbH@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=hongxing.zhu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=l.stach@pengutronix.de \
--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=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sherry.sun@nxp.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