Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751937AbZCHKI3 (ORCPT ); Sun, 8 Mar 2009 06:08:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750921AbZCHKIS (ORCPT ); Sun, 8 Mar 2009 06:08:18 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:33336 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750891AbZCHKIQ (ORCPT ); Sun, 8 Mar 2009 06:08:16 -0400 From: "Rafael J. Wysocki" To: Yinghai Lu Subject: Re: [PATCH] pci: fix kexec with power state D3 Date: Sun, 8 Mar 2009 11:08:23 +0100 User-Agent: KMail/1.11.1 (Linux/2.6.29-rc7-tst; KDE/4.2.1; x86_64; ; ) Cc: Ingo Molnar , Andrew Morton , Jesse Barnes , Matthew Wilcox , Jesse Brandeburg , David Miller , "linux-kernel@vger.kernel.org" , NetDev , linux-pci@vger.kernel.org, pm list References: <49B1F934.5050006@kernel.org> <4807377b0903062318q15ba52a7n82d4c9399b8a7fa8@mail.gmail.com> <49B37D38.7060304@kernel.org> In-Reply-To: <49B37D38.7060304@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903081108.24541.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2574 Lines: 77 On Sunday 08 March 2009, Yinghai Lu wrote: > > 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 This is not enough, because the PM code doesn't change system_state and it uses pci_set_power_state too. > Jesse Brandeburg said that we should do that check in core code instead of > every device driver. Well, I'm not really sure. The drivers are where the bug is. > Signed-off-by: Yinghai Lu > > --- > drivers/pci/pci.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > 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; > + This breaks suspend/hibernation, doesn't it? Surely, we want to put devices into D3 when going for suspend, for example. That's apart from the fact that the 'state == PCI_D3cold' is redundant. > 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; I don't like this at all, sorry. I thought we were supposed to avoid using system_state in such a way, apart from the other things. Thanks, Rafael -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/