From patchwork Fri Sep 23 06:39:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirsher, Jeffrey T" X-Patchwork-Id: 9347519 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 4E97F607D0 for ; Fri, 23 Sep 2016 06:39:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DA812A1D9 for ; Fri, 23 Sep 2016 06:39:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 319B92AA08; Fri, 23 Sep 2016 06:39:27 +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 00AB32A1D9 for ; Fri, 23 Sep 2016 06:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933550AbcIWGjX (ORCPT ); Fri, 23 Sep 2016 02:39:23 -0400 Received: from mga01.intel.com ([192.55.52.88]:24714 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932636AbcIWGjG (ORCPT ); Fri, 23 Sep 2016 02:39:06 -0400 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP; 22 Sep 2016 23:39:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,380,1470726000"; d="scan'208";a="12868214" Received: from jtkirshe-linux.jf.intel.com ([134.134.3.176]) by orsmga004.jf.intel.com with ESMTP; 22 Sep 2016 23:39:02 -0700 From: Jeff Kirsher To: davem@davemloft.net, bhelgaas@google.com Cc: Sasha Neftin , netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com, jogreene@redhat.com, guru.anbalagane@oracle.com, linux-pci@vger.kernel.org, Jeff Kirsher Subject: [net-next 5/5] PCI: disable FLR for 82579 device Date: Thu, 22 Sep 2016 23:39:01 -0700 Message-Id: <1474612741-75681-6-git-send-email-jeffrey.t.kirsher@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474612741-75681-1-git-send-email-jeffrey.t.kirsher@intel.com> References: <1474612741-75681-1-git-send-email-jeffrey.t.kirsher@intel.com> 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 From: Sasha Neftin 82579 has a problem reattaching itself after the device is detached. The bug was reported by Redhat. The suggested fix is to disable FLR capability in PCIe configuration space. Reproduction: Attach the device to a VM, then detach and try to attach again. Fix: Disable FLR capability to prevent the 82579 from hanging. Signed-off-by: Sasha Neftin Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/pci/quirks.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 44e0ff3..59fba6e 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -4431,3 +4431,24 @@ static void quirk_intel_qat_vf_cap(struct pci_dev *pdev) } } DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x443, quirk_intel_qat_vf_cap); +/* + * Workaround FLR issues for 82579 + * This code disables the FLR (Function Level Reset) via PCIe, in order + * to workaround a bug found while using device passthrough, where the + * interface would become non-responsive. + * NOTE: the FLR bit is Read/Write Once (RWO) in config space, so if + * the BIOS or kernel writes this register * then this workaround will + * not work. + */ +static void quirk_intel_flr_cap_dis(struct pci_dev *dev) +{ + int pos = pci_find_capability(dev, PCI_CAP_ID_AF); + if (pos) { + u8 cap; + pci_read_config_byte(dev, pos + PCI_AF_CAP, &cap); + cap = cap & (~PCI_AF_CAP_FLR); + pci_write_config_byte(dev, pos + PCI_AF_CAP, cap); + } +} +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_intel_flr_cap_dis); +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1503, quirk_intel_flr_cap_dis);