From patchwork Wed Aug 19 10:40:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 247944 Delivered-To: patches@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp348145ils; Wed, 19 Aug 2020 03:41:27 -0700 (PDT) X-Received: by 2002:a2e:321a:: with SMTP id y26mr11178190ljy.388.1597833687044; Wed, 19 Aug 2020 03:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597833687; cv=none; d=google.com; s=arc-20160816; b=uhOzCl2n5I9Un/Y2uXY4VnzOqYjH07iIY7L8h/u4HhTVIagx4MP14UzwaWDELERWLl GHC/a4vFGzxoYg05zwaFXZJ5C4hjF4DeM9jnKHvN6fjru/6t17f6qA8IG/xv8HTbUFSv BPf/kfLOp3uNsBSL2pI7RJRP8qROt7f/PyPaE13+Wr62Sl+sVaLdag63XWuf2TRjkfol X2j9uzQqoynGwBXdIeK0B8xGc7YLYSBKHxyPZEWvYYEjCJBfqNKHkiraXXerXElxQfdP 2AE6Hn/tlrhXdHZX53EOcL+OjoBBHPKkhW2GNI2aVb+nYNpskSwe8Dtqw7ALM4r1cnGu Q+BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=6AfisJdiJUtL2PXoC9gz6YzWImXc+sSWUPeXDWlUbHI=; b=ettb+qj7GN/W9rxFkMKEdv9N8XyuvXpLPxfIhzh7bLTJtGcu/X7iC4DPIgM3QSXMMA +QW5EjEFXkPPqa/THpa3XNw5lheM/VxDQeLth9gofSwreUWYEtPugZpTqpG6jlHSEUeC NmK7RuX0frCq9AWfVt67YL9Z1LEVl1oYIwGaSrhNKljKFarpfOd1iBaHJtNxnL1I38YU LCCKSYXRRpdiz8gBGdiFfgpin2sKLmJbdCN0DB+yQjm92QXruE0pvwBV3mm5LM6vgYIc VZobGVO4zNYQ92bDIvO7oQYJ/KuiDJAEQg9DWl+fzxvfk3Z4k+mhhUVaJZwwmcTHGZBM oXsw== 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 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 i20sor5469589lfi.14.2020.08.19.03.41.26 for (Google Transport Security); Wed, 19 Aug 2020 03:41: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=FDmP20zS; 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: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=OPtMuLqHezHYERWl4OL6k0wyW+ywZcNizYkb8IBhhWOPkvXCeZSXNmLohX6rqY/Cfc zP6s2LL7261sjPqgNiR7IZcyZhiylFzKdinuASHZZK7CVIVbm2G8+yW06FoyHikQwSFJ zjLbo/62WLNRlJwOR0ihe6ephXr7xYTiYpMIpWV9kNH5WJR6xFBgAJVEro0rv9BDCBwz MDw1yTMP7S2+zyt8o0CL6zSIsg8DwnQqK4hnh/diElkykW4HI4YP36tT4rKTrt/d4Ngg 50YQSXz7CruXS4HlRHK7EpLdFC9MIyGQSIqDszVbv4hKuctaMHRoJBCEno6xJ1jDi0kQ L5Bw== X-Gm-Message-State: AOAM531Tjo34h8+Eh6XOjdhjWyYQEl1C3PUtNPhHAazCzqKIRs3RjXLG m88YQG5kaIzzva9C6QthIbbZOVKMI0KBj3H6zzU= X-Google-Smtp-Source: ABdhPJygHSyy3z4agvjAxmYVV4QRQjCkH5wyaAw1ePZcKIW+aup9SWYdYaWUsgZtrrWbS9OSPi9VCQ== X-Received: by 2002:a19:cb53:: with SMTP id b80mr11846376lfg.77.1597833686628; Wed, 19 Aug 2020 03:41:26 -0700 (PDT) Return-Path: 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 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(-) -- 2.25.1 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);