Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp315337imm; Tue, 22 May 2018 19:45:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqO23nd3Alg8HG0AB12qUJbOpEvAGHifbJoqa/OVHiUwQ+FnhXd7q3LON73JnFlyJGT39C3 X-Received: by 2002:a63:2a89:: with SMTP id q131-v6mr783943pgq.379.1527043522571; Tue, 22 May 2018 19:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527043522; cv=none; d=google.com; s=arc-20160816; b=lEODRWlxugeElh26ZUF5AOkrwqBYnNXf3czzSp8AajUVf+W1Pn6uQVKozOHf3dZYF6 vHTIa0HtQT7isQwLSF/kHT4LYW2defkgkhsydDA7nDGZd/UOT76NxCwg3ign0LnAZdhw G5+0tDs5yYC1khD/fraG1Q6QkeCM6dsDbwSxvscYK6bigGlrrrbb+4+4IutPk972KXq0 dMfl9v5a2c1e81SJAUynXM2GncIccThfo8Jt5P7nDBacceEzyp8rCHeP4r9IYh/Vg4bZ GjiCNfl1Yl9Eyk/INJp5MuJS/+oPo1Vne6v5h4W+9e4cAxTqvIpqLVPclLNsS6r4ap5Y 19ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=08PjPfklk+sjGjVzXh4uyae3QKKrCeNubVT1tWA5YHo=; b=EmzCn40Y2aN50KMz6d7d8TtTAVgeEXBwwta1zuR65I2VBQpbrFTi9+koZGryAe714d NvS9YsX4Q+egbAVoWYFD8gy8YZQpt+Y+zuScVvXxhwcc19Zw6oUVFJwUTcYSITOQjmNW xHiZghGjuODkud6W8yEfHB9nI1rENWrfzFqRy9J9UL68ctwN0iWycI/hxjuTZxgr42gj HDG0cDiet2aNAPx2whCUgMa8IwijR53G0T3UtlJRpkefgo+VtkSTfd/1IwcCll+s3qXO B2PuL31luONNhwLo3jj8Xwv1s5J56U3oOtsPi8LEXLbcQEqvcqlbfJHCp53P4bCEayhc AShA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=levMOAjK; dkim=pass header.i=@codeaurora.org header.s=default header.b=fR9ccv6U; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5-v6si14022091pgu.341.2018.05.22.19.45.07; Tue, 22 May 2018 19:45:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=levMOAjK; dkim=pass header.i=@codeaurora.org header.s=default header.b=fR9ccv6U; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753856AbeEWCpA (ORCPT + 99 others); Tue, 22 May 2018 22:45:00 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:38408 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753664AbeEWCo6 (ORCPT ); Tue, 22 May 2018 22:44:58 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D1071609D1; Wed, 23 May 2018 02:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527043497; bh=M+Hwn7zIENN3Y5OTKi9Eu4vPgY0AtD0xwUYkU64wiXY=; h=From:To:Cc:Subject:Date:From; b=levMOAjKFXEwCRAruChj1hptZnNc3GCEdHsQ4yswHSRepbQLrwBbpMu7/ghh74/mB P99wG3sZtp1FnGUTWHWB6dWILLgyX23pTt1dMlRZUy3N6L/V0zUFTZdB/eAiJy1Ruk NpY0qzfKQ/RqbzQRSYb9Cilc7PTODbAabp3i7QtA= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A36BA604D4; Wed, 23 May 2018 02:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527043496; bh=M+Hwn7zIENN3Y5OTKi9Eu4vPgY0AtD0xwUYkU64wiXY=; h=From:To:Cc:Subject:Date:From; b=fR9ccv6UDCqe2xd3t8JAkvp4xAnVi92/dS0jbaIDw5RlRczHAIJXx72oPeOJq8Kvx Gl++7qtIlB7HD4KXzix27G6xHQdxj6U6zSrvEjdiEJrd7QvmkInQFus8sLfE/Ij5H2 Oe8PxvwV1Wjmeh6PpdA5Inhp2lCOFyUL7BN5/z/U= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A36BA604D4 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org Cc: ryan@finnie.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , stable@vger.kernel.org, Bjorn Helgaas , "Rafael J. Wysocki" , Greg Kroah-Hartman , Thomas Gleixner , Kate Stewart , Gabriele Paoloni , Frederick Lawler , Dongdong Liu , Mika Westerberg , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V2] PCI/portdrv: do not disable device on reboot/shutdown Date: Tue, 22 May 2018 22:44:46 -0400 Message-Id: <1527043490-17268-1-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'Commit cc27b735ad3a ("PCI/portdrv: Turn off PCIe services during shutdown")' has been added to kernel to shutdown pending PCIe port service interrupts during reboot so that a newly started kexec kernel wouldn't observe pending interrupts. pcie_port_device_remove() is disabling the root port and switches by calling pci_disable_device() after all PCIe service drivers are shutdown. pci_disable_device() has a much wider impact then port service itself and it prevents all inbound transactions to reach to the system and impacts the entire PCI traffic behind the bridge. Issue is that pcie_port_device_remove() doesn't maintain any coordination with the rest of the PCI device drivers in the system before clearing the bus master bit. This has been found to cause crashes on HP DL360 Gen9 machines during reboot. Besides, kexec is already clearing the bus master bit in pci_device_shutdown() after all PCI drivers are removed. Just remove the extra clear in shutdown path by seperating the remove and shutdown APIs in the PORTDRV. Signed-off-by: Sinan Kaya Link: https://bugzilla.kernel.org/show_bug.cgi?id=199779 Fixes: cc27b735ad3a ("PCI/portdrv: Turn off PCIe services during shutdown") Cc: stable@vger.kernel.org Reported-by: Ryan Finnie --- drivers/pci/pcie/portdrv.h | 2 +- drivers/pci/pcie/portdrv_core.c | 5 +++-- drivers/pci/pcie/portdrv_pci.c | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h index d0c6783..f6e88fe 100644 --- a/drivers/pci/pcie/portdrv.h +++ b/drivers/pci/pcie/portdrv.h @@ -86,7 +86,7 @@ int pcie_port_device_register(struct pci_dev *dev); int pcie_port_device_suspend(struct device *dev); int pcie_port_device_resume(struct device *dev); #endif -void pcie_port_device_remove(struct pci_dev *dev); +void pcie_port_device_remove(struct pci_dev *dev, bool disable); int __must_check pcie_port_bus_register(void); void pcie_port_bus_unregister(void); diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index c9c0663..f35341e 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -405,11 +405,12 @@ static int remove_iter(struct device *dev, void *data) * Remove PCI Express port service devices associated with given port and * disable MSI-X or MSI for the port. */ -void pcie_port_device_remove(struct pci_dev *dev) +void pcie_port_device_remove(struct pci_dev *dev, bool disable) { device_for_each_child(&dev->dev, NULL, remove_iter); pci_free_irq_vectors(dev); - pci_disable_device(dev); + if (disable) + pci_disable_device(dev); } /** diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 973f1b8..29afaf3 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -137,7 +137,7 @@ static int pcie_portdrv_probe(struct pci_dev *dev, return 0; } -static void pcie_portdrv_remove(struct pci_dev *dev) +static void __pcie_portdrv_remove(struct pci_dev *dev, bool disable) { if (pci_bridge_d3_possible(dev)) { pm_runtime_forbid(&dev->dev); @@ -145,7 +145,17 @@ static void pcie_portdrv_remove(struct pci_dev *dev) pm_runtime_dont_use_autosuspend(&dev->dev); } - pcie_port_device_remove(dev); + pcie_port_device_remove(dev, disable); +} + +static void pcie_portdrv_remove(struct pci_dev *dev) +{ + return __pcie_portdrv_remove(dev, true); +} + +static void pcie_portdrv_shutdown(struct pci_dev *dev) +{ + return __pcie_portdrv_remove(dev, false); } static pci_ers_result_t pcie_portdrv_error_detected(struct pci_dev *dev, @@ -218,7 +228,7 @@ static struct pci_driver pcie_portdriver = { .probe = pcie_portdrv_probe, .remove = pcie_portdrv_remove, - .shutdown = pcie_portdrv_remove, + .shutdown = pcie_portdrv_shutdown, .err_handler = &pcie_portdrv_err_handler, -- 2.7.4