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: 123156 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9132312qgn; Tue, 2 Jan 2018 08:09:04 -0800 (PST) X-Received: by 10.25.208.73 with SMTP id h70mr7125920lfg.27.1514909344856; Tue, 02 Jan 2018 08:09:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514909344; cv=none; d=google.com; s=arc-20160816; b=DMsMLscsGSSPTanDc9NRXvPP9ROgu62LgyTzQSt+vOn42D1X3mSGff9QDRHpYPIOAi cryEyhbJQZzY4ndPQW/Ww0GNllgCjQLBSTBiaCfd7L2Kh1XIRXQtzoGedzUmoaKKeCYr qKTW/Ok8mTBvjjV6pHAJPCQsO80wm3TyKNNCd3ju/npvi1pOW6hZaNHoJjCLvtoRYWxa GCFiCWaXF3P4v2vWFS3WmJRVKcFojh6PkGEzOPYWw1Dge2IPQfaozWDX1XeLs8PHEyWR MCiJJdlowLLdck0drjrRKcyT5JUAhHLUpsyniyPAVwKGDgHuckv1/w7Ees9eDc5LsLXh Z5qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=qzgVlJAaUoxZcV1T0FZ1W7uGyIHi5+2gErHUg+31Tqg=; b=MewfCd7X2Q/F9QNtQDXxvPw+TCXLyyUYr5XlaBEckOZYD9cQSFavIFKQmBmxiQSC6t YmPWu4EZLuZunQLMGCqNd72N8OvBSKaZsm743x8lZvnVzcZguMhexZw3J06v0ojGFFjc ocVC0n/x7HvIAoBZaPmy12usLgaY8nsMYSKiYCrEbq6JPQ/JBdP60Jxud5O2sSR8jfno anaIVTREHNLxt9Kv0GIDYeRPLGopMB2Unt6n/8qJ2HBmE2zrTUNvlcDQKW0ACm8UgFyM c/I6Si8MZkFOphXF9dyS0bH1GbY1rfQ62AM+YJWLAsyRYfQGkwuG+aj6l/AVFJzPnt1o nbuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M48fErZT; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g78sor3188017lfh.47.2018.01.02.08.09.04 for (Google Transport Security); Tue, 02 Jan 2018 08:09:04 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M48fErZT; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=YywBy77FDjpP92ksxbKB8ruxh74gGbFmg26+6GHYT18PUD/ST30Ax7yctjP3fa2cAm 8lTk1yVmtJ4YPByhaq5Pj5rUN1PeNbxvvzISvcEiNmtfX3m/34/pAE/Lx3/HKf9yP8lr LiOAhbPse8a0zOhyNVpzVOfzymQuuDZbuG6gTv+rOK3xhaQWeplG9r6W7/RIzoTdG3iv hCi0/Z1P4z46ARUFk2JK2EGesqgYnCN46pE77H7fLEUYgHNjZGp7btwZ9/D4tbDegJoA 3TKF9szRBE40gMKBXtW3AO2BqWr4mfk3wm7tHkEyC2PO22Jb+P6+YX/KorUZmPc5M4VV /GiA== X-Gm-Message-State: AKGB3mKRkVq+UlFyAybf0Vogl3uaSiHDpo2SZ+mIlFsvZaQ3S8cAGLtU ZM4m3LB3CR7VSBAlv4RRizLTZjgcyfMWwQ== 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) Return-Path: 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> 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(+) -- 2.7.4 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;