From patchwork Tue Jul 11 15:25:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9834977 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 A0113602A0 for ; Tue, 11 Jul 2017 15:26:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 920E127FB7 for ; Tue, 11 Jul 2017 15:26:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87183283BB; Tue, 11 Jul 2017 15:26:07 +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=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 33AC827FB7 for ; Tue, 11 Jul 2017 15:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933478AbdGKPZy (ORCPT ); Tue, 11 Jul 2017 11:25:54 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:55388 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933371AbdGKPZm (ORCPT ); Tue, 11 Jul 2017 11:25:42 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0941061295; Tue, 11 Jul 2017 15:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1499786742; bh=4N7YHiIk12vlvttQsHw4uRA04Urr2CZ3gfztMQY/OBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ExfF9gqp+XGPA4dGho8rvboTBz/8EuPzHJrr90TVoT09tm8amUWpKoIQUwBEbaJh7 spwHvUFgK6N22EgNC3aigWUr2lnG5R0+npDzB9c6kKc0tU1EhG6aI9YBeccmRpiGY6 1/ZI1nPkuK2+DMCtJ0PcL7IjWyofpfmYalnfODIU= 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 6FC1961295; Tue, 11 Jul 2017 15:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1499786741; bh=4N7YHiIk12vlvttQsHw4uRA04Urr2CZ3gfztMQY/OBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cn/t1f9oDcHFTpY15RJjxYe3TSKlDRtQ03SkwaBoelz8cxq128Ze9qqxAhk3pVSLL 7hHzQ0At8lw8WGbKIrm0dq9cyH8ToSTRkG4Eho+Q8QbzAJKrcwALwMl6McBro+X/h/ 4clsKkIUPqxWVQ+Z9DHWwgUaKGajeH1yHL+Vt6MY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6FC1961295 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 V3 2/2] PCI: Do not enable extended tags if a quirky device is found Date: Tue, 11 Jul 2017 11:25:34 -0400 Message-Id: <1499786735-25782-2-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499786735-25782-1-git-send-email-okaya@codeaurora.org> References: <1499786735-25782-1-git-send-email-okaya@codeaurora.org> 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 According to extended tags ECN document, all PCIe receivers are expected to support extended tags. However, devices with exceptions/quirks were found. If a device with extended tags quirk is found, disable extended tags for all devices in the tree assuming peer-to-peer is possible. Also note that the default value of Extended Tags Enable bit is implementation specific. Therefore, we are clearing the bit by default when incompatible HW is found. 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/probe.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 19c8950..396dd80 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1684,21 +1684,43 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) */ } -static void pci_configure_extended_tags(struct pci_dev *dev) +static int pcie_find_broken_exttags(struct pci_dev *dev, void *data) { + bool *found = data; + + if (!pci_is_pcie(dev)) + return 0; + + if (dev->broken_exttags_completer) + *found = dev->broken_exttags_completer; + + return 0; +} + +static int pcie_bus_configure_exttags(struct pci_dev *dev, void *broken) +{ + bool supported = !*(bool *)broken; u32 dev_cap; int ret; if (!pci_is_pcie(dev)) - return; + return 0; ret = pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &dev_cap); - if (ret) - return; + if (ret || (!(dev_cap & PCI_EXP_DEVCAP_EXT_TAG))) + return 0; - if (dev_cap & PCI_EXP_DEVCAP_EXT_TAG) + if (supported) { + dev_dbg(&dev->dev, "setting extended tags capability\n"); pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_EXT_TAG); + } else { + dev_dbg(&dev->dev, "clearing extended tags capability\n"); + pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, + PCI_EXP_DEVCTL_EXT_TAG); + } + + return 0; } static void pci_configure_device(struct pci_dev *dev) @@ -1707,7 +1729,6 @@ static void pci_configure_device(struct pci_dev *dev) int ret; pci_configure_mps(dev); - pci_configure_extended_tags(dev); memset(&hpp, 0, sizeof(hpp)); ret = pci_get_hp_params(dev, &hpp); @@ -2201,6 +2222,7 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data) void pcie_bus_configure_settings(struct pci_bus *bus) { u8 smpss = 0; + bool broken_exttags = false; if (!bus->self) return; @@ -2224,6 +2246,9 @@ void pcie_bus_configure_settings(struct pci_bus *bus) pcie_bus_configure_set(bus->self, &smpss); pci_walk_bus(bus, pcie_bus_configure_set, &smpss); + + pci_walk_bus(bus, pcie_find_broken_exttags, &broken_exttags); + pci_walk_bus(bus, pcie_bus_configure_exttags, &broken_exttags); } EXPORT_SYMBOL_GPL(pcie_bus_configure_settings);