From nobody Tue Apr 7 07:09:04 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8AA154723; Sun, 15 Mar 2026 16:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773590482; cv=none; b=ZS1fPq5rkYdSqoRCiy19cdJRjTWM4e8/j36zNmFbnUz0ZmkuAXQv9EM4WmbBrIIWDy9OTuLxYQqlsPvGQXTd3ISs8Kp3Cpa1Cz0sPwczM2tTQB1hwqiuHZZmltqn0KjVqh2+6BOaZMOK5ssKNpuFXy3V5LS9izllH15HfKnyDsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773590482; c=relaxed/simple; bh=Y1AnyHAav22SAFmbJKuI/jxkQ4wST/gYkY58BOqFr9U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bQVEfkcuJd6QyHhbgbAAWIOadfKaEklUm3FgUvx0B4Wu4A8ajQlQsctIzQaCe9GI5vPYFdLS7pXVWjSzrUCBuXli1XOA2QshPRVXWONrqMDJZ89yyiEbAZfENhg3CZyzgyOGo1lwOGdGOmbqCGpfxTW9vJfFlcqRMABIDsaIpP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=d40Vtyg9; arc=none smtp.client-ip=220.197.31.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="d40Vtyg9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=sH WBBMxa5mGbfFmcKFkPPyvdgyTCIlj6ndt/oqs2vgo=; b=d40Vtyg9GXLCVwnFHv tuKIHYJu0GAF7Ao9Wy/fJsw3BXxQ6tcenIw1q7w9fnx77wTgQr14HWjjiZ2PMrKx 4QGMYnqsHRBI6zKe5i81O8j+eaP3+JTTBsnVdlf/B7KtYvMqK4/7AXIZg+KNCeoh IhTZVqmhl5xfJamwt5eyzS4xU= Received: from zhb.. (unknown []) by gzga-smtp-mtada-g1-2 (Coremail) with SMTP id _____wBHvwy817ZpjnSYBA--.30374S3; Mon, 16 Mar 2026 00:01:02 +0800 (CST) From: Hans Zhang <18255117159@163.com> To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Zhang <18255117159@163.com> Subject: [PATCH v1 1/3] PCI: Move to_pcie_link_speed() to probe.c and export it Date: Mon, 16 Mar 2026 00:00:55 +0800 Message-Id: <20260315160057.127639-2-18255117159@163.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260315160057.127639-1-18255117159@163.com> References: <20260315160057.127639-1-18255117159@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wBHvwy817ZpjnSYBA--.30374S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7CrWkAryrCFy3KFWfCFWkCrg_yoW8tFW7pa 9rCa10yr18JF15Zr4jv3W5Zry5Xanxu3y2krWxCa4kZFy7AF93XFyaqF43Ar9ayrZrZFy3 A3WayryUC3W7AF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piU5rsUUUUU= X-CM-SenderInfo: rpryjkyvrrlimvzbiqqrwthudrp/xtbCxB8t0Gm217-RnAAA3c Content-Type: text/plain; charset="utf-8" Move the static helper function to_pcie_link_speed() from pci.c to probe.c and export it. This function converts a PCIe link status register value to the corresponding pci_bus_speed enum. Exporting it allows other parts of the PCI subsystem (e.g., sysfs and inline helpers) to use this helper instead of directly accessing the pcie_link_speed array, preparing for better encapsulation. Signed-off-by: Hans Zhang <18255117159@163.com> --- drivers/pci/pci.c | 5 ----- drivers/pci/probe.c | 6 ++++++ include/linux/pci.h | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8479c2e1f74f..b93693575573 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5886,11 +5886,6 @@ int pcie_set_mps(struct pci_dev *dev, int mps) } EXPORT_SYMBOL(pcie_set_mps); =20 -static enum pci_bus_speed to_pcie_link_speed(u16 lnksta) -{ - return pcie_link_speed[FIELD_GET(PCI_EXP_LNKSTA_CLS, lnksta)]; -} - int pcie_link_speed_mbps(struct pci_dev *pdev) { u16 lnksta; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index f85da50a3d83..40f2185ac3b5 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -799,6 +799,12 @@ unsigned char pcie_get_link_speed(unsigned int speed) } EXPORT_SYMBOL_GPL(pcie_get_link_speed); =20 +enum pci_bus_speed to_pcie_link_speed(u16 lnksta) +{ + return pcie_link_speed[FIELD_GET(PCI_EXP_LNKSTA_CLS, lnksta)]; +} +EXPORT_SYMBOL_GPL(to_pcie_link_speed); + const char *pci_speed_string(enum pci_bus_speed speed) { /* Indexed by the pci_bus_speed enum */ diff --git a/include/linux/pci.h b/include/linux/pci.h index 1c270f1d5123..751a2b2ba04c 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1459,6 +1459,7 @@ int pcie_set_mps(struct pci_dev *dev, int mps); u32 pcie_bandwidth_available(struct pci_dev *dev, struct pci_dev **limitin= g_dev, enum pci_bus_speed *speed, enum pcie_link_width *width); +enum pci_bus_speed to_pcie_link_speed(u16 lnksta); int pcie_link_speed_mbps(struct pci_dev *pdev); void pcie_print_link_status(struct pci_dev *dev); int pcie_reset_flr(struct pci_dev *dev, bool probe); --=20 2.34.1 From nobody Tue Apr 7 07:09:04 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C6C1361645; Sun, 15 Mar 2026 16:01:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773590475; cv=none; b=jzgMLU4KtdEjOlcbsyGdUel5+YALtIzCQhHjajVGT2lyxnZKiUUFxCOwNoBGsHIHCVkHcLkRUJNMvD42BI5/ZYEYJalDMaA30L/GLEFb9SUWVWX8fsuuFDLedBJ9l2czDLqx3umDQmF9sO4ixZXpWHn1AJDCgJ3ppH6kWDcVjfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773590475; c=relaxed/simple; bh=uO4av075UJqjg2cyXbeqJsA9Pn8zoxM+MYfcLyvbGKI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AhmzmEVF7XQfHYT5ll3Mx21J7ksR66LAPzCLc6qsWArC12I2w/4Q2LJ/GBClxIIZrgQ00j/eyx3tUPRzXVwvqG2S1Du3IPKiwA9qJZ62ttGUpzsNtQVNYmmuI8Il/P0se4JsollnAmQ8NypI2S3M7Tf2bKWXa1D+jUuX84dn09E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=HYWPuGJm; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="HYWPuGJm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=kU x//bqMg4zEGGoKB97V8gg16VmSVOusKeTn74iwfEQ=; b=HYWPuGJmTKpOUYasye hEG+UHLd04VV4fGQOFoq714+xXs5vVzLrFemPu+jEzNyCOjqCIOil3WZx4kEYBDP FMwz1SKH6TnR6R/VYAfIe976TLD38cBHdIxJpiTR+GpsQVP4yuYSQqwdysBbvMFf aq4NLdlbjDHHpnwycEXL3RaOA= Received: from zhb.. (unknown []) by gzga-smtp-mtada-g1-2 (Coremail) with SMTP id _____wBHvwy817ZpjnSYBA--.30374S4; Mon, 16 Mar 2026 00:01:03 +0800 (CST) From: Hans Zhang <18255117159@163.com> To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Zhang <18255117159@163.com> Subject: [PATCH v1 2/3] PCI: Use to_pcie_link_speed() for link speed conversion Date: Mon, 16 Mar 2026 00:00:56 +0800 Message-Id: <20260315160057.127639-3-18255117159@163.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260315160057.127639-1-18255117159@163.com> References: <20260315160057.127639-1-18255117159@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wBHvwy817ZpjnSYBA--.30374S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ww4fJr17WF1DXryUGw4xtFb_yoW8Xr45pa yUAw15Ar18Jw15Xrs5Z3WDWFy5X3ZakrWjkrZ3Was3XF47CrZ3Xa4Sq3yfJrySvrWDury7 AF1akrnxAFW8JF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zKhF4OUUUUU= X-CM-SenderInfo: rpryjkyvrrlimvzbiqqrwthudrp/xtbC6x8t0Gm217-foAAA3B Content-Type: text/plain; charset="utf-8" Replace direct array indexing with the to_pcie_link_speed() helper in both the sysfs current_link_speed_show() function and the inline helper __pcie_update_link_speed() in pci.h. This unifies link speed conversion and prepares for hiding the pcie_link_speed array. Signed-off-by: Hans Zhang <18255117159@163.com> --- drivers/pci/pci-sysfs.c | 2 +- drivers/pci/pci.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 16eaaf749ba9..c4231f3de5a6 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -235,7 +235,7 @@ static ssize_t current_link_speed_show(struct device *d= ev, if (err) return -EINVAL; =20 - speed =3D pcie_link_speed[linkstat & PCI_EXP_LNKSTA_CLS]; + speed =3D to_pcie_link_speed(linkstat); =20 return sysfs_emit(buf, "%s\n", pci_speed_string(speed)); } diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 409aca7d737a..053fc245a1e3 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -645,7 +645,7 @@ static inline void __pcie_update_link_speed(struct pci_= bus *bus, enum pcie_link_change_reason reason, u16 linksta, u16 linksta2) { - bus->cur_bus_speed =3D pcie_link_speed[linksta & PCI_EXP_LNKSTA_CLS]; + bus->cur_bus_speed =3D to_pcie_link_speed(linksta); bus->flit_mode =3D (linksta2 & PCI_EXP_LNKSTA2_FLIT) ? 1 : 0; =20 trace_pcie_link_event(bus, --=20 2.34.1 From nobody Tue Apr 7 07:09:04 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8FB31A3164; Sun, 15 Mar 2026 16:01:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773590485; cv=none; b=tnW4RKWwfHc5AAmLs94Kwnk11VJbqG8Tg6yhFXU46SDAYYa9euo5qdZC4QX+KwnSKaoWh+z65yPaDcmQjmMkP30OWWSvpkRkKVni4axFVnLA8Mk4oysCMyvOKiVSqvT8oj28FrmeSPXi8gjTBldmUNiEMSNouiQ7Y0UaHAJ9c34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773590485; c=relaxed/simple; bh=BBAj8aXqsxx6BNbIlyPstA2pBqCAYUj/Hq+asA2/ZCc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O2lbLCFHZkmavAcbEBzPoeJd8DVmp+T7sO1AVnSSNhkNxxiJXt7LlIeNhYj5SDuJ0Zfi20RHx68/HatOa81Fm1wvBcfiNi87u6olV+GpxLU/jF++VoE0FXxkJ3SOQKdDbMV9hoL8wLs8CEjKbvZC//Bxe03s+5aZ1xNhQx+cHac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=E1BxutK2; arc=none smtp.client-ip=117.135.210.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="E1BxutK2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=qu It4kRS+73uCd8RPqf14tOszi62vvOEJnAaqSyEPvE=; b=E1BxutK2ynYVG0g38s 6Px4ugkRan4ocwQaOQcQixCJOeRxNmNXd978NQYDivTxg/XZ8dfV5NKHZT7+lFp+ 0GcgwvpH/ScjUH5rKKMj1bTmcLMcrwUTSKX5xf6nQahh18ORYVe/MUF/R1npCUac qs6Eqynx+JYaWFFjBsECqR4y4= Received: from zhb.. (unknown []) by gzga-smtp-mtada-g1-2 (Coremail) with SMTP id _____wBHvwy817ZpjnSYBA--.30374S5; Mon, 16 Mar 2026 00:01:03 +0800 (CST) From: Hans Zhang <18255117159@163.com> To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Zhang <18255117159@163.com> Subject: [PATCH v1 3/3] PCI: Remove extern declaration of pcie_link_speed array Date: Mon, 16 Mar 2026 00:00:57 +0800 Message-Id: <20260315160057.127639-4-18255117159@163.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260315160057.127639-1-18255117159@163.com> References: <20260315160057.127639-1-18255117159@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wBHvwy817ZpjnSYBA--.30374S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7GFW7JF17Ww45GFykJry8AFb_yoW8JF15pa 9rGr10yr1FqF15WrZxZa48uFy5J3ZxCFWUKrW7W39xZFyayFy3X34a9ayfJrnIyrs29rW5 XFnxtryjk3W3tr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziYZXcUUUUU= X-CM-SenderInfo: rpryjkyvrrlimvzbiqqrwthudrp/xtbC7B8t0Gm217-dzAAA3o Content-Type: text/plain; charset="utf-8" With all users of pcie_link_speed converted to use to_pcie_link_speed(), the external declaration in pci.h is no longer needed. Remove it to prevent new code from directly accessing the array and to reduce the global symbol footprint. Signed-off-by: Hans Zhang <18255117159@163.com> --- drivers/pci/pci.h | 1 - drivers/pci/probe.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 053fc245a1e3..b2f91409b439 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -107,7 +107,6 @@ struct pcie_tlp_log; #define PCI_EXP_AER_FLAGS (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \ PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE) =20 -extern const unsigned char pcie_link_speed[]; unsigned char pcie_get_link_speed(unsigned int speed); =20 extern bool pci_early_dump; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 40f2185ac3b5..0c93eff80b71 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -781,7 +781,6 @@ const unsigned char pcie_link_speed[] =3D { PCI_SPEED_UNKNOWN, /* E */ PCI_SPEED_UNKNOWN /* F */ }; -EXPORT_SYMBOL_GPL(pcie_link_speed); =20 /** * pcie_get_link_speed - Get speed value from PCIe generation number --=20 2.34.1