From: Bjorn Helgaas <helgaas@kernel.org>
To: Sherry Sun <sherry.sun@nxp.com>
Cc: "robh@kernel.org" <robh@kernel.org>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
Frank Li <frank.li@nxp.com>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"kernel@pengutronix.de" <kernel@pengutronix.de>,
"festevam@gmail.com" <festevam@gmail.com>,
"lpieralisi@kernel.org" <lpieralisi@kernel.org>,
"kwilczynski@kernel.org" <kwilczynski@kernel.org>,
"mani@kernel.org" <mani@kernel.org>,
"bhelgaas@google.com" <bhelgaas@google.com>,
Hongxing Zhu <hongxing.zhu@nxp.com>,
"l.stach@pengutronix.de" <l.stach@pengutronix.de>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V14 02/12] PCI: host-generic: Add common helpers for parsing Root Port properties
Date: Mon, 18 May 2026 17:37:58 -0500 [thread overview]
Message-ID: <20260518223758.GA649325@bhelgaas> (raw)
In-Reply-To: <VI0PR04MB1211452312EB9BC6EF1ED2E0192032@VI0PR04MB12114.eurprd04.prod.outlook.com>
On Mon, May 18, 2026 at 08:42:38AM +0000, Sherry Sun wrote:
> > Subject: Re: [PATCH V14 02/12] PCI: host-generic: Add common helpers for
> > parsing Root Port properties
> >
> > On Wed, Apr 22, 2026 at 05:35:39PM +0800, Sherry Sun wrote:
> > > Introduce generic helper functions to parse Root Port device tree
> > > nodes and extract common properties like reset GPIOs. This allows
> > > multiple PCI host controller drivers to share the same parsing logic.
> > >
> > > Define struct pci_host_port to hold common Root Port properties
> > > (currently only list of PERST# GPIO descriptors) and add
> > > pci_host_common_parse_ports() to parse Root Port nodes from device
> > tree.
> > >
> > > Also add the 'ports' list to struct pci_host_bridge for better
> > > maintain parsed Root Port information.
> > > ...
> >
> > > +static int pci_host_common_parse_port(struct device *dev,
> > > + struct pci_host_bridge *bridge,
> > > + struct device_node *node)
> > > +{
> > > + struct pci_host_port *port;
> > > + int ret;
> > > +
> > > + port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> > > + if (!port)
> > > + return -ENOMEM;
> > > +
> > > + INIT_LIST_HEAD(&port->perst);
> > > +
> > > + ret = pci_host_common_parse_perst(dev, port, node);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + /*
> > > + * 1. PERST# found in RP or its child nodes - list is not empty, continue
> > > + * 2. PERST# not found in RP/children, but found in RC node - return -
> > ENODEV
> > > + * to fallback legacy binding
> > > + * 3. PERST# not found anywhere - list is empty, continue (optional
> > PERST#)
> > > + */
> > > + if (list_empty(&port->perst)) {
> > > + if (of_property_present(dev->of_node, "reset-gpios") ||
> > > + of_property_present(dev->of_node, "reset-gpio"))
> > > + return -ENODEV;
> >
> > This doesn't seem right to me. The parser of per-Root Port properties should
> > not be responsible for deciding whether legacy methods are valid, i.e.,
> > whether a property is in the Root Complex node. I think it's up to the caller
> > to decide whether it needs to look elsewhere.
> >
> > I don't think this even needs to return a "success/failure" value because there
> > may be more properties in the future, and not all will be required. This
> > function can't tell which properties a specific driver requires and which are
> > optional.
> >
> > The caller can check whether we found what it needs and fall back to a legacy
> > method as needed.
>
> Hi Bjorn,
> The code here was suggested by Mani, https://lore.kernel.org/all/lnzprzrdwra7pn7d6m3sbj5pvjy64blwpjl6i3lmlnfbyho63b@czpyhpgz5vum/.
> I think your suggestion here is reasonable, the per-Root Port parser shouldn't
> check the RC-level binding. That's a policy decision that belongs to the caller.
>
> Hi Mani, if you also agree, I'll rework this so that:
> 1. pci_host_common_parse_port() only parses properties from the Root Port
> (and its children) without checking the RC node.
> 2. The function won't return failure for "property not found" - it will only return
> errors for real failures (e.g., -ENOMEM, GPIO acquisition errors).
> 3. The legacy fallback logic will be moved to the caller, which can inspect the
> parsed result and decide whether to fall back to the legacy binding.
This is only used for imx6 so far, so I think this is OK as-is for
v7.2. We can file this under "possible future rework or kernel
mentee project."
next prev parent reply other threads:[~2026-05-18 22:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 9:35 [PATCH V14 00/12] pci-imx6: Add support for parsing the reset property in new Root Port binding Sherry Sun
2026-04-22 9:35 ` [PATCH V14 01/12] dt-bindings: PCI: fsl,imx6q-pcie: Add reset GPIO in Root Port node Sherry Sun
2026-04-22 9:35 ` [PATCH V14 02/12] PCI: host-generic: Add common helpers for parsing Root Port properties Sherry Sun
2026-05-13 22:49 ` Bjorn Helgaas
2026-05-18 8:42 ` Sherry Sun
2026-05-18 22:37 ` Bjorn Helgaas [this message]
2026-05-19 5:52 ` mani
2026-05-19 6:07 ` Sherry Sun (OSS)
2026-04-22 9:35 ` [PATCH V14 03/12] PCI: imx6: Assert PERST# before enabling regulators Sherry Sun
2026-05-08 3:15 ` Hongxing Zhu
2026-04-22 9:35 ` [PATCH V14 04/12] PCI: imx6: Add support for parsing the reset property in new Root Port binding Sherry Sun
2026-05-08 3:15 ` Hongxing Zhu
2026-04-22 9:35 ` [PATCH V14 05/12] arm: dts: imx6qdl: Add Root Port node and PERST property Sherry Sun
2026-04-22 9:35 ` [PATCH V14 06/12] arm: dts: imx6sx: " Sherry Sun
2026-04-22 9:35 ` [PATCH V14 07/12] arm: dts: imx7d: " Sherry Sun
2026-04-22 9:35 ` [PATCH V14 08/12] arm64: dts: imx8mm: " Sherry Sun
2026-04-22 9:35 ` [PATCH V14 09/12] arm64: dts: imx8mp: " Sherry Sun
2026-04-22 9:35 ` [PATCH V14 10/12] arm64: dts: imx8mq: " Sherry Sun
2026-04-22 9:35 ` [PATCH V14 11/12] arm64: dts: imx8dxl/qm/qxp: " Sherry Sun
2026-04-22 9:35 ` [PATCH V14 12/12] arm64: dts: imx95: " Sherry Sun
2026-05-12 12:55 ` (subset) [PATCH V14 00/12] pci-imx6: Add support for parsing the reset property in new Root Port binding Manivannan Sadhasivam
2026-05-13 2:01 ` Sherry Sun
2026-05-13 18:56 ` Frank Li
2026-06-01 15:11 ` Frank.Li
2026-06-01 15:19 ` Frank.Li
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=20260518223758.GA649325@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=frank.li@nxp.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