From patchwork Mon Feb 4 11:55:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 217887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BD6702C02A8 for ; Mon, 4 Feb 2013 23:16:20 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754582Ab3BDL4E (ORCPT ); Mon, 4 Feb 2013 06:56:04 -0500 Received: from mail-lb0-f172.google.com ([209.85.217.172]:56171 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754567Ab3BDL4D (ORCPT ); Mon, 4 Feb 2013 06:56:03 -0500 Received: by mail-lb0-f172.google.com with SMTP id n8so6599621lbj.31 for ; Mon, 04 Feb 2013 03:56:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=Y7DLtP5kFnGI/WimLJR8fvzY1/OsDtue4ospaqW8H/g=; b=xGIvWyLYp+DECkSmeDzKKlj7Kn4/0IdJtCqg6mTC3S5oIqQXuAm2PK88hfjdN/J9GA DwL07PptCt31lD8jwYS+A8dmuikQoliF2hpypTemvFI81Nys7EVbS+a+nFu3frgGos86 kEEKkb7M88oXgkCOSbtGxmJiETDFUk8bX5UBGqRCb+sokXattIBULv2hYyHoV4gQr4rz TKHmd55SIx7bUvhqFRQjl2TqaH27nx2R5zaUHNgluOx9sv5fQSRZmgTqd78x6UShPRtt GvbeOX/q5YNipEXZC5qj6fk7zcjWTGonrCPTG0o1kBNopUjvkvm/BkjBGQlNgcLVuP0p B8HQ== X-Received: by 10.152.145.37 with SMTP id sr5mr19155882lab.33.1359978960784; Mon, 04 Feb 2013 03:56:00 -0800 (PST) Received: from localhost (swsoft-msk-nat.sw.ru. [195.214.232.10]) by mx.google.com with ESMTPS id pz15sm8878228lab.3.2013.02.04.03.55.59 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 04 Feb 2013 03:55:59 -0800 (PST) Subject: [PATCH v2 2/7] PCI: don't touch enable_cnt in pci_device_shutdown() To: e1000-devel@lists.sourceforge.net, linux-pci@vger.kernel.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org From: Konstantin Khlebnikov Cc: Bjorn Helgaas , Khalid Aziz , Andi Kleen , Alan Cox , Matthew Garrett Date: Mon, 04 Feb 2013 15:55:58 +0400 Message-ID: <20130204115557.5569.9748.stgit@zurg> In-Reply-To: <20130204115246.5569.85829.stgit@zurg> References: <20130204115246.5569.85829.stgit@zurg> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Matthew Garrett and Alan Cox said (see LKML link below) that clearing bus-master for all PCI devices may lead to unpredictable consequences, some devices ignores this bit and continues DMA, some of them hang after that or crash whole system. Probably we should leave here only warning and disable bus-mastering for each driver individually in ->shutdown() callback. Link: https://lkml.org/lkml/2012/6/6/278 Signed-off-by: Konstantin Khlebnikov Cc: Rafael J. Wysocki Cc: Bjorn Helgaas Cc: Khalid Aziz Cc: linux-pci@vger.kernel.org Cc: Matthew Garrett Cc: Alan Cox Cc: Andi Kleen --- drivers/pci/pci-driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index f79cbcd..dc5bdce 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); } #ifdef CONFIG_PM