From patchwork Wed Apr 10 09:55:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162010 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp5996359jan; Wed, 10 Apr 2019 02:55:27 -0700 (PDT) X-Received: by 2002:ac2:4242:: with SMTP id m2mr1528792lfl.142.1554890127523; Wed, 10 Apr 2019 02:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554890127; cv=none; d=google.com; s=arc-20160816; b=z4PHM4ReirBHavw1w3ltXvSkcbFhyC8kWWT7Ar+wiKT7i7WTe+/FbtpQTHzu2DqVPa TPRGHGkKQvmmgds2oB7qMs895F6lyxAWKHh6mxpEKF2HwW1+l3k8T/5dsgEGvOEPL/Ov wNnkcfTK+Cdtd0MeTh9ZzRyxCT3X+V0sdOimKGe9Dbj8rzPaCVzxGs5pFuD1zcHX0eva 9stcp7VQEjJkUeaFJuI4HjzWXQpLC9kR4bgMJ6Dq/rk/GFarwtNry9y8se6MxdweVNVK tXTJ8KpY8aC/7u21gj9tBDdM/bbGNtSa5oRj8SMtJx/NAJtoKicu5QNnMstrVHX1OFxq 69Tg== 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; bh=IdJSlX082YGa+o2RjrcHVg2ClWPcfT2dSVotJi56VHg=; b=HqGWLkefrluSyiZ9NHi6R9BzDaZ5SNA6FRjOIm/o27ZSKhLcDmWJ46WP0aIOi398bR wla0WGAhPkAakyCAdxTOO0HAkWNuja//G9Umt1VhQvIVc3W++U2A83d0hDZQ0IzKL6Ve 6h62Gd3XxHsW0OUvvu/3f5m73BctKhFE1Ogb0REKwOvG4TBTeLYd3TuiaIaFDphlzzRz qXDg0Ud4zXyh5P/Eafbb6auc3r2jrR4qVe4LI4OTQleRnarENucdyvai8pZwYwQyrgUU CR3egcpmHGIxANLiGuHQ07Yr9UZxzXEjtfgqsg2xP425Nw44edzA9vakSMQZaejGkky4 srlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LXkahYLK; 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 t12sor18435076ljg.19.2019.04.10.02.55.27 for (Google Transport Security); Wed, 10 Apr 2019 02:55:27 -0700 (PDT) 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=LXkahYLK; 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=IdJSlX082YGa+o2RjrcHVg2ClWPcfT2dSVotJi56VHg=; b=LXkahYLKzcDWcov3EhmrnSqF7l0ZXLldbNSWy+3WOKivzEWNVsDEMAc/w1fGAJ0d+S jU+gZtakF/P20vRD0HTjJydZ0aodQzLjGq1sxd7k7PMNOCTsAYwSdIMuxElevBFQbOsE oelE3y3dezV9zqaCi//YyPIEGhlmkX6pCoER0fRz9WRyqRXOToansJreNKndeL0vud5f MtXOSNFAk98IV0gHyxqzBdceik6Fls+cTt+p7vAbsGxieUdDdkJRRuH0YIjLomA8qS9F B1UBFGwoqaeC9YQZFqO0vnTdET8iiYBdIq6ceOmemhmAz+LCCRV1JpTdrL+YS8+RjKWS Lvww== 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=IdJSlX082YGa+o2RjrcHVg2ClWPcfT2dSVotJi56VHg=; b=ZwdO94xJcTzrAR3LnvFQPCwxE4H+9rnjtfSTr3YbcnhHSnrLN83s2eSM+QbA+jcivi 6MXpJo2gPmcorahD2rLiW+7Ksu8hILEvsXAVC2dp2z8DDIZLsu4ea8zc4StmcxoL686d Up4J9HCr8M5GSrMhZIZtOgE8cxIQ3xfvDwl0XqnaD8mi27HHCEtDwGRmg6tAfUwb00Jo qY8yWEgoUAA+kbAjyXNOcn3wO8YyLnkpMPBeFpJ4DFWAFX0pptpSY1+gsTSMUrSe9FMJ 6eB5CDVZJOrN8WftSQdR+3H/GMuv02UOaiBui5oxMbFvhPxDssvMz0vbexlKaIJXKjF5 lqnA== X-Gm-Message-State: APjAAAVf0YWtZiGXVD/UA6wcOmZU0YbwYcAUaUhFK576oIinv7/61Fdh 3QP1aJP8xiJVblHGB1IwXik8OI2f X-Google-Smtp-Source: APXvYqwk7081QudqCuERp6RleVPoGeEKggtgjEdb4dksKdX/YeywMTxgd+NhOrUbEYXQ2jg1bnL9HA== X-Received: by 2002:a2e:9013:: with SMTP id h19mr16508925ljg.136.1554890126771; Wed, 10 Apr 2019 02:55:26 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id h3sm113941lfe.87.2019.04.10.02.55.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 02:55:26 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Loic Pallardy , Linus Walleij , Alexandre Torgue , Rob Herring , Greg Kroah-Hartman , Johan Hovold , linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH] PM / core: Propagate dev->power.wakeup_path when no callbacks Date: Wed, 10 Apr 2019 11:55:16 +0200 Message-Id: <20190410095516.6170-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 The dev->power.direct_complete flag may become set in device_prepare() in case the device don't have any PM callbacks (dev->power.no_pm_callbacks is set). This leads to a broken behaviour, when there is child having wakeup enabled and relies on its parent to be used in the wakeup path. More precisely, when the direct complete path becomes selected for the child in __device_suspend(), the propagation of the dev->power.wakeup_path becomes skipped as well. Let's address this problem, by checking if the device is a part the wakeup path or has wakeup enabled, then prevent the direct complete path from being used. Reported-by: Loic Pallardy Signed-off-by: Ulf Hansson --- More background: This problem was reported by Loic Pallardy, offlist, while he was working on enabling wakeup for a tty serial console driver. When I looked more closely, I noticed that uart_suspend_port() calls device_may_wakeup() for the tty child devices, and then also the used serial driver check its device (parent) for device_may_wakeup(). To me this looks like workarounds to fix a behaviour that really should be dealt with from the PM core, no matter of whether the child have PM callbacks assigned or not. In other words, it seems like the serial driver(s) should be checking the wakeup_path flag for the parent, solely, instead. I haven't digested further behaviours for other subsystem, but recently reviewed a patch for a gpio driver [1], that seems to be suffering from the similar problems. Kind regards Ulf Hansson [1] https://lkml.org/lkml/2019/4/4/1283 --- drivers/base/power/main.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.17.1 diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 41eba82ee7b9..f9cfdeee8288 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1747,6 +1747,10 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) if (dev->power.syscore) goto Complete; + /* Avoid direct_complete, to let wakeup_path being propagated. */ + if (device_may_wakeup(dev) || dev->power.wakeup_path) + dev->power.direct_complete = false; + if (dev->power.direct_complete) { if (pm_runtime_status_suspended(dev)) { pm_runtime_disable(dev);