From patchwork Wed Jul 12 04:04:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9835861 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 80829602D8 for ; Wed, 12 Jul 2017 04:04:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FDD5285AB for ; Wed, 12 Jul 2017 04:04:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53442285D2; Wed, 12 Jul 2017 04:04:25 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 C85B4285AB for ; Wed, 12 Jul 2017 04:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751258AbdGLEEX (ORCPT ); Wed, 12 Jul 2017 00:04:23 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:38304 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750731AbdGLEEW (ORCPT ); Wed, 12 Jul 2017 00:04:22 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8E8E661258; Wed, 12 Jul 2017 04:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1499832261; bh=QzqneJnsQk5KfsVd5esRmRevHv3ukrLIkw8jdi/2qW4=; h=From:To:Cc:Subject:Date:From; b=OCiF+sI4RF6FA04w09U80m28hFgzFRUnUmrrhXRCvl+qip+5sNDceBCMXCFqsQ4FL zP2nAZJxUlZxBN9yFWcH4ipOJbaKuKSrBYIZA2bPw2C+caCCqT1uvk2A2yMjlXi4JN rzs3yk/de4JBmven7KyqLTqZuxIpw1LOTtjw9MhQ= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id DEB36612CA; Wed, 12 Jul 2017 04:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1499832260; bh=QzqneJnsQk5KfsVd5esRmRevHv3ukrLIkw8jdi/2qW4=; h=From:To:Cc:Subject:Date:From; b=PiXjRuTX3mMctLWDLpWbTNsJEZ22laelCIjiPbAmnyt/z2CQ58yCP/VOblkND2/e3 ip3VcvWW3oR69GNDpIzEky8BSUn9UJV50vts3vGIkBwsCTuaF7+rORmqqjTME5nVn5 3Cvctpfa6W0NFNleUOyBcFNo4HVx3fSE+7A5/Ddw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DEB36612CA Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org, wim.ten.have@oracle.com Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Bjorn Helgaas , linux-kernel@vger.kernel.org Subject: [PATCH V4] PCI: Add Extended Tags quirk for Broadcom HT2100 Root Port Date: Wed, 12 Jul 2017 00:04:14 -0400 Message-Id: <1499832255-9845-1-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 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 All PCIe devices are expected to be able to handle 8-bit tags. 'commit 60db3a4d8cc9 ("PCI: Enable PCIe Extended Tags if supported")' enabled extended tags for all devices based on the spec direction. The Broadcom HT2100 seems to be having issues with handling 8-bit tags. Mark it as broken. If a device with extended tags quirk is found, disable extended tags for all devices in the tree assuming peer-to-peer is possible. The pci_walk_bus() in the quirk handles all devices we've already enumerated, and all devices we'll enumerate in the future are handled in pci_configure_device(). Reported-by: Wim ten Have Link: https://bugzilla.redhat.com/show_bug.cgi?id=1467674 Fixes: 60db3a4d8cc9 ("PCI: Enable PCIe Extended Tags if supported") Signed-off-by: Sinan Kaya --- drivers/pci/pci.h | 1 + drivers/pci/probe.c | 35 ++++++++++++++++++++++++++++++----- drivers/pci/quirks.c | 19 +++++++++++++++++++ include/linux/pci.h | 1 + 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index f8113e5..7153c92 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -239,6 +239,7 @@ enum pci_bar_type { pci_bar_mem64, /* A 64-bit memory BAR */ }; +int pci_configure_extended_tags(struct pci_dev *dev, void *ign); bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *pl, int crs_timeout); int pci_setup_device(struct pci_dev *dev); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 19c8950..bc067fb 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1684,22 +1684,47 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) */ } -static void pci_configure_extended_tags(struct pci_dev *dev) +int pci_configure_extended_tags(struct pci_dev *dev, void *ign) { + struct pci_host_bridge *host; u32 dev_cap; int ret; + u16 ctl; if (!pci_is_pcie(dev)) - return; + return 0; ret = pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &dev_cap); if (ret) - return; + return 0; + + if (!(dev_cap & PCI_EXP_DEVCAP_EXT_TAG)) + return 0; + + ret = pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &ctl); + if (ret) + return 0; + + host = pci_find_host_bridge(dev->bus); + if (!host) + return 0; - if (dev_cap & PCI_EXP_DEVCAP_EXT_TAG) + if (host->broken_ext_tags) { + if (ctl & PCI_EXP_DEVCTL_EXT_TAG) { + dev_info(&dev->dev, "disabling Extended Tags\n"); + pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, + PCI_EXP_DEVCTL_EXT_TAG); + } + return 0; + } + if (!(ctl & PCI_EXP_DEVCTL_EXT_TAG)) { + dev_info(&dev->dev, "enabling Extended Tags\n"); pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_EXT_TAG); + } + return 0; } +EXPORT_SYMBOL(pci_configure_extended_tags); static void pci_configure_device(struct pci_dev *dev) { @@ -1707,7 +1732,7 @@ static void pci_configure_device(struct pci_dev *dev) int ret; pci_configure_mps(dev); - pci_configure_extended_tags(dev); + pci_configure_extended_tags(dev, NULL); memset(&hpp, 0, sizeof(hpp)); ret = pci_get_hp_params(dev, &hpp); diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 085fb78..b5dc99c 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -4664,3 +4664,22 @@ static void quirk_intel_no_flr(struct pci_dev *dev) } DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_intel_no_flr); DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1503, quirk_intel_no_flr); + +static void quirk_exttags_completer(struct pci_dev *pdev) +{ + struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->bus); + + if (!bridge) + return; + + bridge->broken_ext_tags = 1; + dev_info(&pdev->dev, "Extended Tag handling is broken\n"); + + pci_walk_bus(bridge->bus, pci_configure_extended_tags, NULL); +} +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0140, + quirk_exttags_completer); +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0142, + quirk_exttags_completer); +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0144, + quirk_exttags_completer); diff --git a/include/linux/pci.h b/include/linux/pci.h index 8039f9f..2b22c3e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -441,6 +441,7 @@ struct pci_host_bridge { void *release_data; struct msi_controller *msi; unsigned int ignore_reset_delay:1; /* for entire hierarchy */ + unsigned int broken_ext_tags:1; /* Resource alignment requirements */ resource_size_t (*align_resource)(struct pci_dev *dev, const struct resource *res,