From: Hans Zhang <18255117159@163.com>
To: bhelgaas@google.com, lpieralisi@kernel.org, kw@linux.com,
kwilczynski@kernel.org, mani@kernel.org,
ilpo.jarvinen@linux.intel.com, jingoohan1@gmail.com
Cc: robh@kernel.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, Hans Zhang <18255117159@163.com>
Subject: [PATCH v2 1/3] PCI: Add PCIE_SPEED2LNKCTL2_TLS conversion macro
Date: Sat, 7 Jun 2025 23:55:43 +0800 [thread overview]
Message-ID: <20250607155545.806496-2-18255117159@163.com> (raw)
In-Reply-To: <20250607155545.806496-1-18255117159@163.com>
Introduce PCIE_SPEED2LNKCTL2_TLS() macro to standardize the conversion
between PCIe speed enumerations and LNKCTL2_TLS register values. This
centralizes speed-to-register mapping logic, eliminating duplicated
conversion code across multiple drivers.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/pci.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 12215ee72afb..b5a3ce6c239b 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -419,6 +419,15 @@ void pci_bus_put(struct pci_bus *bus);
(lnkctl2) == PCI_EXP_LNKCTL2_TLS_2_5GT ? PCIE_SPEED_2_5GT : \
PCI_SPEED_UNKNOWN)
+#define PCIE_SPEED2LNKCTL2_TLS(speed) \
+ ((speed) == PCIE_SPEED_2_5GT ? PCI_EXP_LNKCTL2_TLS_2_5GT : \
+ (speed) == PCIE_SPEED_5_0GT ? PCI_EXP_LNKCTL2_TLS_5_0GT : \
+ (speed) == PCIE_SPEED_8_0GT ? PCI_EXP_LNKCTL2_TLS_8_0GT : \
+ (speed) == PCIE_SPEED_16_0GT ? PCI_EXP_LNKCTL2_TLS_16_0GT : \
+ (speed) == PCIE_SPEED_32_0GT ? PCI_EXP_LNKCTL2_TLS_32_0GT : \
+ (speed) == PCIE_SPEED_64_0GT ? PCI_EXP_LNKCTL2_TLS_64_0GT : \
+ 0)
+
/* PCIe speed to Mb/s reduced by encoding overhead */
#define PCIE_SPEED2MBS_ENC(speed) \
((speed) == PCIE_SPEED_64_0GT ? 64000*1/1 : \
--
2.25.1
next prev parent reply other threads:[~2025-06-07 15:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-07 15:55 [PATCH v2 0/3] PCIe: Refactor link speed configuration with unified macro Hans Zhang
2025-06-07 15:55 ` Hans Zhang [this message]
2025-06-07 15:55 ` [PATCH v2 2/3] PCI: dwc: Simplify link speed configuration with macro Hans Zhang
2025-06-07 15:55 ` [PATCH v2 3/3] PCI/bwctrl: Replace legacy speed conversion with shared macro Hans Zhang
2025-06-19 13:26 ` [PATCH v2 0/3] PCIe: Refactor link speed configuration with unified macro Manivannan Sadhasivam
2025-06-24 15:13 ` 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=20250607155545.806496-2-18255117159@163.com \
--to=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 \
/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