Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp368247pxa; Wed, 19 Aug 2020 03:45:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxurfCbyn5Bm7blaMUK1O42VOCWxjho8G0SZNmQWIHpmtB8mnZwbfH3apIFPg6RgwcIcZMU X-Received: by 2002:a05:6402:1593:: with SMTP id c19mr24876460edv.318.1597833943116; Wed, 19 Aug 2020 03:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597833943; cv=none; d=google.com; s=arc-20160816; b=Xzl/qF82hppxNDb/b59ZjXv6NnaEmmPeIdspI6zcqO2eXYuOMir6TIEcO3X+hWCbuc SAb/ELV0ScBgwQsOYx2v0Yd3obFup7Ev9iw6zbwrqnyA6GqDqe1YWhBqa8VPb1/ybVNB az+dAGd1YLl8fFTIlElqQKJCeyo51bE8ACh7U6esV8GuKYI/toTyP2SuR4OkSVewnkMx nI3jegb692KSE5tFvWejn2qAjr6kooJsxupDy2whHeaDa8n+1QF/egUKmdPt0LMniizX C31h+/T80dYO0nAnaKz8PTi1w5MSafdgyChMhi3/BsPoEyD6YUpdIt3mW8Jf+yByYgCH b6hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6AfisJdiJUtL2PXoC9gz6YzWImXc+sSWUPeXDWlUbHI=; b=YbMc+nJaeo1/1nUJtWD7Z6zHALlv3RV7O97TOMgnltblXQ+/OogJe30pQREzDcy5H4 8twyY6/0XQo5OakXi7RuHhw6DLmsv02sR+IXD45r3KoYhDLj/3inNz92Dt+hwHTJ+AA3 Y8gpFFOtL79qx1AExKlS4C7yqy1gqDZoqCkG1qnMljY2uVG5GhAH5RO1QuVobtVfdU/y uGaPgXeHxlt+U13XyZ7KLfGvDK1mz2ks3hcBZsFfDpERJXUlSM9Juors2D+9xY3vBqXh 1KItn10Kp4pXDf7PKscG4BrI0yg7dz9vgNPGy3bIdrry7hDhED2+aviQ2Sc9UKYJaA3g LU9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FDmP20zS; 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 v3si15061776ejb.659.2020.08.19.03.45.19; Wed, 19 Aug 2020 03:45:43 -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=FDmP20zS; 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 S1727949AbgHSKmC (ORCPT + 99 others); Wed, 19 Aug 2020 06:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727846AbgHSKld (ORCPT ); Wed, 19 Aug 2020 06:41:33 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E20C061346 for ; Wed, 19 Aug 2020 03:41:31 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id j15so29080lfg.7 for ; Wed, 19 Aug 2020 03:41:31 -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=6AfisJdiJUtL2PXoC9gz6YzWImXc+sSWUPeXDWlUbHI=; b=FDmP20zScS9Lp7NKqKhHNqZWR3liO/ZnL7w+TyagTnjUgOnvbWYGP2viYAlT07dtf9 tzK3xWyFoLgHKBhueu6FnaKkhTojI9LUqKWVL8IsUd5nmJLNd8CZzvGMPbbwzwm9iW8z O087glIP1Z7zeJKFKxZwBIOC3bJlf/NudjYGq4tcFESU3ROywqhOTSrQ83v+uqDEZe3k D59T/x538Q36zAC1Q7SAWFT0byDw1FjFnmfs484p02nBj2CKmFOizB29nOJ4Zm1GroJr xiorhamZgN4JM/GM+2+jfuXcACWB3Wj12pb9iBlAZE4okK13c3vLRwcrOb8Z6+36YDAQ 0boA== 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=6AfisJdiJUtL2PXoC9gz6YzWImXc+sSWUPeXDWlUbHI=; b=WzTG9M7e/U9h+aAXyOM93TDx+4pm59A7yKvoNDLIRwNhx4ynDXHYvX30bS8fjvbadm Xxs9TfXXjR25vWlrF4e4cucHEUl+kbSejyI06RemS6HAxTe88AEEYneoWVcGgD7Fh2y/ 1j7BEC0plqZR3wS5Sniq34LTj1HfVGgogNtAFloNW+7kufqOmFnXfZ4K+kSt6wVfHC9s ZRMMrceYH7qnMqX+n0GjQBKhdPzcupzibsJgRwZ5BOrvXr5v2PWYh22PHbEdIb5vaWzX IX4AKKAIs9uotVJRYUpcSrENIPHVFFJ0N8yxxUP67m9Ni9nga1J8KM/+jai8wSg5e6j+ eSPQ== X-Gm-Message-State: AOAM531gw1ktsQ40mzUwAfoX//8P++1RBOD/Wz8O6Oa5MoMAjp7agH/W g1poBos1WkYJ1W31X7L3aJsWOw== X-Received: by 2002:a19:cb53:: with SMTP id b80mr11846376lfg.77.1597833686628; Wed, 19 Aug 2020 03:41:26 -0700 (PDT) Received: from localhost.localdomain (h-98-128-180-79.NA.cust.bahnhof.se. [98.128.180.79]) by smtp.gmail.com with ESMTPSA id y13sm6534822ljd.19.2020.08.19.03.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 03:41:25 -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 , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] PM / Domains: Allow to abort power off when no ->power_off() callback Date: Wed, 19 Aug 2020 12:40:56 +0200 Message-Id: <20200819104057.318230-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200819104057.318230-1-ulf.hansson@linaro.org> References: <20200819104057.318230-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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 --- 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 2ea99032b658..4b787e1ff188 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