Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp221074pxk; Thu, 24 Sep 2020 04:09:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZ/NK01KvhulLU0x3U48955Cw74ntW5WcPgDK/1i6TF2RfiiR12THPO++NQjWJKXE0lbWh X-Received: by 2002:a50:ab59:: with SMTP id t25mr407112edc.364.1600945768963; Thu, 24 Sep 2020 04:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600945768; cv=none; d=google.com; s=arc-20160816; b=sKCjJ68hS7LB2YkTfpd+dFkeodUqr7Jj7UnR4HYmagI3yvgdfcEpw7wP8XR/NzGH+s ADHbhL//CwFUSaiBq48di/Ag/ig1MS1iZ1fpXj/R6Rl1qgW7LlGKRpSoQc8hKvu1m0fe 2v9T9Qin5UO1fuXN+LCAmzBjyL1wn9e+4qiX3h3fhaAVq0UWv8qAnl8DLEEZvllkgDfp SL8jzk3AAw4Ixy7cwMn0eWfmlt8WOgFJun1CDNmC2ScYfmP6oUZU4Rx2N+ESrZ7zQsCZ rwLc/mezwEU/XdHShSltGwwu0hujOz0VuI6jzP2wSDDhSVkvNadIOSyAXQ4JlokU5jsi vsxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gaTG8nB7urYK9rRS90jMgYPOQXnTJzMb/qGUVRNiFp8=; b=rVt3Nqm90mSVlYwiiisdnfsrWuGRk3prgEQp2bVYfpyPI7Bc/LN5cT2ka1tOwjX5Bz zV4b+EbdgABo3XU/MRvCPP4IfMZDN59YbI7Ie2amaQGEApvLt7KJhEpKZY052hYQpgv6 ZN0GXMk8oLR3UuVRFTo3NLyw52JjX5ry2+8jJ0BTlbMUVMX/57hxQHSw9i8r/T98zbfm 1DmdY4Il9gNVFBDTAZOuOPMzQuwZQw9p1NdAYrYMTpKeK/qeLqMM4ZBXTHhJr44FjWxF 3QZO4qBr2AM6btezcpg0FX2gVs5fG3ece9ynWEsGocWqGpQZk5Kmmwlb48LIlPmIG5/L 9VCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H3Oho9fG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si333632ejx.452.2020.09.24.04.09.05; Thu, 24 Sep 2020 04:09:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H3Oho9fG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727560AbgIXLGn (ORCPT + 99 others); Thu, 24 Sep 2020 07:06:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727470AbgIXLGV (ORCPT ); Thu, 24 Sep 2020 07:06:21 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52EC7C0613D3 for ; Thu, 24 Sep 2020 04:06:21 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id q8so3422663lfb.6 for ; Thu, 24 Sep 2020 04:06:21 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=gaTG8nB7urYK9rRS90jMgYPOQXnTJzMb/qGUVRNiFp8=; b=H3Oho9fGD6RyE7bc1Vbkj0h4ig5GO+l5hocswqpFb3dkMRdGklpkEO9eBeBB09TcZ9 dftfi52ZqomV7nQ5Jw4OENJNRUEafEY7gOz2sx2BWm9cKXHYJ3ewwEeGRbghiXv6jogt pq/UIkU9ZDJCvoaCwnFnveqJoBFTG0thF0oLs7pGD1AQss2M3HJgb8Sxn5yiuQodFhYQ hJ06vs873IdJJRlZHWgRr0oI3i4ffJ+zB+41wDaroaypmlaxB1CosR1jfIh3LdygOJ+e NyQtY3j5INzmct44KCjDtbRCFhjJPwVkl5ISX6mEJuMJa0p1tORTGhFUuRX7TYNJ50ZX vkRg== 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:mime-version:content-transfer-encoding; bh=gaTG8nB7urYK9rRS90jMgYPOQXnTJzMb/qGUVRNiFp8=; b=PpJiXTJzWM8BS8m0QgJBtEl20n61MMQU16s9PkFUsgMlBpc8ATwmEnNNjNoHF/R456 UFRFx5OobFKvf1zEMWOxfYzP/bvMGCpcAk10nh/CRNLn6z8NCFH7ftmwvG06jxXcL/lP uos8ERtUNa0DMjXbQIs6JSAcYDWLHa2cPa7cSEUmgFDJVVZckmc47p+ul5nd9iSiyq+n x1Qush1eAyvqIm95PTSyWxwAeW5qEzsfBJKnjWnytVuGKNOuaYHXlV3maqoDW8Xob56P txv1PGxLb71B9ywSwV9p7RVjylYhbzQaz1akUyR564lfDg7mGF9m9Rz5PlXseRwmgEYj 2QuQ== X-Gm-Message-State: AOAM532pHA7cJrce4mL8mks8krAtxIiIgwk94EAzWEJ9nwnYXT/m/Yji 0YXL04vL3n89KntMu2uXyKp+rg== X-Received: by 2002:a19:674f:: with SMTP id e15mr108526lfj.50.1600945579746; Thu, 24 Sep 2020 04:06:19 -0700 (PDT) Received: from localhost.localdomain (h-155-4-133-169.NA.cust.bahnhof.se. [155.4.133.169]) by smtp.gmail.com with ESMTPSA id w4sm1762393lfr.139.2020.09.24.04.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 04:06:18 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Kevin Hilman , linux-pm@vger.kernel.org Cc: Sudeep Holla , Lorenzo Pieralisi , Daniel Lezcano , Lina Iyer , Lukasz Luba , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] PM / Domains: Allow to abort power off when no ->power_off() callback Date: Thu, 24 Sep 2020 13:04:48 +0200 Message-Id: <20200924110449.329523-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200924110449.329523-1-ulf.hansson@linaro.org> References: <20200924110449.329523-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In genpd_power_off() we may decide to abort the power off of the PM domain, even beyond the point when the governor would accept it. The abort is done if it turns out that a child domain has been requested to be powered on, which means it's waiting for the lock of the parent to be released. However, the abort is currently only considered if the genpd in question has a ->power_off() callback assigned. This is unnecessary limiting, especially if the genpd would have a parent of its own. Let's remove the limitation and make the behaviour consistent. Signed-off-by: Ulf Hansson --- Changes in v2: - None. --- drivers/base/power/domain.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 23aa2feced77..0198af358503 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -497,6 +497,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, struct pm_domain_data *pdd; struct gpd_link *link; unsigned int not_suspended = 0; + int ret; /* * Do not try to power off the domain in the following situations: @@ -544,24 +545,13 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, if (!genpd->gov) genpd->state_idx = 0; - if (genpd->power_off) { - int ret; - - if (atomic_read(&genpd->sd_count) > 0) - return -EBUSY; + /* Don't power off, if a child domain is waiting to power on. */ + if (atomic_read(&genpd->sd_count) > 0) + return -EBUSY; - /* - * If sd_count > 0 at this point, one of the subdomains hasn't - * managed to call genpd_power_on() for the parent yet after - * incrementing it. In that case genpd_power_on() will wait - * for us to drop the lock, so we can call .power_off() and let - * the genpd_power_on() restore power for us (this shouldn't - * happen very often). - */ - ret = _genpd_power_off(genpd, true); - if (ret) - return ret; - } + ret = _genpd_power_off(genpd, true); + if (ret) + return ret; genpd->status = GENPD_STATE_OFF; genpd_update_accounting(genpd); -- 2.25.1