Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2955010imm; Mon, 28 May 2018 20:52:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZojJPeKo1lXHFPQeAAguwoqU8ajuahlnoLjUJOzalIy9YIlssdrnnO6+QNev+E36MCn7Q/s X-Received: by 2002:a63:2ace:: with SMTP id q197-v6mr12638967pgq.60.1527565927310; Mon, 28 May 2018 20:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527565927; cv=none; d=google.com; s=arc-20160816; b=SFYBtu+kFN93b1SMVRO4LJx9gMJ8ZWypTAGQOrAG7grzA7NtDUX6iIVj0LDqe2r02o AjmFqQMV1jOH4pFTrbloO5CdumPECHY/pRO34+PRONxxaNM/v+25ogzkD3UQyyZsmt/1 cnLKAfR9q3RVfgfDwfwOTzoAzKWptgdJeMTpWq+P3CYPac2oD/It+luqgKQbMOM7XXwv ft4uEZ6FFXdy84VhtK0AW1CDs6Wtqfx2c2sHzZHpp4V6fINtnoG8i7pWyXNGH4HfTXqQ 6FK6Ri2egUeNkn6d8Jf3OmnuLEfE3uqJhl/FGw9rsMbGl3ekouv+XSdn+ofygP9mG39Z iWbQ== 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=fTy4+ImrqQ2azwAaJCvoqwd0N6bNeSPe+ozySM7ES1A=; b=B48Ei3gN/lq40pO4ViAZxn0H/E0+lVywYtH0p0b1pezUDsVDglSfzI9KgYMoO3bP6N kf9mcA0EqrU9iqWC5F+rO/43SunbYxODlu+4cagcR4SsuKWQ5LkZIVVdbKVg5sskPRB8 Lc6eCht014h6I4KvDIW4tKxB7DmWn2S/JCQ5oNT85rV+css8NLfuQTSWKsCNFLBGcWgk r17qx+qLXykKP0vabbybUOONUG+I3SPCLLGH8XL2a4CSW304hHJWRFJ1IjsgvZVZRnF0 /wfk5yyElsUBW3amlCYWPWnllwuwx/0uEu5j7xUu4Pq5SWU7EGwmXLYQifORi2pLFy+o ZXJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=IB1VencN; dkim=pass header.i=@codeaurora.org header.s=default header.b=AviuFW8/; 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 i3-v6si30831251pld.189.2018.05.28.20.51.22; Mon, 28 May 2018 20:52:07 -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=IB1VencN; dkim=pass header.i=@codeaurora.org header.s=default header.b=AviuFW8/; 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 S934176AbeE1VVW (ORCPT + 99 others); Mon, 28 May 2018 17:21:22 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:32806 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934151AbeE1VVS (ORCPT ); Mon, 28 May 2018 17:21:18 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6784A60591; Mon, 28 May 2018 21:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527542478; bh=J3YUQblI7jH9b8qOQWBFxZTFZcLj0oMkcDxzgwfABwI=; h=From:To:Cc:Subject:Date:From; b=IB1VencNJlLlFhfCY5g6kRTa60PakHAnf0IOJZTcOO61tVZV6Xk/e9WFbuum5IB8v 5Z2It8591wVglbSugM+xS5YPI/lbXYlPtsnTh8ha72LPJWhiU5YKGLjNpnEeTj75Rx Vbj3drxN/YDH3eKS57R12HD0d9kC4350vUaMiDjc= 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 C36C16044B; Mon, 28 May 2018 21:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527542477; bh=J3YUQblI7jH9b8qOQWBFxZTFZcLj0oMkcDxzgwfABwI=; h=From:To:Cc:Subject:Date:From; b=AviuFW8/2DZoveCFg+UDwwyzEcI7IkP77a5XligPAyu3kn9QPUBuOnRjp3ZAXbEOU bGb67b7u8X/JqmVq5Eg4uxq4l1NosHFhTPPmt+SwinlJGgxgqAj9MYMQTT7xTPdI2q JerxTKBZxkg0+qcbRphXwOlgJunOiCnDbo+M2Hjg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C36C16044B 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, ryan@finnie.org, timur@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , stable@vger.kernel.org, Bjorn Helgaas , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V3 1/2] PCI: Try to clean up resources via remove if shutdown doesn't exist Date: Mon, 28 May 2018 17:21:10 -0400 Message-Id: <1527542471-10316-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 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 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/pci-driver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index cbda0e6..75a00fe 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -477,8 +477,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 -- 2.7.4