From: Alex Elder <elder@riscstar.com>
To: sashiko-reviews@lists.linux.dev
Cc: robh@kernel.org, linux-pci@vger.kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v3 3/4] PCI: of: introduce of_pci_verify_node()
Date: Mon, 31 Aug 2026 21:42:46 -0500 [thread overview]
Message-ID: <cde3da8f-933a-41ef-b7b8-f78317ca2d67@riscstar.com> (raw)
In-Reply-To: <20260901012128.2AC6E1F000E9@smtp.kernel.org>
On 8/31/26 8:21 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The check in of_pci_verify_node() falsely flags compliant CardBus and PowerPC PCIe bridges as having an invalid device_type.
I was unfortunately not considering those types of bridges,
and don't have experience with (or access to) either.
In the devicetree code, of_bus_pci_match() does check for
device_type "pciex" but does not handle "cardbus" (at least,
not explicitly--the "default-flags" bus type might do the
right thing).
I would love to get some pointers from others on how to
do this correctly, but in any case I'll do a little more
research on this before I post version 4.
-Alex
> --
>
> commit 72a980b9469901bec37d04c04dd8de642179aa44
> Author: Alex Elder <elder@riscstar.com>
>
> PCI: of: introduce of_pci_verify_node()
>
> This commit introduces a runtime check to verify PCI devicetree nodes. It
> ensures that bridge devices have the "pci" device_type property and that
> endpoint devices do not.
>
>> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
>> index a51dff91b196d..1838a3109514c 100644
>> --- a/drivers/pci/of.c
>> +++ b/drivers/pci/of.c
>
> [ ... ]
>
>> @@ -1085,3 +1085,34 @@ int of_pci_get_equalization_presets(struct device *dev,
>> return 0;
>> }
>> EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
>> +
>> +/**
>> + * of_pci_verify_node - Sanity check some PCI device node properties
>> + * @pdev: The PCI device whose device node is checked
> [ ... ]
>> +void of_pci_verify_node(struct pci_dev *pdev)
>> +{
>> + struct device_node *np = pci_device_to_OF_node(pdev);
>> + bool device_is_bridge;
>> + bool device_type_pci;
>> +
>> + /* Nothing to check if there's no pre-existing devicetree node */
>> + if (!np)
>> + return;
>> +
>> + device_is_bridge = pci_is_bridge(pdev);
>> + device_type_pci = of_node_is_type(np, "pci");
>> +
>> + /* Bridges should have device type "pci"; endpoints should not */
>> + if (device_is_bridge == device_type_pci)
>> + return;
>> +
>> + dev_err(&pdev->dev, "PCI %s have \"pci\" device_type property\n",
>> + device_is_bridge ? "bridge should" : "endpoint should not");
>
> [Severity: Medium]
> Will this falsely flag compliant CardBus and PowerPC PCIe bridges as having an
> invalid device type?
>
> The check in of_pci_verify_node() expects all bridges to have a device type of
> exactly "pci". However, valid PCI bridges can legitimately use "cardbus" or
> "pciex" as their device_type property.
>
> When a PCI bridge with one of these valid types is added, the following call
> chain unconditionally triggers this error:
>
> pci_bus_add_device()
> of_pci_verify_node()
>
> This could emit a false dev_err() during boot on platforms using these
> standard bridges, which might alarm users by polluting the kernel logs.
>
>> +}
>
next prev parent reply other threads:[~2026-09-01 2:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 1:13 [PATCH v3 0/4] PCI: of: warn on bogus device_type property Alex Elder
2026-09-01 1:13 ` [PATCH v3 1/4] PCI: of: drop the reg_num argument to of_pci_set_address() Alex Elder
2026-09-01 1:16 ` sashiko-bot
2026-09-01 1:13 ` [PATCH v3 2/4] PCI: of: don't zero flags in of_pci_get_addr_flags() Alex Elder
2026-09-01 1:20 ` sashiko-bot
2026-09-01 2:42 ` Alex Elder
2026-09-01 1:13 ` [PATCH v3 3/4] PCI: of: introduce of_pci_verify_node() Alex Elder
2026-09-01 1:21 ` sashiko-bot
2026-09-01 2:42 ` Alex Elder [this message]
2026-09-01 17:32 ` Rob Herring
2026-09-02 12:54 ` Alex Elder
2026-09-01 6:11 ` Herve Codina
2026-09-01 1:13 ` [PATCH v3 4/4] of: address: kill of_node_is_pcie() Alex Elder
2026-09-01 1:18 ` sashiko-bot
2026-09-01 2:03 ` Alex Elder
2026-09-01 6:45 ` Herve Codina
2026-09-01 14:58 ` Alex Elder
2026-09-01 15:15 ` Herve Codina
2026-09-01 15:25 ` Alex Elder
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=cde3da8f-933a-41ef-b7b8-f78317ca2d67@riscstar.com \
--to=elder@riscstar.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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