From patchwork Fri May 25 14:04:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10427527 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 F31C9601D5 for ; Fri, 25 May 2018 14:18:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1F6A291D3 for ; Fri, 25 May 2018 14:18:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D54B12972D; Fri, 25 May 2018 14:18:39 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3323E291D3 for ; Fri, 25 May 2018 14:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=12FQ2fuTvEahHS0pVMykRubbmoozz9LaTS1vVo7xmxE=; b=KAE0rlilPiXqpY i/QOKppQs9kG+Rf1S58iFvl8eEGCMWf7KqbmqlAHiR41CdYhhqF8feIZ3onUVmLYuYFzJ70mAaW6U Hgl+yMgrpqnJXQyfM9KzDR3W4PUXlj23OV4urVnj26KIAz0+isiRFmfb4Pt4CwYQ0AHQ7jHpFml+B zEYD+jUKcLff+dlUO9xNvFWL7uRhFew2s8bvCM/hAF0vMZccZ6l+ptzi5uBXGBQ+D4R7yZVZkpU1D 2/B3hv4MR3bDvwhm2PlkUShWFOLJZ+NPaz6meSwpZ9I5SY5gqPldj7R8ihMv750kiXf/7PCsC9/H0 1hEsRftd4ql8P7I3aaKg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fMDY5-0004be-T0; Fri, 25 May 2018 14:18:29 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fMDXe-0004Ha-PA for linux-arm-kernel@bombadil.infradead.org; Fri, 25 May 2018 14:18:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=xz4miAkKmw0yt6doyDT953jflJoBqBD+vZ77W3v9KWk=; b=Avgi/g+wDWraNtnJcLqe9yD5Af l14Ck76LL9jMN/0lyNlmwo3eFzqwtkSjlKoFVYerxiiVBQJ346MZ+gx0qyrmkkSP1rjrzNtJCCh3q TVuk000lhrO6U+KcvZ4qGlw1op3VYMNQKMSCmLUQRvtyz1EUUBUQYTQr1fu4AwIHxu8cM/uz2zgl0 jgub/S6VwXNEjFFy9Xd7/pd037EZ0Q8NvdTgdaDgSmno8Xckbn9DObc2cKE/jSjwO12xO+3JZJBMN CxT062q95uMCqiEHsEDy5dHVOjyL8Kek87WSK9LPaY1/xr4t+2VRLd8ONyBBoGXLp7VYYVlOPpjeq ZtNChCCA==; Received: from smtp.codeaurora.org ([198.145.29.96]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fMDKq-0001Hy-W4 for linux-arm-kernel@lists.infradead.org; Fri, 25 May 2018 14:04:50 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3D70360881; Fri, 25 May 2018 14:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527257075; bh=vMC9+7Kmqdozio/mHWCCOdd0cJ4U8nEi1ofvs149E58=; h=From:To:Cc:Subject:Date:From; b=EZNfCCOXIa/NGARLRS/kNY6yHiq/mTBzaVXxgxwC/XZM8emGSXmTxyVmOTJdDjEhj wIge+yABzdCve+sMpwbIO/X6aPzF1rZkC0EkZwRsJBHFOUqv9ssIW7VhacQVw9YY7i r4VpfdOmhjcVCu+94rHVOmWN/Rdfw2vgtIjiLzIc= 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 E9839601E8; Fri, 25 May 2018 14:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527257074; bh=vMC9+7Kmqdozio/mHWCCOdd0cJ4U8nEi1ofvs149E58=; h=From:To:Cc:Subject:Date:From; b=nQkx7ScACnoYtVXdvjCQp2WPXYqEFs/tw4UMo9mQBkxwLVujLECxTaMBqS3+41Y4I d6beWQrm444whuhaI1buccmds0GQ6A1C8i5N4YT1OjeXXyUwXp2yK+0fiAwRq2/K94 bkWCFlq8cA6sYVKlZWloKsO0P8oQ/L/JR811Eb3c= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E9839601E8 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 Subject: [PATCH] PCI: Try to clean up resources via remove if shutdown doesn't exist Date: Fri, 25 May 2018 10:04:23 -0400 Message-Id: <1527257063-15843-1-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180525_150449_161693_D5F1612D X-CRM114-Status: GOOD ( 13.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sinan Kaya , linux-arm-msm@vger.kernel.org, Bjorn Helgaas , open list , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP It is up to a driver to implement shutdown() callback. If shutdown() callback is not implemented, PCI device can have pending interrupt and even do DMA transactions while the system is going down. If kexec is in use, this can damage the newly booting kexec kernel or even prevent it from booting altogether. Fallback to calling the remove() callback if shutdown() isn't implemented for a given driver. Signed-off-by: Sinan Kaya --- drivers/pci/pci-driver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 6ace470..4ac72e3 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -475,8 +475,17 @@ static void pci_device_shutdown(struct device *dev) pm_runtime_resume(dev); + /* + * Try shutdown callback if it exists, otherwise fallback to remove + * callback. PCI drivers can do DMA and have pending interrupts. + * Leaving the DMA and interrupts pending could damage the newly + * booting kexec kernel as well as prevent it from booting altogether + * if the pending interrupt is level. + */ if (drv && drv->shutdown) drv->shutdown(pci_dev); + else if (drv && drv->remove) + drv->remove(pci_dev); /* * If this is a kexec reboot, turn off Bus Master bit on the