From patchwork Sun Mar 8 08:09:28 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 24174 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 831EDDDF66 for ; Sun, 8 Mar 2009 19:11:33 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751269AbZCHILM (ORCPT ); Sun, 8 Mar 2009 04:11:12 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751172AbZCHILM (ORCPT ); Sun, 8 Mar 2009 04:11:12 -0400 Received: from hera.kernel.org ([140.211.167.34]:39091 "EHLO hera.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079AbZCHILJ (ORCPT ); Sun, 8 Mar 2009 04:11:09 -0400 Received: from [129.150.16.117] (sca-ea-fw-1.Sun.COM [192.18.43.225]) (authenticated bits=0) by hera.kernel.org (8.14.2/8.13.8) with ESMTP id n288A2il025223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 8 Mar 2009 08:10:04 GMT Message-ID: <49B37D38.7060304@kernel.org> Date: Sun, 08 Mar 2009 00:09:28 -0800 From: Yinghai Lu User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 To: "Rafael J. Wysocki" , Ingo Molnar , Andrew Morton , Jesse Barnes , Matthew Wilcox CC: Jesse Brandeburg , David Miller , "linux-kernel@vger.kernel.org" , NetDev , linux-pci@vger.kernel.org Subject: [PATCH] pci: fix kexec with power state D3 References: <49B1F934.5050006@kernel.org> <4807377b0903062318q15ba52a7n82d4c9399b8a7fa8@mail.gmail.com> In-Reply-To: <4807377b0903062318q15ba52a7n82d4c9399b8a7fa8@mail.gmail.com> X-Virus-Scanned: ClamAV 0.93.3/9080/Fri Mar 6 19:13:38 2009 on hera.kernel.org X-Virus-Status: Clean Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Impact: second kernel by kexec will have some pci devices working Found one system with 82575EB, in the kernel that is kexeced, probe igb failed with -2. it looks like the same behavior happened on forcedeth. try to check system_state to make sure if put it on D3 Jesse Brandeburg said that we should do that check in core code instead of every device driver. Signed-off-by: Yinghai Lu --- drivers/pci/pci.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/pci/pci.c =================================================================== --- linux-2.6.orig/drivers/pci/pci.c +++ linux-2.6/drivers/pci/pci.c @@ -593,6 +593,14 @@ int pci_set_power_state(struct pci_dev * if (state == PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3)) return 0; + /* + * Apparently it is not possible to reinitialise from D3 hot, + * only put the device into D3 if we really go for poweroff. + */ + if (system_state != SYSTEM_POWER_OFF && + (state == PCI_D3hot || state == PCI_D3cold)) + return 0; + error = pci_raw_set_power_state(dev, state, true); if (state > PCI_D0 && platform_pci_power_manageable(dev)) { @@ -1124,6 +1132,15 @@ int pci_enable_wake(struct pci_dev *dev, int error = 0; bool pme_done = false; + /* + * Apparently it is not possible to reinitialise from D3 hot, + * only put the device into D3 if we really go for poweroff. + * we only need to enable wake when we are going to power off + */ + if (enable && system_state != SYSTEM_POWER_OFF && + (state == PCI_D3hot || state == PCI_D3cold)) + return 0; + if (enable && !device_may_wakeup(&dev->dev)) return -EINVAL;