From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Hans Zhang <18255117159@163.com>
Cc: bhelgaas@google.com, lpieralisi@kernel.org, kw@linux.com,
kwilczynski@kernel.org, mani@kernel.org, jingoohan1@gmail.com,
robh@kernel.org, linux-pci@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 2/3] PCI: Move pci_bus_speed2lnkctl2() to public header
Date: Tue, 7 Apr 2026 11:11:06 +0300 (EEST) [thread overview]
Message-ID: <d19c8a93-71ae-187d-4aa6-a22105edcde3@linux.intel.com> (raw)
In-Reply-To: <20260406104708.1218648-3-18255117159@163.com>
On Mon, 6 Apr 2026, Hans Zhang wrote:
> Move the static array-based pci_bus_speed2lnkctl2() function from
> bwctrl.c to pci.h as a public inline function.
>
> This provides efficient O(1) speed-to-LNKCTL2 value conversion using
> static array lookup, maintaining optimal performance while enabling
> code reuse by other PCIe drivers.
>
> Signed-off-by: Hans Zhang <18255117159@163.com>
> ---
> drivers/pci/pci.h | 17 +++++++++++++++++
> drivers/pci/pcie/bwctrl.c | 17 -----------------
> 2 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index f0a082bfd6f1..db91878a86ac 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -611,6 +611,23 @@ static inline bool pcie_valid_speed(enum pci_bus_speed speed)
> return (speed >= PCIE_SPEED_2_5GT) && (speed <= PCIE_SPEED_64_0GT);
> }
>
> +static inline u16 pci_bus_speed2lnkctl2(enum pci_bus_speed speed)
> +{
> + static const u8 speed_conv[] = {
> + [PCIE_SPEED_2_5GT] = PCI_EXP_LNKCTL2_TLS_2_5GT,
> + [PCIE_SPEED_5_0GT] = PCI_EXP_LNKCTL2_TLS_5_0GT,
> + [PCIE_SPEED_8_0GT] = PCI_EXP_LNKCTL2_TLS_8_0GT,
> + [PCIE_SPEED_16_0GT] = PCI_EXP_LNKCTL2_TLS_16_0GT,
> + [PCIE_SPEED_32_0GT] = PCI_EXP_LNKCTL2_TLS_32_0GT,
> + [PCIE_SPEED_64_0GT] = PCI_EXP_LNKCTL2_TLS_64_0GT,
> + };
> +
> + if (WARN_ON_ONCE(!pcie_valid_speed(speed)))
drivers/pci/pci.h doesn't seem to have include for WARN_ON_ONCE() so you
should add it.
--
i.
next prev parent reply other threads:[~2026-04-07 8:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-06 10:47 [PATCH v5 0/3] PCI: Refactor PCIe speed validation and conversion functions Hans Zhang
2026-04-06 10:47 ` [PATCH v5 1/3] PCI: Add public pcie_valid_speed() for shared validation Hans Zhang
2026-04-06 10:47 ` [PATCH v5 2/3] PCI: Move pci_bus_speed2lnkctl2() to public header Hans Zhang
2026-04-07 8:11 ` Ilpo Järvinen [this message]
2026-04-07 12:09 ` Hans Zhang
2026-04-07 12:26 ` Ilpo Järvinen
2026-04-07 12:29 ` Hans Zhang
2026-04-07 12:48 ` Hans Zhang
2026-04-07 12:53 ` Ilpo Järvinen
2026-04-07 13:01 ` Hans Zhang
2026-04-06 10:47 ` [PATCH v5 3/3] PCI: dwc: Use common speed conversion function Hans Zhang
2026-04-06 10:54 ` Hans Zhang
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=d19c8a93-71ae-187d-4aa6-a22105edcde3@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=18255117159@163.com \
--cc=bhelgaas@google.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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.