From patchwork Tue Jan 15 03:12:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 1974431 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 032973FE33 for ; Tue, 15 Jan 2013 03:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755202Ab3AODPl (ORCPT ); Mon, 14 Jan 2013 22:15:41 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:5447 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754869Ab3AODPl (ORCPT ); Mon, 14 Jan 2013 22:15:41 -0500 Received: from 172.24.2.119 (EHLO szxeml207-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id AVQ97127; Tue, 15 Jan 2013 11:15:23 +0800 (CST) Received: from SZXEML422-HUB.china.huawei.com (10.82.67.161) by szxeml207-edg.china.huawei.com (172.24.2.56) with Microsoft SMTP Server (TLS) id 14.1.323.3; Tue, 15 Jan 2013 11:14:27 +0800 Received: from localhost (10.135.76.69) by szxeml422-hub.china.huawei.com (10.82.67.161) with Microsoft SMTP Server id 14.1.323.3; Tue, 15 Jan 2013 11:14:16 +0800 From: Yijing Wang To: Bjorn Helgaas , Yu Zhao CC: Kenji Kaneshige , Scott Murray , Yinghai Lu , , Hanjun Guo , , Yijing Wang Subject: [PATCH -v3 1/7] PCI: rework pci_enable_ari to support disable ari forwarding Date: Tue, 15 Jan 2013 11:12:16 +0800 Message-ID: <1358219542-16880-2-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.11.msysgit.1 In-Reply-To: <1358219542-16880-1-git-send-email-wangyijing@huawei.com> References: <1358219542-16880-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.135.76.69] X-CFilter-Loop: Reflected Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org pci_enable_ari will set the pci bridge ARI Forwarding Enable bit in Device Control 2 Register when a ARI pcie device connected found. But the bridge ARI Forwarding Enable bit will never be cleared when the ARI device hot removed. As PCIe Spec 2.0(6.13/441) recommends: "Following a hot-plug event below a Downstream Port, it is strongly recommended that software Clear the ARI Forwarding Enable bit in the Downstream Port until software determines that a newly added component is in fact an ARI Device" This patch rework pci_enable_ari to support disable ARI Forwarding whenever found the new pci device is a non-ari device. Signed-off-by: Yijing Wang Signed-off-by: Jiang Liu --- drivers/pci/pci.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 5cb5820..a17129f 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2078,9 +2078,6 @@ void pci_enable_ari(struct pci_dev *dev) if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn) return; - if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI)) - return; - bridge = dev->bus->self; if (!bridge) return; @@ -2088,9 +2085,16 @@ void pci_enable_ari(struct pci_dev *dev) pcie_capability_read_dword(bridge, PCI_EXP_DEVCAP2, &cap); if (!(cap & PCI_EXP_DEVCAP2_ARI)) return; - - pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_ARI); - bridge->ari_enabled = 1; + + if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI)) { + pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, + PCI_EXP_DEVCTL2_ARI); + bridge->ari_enabled = 1; + } else { + pcie_capability_clear_word(bridge, PCI_EXP_DEVCTL2, + PCI_EXP_DEVCTL2_ARI); + bridge->ari_enabled = 0; + } } /**