From patchwork Wed Mar 18 09:37:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Bolle X-Patchwork-Id: 6037321 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 7FF44BF90F for ; Wed, 18 Mar 2015 09:37:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DF74204D5 for ; Wed, 18 Mar 2015 09:37:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 019B92045E for ; Wed, 18 Mar 2015 09:37:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1EB126E1B0; Wed, 18 Mar 2015 02:37:21 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cpsmtpb-ews06.kpnxchange.com (cpsmtpb-ews06.kpnxchange.com [213.75.39.9]) by gabe.freedesktop.org (Postfix) with ESMTP id 050AB6E1B0; Wed, 18 Mar 2015 02:37:19 -0700 (PDT) Received: from cpsps-ews25.kpnxchange.com ([10.94.84.191]) by cpsmtpb-ews06.kpnxchange.com with Microsoft SMTPSVC(7.5.7601.17514); Wed, 18 Mar 2015 10:37:18 +0100 Received: from CPSMTPM-TLF101.kpnxchange.com ([195.121.3.4]) by cpsps-ews25.kpnxchange.com with Microsoft SMTPSVC(7.5.7601.17514); Wed, 18 Mar 2015 10:37:17 +0100 Received: from x41 ([77.173.140.92]) by CPSMTPM-TLF101.kpnxchange.com with Microsoft SMTPSVC(7.5.7601.17514); Wed, 18 Mar 2015 10:37:17 +0100 Message-ID: <1426671436.2649.19.camel@tiscali.nl> Subject: Re: [PATCH v2] drm/i915: gen4: work around hang during hibernation From: Paul Bolle To: Imre Deak Date: Wed, 18 Mar 2015 10:37:16 +0100 In-Reply-To: <1425294281-7297-1-git-send-email-imre.deak@intel.com> References: <1425294281-7297-1-git-send-email-imre.deak@intel.com> X-Mailer: Evolution 3.12.11 (3.12.11-1.fc21) Mime-Version: 1.0 X-OriginalArrivalTime: 18 Mar 2015 09:37:17.0345 (UTC) FILETIME=[1F95E910:01D0615F] X-RcptDomain: lists.freedesktop.org Cc: Jani Nikula , Daniel Vetter , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, =?ISO-8859-1?Q?Bj=F8rn?= Mork , David Weinehall 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, 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 Imre Deak schreef op ma 02-03-2015 om 13:04 [+0200]: > 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. > > v2: > - Another GEN4 Lenovo laptop had the same issue, while platforms from > other vendors (including mobile and desktop, GEN4 and non-GEN4) seem > to work fine. Based on this apply the workaround on all GEN4 Lenovo > platforms. > - add code comment about failing platforms (Ville) The outdated ThinkPad X41 that I torture by running rc's showed identical symptoms, also since v3.19-rc1. It uses a gen3 chipset (it has a 915GM, I think, but I keep forgetting details like that). I did everything wrong to get this fixed (1: hope this gets magically fixed; 2: bisect it myself, thinking every now and then that I know better than git bisect which commit to choose; 3: finally grep lkml). So here I am late to the show. > 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 | 30 +++++++++++++++++++++++++----- > 1 file changed, 25 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c > index 4badb23..ff3662f 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,17 @@ 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 GEN4 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. Platforms where this was seen: > + * Lenovo Thinkpad X301, X61s > + */ > + if (!(hibernation && > + drm_dev->pdev->subsystem_vendor == PCI_VENDOR_ID_LENOVO && > + INTEL_INFO(dev_priv)->gen == 4)) > + pci_set_power_state(drm_dev->pdev, PCI_D3hot); > > return 0; > } I'll paste a DRAFT patch that fixes this for that X41 at the end of the message. The patch is rather ugly. Should we perhaps try a quirk table or something like that? Paul Bolle -------->8-------- Subject: [PATCH] drm/i915: work around hang during hibernation on gen3 too Commit ab3be73fa7b4 ("drm/i915: gen4: work around hang during hibernation") was targetted at gen4 platforms shipped by Lenovo. The same problem can also be seen on a Lenovo ThinkPad X41. Expand the test to catch that system too. Sadly, this system still uses IBM's subsystem vendor id. So we end up with a rather unpleasant test. Use the IS_GEN3() and IS_GEN4() macros to lessen the pain a bit. Not-yet-signed-off-by: Paul Bolle --- drivers/gpu/drm/i915/i915_drv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index cc6ea53d2b81..3a07164f5860 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -641,11 +641,12 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev, bool hibernation) * 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. Platforms where this was seen: - * Lenovo Thinkpad X301, X61s + * Lenovo Thinkpad X301, X61s, X41 */ if (!(hibernation && - drm_dev->pdev->subsystem_vendor == PCI_VENDOR_ID_LENOVO && - INTEL_INFO(dev_priv)->gen == 4)) + (drm_dev->pdev->subsystem_vendor == PCI_VENDOR_ID_LENOVO || + drm_dev->pdev->subsystem_vendor == PCI_SUBVENDOR_ID_IBM) && + (IS_GEN3(dev_priv) || IS_GEN4(dev_priv)))) pci_set_power_state(drm_dev->pdev, PCI_D3hot); return 0;