From patchwork Mon Apr 24 20:42:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 9697191 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 148D9603F3 for ; Mon, 24 Apr 2017 20:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 069E9203C0 for ; Mon, 24 Apr 2017 20:42:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFA8C204BD; Mon, 24 Apr 2017 20:42:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C49C203C0 for ; Mon, 24 Apr 2017 20:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S977723AbdDXUmT (ORCPT ); Mon, 24 Apr 2017 16:42:19 -0400 Received: from mailout2.hostsharing.net ([83.223.90.233]:40085 "EHLO mailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S977803AbdDXUmS (ORCPT ); Mon, 24 Apr 2017 16:42:18 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout2.hostsharing.net (Postfix) with ESMTPS id 930B610189ACE; Mon, 24 Apr 2017 22:41:56 +0200 (CEST) Received: from localhost (5-38-90-81.adsl.cmo.de [81.90.38.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id C5C93603E10E; Mon, 24 Apr 2017 22:42:14 +0200 (CEST) Date: Mon, 24 Apr 2017 22:42:42 +0200 From: Lukas Wunner To: Imre Deak Cc: intel-gfx@lists.freedesktop.org, "Rafael J. Wysocki" , Bjorn Helgaas , linux-pci@vger.kernel.org Subject: Re: [PATCH v2 1/2] PCI / PM: Add needs_resume flag to avoid suspend complete optimization Message-ID: <20170424204242.GA9933@wunner.de> References: <1493044063-2095-1-git-send-email-imre.deak@intel.com> <20170424200230.GA9910@wunner.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170424200230.GA9910@wunner.de> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Apr 24, 2017 at 10:02:30PM +0200, Lukas Wunner wrote: > On Mon, Apr 24, 2017 at 05:27:42PM +0300, Imre Deak wrote: > > Some drivers - like i915 - may not support the system suspend direct > > complete optimization due to differences in their runtime and system > > suspend sequence. Add a flag that when set resumes the device before > > calling the driver's system suspend handlers which effectively disables > > the optimization. > > FWIW, there are at least two alternative solutions to this problem which > do not require changes to the PCI core: > > (1) Add a ->prepare hook to i915_pm_ops which calls pm_runtime_get_sync() > and a ->complete hook which calls pm_runtime_put(). Thinking a bit more about this, it's even simpler: The PM core acquires a runtime PM ref in device_prepare() and releases it in device_complete(), so it's sufficient to just call pm_runtime_resume() in a ->prepare hook that's newly added to i915. No ->complete hook necessary. Tentative patch below, based on drm-intel-fixes, would replace both of your patches. Thanks, Lukas -- >8 -- diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 5c089b3..6ef156b 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -1820,6 +1820,11 @@ void i915_reset(struct drm_i915_private *dev_priv) goto wakeup; } +static int i915_pm_prepare(struct device *kdev) +{ + pm_runtime_resume(kdev); +} + static int i915_pm_suspend(struct device *kdev) { struct pci_dev *pdev = to_pci_dev(kdev); @@ -2451,6 +2456,7 @@ static int intel_runtime_resume(struct device *kdev) * S0ix (via system suspend) and S3 event handlers [PMSG_SUSPEND, * PMSG_RESUME] */ + .prepare = i915_pm_prepare, .suspend = i915_pm_suspend, .suspend_late = i915_pm_suspend_late, .resume_early = i915_pm_resume_early,