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: 9697193 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 24950603F3 for ; Mon, 24 Apr 2017 20:42:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1657A203C0 for ; Mon, 24 Apr 2017 20:42:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AD49204BD; Mon, 24 Apr 2017 20:42:22 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9BCB6203C0 for ; Mon, 24 Apr 2017 20:42:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C84C589998; Mon, 24 Apr 2017 20:42:20 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mailout2.hostsharing.net (mailout2.hostsharing.net [83.223.90.233]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF66F89998 for ; Mon, 24 Apr 2017 20:42:18 +0000 (UTC) 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 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) Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, intel-gfx@lists.freedesktop.org, "Rafael J. Wysocki" Subject: Re: [Intel-gfx] [PATCH v2 1/2] PCI / PM: Add needs_resume flag to avoid suspend complete optimization X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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,