From patchwork Thu Oct 18 12:30:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 10647087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 073BA17D4 for ; Thu, 18 Oct 2018 12:30:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E901828723 for ; Thu, 18 Oct 2018 12:30:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDA2928870; Thu, 18 Oct 2018 12:30:52 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 6392428867 for ; Thu, 18 Oct 2018 12:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbeJRUbj (ORCPT ); Thu, 18 Oct 2018 16:31:39 -0400 Received: from mga04.intel.com ([192.55.52.120]:60958 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbeJRUbi (ORCPT ); Thu, 18 Oct 2018 16:31:38 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Oct 2018 05:30:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,396,1534834800"; d="scan'208";a="100519703" Received: from mylly.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.72]) by orsmga001.jf.intel.com with ESMTP; 18 Oct 2018 05:30:44 -0700 From: Jarkko Nikula To: linux-pci@vger.kernel.org Cc: linux-pm@vger.kernel.org, Bjorn Helgaas , "Rafael J . Wysocki" , Mika Westerberg , Jean Delvare , Wolfram Sang , Jarkko Nikula , stable@vger.kernel.org Subject: [PATCH] PCI / PM: Allow runtime PM without callback functions Date: Thu, 18 Oct 2018 15:30:38 +0300 Message-Id: <20181018123038.21386-1-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow PCI core to do runtime PM to devices without needing to use dummy runtime PM callback functions if there is no need to do anything device specific beyond PCI device power state management. Implement this by letting core to change device power state during runtime PM transitions even if no callback functions are defined. Fixes: a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") Reported-by: Mika Westerberg Cc: Signed-off-by: Jarkko Nikula Reviewed-by: Rafael J. Wysocki --- This is related to my i2c-i801.c fix thread back in June which I completely forgot till now: https://lkml.org/lkml/2018/6/27/642 Discussion back then was that it should be handled in the PCI PM instead of having dummy functions in the drivers. I wanted to respin with a patch. --- drivers/pci/pci-driver.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index bef17c3fca67..6185b878ede1 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1239,7 +1239,7 @@ static int pci_pm_runtime_suspend(struct device *dev) struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; pci_power_t prev = pci_dev->current_state; - int error; + int error = 0; /* * If pci_dev->driver is not set (unbound), we leave the device in D0, @@ -1251,11 +1251,9 @@ static int pci_pm_runtime_suspend(struct device *dev) return 0; } - if (!pm || !pm->runtime_suspend) - return -ENOSYS; - pci_dev->state_saved = false; - error = pm->runtime_suspend(dev); + if (pm && pm->runtime_suspend) + error = pm->runtime_suspend(dev); if (error) { /* * -EBUSY and -EAGAIN is used to request the runtime PM core @@ -1292,7 +1290,7 @@ static int pci_pm_runtime_suspend(struct device *dev) static int pci_pm_runtime_resume(struct device *dev) { - int rc; + int rc = 0; struct pci_dev *pci_dev = to_pci_dev(dev); const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; @@ -1306,14 +1304,12 @@ static int pci_pm_runtime_resume(struct device *dev) if (!pci_dev->driver) return 0; - if (!pm || !pm->runtime_resume) - return -ENOSYS; - pci_fixup_device(pci_fixup_resume_early, pci_dev); pci_enable_wake(pci_dev, PCI_D0, false); pci_fixup_device(pci_fixup_resume, pci_dev); - rc = pm->runtime_resume(dev); + if (pm && pm->runtime_resume) + rc = pm->runtime_resume(dev); pci_dev->runtime_d3cold = false;