From patchwork Thu Feb 9 23:33:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 9565671 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7EC1601C3 for ; Thu, 9 Feb 2017 23:33:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA85728553 for ; Thu, 9 Feb 2017 23:33:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF64928562; Thu, 9 Feb 2017 23:33:55 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 5193E28553 for ; Thu, 9 Feb 2017 23:33:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751176AbdBIXdw (ORCPT ); Thu, 9 Feb 2017 18:33:52 -0500 Received: from mail.kernel.org ([198.145.29.136]:50210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750940AbdBIXdv (ORCPT ); Thu, 9 Feb 2017 18:33:51 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB3B9201C7; Thu, 9 Feb 2017 23:33:49 +0000 (UTC) Received: from localhost (unknown [69.55.156.165]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F2F5820160; Thu, 9 Feb 2017 23:33:47 +0000 (UTC) Date: Thu, 9 Feb 2017 17:33:46 -0600 From: Bjorn Helgaas To: Sinan Kaya Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2] PCI: enable extended tags support for PCIe devices Message-ID: <20170209233346.GB29169@bhelgaas-glaptop.roam.corp.google.com> References: <1484921814-8511-1-git-send-email-okaya@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1484921814-8511-1-git-send-email-okaya@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: ClamAV using ClamSMTP 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 On Fri, Jan 20, 2017 at 09:16:51AM -0500, Sinan Kaya wrote: > Each PCIe device can issue up to 32 transactions at a time by default. > This limitation is historically coming from PCI. Each transaction is > tracked by a tag number on the bus. 2.2.6.2. Transaction Descriptor > – Transaction ID Field section of the PCIe 3.1 specification describes > extended tags. > > PCI supports 32 outstanding non-posted requests at a given time. This > number has been extended to 256 on PCI Express. According to the > specification, all PCIe devices are required to support receiving > 8-bit Tags (Tag completer). The PCIe-PCI bridges handle the translation > of 8-bit tags to 5-bit tags. > > However, the generation of 8-bit tags is left optional to a particular HW > implementation. The code needs to check HW support before attempting > to enable extended tags producer capability. > > 32 outstanding transactions is not enough for some performance critical > applications especially when a lot of small sized frames are transmitted. > > Extended tags support increases this number to 256. Devices not > supporting extended tags tie-off this field to 0. According to ECN, it > is safe to enable this feature for all PCIe devices. > > Signed-off-by: Sinan Kaya Applied to pci/enumeration for v4.11 as follows, thanks! I added a check for PCIe, so we don't have to rely on pcie_capability_read_dword() doing the right thing for PCI and PCI-X devices. I think pcie_capability_read_dword() would set dev_cap to zero and return zero, which would be safe, but I don't the reader should have to do that much analysis to figure it out. commit 8de9dcb0d1e0c92c525a826dd69ce61a21264050 Author: Sinan Kaya Date: Fri Jan 20 09:16:51 2017 -0500 PCI: Enable PCIe Extended Tags if supported Every PCIe device can generate 5-bit transaction Tags, which allow up to 32 concurrent requests. Some devices can generate 8-bit Extended Tags, which allow up to 256 concurrent requests. Per the ECN mentioned below, all PCIe Receivers are expected to support Extended Tags, so devices are allowed (but not required) to enable them by default. If a device supports Extended Tags but does not enable them by default, enable them. This allows the device to have up to 256 outstanding transactions at a time, which may improve performance. [bhelgaas: changelog, check for PCIe device] Link: https://pcisig.com/sites/default/files/specification_documents/ECN_Extended_Tag_Enable_Default_05Sept2008_final.pdf Signed-off-by: Sinan Kaya Signed-off-by: Bjorn Helgaas > --- > drivers/pci/probe.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index e164b5c..1192475 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -1650,12 +1650,28 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) > */ > } > > +static void pci_configure_extended_tags(struct pci_dev *pdev) > +{ > + u32 dev_cap; > + int ret; > + > + ret = pcie_capability_read_dword(pdev, PCI_EXP_DEVCAP, &dev_cap); > + > + if (ret) > + return; > + > + if (dev_cap & PCI_EXP_DEVCAP_EXT_TAG) > + pcie_capability_set_word(pdev, PCI_EXP_DEVCTL, > + PCI_EXP_DEVCTL_EXT_TAG); > +} > + > static void pci_configure_device(struct pci_dev *dev) > { > struct hotplug_params hpp; > int ret; > > pci_configure_mps(dev); > + pci_configure_extended_tags(dev); > > memset(&hpp, 0, sizeof(hpp)); > ret = pci_get_hp_params(dev, &hpp); > -- > 1.9.1 > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index aca5b2466adb..3abc94212197 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1661,12 +1661,30 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) */ } +static void pci_configure_extended_tags(struct pci_dev *dev) +{ + u32 dev_cap; + int ret; + + if (!pci_is_pcie(dev)) + return; + + ret = pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &dev_cap); + if (ret) + return; + + if (dev_cap & PCI_EXP_DEVCAP_EXT_TAG) + pcie_capability_set_word(dev, PCI_EXP_DEVCTL, + PCI_EXP_DEVCTL_EXT_TAG); +} + static void pci_configure_device(struct pci_dev *dev) { struct hotplug_params hpp; int ret; pci_configure_mps(dev); + pci_configure_extended_tags(dev); memset(&hpp, 0, sizeof(hpp)); ret = pci_get_hp_params(dev, &hpp);