Re: [PATCH v7 1/3] PCI: Add public pcie_valid_speed() for shared validation

From: Bjorn Helgaas

Date: Mon Jun 22 2026 - 13:17:00 EST


On Fri, Jun 19, 2026 at 11:33:11PM +0800, Hans Zhang wrote:
> On 6/15/26 23:17, Hans Zhang wrote:
> > On 6/12/26 01:23, Bjorn Helgaas wrote:
> > > 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@xxxxxxx>
> > > > Reviewed-by: Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>
> > >
> > > Acked-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> > >
> > > 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.
> >
> > Hi Mani,
> >
> > Gentle ping on this series. Please apply it when you have time. Thank
> > you very much!
>
> Hello Mani,
>
> May I check if there is still window to merge it into v7.2-RC1?

There is not. Unless there's some catastrophe the bits in pci/next
are what will be in v7.2-rc1 (I will update some merge commit logs,
but "git diff 40e92a5476e7 pci/next" should be empty).

> > > > ---
> > > >   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
> > > >
> >
>