From patchwork Tue Sep 6 22:00:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 9317961 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 D433160869 for ; Tue, 6 Sep 2016 22:00:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B874028F02 for ; Tue, 6 Sep 2016 22:00:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAB4C28F06; Tue, 6 Sep 2016 22:00:30 +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 0284F28F02 for ; Tue, 6 Sep 2016 22:00:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933750AbcIFWA2 (ORCPT ); Tue, 6 Sep 2016 18:00:28 -0400 Received: from mga11.intel.com ([192.55.52.93]:65205 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933811AbcIFWA0 (ORCPT ); Tue, 6 Sep 2016 18:00:26 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 06 Sep 2016 15:00:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,293,1470726000"; d="scan'208";a="1036270892" Received: from dcgshare.lm.intel.com ([10.232.118.254]) by fmsmga001.fm.intel.com with ESMTP; 06 Sep 2016 15:00:22 -0700 Received: by dcgshare.lm.intel.com (Postfix, from userid 1017) id 5431DE0C74; Tue, 6 Sep 2016 16:00:20 -0600 (MDT) From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Jon Derrick , Wei Zhang , Keith Busch Subject: [PATCHv2 4/4] pci/msix: Skip disabling removed devices Date: Tue, 6 Sep 2016 16:00:19 -0600 Message-Id: <1473199219-3369-5-git-send-email-keith.busch@intel.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1473199219-3369-1-git-send-email-keith.busch@intel.com> References: <1473199219-3369-1-git-send-email-keith.busch@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 There is no need to disable MSIx interrupts or write message data on a device that isn't present. This patch checks the device removed state prior to executing device shutdown operations so that teardown on removed devices is quicker. Signed-off-by: Keith Busch --- drivers/pci/msi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index a02981e..474d808 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -316,7 +316,7 @@ void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg) { struct pci_dev *dev = msi_desc_to_pci_dev(entry); - if (dev->current_state != PCI_D0) { + if (dev->current_state != PCI_D0 || dev->is_removed) { /* Don't touch the hardware now */ } else if (entry->msi_attrib.is_msix) { void __iomem *base = pci_msix_desc_addr(entry); @@ -999,6 +999,11 @@ void pci_msix_shutdown(struct pci_dev *dev) if (!pci_msi_enable || !dev || !dev->msix_enabled) return; + if (dev->is_removed) { + dev->msix_enabled = 0; + return; + } + /* Return the device with MSI-X masked as initial states */ for_each_pci_msi_entry(entry, dev) { /* Keep cached states to be restored */