From patchwork Fri May 13 11:15:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 9090481 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7396C9F441 for ; Fri, 13 May 2016 11:16:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88F8B2022D for ; Fri, 13 May 2016 11:16:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 932712021A for ; Fri, 13 May 2016 11:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752473AbcEMLQs (ORCPT ); Fri, 13 May 2016 07:16:48 -0400 Received: from mailout3.hostsharing.net ([176.9.242.54]:45896 "EHLO mailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752102AbcEMLQs (ORCPT ); Fri, 13 May 2016 07:16:48 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout3.hostsharing.net (Postfix) with ESMTPS id A99CB1040FFBF; Fri, 13 May 2016 13:16:45 +0200 (CEST) Received: from localhost (6-38-90-81.adsl.cmo.de [81.90.38.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id 8B41E603E03D; Fri, 13 May 2016 13:16:43 +0200 (CEST) X-Mailbox-Line: From f7fa3cf94bbf7f04e97aecbb65255ce65afc2631 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Lukas Wunner Date: Fri, 13 May 2016 13:15:31 +0200 Subject: [PATCH v2 05/13] PCI: Use portdrv pm iterator on further callbacks To: linux-pci@vger.kernel.org, linux-pm@vger.kernel.org Cc: Andreas Noever Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 We already allow service drivers to declare ->suspend and ->resume callbacks which get called one by one when the port is suspended or resumed. Allow the same for ->prepare, ->complete, ->resume_noirq, ->runtime_suspend and ->runtime_resume. Call pcie_port_resume_noirq() also on ->restore_noirq. Signed-off-by: Lukas Wunner --- drivers/pci/pcie/portdrv_pci.c | 29 ++++++++++++++++++++++++++--- include/linux/pcieport_if.h | 5 +++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index acbd1d2..f75d4b5 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -104,6 +104,18 @@ static int generic_iter(struct device *dev, void *data) * The return value is 0 if all port services' callbacks returned 0, otherwise * it is the return value of the last callback executed. */ +static int pcie_port_prepare(struct device *dev) +{ + size_t o = offsetof(struct pcie_port_service_driver, prepare); + return device_for_each_child(dev, &o, generic_iter); +} + +static void pcie_port_complete(struct device *dev) +{ + size_t o = offsetof(struct pcie_port_service_driver, complete); + device_for_each_child(dev, &o, generic_iter); +} + static int pcie_port_suspend(struct device *dev) { size_t o = offsetof(struct pcie_port_service_driver, suspend); @@ -118,6 +130,7 @@ static int pcie_port_resume(struct device *dev) static int pcie_port_resume_noirq(struct device *dev) { + size_t o = offsetof(struct pcie_port_service_driver, resume_noirq); struct pci_dev *pdev = to_pci_dev(dev); /* @@ -127,17 +140,24 @@ static int pcie_port_resume_noirq(struct device *dev) */ if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT) pcie_clear_root_pme_status(pdev); - return 0; + + return device_for_each_child(dev, &o, generic_iter); } static int pcie_port_runtime_suspend(struct device *dev) { - return to_pci_dev(dev)->bridge_d3 ? 0 : -EBUSY; + size_t o = offsetof(struct pcie_port_service_driver, runtime_suspend); + + if (!to_pci_dev(dev)->bridge_d3) + return -EBUSY; + + return device_for_each_child(dev, &o, generic_iter); } static int pcie_port_runtime_resume(struct device *dev) { - return 0; + size_t o = offsetof(struct pcie_port_service_driver, runtime_resume); + return device_for_each_child(dev, &o, generic_iter); } static int pcie_port_runtime_idle(struct device *dev) @@ -151,6 +171,8 @@ static int pcie_port_runtime_idle(struct device *dev) } static const struct dev_pm_ops pcie_portdrv_pm_ops = { + .prepare = pcie_port_prepare, + .complete = pcie_port_complete, .suspend = pcie_port_suspend, .resume = pcie_port_resume, .freeze = pcie_port_suspend, @@ -158,6 +180,7 @@ static const struct dev_pm_ops pcie_portdrv_pm_ops = { .poweroff = pcie_port_suspend, .restore = pcie_port_resume, .resume_noirq = pcie_port_resume_noirq, + .restore_noirq = pcie_port_resume_noirq, .runtime_suspend = pcie_port_runtime_suspend, .runtime_resume = pcie_port_runtime_resume, .runtime_idle = pcie_port_runtime_idle, diff --git a/include/linux/pcieport_if.h b/include/linux/pcieport_if.h index d205bd6..092517d 100644 --- a/include/linux/pcieport_if.h +++ b/include/linux/pcieport_if.h @@ -49,8 +49,13 @@ struct pcie_port_service_driver { const char *name; int (*probe) (struct pcie_device *dev); void (*remove) (struct pcie_device *dev); + int (*prepare) (struct pcie_device *dev); + int (*complete) (struct pcie_device *dev); int (*suspend) (struct pcie_device *dev); int (*resume) (struct pcie_device *dev); + int (*resume_noirq) (struct pcie_device *dev); + int (*runtime_suspend) (struct pcie_device *dev); + int (*runtime_resume) (struct pcie_device *dev); /* Service Error Recovery Handler */ const struct pci_error_handlers *err_handler;