From patchwork Wed Jan 10 20:31:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 124131 Delivered-To: patches@linaro.org Received: by 10.80.140.226 with SMTP id r31csp2078533edr; Wed, 10 Jan 2018 12:32:00 -0800 (PST) X-Received: by 10.46.23.156 with SMTP id 28mr2859828ljx.29.1515616320772; Wed, 10 Jan 2018 12:32:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515616320; cv=none; d=google.com; s=arc-20160816; b=s+OL0K9PmEAKHZGSVsi2Ya3jEj42D4vSIzQ03QOlfWyspyqmZwmdtYOl0aqc1piB2a KufCw/VU6akNdKSCzLCisQpzGMdWwifTBXVGPiTFQQ51jPJB58t2YxB1rXsIKtmOP0Kw iiCQiKasaija5kMI6a36+60XGtV9rBqDmbc5d3HONlCWjgUFQyD8PuwcM6GxS3cc9pRd sSObo9huaVupTAXHkzZldKpO5Q7Sl8Thxc+Lcmc/RXEOWhRpAfe9aOaCQS59RXpVwHqT Y7bTJYm4fngoU8uhmPy2E7jqjc0ntGXty8bzGCLVk7Y9jDBsIAXYiyiS1Q7tyefONNln YUoA== 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=lgn+OvDMi8kaGdHEcFsU1kO3VFOemp18eA78uEQKwes=; b=v4ugeZlmzQGWsAa96eNFLrfFZjsgseLLkaq+ayXuG+iyLK8SP5judZZgcMsYexgRNx 4r18lFj5u+UslJSfqKynt0Z7Yr/yg6lf/mwslSpqDjMN0VJaKAFN0wKYYPJfWEXc298d XJoDuebUfZyvn2aOoogQGcdVCfZ8+RXEsmfvW/aUJvcXtzFqOqxXULDIhy6BMA5EXmc2 mnQjVqeR+X70mIPwbfXORMuKxLoTDTgnt5hIgpyHL2zNBRXnVdSnyIHO3RrN3jp+IzNv rpCcOhFotmD0Sg/JXu4MKJyF5xt/NT43k3ZsYKvxWWmqkqyzE3/KJ4TrtaYBe4DS7BQI y9gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h+JHngqr; 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 199sor3139682ljj.75.2018.01.10.12.32.00 for (Google Transport Security); Wed, 10 Jan 2018 12:32:00 -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=h+JHngqr; 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=lgn+OvDMi8kaGdHEcFsU1kO3VFOemp18eA78uEQKwes=; b=h+JHngqr3lWsDirsgJ2iKAvOcXVy2bnPm7mPuomHwogcu0TT8EZfXw/h1jtyIrtM47 iZHpouJs9Nq1AMo5tpwIfAmzEpXym9ot9Ex8f06f/K7DAkI8IpilJcaMZFObMcPPaRCI CDeGFZmjyNeoK0tLFoKGahbbtkX4Q/CMsdFMQ= 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=lgn+OvDMi8kaGdHEcFsU1kO3VFOemp18eA78uEQKwes=; b=QmghrlvZonvUKKJWqz75MP1ZDr+eGGcfVEAnXqw5YBmP9WdXhuY2ibfZ1Vbgidc6pY i1e2TVMVwHYDUJA81l3r5FhTdOdbCBXKSgIJHq12Hc3j1JhaO89ihN6U81+81ufuRht1 OdSHZPzdkVxwkgMrHnSE/KDTy5Vx20Zp5bfwyrWMz73hx5NsX2W9ARPIUm8Z/keoSQFG lSEjzHCNHOxaT6YB9RDe5Ej4+R190dHkgAF1HQJKNjrukYdlxwIGUhv0pbkXoKyjoe4J rQ3laVtRQBV/X0p9eePGhhR/reFsIssLBHiPZ+D6fUXck9V+K+k/cthCbqItoQDfLON8 Nuaw== X-Gm-Message-State: AKGB3mLqUrxg7pDU6TorQHnKTYyIKZivoOQhtnAkTiNRId7YU9qfaYwW 2/GQe5ZHjc1JOjARAgAtaEWcGZ1JodhiTA== X-Google-Smtp-Source: ACJfBou5kk+xWxmgzkoViMI0QZ+0P2IUpkekHXSwowM4fv2ZE5s5kDBM4CQrtwIA1U0I2Jy4ofsi8w== X-Received: by 10.46.18.8 with SMTP id t8mr11810799lje.76.1515616320241; Wed, 10 Jan 2018 12:32:00 -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 85sm3510910ljc.82.2018.01.10.12.31.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jan 2018 12:31:59 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Ulf Hansson , linux-pm@vger.kernel.org Cc: khilman@kernel.org, Geert Uytterhoeven , Mikko Perttunen Subject: [PATCH] PM / Domains: Don't skip driver's ->suspend|resume_noirq() callbacks Date: Wed, 10 Jan 2018 21:31:56 +0100 Message-Id: <1515616316-5118-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 The commit 10da65423fdb ("PM / Domains: Call driver's noirq callbacks") started to respect driver's noirq callbacks, but while doing that it also introduced a few potential problems. More precisely, in genpd_finish_suspend() and genpd_resume_noirq() the noirq callbacks at the driver level should be invoked, no matter of whether dev->power.wakeup_path is set or not. Additionally, the commit in question also made genpd_resume_noirq() to ignore the return value from pm_runtime_force_resume(). Let's fix both these issues! Fixes: 10da65423fdb ("PM / Domains: Call driver's noirq callbacks") Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index f9dcc98..48255ce 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1032,15 +1032,12 @@ static int genpd_prepare(struct device *dev) static int genpd_finish_suspend(struct device *dev, bool poweroff) { struct generic_pm_domain *genpd; - int ret; + int ret = 0; genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; - if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd)) - return 0; - if (poweroff) ret = pm_generic_poweroff_noirq(dev); else @@ -1048,10 +1045,18 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff) if (ret) return ret; + if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd)) + return 0; + if (genpd->dev_ops.stop && genpd->dev_ops.start) { ret = pm_runtime_force_suspend(dev); - if (ret) + if (ret) { + if (poweroff) + pm_generic_restore_noirq(dev); + else + pm_generic_resume_noirq(dev); return ret; + } } genpd_lock(genpd); @@ -1085,7 +1090,7 @@ static int genpd_suspend_noirq(struct device *dev) static int genpd_resume_noirq(struct device *dev) { struct generic_pm_domain *genpd; - int ret = 0; + int ret; dev_dbg(dev, "%s()\n", __func__); @@ -1094,21 +1099,20 @@ static int genpd_resume_noirq(struct device *dev) return -EINVAL; if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd)) - return 0; + return pm_generic_resume_noirq(dev); genpd_lock(genpd); genpd_sync_power_on(genpd, true, 0); genpd->suspended_count--; genpd_unlock(genpd); - if (genpd->dev_ops.stop && genpd->dev_ops.start) + if (genpd->dev_ops.stop && genpd->dev_ops.start) { ret = pm_runtime_force_resume(dev); + if (ret) + return ret; + } - ret = pm_generic_resume_noirq(dev); - if (ret) - return ret; - - return ret; + return pm_generic_resume_noirq(dev); } /**