From patchwork Fri Apr 28 14:16:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 756420 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wDwpg6yggz9s8M for ; Sat, 29 Apr 2017 00:16:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967992AbdD1OQK (ORCPT ); Fri, 28 Apr 2017 10:16:10 -0400 Received: from mga01.intel.com ([192.55.52.88]:55113 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967342AbdD1OQJ (ORCPT ); Fri, 28 Apr 2017 10:16:09 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Apr 2017 07:16:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,388,1488873600"; d="scan'208";a="962225973" Received: from ideak-desk.fi.intel.com ([10.237.72.61]) by orsmga003.jf.intel.com with ESMTP; 28 Apr 2017 07:16:05 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Cc: Jani Nikula , "Rafael J. Wysocki" , Bjorn Helgaas , linux-pci@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v3 1/2] PCI / PM: Add needs_resume flag to avoid suspend complete optimization Date: Fri, 28 Apr 2017 17:16:02 +0300 Message-Id: <1493388963-5278-1-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 2.5.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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. Needed by the next patch fixing suspend/resume on i915. Suggested by Rafael. Cc: Rafael J. Wysocki Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org Cc: stable@vger.kernel.org Signed-off-by: Imre Deak Acked-by: Rafael J. Wysocki --- [ After discussing with Jani, I'm going to apply this and the next patch for now to the intel-gfx specific CI branch to unblock our testing. ] drivers/pci/pci.c | 3 ++- include/linux/pci.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7904d02..020f02d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2141,7 +2141,8 @@ bool pci_dev_keep_suspended(struct pci_dev *pci_dev) if (!pm_runtime_suspended(dev) || pci_target_state(pci_dev) != pci_dev->current_state - || platform_pci_need_resume(pci_dev)) + || platform_pci_need_resume(pci_dev) + || pci_dev->needs_resume) return false; /* diff --git a/include/linux/pci.h b/include/linux/pci.h index 5948cfd..2f012f8 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -316,6 +316,9 @@ struct pci_dev { unsigned int hotplug_user_indicators:1; /* SlotCtl indicators controlled exclusively by user sysfs */ + unsigned int needs_resume:1; /* Resume before calling the driver's + system suspend hooks, disabling the + direct_complete optimization. */ unsigned int d3_delay; /* D3->D0 transition time in ms */ unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */ @@ -1110,6 +1113,10 @@ bool pci_check_pme_status(struct pci_dev *dev); void pci_pme_wakeup_bus(struct pci_bus *bus); void pci_d3cold_enable(struct pci_dev *dev); void pci_d3cold_disable(struct pci_dev *dev); +static inline void pci_resume_before_suspend(struct pci_dev *dev, bool enable) +{ + dev->needs_resume = enable; +} static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable)