From patchwork Wed Feb 20 01:20:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alex G." X-Patchwork-Id: 10820989 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38B496CB for ; Wed, 20 Feb 2019 01:20:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20C902CFCD for ; Wed, 20 Feb 2019 01:20:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 143D82C165; Wed, 20 Feb 2019 01:20:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 902F42C165 for ; Wed, 20 Feb 2019 01:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726286AbfBTBUw (ORCPT ); Tue, 19 Feb 2019 20:20:52 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:33156 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726214AbfBTBUv (ORCPT ); Tue, 19 Feb 2019 20:20:51 -0500 Received: by mail-ot1-f66.google.com with SMTP id i20so37573890otl.0; Tue, 19 Feb 2019 17:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0csvRJO9q2/FaX/o0eEuWXuIPQ1fh/fIC0tbNVmVNFY=; b=vX4S0FZEiZ6zhRlOjEZNXfZ7KpkNT2TAXtdAYVwhS5CLiFK0gDnMguL6fT6pkt+EeW +VqkzSm1taxY8ev+qPvjrFH6yf6xSnRYjrBwpvif3wz+GTHqyfA99hD1AQAri6vTqdEX AqEYUaaSgdTk9rtbLz4kgIIULSEBrrKmwZEYP7b6nBxsA72DtW26qArpLeLgoHlr6qIO syU/uaYmXEIpH2XAuJ946sE4e8yZsl6c/GrvF4wz/Ka1OD59qlRLh75n+qyFX9r0X6vF yII5QXryk3F2xREfz2136R34wuR4Ko7/OuYNNExMMCO0qTjB2Z3vbEOl99RPO6crsvVF Ohsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0csvRJO9q2/FaX/o0eEuWXuIPQ1fh/fIC0tbNVmVNFY=; b=RzOQgIDNSdeTTctD0VUVbr51PJAT3IAC2nBG8WPCwJ8Mm27mAxgfnZloz9JEoYAjb5 9H9CRB7PrOab+tsf/da6b8Ll6/EeikfexVuIrs1pcDUoYPWBK/ZuWG1FQ/Wy5dp79fbE 56F5JRG7lETcdmQ7NKsBQHOQLEtm70BXlEzKDULM8W4hX27S1UVgoZs59HoZzeX3WCmc bJXUbQmYMz+TKxTkiekYmV6cl+LMXdg0PRXYIUgoK2+lCMP+IpPirJnGoFhIovdy9eEc 7rAJD4zaRHqs69VNw8EsnmkAG80g6wzQsAhHllMsKKKlZsFtSDIPLjxzeIvcRu/nfo9u odlA== X-Gm-Message-State: AHQUAuYOkiFRQXHDOYD7R/xrXstVZAkN6uSLnRkAVup4gvsqCEnx6E2q Td/B6HjMnUVbpqxNH7X42W0= X-Google-Smtp-Source: AHgI3IZU08WTMWIwwZlfeWAm3wMV40RmxOr3ER9crN5MJvmKZ+s34D9tS5Vz86uJJ3Dy2lOYqodjLg== X-Received: by 2002:aca:4d3:: with SMTP id 202mr4217306oie.31.1550625650495; Tue, 19 Feb 2019 17:20:50 -0800 (PST) Received: from nuclearis2-1.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id d67sm8000424oig.36.2019.02.19.17.20.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Feb 2019 17:20:50 -0800 (PST) From: Alexandru Gagniuc To: bhelgaas@google.com Cc: austin_bolen@dell.com, alex_gagniuc@dellteam.com, keith.busch@intel.com, Shyam_Iyer@Dell.com, lukas@wunner.de, okaya@kernel.org, linux-pci@vger.kernel.org, Alexandru Gagniuc , "Rafael J. Wysocki" , Andy Shevchenko , Mika Westerberg , Oza Pawandeep , linux-kernel@vger.kernel.org Subject: [PATCH RFC v2 1/4] PCI: hotplug: Add support for disabling in-band presence Date: Tue, 19 Feb 2019 19:20:27 -0600 Message-Id: <20190220012031.10741-2-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190220012031.10741-1-mr.nuke.me@gmail.com> References: <20190220012031.10741-1-mr.nuke.me@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The presence detect state (PDS) is normally a logical or of in-band and out-of-band presence. In PCIe 4.0, there is the option to disable in-band presence so that the PDS bit always reflects the state of the out-of-band presence. The recommendation of the PCIe spec is to disable in-band presence whenever supported. Signed-off-by: Alexandru Gagniuc --- drivers/pci/hotplug/pciehp.h | 1 + drivers/pci/hotplug/pciehp_hpc.c | 12 +++++++++++- include/linux/pci.h | 1 + include/uapi/linux/pci_regs.h | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 506e1d923a1f..6f729ce4a7b9 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -98,6 +98,7 @@ struct controller { struct pcie_device *pcie; u32 slot_cap; /* capabilities and quirks */ + unsigned int inband_presence_disabled:1; u16 slot_ctrl; /* control register access */ struct mutex ctrl_lock; diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 7dd443aea5a5..f77dc7c38f9a 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -824,7 +824,7 @@ static inline void dbg_ctrl(struct controller *ctrl) struct controller *pcie_init(struct pcie_device *dev) { struct controller *ctrl; - u32 slot_cap, link_cap; + u32 slot_cap, slot_cap2, link_cap; u8 poweron; struct pci_dev *pdev = dev->port; struct pci_bus *subordinate = pdev->subordinate; @@ -846,6 +846,9 @@ struct controller *pcie_init(struct pcie_device *dev) if (pdev->is_thunderbolt) slot_cap |= PCI_EXP_SLTCAP_NCCS; + if (pdev->no_in_band_presence) + ctrl->inband_presence_disabled = 1; + ctrl->slot_cap = slot_cap; mutex_init(&ctrl->ctrl_lock); mutex_init(&ctrl->state_lock); @@ -882,6 +885,13 @@ struct controller *pcie_init(struct pcie_device *dev) FLAG(link_cap, PCI_EXP_LNKCAP_DLLLARC), pdev->broken_cmd_compl ? " (with Cmd Compl erratum)" : ""); + pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP2, &slot_cap2); + if (slot_cap2 & PCI_EXP_SLTCAP2_IBPD) { + pcie_write_cmd_nowait(ctrl, PCI_EXP_SLTCTL_IBPD_DISABLE, + PCI_EXP_SLTCTL_IBPD_DISABLE); + ctrl->inband_presence_disabled = 1; + } + /* * If empty slot's power status is on, turn power off. The IRQ isn't * requested yet, so avoid triggering a notification with this command. diff --git a/include/linux/pci.h b/include/linux/pci.h index 65f1d8c2f082..9d08cdbca459 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -413,6 +413,7 @@ struct pci_dev { unsigned int non_compliant_bars:1; /* Broken BARs; ignore them */ unsigned int is_probed:1; /* Device probing in progress */ unsigned int link_active_reporting:1;/* Device capable of reporting link active */ + unsigned int no_in_band_presence:1; /* Device does not report in-band presence */ unsigned int no_vf_scan:1; /* Don't scan for VFs after IOV enablement */ pci_dev_flags_t dev_flags; atomic_t enable_cnt; /* pci_enable_device has been called */ diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index e1e9888c85e6..5423dc476c77 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -597,6 +597,7 @@ #define PCI_EXP_SLTCTL_PWR_OFF 0x0400 /* Power Off */ #define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */ #define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */ +#define PCI_EXP_SLTCTL_IBPD_DISABLE 0x4000 /* In-band PD disable */ #define PCI_EXP_SLTSTA 26 /* Slot Status */ #define PCI_EXP_SLTSTA_ABP 0x0001 /* Attention Button Pressed */ #define PCI_EXP_SLTSTA_PFD 0x0002 /* Power Fault Detected */ @@ -667,6 +668,7 @@ #define PCI_EXP_LNKSTA2 50 /* Link Status 2 */ #define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 52 /* v2 endpoints with link end here */ #define PCI_EXP_SLTCAP2 52 /* Slot Capabilities 2 */ +#define PCI_EXP_SLTCAP2_IBPD 0x0001 /* In-band PD Disable Supported */ #define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */ #define PCI_EXP_SLTSTA2 58 /* Slot Status 2 */