From patchwork Thu Oct 25 17:44:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Derrick X-Patchwork-Id: 989272 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42gvpf2hMjz9sD9 for ; Fri, 26 Oct 2018 04:52:26 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727615AbeJZC0L (ORCPT ); Thu, 25 Oct 2018 22:26:11 -0400 Received: from mga05.intel.com ([192.55.52.43]:1799 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbeJZC0L (ORCPT ); Thu, 25 Oct 2018 22:26:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2018 10:52:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,425,1534834800"; d="scan'208";a="84468283" Received: from unknown (HELO localhost.localdomain.localdomain) ([10.232.117.194]) by orsmga008.jf.intel.com with ESMTP; 25 Oct 2018 10:52:24 -0700 From: Jon Derrick To: Cc: Bjorn Helgaas , Lorenzo Pieralisi , Jon Derrick Subject: [PATCH] PCI/MSI: Prevent MSI/X masking IO to a removed device Date: Thu, 25 Oct 2018 11:44:49 -0600 Message-Id: <1540489489-2622-1-git-send-email-jonathan.derrick@intel.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org A removed device won't be able to accept mmio or config cycles setting or clearing MSI/X mask bits. Shortcut this path by preventing the writes and subsequent reads which may result in unsupported requests or completer abort. Signed-off-by: Jon Derrick --- drivers/pci/msi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index af24ed5..3a41024 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -227,6 +227,14 @@ static void msi_set_mask_bit(struct irq_data *data, u32 flag) { struct msi_desc *desc = irq_data_get_msi_desc(data); + /* + * Prevent non-posted IO to the device if it has been removed and is in + * the process of removal cleanup, in order to prevent unsupported + * requests or completer aborts or other issues. + */ + if (pci_dev_is_disconnected(msi_desc_to_pci_dev(desc))) + return; + if (desc->msi_attrib.is_msix) { msix_mask_irq(desc, flag); readl(desc->mask_base); /* Flush write to device */