From: Hans Zhang <18255117159@163.com>
To: Shawn Lin <shawn.lin@rock-chips.com>,
lpieralisi@kernel.org, jingoohan1@gmail.com, mani@kernel.org,
kwilczynski@kernel.org, bhelgaas@google.com, helgaas@kernel.org,
florian.fainelli@broadcom.com, jim2101024@gmail.com
Cc: robh@kernel.org, ilpo.jarvinen@linux.intel.com,
linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-renesas-soc@vger.kernel.org,
claudiu.beznea.uj@bp.renesas.com,
linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,
linux-omap@vger.kernel.org,
bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 5/5] PCI: of: Remove max-link-speed generation validation
Date: Sat, 14 Mar 2026 00:55:05 +0800 [thread overview]
Message-ID: <f7e6c82e-5300-447a-b007-917ea0a5b6f2@163.com> (raw)
In-Reply-To: <44e74dff-c321-7cfe-e304-a21644ac7787@rock-chips.com>
On 2026/3/13 15:04, Shawn Lin wrote:
> Hi Hans
>
> 在 2026/03/13 星期五 0:36, Hans Zhang 写道:
>> The of_pci_get_max_link_speed() function currently validates the
>> "max-link-speed" DT property to be in the range 1..4 (Gen1..Gen4).
>> This imposes a maintenance burden because each new PCIe generation
>> would require updating this validation.
>>
>> Remove the range check so the function returns the raw property value
>> (or a negative error code if the property is missing or malformed).
>> Callers must now validate the returned speed against the range they
>> support. A subsequent patch adds such validation to the DWC driver,
>> which is the primary user of this function.
>>
>> Removing the validation from this common function allows future PCIe
>> generations to be supported without modifying drivers/pci/of.c.
>>
>> Signed-off-by: Hans Zhang <18255117159@163.com>
>> ---
>> drivers/pci/of.c | 12 +++++++-----
>> 1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
>> index 9f8eb5df279e..fbb779a94202 100644
>> --- a/drivers/pci/of.c
>> +++ b/drivers/pci/of.c
>> @@ -875,8 +875,9 @@ EXPORT_SYMBOL_GPL(of_pci_supply_present);
>> * of_pci_get_max_link_speed - Find the maximum link speed of the
>> given device node.
>> * @node: Device tree node with the maximum link speed information.
>> *
>> - * This function will try to find the limitation of link speed by
>> finding
>> - * a property called "max-link-speed" of the given device node.
>> + * This function will try to read the "max-link-speed" property of
>> the given
>> + * device tree node. It does NOT validate the value of the property
>> (e.g.,
>> + * range checks for PCIe generations).
>> *
>> * Return:
>> * * > 0 - On success, a maximum link speed.
>
> Thanks for the patch. However, after applying it, I noticed this part
> still seems off. There is a detailed comment in the file saying this
> function checks if the max-link-speed is invalid, just a few lines below
> your change. Could you please take another look at that comment and
> adjust them?
Hi Shawn,
Thanks. Will change.
Best regards,
Hans
>
>> @@ -889,10 +890,11 @@ EXPORT_SYMBOL_GPL(of_pci_supply_present);
>> int of_pci_get_max_link_speed(struct device_node *node)
>> {
>> u32 max_link_speed;
>> + int ret;
>> - if (of_property_read_u32(node, "max-link-speed", &max_link_speed) ||
>> - max_link_speed == 0 || max_link_speed > 4)
>> - return -EINVAL;
>> + ret = of_property_read_u32(node, "max-link-speed", &max_link_speed);
>> + if (ret)
>> + return ret;
>> return max_link_speed;
>> }
>>
prev parent reply other threads:[~2026-03-13 16:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 16:36 [PATCH v8 0/5] " Hans Zhang
2026-03-12 16:36 ` [PATCH v8 1/5] PCI: Add pcie_get_link_speed() helper for safe array access Hans Zhang
2026-03-13 18:18 ` kernel test robot
2026-03-13 23:19 ` kernel test robot
2026-03-12 16:36 ` [PATCH v8 2/5] PCI: dwc: Use " Hans Zhang
2026-03-12 16:36 ` [PATCH v8 3/5] PCI: j721e: Validate max-link-speed from DT Hans Zhang
2026-03-12 16:36 ` [PATCH v8 4/5] PCI: controller: Validate max-link-speed Hans Zhang
2026-03-12 17:06 ` Florian Fainelli
2026-03-12 16:36 ` [PATCH v8 5/5] PCI: of: Remove max-link-speed generation validation Hans Zhang
2026-03-13 7:04 ` Shawn Lin
2026-03-13 16:55 ` Hans Zhang [this message]
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=f7e6c82e-5300-447a-b007-917ea0a5b6f2@163.com \
--to=18255117159@163.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhelgaas@google.com \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=florian.fainelli@broadcom.com \
--cc=helgaas@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jim2101024@gmail.com \
--cc=jingoohan1@gmail.com \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=shawn.lin@rock-chips.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
all inboxes | Powered by JetHome®