From nobody Sun Apr 5 16:32:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEAAAC54EE9 for ; Sat, 17 Sep 2022 12:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbiIQMDR (ORCPT ); Sat, 17 Sep 2022 08:03:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbiIQMDM (ORCPT ); Sat, 17 Sep 2022 08:03:12 -0400 X-Greylist: delayed 6951 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 17 Sep 2022 05:03:10 PDT Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E12AA3054F for ; Sat, 17 Sep 2022 05:03:10 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 13F2192009C; Sat, 17 Sep 2022 14:03:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 0E49D92009B; Sat, 17 Sep 2022 13:03:10 +0100 (BST) Date: Sat, 17 Sep 2022 13:03:09 +0100 (BST) From: "Maciej W. Rozycki" To: Bjorn Helgaas cc: Stefan Roese , Jim Wilson , David Abdurachmanov , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/5] PCI: Consistently report presence of PCIe link registers In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Consistently with commit c8b303d0206b ("PCI: Remove PCIe Capability=20 version checks") only consider the PCI Express capability's Link Control=20 2, etc. registers present if the Link Control register is. Before said commit with PCI Express capability versions higher than one=20 all link registers used to be considered present, however starting from=20 said commit Link Control, etc. original registers are only considered=20 present in devices with links, but Link Control 2, etc. registers=20 continue being considered always present even though likewise they are=20 only present in devices with links. Fix the inconsistency then. Signed-off-by: Maciej W. Rozycki --- New change in v5. --- drivers/pci/access.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) linux-pcie-cap-has-lnkctl2.diff Index: linux-macro/drivers/pci/access.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-macro.orig/drivers/pci/access.c +++ linux-macro/drivers/pci/access.c @@ -350,6 +350,11 @@ bool pcie_cap_has_lnkctl(const struct pc type =3D=3D PCI_EXP_TYPE_PCIE_BRIDGE; } =20 +static inline bool pcie_cap_has_lnkctl2(const struct pci_dev *dev) +{ + return pcie_cap_has_lnkctl(dev) && pcie_cap_version(dev) > 1; +} + static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev) { return pcie_downstream_port(dev) && @@ -390,10 +395,11 @@ static bool pcie_capability_reg_implemen return pcie_cap_has_rtctl(dev); case PCI_EXP_DEVCAP2: case PCI_EXP_DEVCTL2: + return pcie_cap_version(dev) > 1; case PCI_EXP_LNKCAP2: case PCI_EXP_LNKCTL2: case PCI_EXP_LNKSTA2: - return pcie_cap_version(dev) > 1; + return pcie_cap_has_lnkctl2(dev); default: return false; }