From patchwork Thu Jan 11 08:18:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 124152 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp355385qgn; Thu, 11 Jan 2018 00:19:07 -0800 (PST) X-Received: by 10.46.17.80 with SMTP id f77mr12265425lje.54.1515658747757; Thu, 11 Jan 2018 00:19:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515658747; cv=none; d=google.com; s=arc-20160816; b=EjaUBv4Lpm7+JSNaDvAOXdgAZnPFhBJyYUmeopHvxfTx24CAj6LDvL2YJfzkGxVI1A pBEjJY2S2sFlNBaGBY+NAs8OuA5WHxdpuFyHTiluGCMw7w4rRidFmnIaaneMdCd4469l 3AXfo/3eJUkz6ZVQ7sw4WjE0qx6qNsaf66RYcoTIrUEEZHJ6jZvHBNY+pvlSR3GL6XQq Xw8GGWAfWVEFscr3UpI5dJVPvfU/AbD7xM62ukjzgEk+K0cJfi9pOSCR0pLDPA5H6wx2 I1lICbluwMgKuXTJmmN1WWHmTso0QxrKfq03Mvn10s7fJ6PG5Rx37/6XvnVtkTCRRCDj aT9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ISr/ZlGciKx+MMnHPVY2yh+um78pY3IQutM5jfldZKM=; b=LlQguNXPcNbgx5/10bJtR/zSKcE1O2k07Nzoep7pp5ttgynE0QhemvizxUvgoIW+dr zi/ODpvbxCyFmSy9XtbdaEc9OpeMq47wMXHnO9ZbGuEuVxRI+Lgx5ECCkX7UEaMbjbHT u568KJN7mmEIh0Cifg2Hw+oE7S16GhoXwFmHdmIsHivu6z7OGojDZMHimz2/2DWP7ZNU 6iRTnEwsbFYM72RppvZQ1s9i5fVhtq5jkKr9uGB3wALZW4lFYQlpeqPOCc5m0rDfD9eF j3N+kON3hIm3Z+/sg+1huLIopN2Ezsgm8Pv6GZvgHR8geSg9wBCeqn2/zxPHBiCPXxfD +XSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F/AFot6W; 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 z68sor971078lje.21.2018.01.11.00.19.07 for (Google Transport Security); Thu, 11 Jan 2018 00:19:07 -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=F/AFot6W; 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; bh=ISr/ZlGciKx+MMnHPVY2yh+um78pY3IQutM5jfldZKM=; b=F/AFot6WVXf/iXEhqPmlZa5t7UnPBQKka2aGtcGlcpVZ9ASNpchqWfyc/4Un0aL2ue CDuzQEcPxG1hxJdrMgwODxIpAgvEzcRONLrhRUoCFfY8B5Z1rbI6vmaFBBjLkKQubw60 enUL3wdcF+nk2p15vC5bXV/tRtK1JpqZ5PIYg= 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; bh=ISr/ZlGciKx+MMnHPVY2yh+um78pY3IQutM5jfldZKM=; b=j3zSnRD5I1t+epd28M8TkE3FDm126SnO4CWdfXDac9fEEaLnlTLiOgYh5gd9kpdlkV lz/8hGS5EVpxCb/b9WWAqPb/YEIC+aAfTNShK3g1PeQi+j9+gl+CPQFsICBKmn4lcT0D xzqFeLQOPcIokHMAh1/jkQ6WMFwD0k1gy7Wv3x7EqfXONF8mfOYUfu2G9kHCdxMg4jXK ivbm9X24l63xQHPHzIlmtxMDPC6w972KtjjDdS0kFayL15auewTXayDwFKeG2aDnDdTc 2M20gOoYYYoa8oZdC4su6GL16T2NMdsYLb2ryuZPscrPV2Oh8EQzMg8WE9elqPRZz0jo chfw== X-Gm-Message-State: AKGB3mLGF8FHiJ2NV/GCu1e2zeKzrt92h0y77JmYXxrGLvtCFqeSI7US 0p4c7opwqVU19LaVEMQhbwRGkuCq X-Google-Smtp-Source: ACJfBoug8rrMK8vKTHrJRs7ucTdjSr4NlP45izsQFniogtVqzAMa0igpcjdDTnglRefE/C/MQ3oHMQ== X-Received: by 10.46.21.68 with SMTP id 4mr13896604ljv.95.1515658747046; Thu, 11 Jan 2018 00:19:07 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r5sm1941752lfi.14.2018.01.11.00.19.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Jan 2018 00:19:06 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Ulf Hansson Subject: [PATCH v5] PM / wakeup: Print warn if device gets enabled as wakeup source during sleep Date: Thu, 11 Jan 2018 09:18:59 +0100 Message-Id: <1515658739-24833-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 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 --- Changes in v5: - Fix build error when CONFIG_SUSPEND is unset and CONFIG_PM_SLEEP is set. Changes in v4: - Send this as a separate change. - Changed from dev_warn() to dev_dbg(). --- drivers/base/power/wakeup.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.7.4 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index e73a081..c9dc468 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -19,6 +19,11 @@ #include "power.h" +#ifndef CONFIG_SUSPEND +suspend_state_t pm_suspend_target_state; +#define pm_suspend_target_state (PM_SUSPEND_ON) +#endif + /* * If set, the suspend/hibernate code will abort transitions to a sleep state * if wakeup events are registered during or immediately before the transition. @@ -268,6 +273,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_dbg(dev, "don't enable as wakup source during sleep!\n"); + ws = wakeup_source_register(dev_name(dev)); if (!ws) return -ENOMEM;