From patchwork Thu Feb 26 18:50:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 5895461 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 83E77BF6C3 for ; Thu, 26 Feb 2015 18:54:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F7CB20212 for ; Thu, 26 Feb 2015 18:54:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 077DA203A1 for ; Thu, 26 Feb 2015 18:54:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E0EEF6E24B; Thu, 26 Feb 2015 10:54:43 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 178CB6E130; Thu, 26 Feb 2015 10:54:42 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 26 Feb 2015 10:50:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,654,1418112000"; d="scan'208,223";a="683954864" Received: from ideak-desk.fi.intel.com ([10.237.72.74]) by fmsmga002.fm.intel.com with ESMTP; 26 Feb 2015 10:50:48 -0800 Message-ID: <1424976648.17078.1.camel@intel.com> Subject: Re: [PATCH] drm/i915: fix failure to power off after hibernate From: Imre Deak To: =?ISO-8859-1?Q?Bj=F8rn?= Mork Date: Thu, 26 Feb 2015 20:50:48 +0200 In-Reply-To: <87bnkhqan8.fsf@nemi.mork.no> References: <87bnkjcqjt.fsf@nemi.mork.no> <1424789904-26699-1-git-send-email-bjorn@mork.no> <1424794340.15554.3.camel@intel.com> <878ufnjfrr.fsf@nemi.mork.no> <1424889214.5991.4.camel@intel.com> <87bnkhqan8.fsf@nemi.mork.no> Organization: Intel X-Mailer: Evolution 3.12.7-0ubuntu1 Mime-Version: 1.0 Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, stable@vger.kernel.org, Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: imre.deak@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On to, 2015-02-26 at 10:34 +0100, Bjørn Mork wrote: > Imre Deak writes: > > >> That patch fixes the problem, with only pci_set_power_state commented > >> out. Do you still want me to try with pci_disable_device() commented > >> out as well? > > > > No, but it would help if you could still try the two attached patch > > separately, without any of the previous workarounds. Based on the > > result, we'll follow up with a fix that adds for your specific platform > > either of the attached workarounds or simply avoids putting the device > > into D3 (corresponding to the patch you already tried). > > None of those patches made any difference. The laptop still hangs at > power-off. > > Not really surprising, is it? Previous testing shows that the hang > occurs at the pci_set_power_state(drm_dev->pdev, PCI_D3hot) call in the > poweroff_late hook. It is hard to see how replacing it by an attempt to > set D3cold, or adding any call after this point, could possibly change > anything. The system is stil hanging at the pci_set_power_state() call. Judging from the blinking LED, I assume that it's not pci_set_power_state() that hangs the machine, but the hang happens in BIOS code. > The generic pci-driver code will put the i915 device into PCI_D3hot for > you, won't it? Why do you need to duplicate that in the driver, > *knowing* that doing so breaks (at least some) systems? Letting the pci core put the device into D3 wouldn't get rid of the problem. It's putting the device into D3 in the first place what causes it. > I honestly don't think this "let's try some random code" is the proper > way to fix this bug (or any other bug for that matter). You need to > start understanding the code you write, and the first step is by > actually explaining the changes you make. We have a good understanding about the issue: the BIOS on your platform does something unexpected behind the back of the driver/kernel. In that sense the patches were not random, for instance the first one is based on an existing workaround for an issue that resembles quite a lot yours, see pci_pm_poweroff_noirq(). > I also believe that you completely miss the fact that this bug has > survived a full release cycle before you became aware of it, and the > implications this has wrt other affected systems/users. I assume you > understand that my system isn't one-of-a-kind, This means that there are > other affected users with identical/similar systems. Now, if none of > those users reported the bug to you (we all know why: Linux kernel > development is currently limited by the available testing resources, NOT > by the available developer resources), then how do you know that there > aren't a number of other systems affected as well? > > Let me answer that for you: You don't. > > Which is why you must explain the mechanism triggering the bug, proving > that it is a chipset/system specific issue. Because that's the only way > you will *know* that you have solved the problem not only for me, but for > all affected users. > > IMHO, the only safe and sane solution at the moment is the revert patch > I posted. It's a simple fix, reverting back to the *known* working > state before this regression was introduced. > > Then you can start over from there, trying to implement this properly. The current way is the proper one that we want for the generic case. The issue on your platform is the exception, so working around that is a sensible choice. Attached is the proposed fix for this issue. --Imre From 5c23657bc168db12a1ba100ab65fabd305c89c8a Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Thu, 26 Feb 2015 18:38:53 +0200 Subject: [PATCH] drm/i915: gm45: work around hang during hibernation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bjørn reported that his machine hang during hibernation and eventually bisected the problem to the following commit: commit da2bc1b9db3351addd293e5b82757efe1f77ed1d Author: Imre Deak Date: Thu Oct 23 19:23:26 2014 +0300 drm/i915: add poweroff_late handler The problem seems to be that after the kernel puts the device into D3 the BIOS still tries to access it, or otherwise assumes that it's in D0. This is clearly bogus, since ACPI mandates that devices are put into D3 by the OSPM if they are not wake-up sources. In the future we want to unify more of the driver's runtime and system suspend paths, for example by skipping all the system suspend/hibernation hooks if the device is runtime suspended already. Accordingly for all other platforms the goal is still to properly power down the device during hibernation. Reference: http://lists.freedesktop.org/archives/intel-gfx/2015-February/060633.html Reported-and-bisected-by: Bjørn Mork Signed-off-by: Imre Deak --- drivers/gpu/drm/i915/i915_drv.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 4badb23..67d212b 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -637,7 +637,7 @@ static int i915_drm_suspend(struct drm_device *dev) return 0; } -static int i915_drm_suspend_late(struct drm_device *drm_dev) +static int i915_drm_suspend_late(struct drm_device *drm_dev, bool hibernation) { struct drm_i915_private *dev_priv = drm_dev->dev_private; int ret; @@ -651,7 +651,14 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev) } pci_disable_device(drm_dev->pdev); - pci_set_power_state(drm_dev->pdev, PCI_D3hot); + /* + * During hibernation on some GM45 platforms the BIOS may try to access + * the device even though it's already in D3 and hang the machine. So + * leave the device in D0 on those platforms and hope the BIOS will + * power down the device properly. + */ + if (!(hibernation && IS_GM45(dev_priv))) + pci_set_power_state(drm_dev->pdev, PCI_D3hot); return 0; } @@ -677,7 +684,7 @@ int i915_suspend_legacy(struct drm_device *dev, pm_message_t state) if (error) return error; - return i915_drm_suspend_late(dev); + return i915_drm_suspend_late(dev, false); } static int i915_drm_resume(struct drm_device *dev) @@ -965,7 +972,17 @@ static int i915_pm_suspend_late(struct device *dev) if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) return 0; - return i915_drm_suspend_late(drm_dev); + return i915_drm_suspend_late(drm_dev, false); +} + +static int i915_pm_poweroff_late(struct device *dev) +{ + struct drm_device *drm_dev = dev_to_i915(dev)->dev; + + if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) + return 0; + + return i915_drm_suspend_late(drm_dev, true); } static int i915_pm_resume_early(struct device *dev) @@ -1535,7 +1552,7 @@ static const struct dev_pm_ops i915_pm_ops = { .thaw_early = i915_pm_resume_early, .thaw = i915_pm_resume, .poweroff = i915_pm_suspend, - .poweroff_late = i915_pm_suspend_late, + .poweroff_late = i915_pm_poweroff_late, .restore_early = i915_pm_resume_early, .restore = i915_pm_resume, -- 2.1.0