From patchwork Tue Jan 2 16:08:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10140979 X-Patchwork-Delegate: geert@linux-m68k.org 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 08ED160594 for ; Tue, 2 Jan 2018 16:09:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E90A028433 for ; Tue, 2 Jan 2018 16:09:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDE1128B7B; Tue, 2 Jan 2018 16:09:08 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 B03D528BCC for ; Tue, 2 Jan 2018 16:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751145AbeABQJH (ORCPT ); Tue, 2 Jan 2018 11:09:07 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:40871 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993AbeABQJF (ORCPT ); Tue, 2 Jan 2018 11:09:05 -0500 Received: by mail-lf0-f66.google.com with SMTP id u84so36187643lff.7 for ; Tue, 02 Jan 2018 08:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qzgVlJAaUoxZcV1T0FZ1W7uGyIHi5+2gErHUg+31Tqg=; b=M48fErZTjgCJYTmBEk6/n5f0ge/yt0xBAYguU9ePHFTEVfZf7nUpU0FWWu1gL9gkHY z5IDN69uicL1uFbMV8vxe7ceOSjMroapFCHq3a3JA3vcdk5c6zobFDSm4Q1QSkwgDcPS hQwXKwIS1egUI61NbYJV5vyTX1yLFXruupnQA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qzgVlJAaUoxZcV1T0FZ1W7uGyIHi5+2gErHUg+31Tqg=; b=mp20/vcaLIzYg+rOSWcbyQtbaZBurG2o7sZQMJOZVjX+vkl/3i/CCq6aWGPD8egCR/ bZoFRbyHBIklLPwfEfIzKxpG1K5lgzAVSYV4Zzz49dc4XIYaK1F77DiFmIkB/BpOIsR4 o13vHe8ZYt4IxupgC2j1D+ebPl/7v7TmKUZhOjCehPB8YusiSn9UBJ8Ytv/0TQENYQGX YREkyg4rPrsS3N5yC74R8gzSYfqNar33xMlBYRO8d28pq+xSeG6gLBuLeHSrju67FIcp mUmyfyvjNm1d4d2F7PVTlp4ANUovQ2Q+GvKAH73TW+jehlGeiRG20c666crLCyF1kzKu 1Ixw== X-Gm-Message-State: AKGB3mI91dadTt4tOu5bufIHc6fDJ+2uvDpbGoAKrugkSP/XjiIClewR Eu1dZyU4HrOjTMefITBU98k7lQ== X-Google-Smtp-Source: ACJfBot3p1SS6/ZEjF7NB4yvB8l/SwxoqueLuY5pN/w31TVP4uaCEAl9n6+3FQVmMpBNSLE8kli7zg== X-Received: by 10.25.145.85 with SMTP id y21mr15749894lfj.123.1514909344492; Tue, 02 Jan 2018 08:09:04 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id f4sm1619422lfl.17.2018.01.02.08.09.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:09:03 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Kevin Hilman , Viresh Kumar , Geert Uytterhoeven , Simon Horman , Niklas Soderlund , Vincent Guittot , linux-renesas-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 4/4] PM / wakeup: Print warn if device gets enabled as wakeup source during sleep Date: Tue, 2 Jan 2018 17:08:53 +0100 Message-Id: <1514909333-4450-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514909333-4450-1-git-send-email-ulf.hansson@linaro.org> References: <1514909333-4450-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In general, wakeup settings are not supposed to be changed during any of the system wide PM phases. The reason is simply that it would break guarantees provided by the PM core, to properly act on active wakeup sources. However, there are exceptions to when, in particular, disabling a device as wakeup source makes sense. For example, in cases when a driver realizes that its device is dead during system suspend. For these scenarios, we don't need to care about acting on the wakeup source correctly, because a dead device shouldn't deliver wakeup signals. To this reasoning and to help users to properly manage wakeup settings, let's print a warning in cases someone calls device_wakeup_enable() during system sleep. Suggested-by: Rafael J. Wysocki Signed-off-by: Ulf Hansson --- drivers/base/power/wakeup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index b7b8b2f..272c44b 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -268,6 +268,9 @@ int device_wakeup_enable(struct device *dev) if (!dev || !dev->power.can_wakeup) return -EINVAL; + if (pm_suspend_target_state != PM_SUSPEND_ON) + dev_warn(dev, "don't enable as wakup source during sleep!\n"); + ws = wakeup_source_register(dev_name(dev)); if (!ws) return -ENOMEM;