From patchwork Thu Nov 30 12:47:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongdong Liu X-Patchwork-Id: 10084779 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 92EA860234 for ; Thu, 30 Nov 2017 12:48:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 808DE29F10 for ; Thu, 30 Nov 2017 12:48:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 755EE29F7A; Thu, 30 Nov 2017 12:48:14 +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=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 E526A29F10 for ; Thu, 30 Nov 2017 12:48:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752242AbdK3MsN (ORCPT ); Thu, 30 Nov 2017 07:48:13 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11458 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752321AbdK3MsM (ORCPT ); Thu, 30 Nov 2017 07:48:12 -0500 Received: from 172.30.72.59 (EHLO DGGEMS402-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DLP69798; Thu, 30 Nov 2017 20:47:44 +0800 (CST) Received: from [127.0.0.1] (10.63.141.25) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Thu, 30 Nov 2017 20:47:38 +0800 Subject: Re: [Question] Unsupported Request During PCI Enumeration To: Bjorn Helgaas References: <26340670-2744-b2e0-eed7-eb8e0ad2bc84@huawei.com> <20171128003208.GB11228@bhelgaas-glaptop.roam.corp.google.com> <20171128145748.GD11228@bhelgaas-glaptop.roam.corp.google.com> CC: Linux PCI , Linuxarm From: Dongdong Liu Message-ID: <12079a9c-9018-b1be-1596-8a2f6746677b@huawei.com> Date: Thu, 30 Nov 2017 20:47:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20171128145748.GD11228@bhelgaas-glaptop.roam.corp.google.com> X-Originating-IP: [10.63.141.25] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.5A1FFDF0.00EA, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 6cfeb6d2f6908acb433c515dbfa39677 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 > I do not think drivers should be calling > pci_enable_pcie_error_reporting() directly. And I don't think we > should depend on _HPX. _HPX is intended for *platform-specific* > things, and I don't think this is platform-specific. And of course, > _HPX only works on ACPI systems, and we want this to work everywhere. > > So I think we need a more comprehensive generic solution in Linux. I > think we need several pieces: > > - Disable UR reporting during enumeration, similar to how we disable > Master Abort reporting. > > - Restore original UR reporting setting after enumeration. > > - Clear any logged UR errors after enumeration. Agree. > > - Enable UR reporting as part of configuring every device, e.g., in > pci_configure_device() or pci_init_capabilities(). Enable UR reporting in pci_configure_device() or pci_init_capabilities() is not ok. It will still report UR as it is still in enumeration. > > I don't know whether we should enable UR reporting if AER is not > present; we'll have to think about that. We may also have to > restructure how the AER driver works, because I think it currently > comes into play *after* we call pci_init_capabilities(). There are > probably some ordering issues there. I write a sample code as below, it can avoid report UR during enumeration. What do you think about the code ? Dongdong > > Bjorn > > . > diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index bc56cf1..1a46026 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "pci.h" @@ -311,6 +312,16 @@ void __weak pcibios_bus_add_device(struct pci_dev *pdev) { } void pci_bus_add_device(struct pci_dev *dev) { int retval; + u16 reg16; + + /* Clear PCIe Capability's Device Status */ + pcie_capability_read_word(dev, PCI_EXP_DEVSTA, ®16); + pcie_capability_write_word(dev, PCI_EXP_DEVSTA, reg16); + pci_cleanup_aer_error_status_regs(dev); + + /* Restore UR reporting */ + if (dev->devctl_ur) + pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_URRE); /* * Can not put in pci_device_add yet because resources diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 14e0ea1..7b34083 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2119,9 +2119,21 @@ static void pci_set_msi_domain(struct pci_dev *dev) void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) { int ret; + u16 reg16; pci_configure_device(dev); + pcie_capability_read_word(dev, PCI_EXP_DEVCTL, ®16); + dev->devctl_ur = reg16 & PCI_EXP_DEVCTL_URRE; + if (dev->devctl_ur) { + /* + * Turn off UR reporting, later restore UR reporting + * after enumeration. + */ + reg16 = reg16 & (~PCI_EXP_DEVCTL_URRE); + pcie_capability_write_word(dev, PCI_EXP_DEVCTL, reg16); + } + device_initialize(&dev->dev); dev->dev.release = pci_release_dev; diff --git a/include/linux/pci.h b/include/linux/pci.h index ae8d2b4..c2a90f1 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -440,6 +440,7 @@ struct pci_dev { char *driver_override; /* Driver name to force a match */ unsigned long priv_flags; /* Private flags for the pci driver */ + u16 devctl_ur; }; Thanks,