From: Bjorn Helgaas <helgaas@kernel.org>
To: Hans Zhang <18255117159@163.com>
Cc: bhelgaas@google.com, lpieralisi@kernel.org, kw@linux.com,
kwilczynski@kernel.org, mani@kernel.org,
ilpo.jarvinen@linux.intel.com, jingoohan1@gmail.com,
robh@kernel.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org,
Shawn Lin <shawn.lin@rock-chips.com>
Subject: Re: [PATCH v7 1/3] PCI: Add public pcie_valid_speed() for shared validation
Date: Thu, 11 Jun 2026 12:23:01 -0500 [thread overview]
Message-ID: <20260611172301.GA490724@bhelgaas> (raw)
In-Reply-To: <20260407130450.1489318-2-18255117159@163.com>
On Tue, Apr 07, 2026 at 09:04:48PM +0800, Hans Zhang wrote:
> Extract the PCIe speed validation logic from bwctrl.c's static
> pcie_valid_speed() into a public static inline function in pci.h.
>
> This allows consistent speed range checks (2.5GT/s to 64.0GT/s) across
> multiple drivers and functions, avoiding duplicate code and ensuring
> validation consistency as per PCIe specifications.
>
> Signed-off-by: Hans Zhang <18255117159@163.com>
> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Any objection, Ilpo?
It looks like 1/3 and 2/3 are pure moves, and the interesting part is
the use in dwc, which I'd like to be reviewed and applied by Mani.
> ---
> drivers/pci/pci.h | 5 +++++
> drivers/pci/pcie/bwctrl.c | 5 -----
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 4a14f88e543a..f0a082bfd6f1 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -606,6 +606,11 @@ void pci_bus_put(struct pci_bus *bus);
> (speed) == PCIE_SPEED_2_5GT ? 2500*8/10 : \
> 0)
>
> +static inline bool pcie_valid_speed(enum pci_bus_speed speed)
> +{
> + return (speed >= PCIE_SPEED_2_5GT) && (speed <= PCIE_SPEED_64_0GT);
> +}
> +
> static inline int pcie_dev_speed_mbps(enum pci_bus_speed speed)
> {
> switch (speed) {
> diff --git a/drivers/pci/pcie/bwctrl.c b/drivers/pci/pcie/bwctrl.c
> index c4c8d260bf96..ea82e326f164 100644
> --- a/drivers/pci/pcie/bwctrl.c
> +++ b/drivers/pci/pcie/bwctrl.c
> @@ -48,11 +48,6 @@ struct pcie_bwctrl_data {
> /* Prevent port removal during Link Speed changes. */
> static DECLARE_RWSEM(pcie_bwctrl_setspeed_rwsem);
>
> -static bool pcie_valid_speed(enum pci_bus_speed speed)
> -{
> - return (speed >= PCIE_SPEED_2_5GT) && (speed <= PCIE_SPEED_64_0GT);
> -}
> -
> static u16 pci_bus_speed2lnkctl2(enum pci_bus_speed speed)
> {
> static const u8 speed_conv[] = {
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-06-11 17:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 13:04 [PATCH v7 0/3] PCI: Refactor PCIe speed validation and conversion functions Hans Zhang
2026-04-07 13:04 ` [PATCH v7 1/3] PCI: Add public pcie_valid_speed() for shared validation Hans Zhang
2026-06-11 17:23 ` Bjorn Helgaas [this message]
2026-06-11 17:43 ` Ilpo Järvinen
2026-06-15 15:17 ` Hans Zhang
2026-06-19 15:33 ` Hans Zhang
2026-06-22 17:16 ` Bjorn Helgaas
2026-07-01 6:34 ` Hans Zhang
2026-04-07 13:04 ` [PATCH v7 2/3] PCI: Move pci_bus_speed2lnkctl2() to public header Hans Zhang
2026-06-11 17:23 ` Bjorn Helgaas
2026-04-07 13:04 ` [PATCH v7 3/3] PCI: dwc: Use common speed conversion function Hans Zhang
2026-06-11 17:55 ` Ilpo Järvinen
2026-06-15 15:17 ` Hans Zhang
2026-04-11 1:21 ` [PATCH v7 0/3] PCI: Refactor PCIe speed validation and conversion functions Hans Zhang
2026-05-07 14:47 ` Hans Zhang
2026-06-11 17:07 ` Hans Zhang
2026-07-15 8:10 ` Hans Zhang
2026-07-15 13:15 ` Manivannan Sadhasivam
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=20260611172301.GA490724@bhelgaas \
--to=helgaas@kernel.org \
--cc=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jingoohan1@gmail.com \
--cc=kw@linux.com \
--cc=kwilczynski@kernel.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=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
Powered by JetHome