From patchwork Thu Sep 24 11:04:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11796997 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B09A59D for ; Thu, 24 Sep 2020 11:08:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C61F0239A1 for ; Thu, 24 Sep 2020 11:08:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ui55aITC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="H3Oho9fG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C61F0239A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0K7RYXAuPUg7Bs8Z1BjCSNK5XlaIrAikMPKapTQ8B98=; b=Ui55aITCoi13BK722JosA8UPF 4kxl1PLAWlxkjCd4Lkswm7nghaBLE9iBE4gxNNLpwI5dL03Zvpj5p8pANsR2RSQjvT6X8/J29ZTK9 N9ZAL/JogHbnCnL7wJ0xXIALNAvjXGtRZhpb3aHWus4FsEVHO9pTfqal0MOFRER295DTQ3O2sgTcp lvxerZTSMtw9oQ6+9dAaZmi2yTvqK4U6IS1wZkSNjhgwcytWHueR4LplIHCOzitLXZ5DhhISqD6Gk UTiXw3aV8dW+y3nXfN30RDTa14tn5lHw/MlCZcLCIXMvogN3Wy9SSNpZbik1GHTZjFSTWOCbIOGsr bgPI+yhbg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLP5X-0000j7-1i; Thu, 24 Sep 2020 11:06:59 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLP4v-0000Ud-9E for linux-arm-kernel@lists.infradead.org; Thu, 24 Sep 2020 11:06:22 +0000 Received: by mail-lf1-x143.google.com with SMTP id z17so3370617lfi.12 for ; Thu, 24 Sep 2020 04:06:20 -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=c3fKrGTYSL30NFpvqRAz0RyRXa4jNs2t+DNKESTZ5YpgjPcG4NXk/OR7HCGd9dZfZM IgvLzKBHBdRT1jlF3eoWdvcKzPjlfoSReoC5NqpGzlaz+15tBpNHoxsoCgauWC7vPhXl 0yxjW8KzbI7pDBn/4JZZKWH+ycT7jwCA6BCeSa7bNL8JCevLYylTMUjq2iIt9OIfptMg bgLHKrygU6oFXbwAXWvNeSiesvTr+QrAnykjTtJayNsch/dDbpIrZTld/zoUj00vpvLX kRTz8QXrGYf/oY0luPuYRjknU5WNWzGft3IUKws1cGn/iDTI3tAmEFYSDeo4F6RiHs89 N4KQ== X-Gm-Message-State: AOAM5336Pq031H2UdJ5vx8fTaC+jlNsUPNmum0PNUn3hfX9IDkkNw/46 ZTG/G11GXVHB3ya7/0mvxPxl9w== X-Google-Smtp-Source: ABdhPJymetcRsIgXO87ErAfpmmQHrT9SqTFIGB3QpkJ315XgLg9UgC/VPtV4CqPurtYJMsiQe6O3rQ== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200924_070621_382114_2B6DB4CB X-CRM114-Status: GOOD ( 20.79 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:143 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Lorenzo Pieralisi , Vincent Guittot , Stephen Boyd , Daniel Lezcano , linux-kernel@vger.kernel.org, Lina Iyer , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, Sudeep Holla , Lukasz Luba Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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);