From patchwork Mon Feb 4 11:56:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 2091271 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 30CE53FD56 for ; Mon, 4 Feb 2013 12:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271Ab3BDMNr (ORCPT ); Mon, 4 Feb 2013 07:13:47 -0500 Received: from mail-la0-f48.google.com ([209.85.215.48]:47454 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754495Ab3BDL4Q (ORCPT ); Mon, 4 Feb 2013 06:56:16 -0500 Received: by mail-la0-f48.google.com with SMTP id fq13so4431196lab.21 for ; Mon, 04 Feb 2013 03:56:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=GDJ/vWCeJl5a7hS7GHE85cFitnjD2WopQdGHdet3hqU=; b=GCRrnKmAQWXoMBH6K16qELmXvfin4bofMcFpQuFqlcbuvbMH+9X0G7bE1lPvHoR+Gj U0HJ+7RRy1KpdQ497pFjEXh3weudY2wSg1DuZSEWrhyAMNp/VyutQ7pkIfbMIgmgqkEO zuvWPSuMSaNM3PHNkOm/qDXG41isOTra4oZKNEOe/DLwlg7GUPnYCxUM1A0cxzfc9RkT dsls3Fo2sVwqz0UE2XOAtNLeI+/NEhESujmAHEwfehSj0s695aoTPWmwrMnMDvmssaCv 7luDMvRwpO7tpPdV680O6IsmU6P7H4sAmpMEyuhVDaOh2kJn4z77NIilRYg/dCMcI9hm de5g== X-Received: by 10.152.109.146 with SMTP id hs18mr19123903lab.8.1359978974715; Mon, 04 Feb 2013 03:56:14 -0800 (PST) Received: from localhost (swsoft-msk-nat.sw.ru. [195.214.232.10]) by mx.google.com with ESMTPS id iw6sm8878850lab.2.2013.02.04.03.56.13 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 04 Feb 2013 03:56:13 -0800 (PST) Subject: [PATCH v2 6/7] PCI/PM: warn about incomplete actions in ->runtime_suspend() callback To: e1000-devel@lists.sourceforge.net, linux-pci@vger.kernel.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org From: Konstantin Khlebnikov Cc: Bjorn Helgaas Date: Mon, 04 Feb 2013 15:56:12 +0400 Message-ID: <20130204115612.5569.49895.stgit@zurg> In-Reply-To: <20130204115246.5569.85829.stgit@zurg> References: <20130204115246.5569.85829.stgit@zurg> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Documentation/power/pci.txt says: | It is expected that the device driver's pm->runtime_suspend() callback will | not attempt to prepare the device for signaling wakeup or to put it into a | low-power state. The driver ought to leave these tasks to the PCI subsystem | that has all of the information necessary to perform them. After commit 42eca2302146fed51335b95128e949ee6f54478f ("PCI: Don't touch card regs after runtime suspend D3") | If the driver takes care of state saving, don't touch any registers on it. pci_pm_runtime_suspend() thinks if state has been saved by ->runtime_suspend() that means device alredy prepared for wakeup and probably no longer accessible. Thus driver must either do all actions or leave all these tasks to PCI subsystem. Signed-off-by: Konstantin Khlebnikov Cc: Rafael J. Wysocki Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org --- drivers/pci/pci-driver.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index f9aa311..2b0ff9a 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1009,12 +1009,19 @@ static int pci_pm_runtime_suspend(struct device *dev) return 0; } - if (!pci_dev->state_saved) { - pci_save_state(pci_dev); - pci_finish_runtime_suspend(pci_dev); + if (pci_dev->state_saved) { + WARN_ONCE(pci_dev->current_state == prev, + "PCI PM: Power state of device not changed by %pF\n", + pm->runtime_suspend); + WARN_ONCE(pci_dev_run_wake(pci_dev) && + !pci_dev->wakeup_prepared, + "PCI PM: Waking of device not configured by %pF\n", + pm->runtime_suspend); + return 0; } - return 0; + pci_save_state(pci_dev); + return pci_finish_runtime_suspend(pci_dev); } static int pci_pm_runtime_resume(struct device *dev)