From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755548Ab3A1Xkh (ORCPT ); Mon, 28 Jan 2013 18:40:37 -0500 Received: from mail-vc0-f178.google.com ([209.85.220.178]:35937 "EHLO mail-vc0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753504Ab3A1Xke (ORCPT ); Mon, 28 Jan 2013 18:40:34 -0500 MIME-Version: 1.0 In-Reply-To: <20130118114225.6698.42016.stgit@zurg> References: <20130118113019.6698.25941.stgit@zurg> <20130118114225.6698.42016.stgit@zurg> From: Bjorn Helgaas Date: Mon, 28 Jan 2013 16:40:13 -0700 Message-ID: Subject: Re: [PATCH 4/5] PCI: don't touch enable_cnt in pci_device_shutdown() To: Konstantin Khlebnikov Cc: linux-kernel@vger.kernel.org, e1000-devel@lists.sourceforge.net, linux-pci@vger.kernel.org, Khalid Aziz Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 18, 2013 at 4:42 AM, Konstantin Khlebnikov wrote: > comment in commit b566a22c23327f18ce941ffad0ca907e50a53d41 > ("PCI: disable Bus Master on PCI device shutdown") says: > > | Disable Bus Master bit on the device in pci_device_shutdown() to ensure PCI > | devices do not continue to DMA data after shutdown. This can cause memory > | corruption in case of a kexec where the current kernel shuts down and > | transfers control to a new kernel while a PCI device continues to DMA to > | memory that does not belong to it any more in the new kernel. > > Seems like pci_clear_master() must be used here instead of pci_disable_device(), > because it disables Bus Muster unconditionally and doesn't changes enable_cnt. > > Signed-off-by: Konstantin Khlebnikov > Cc: linux-pci@vger.kernel.org > Cc: Bjorn Helgaas > Cc: Khalid Aziz > --- > drivers/pci/pci-driver.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c > index 030dbf0..853d605 100644 > --- a/drivers/pci/pci-driver.c > +++ b/drivers/pci/pci-driver.c > @@ -392,7 +392,7 @@ static void pci_device_shutdown(struct device *dev) > * Turn off Bus Master bit on the device to tell it to not > * continue to do DMA > */ > - pci_disable_device(pci_dev); > + pci_clear_master(pci_dev); We currently only call pci_enable_device() and pci_disable_device() from drivers, and I think that's a nice division that's worth keeping. It keeps the core's mitts off device operation and helps preserve the enable_cnt integrity. So I like this change from that perspective. Any objections to this, Khalid? > } > > #ifdef CONFIG_PM >