Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3439778pxa; Tue, 25 Aug 2020 23:40:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx6Pxj4/hssCg4ZsJnslTz00fuFvcSx3V4sKWgb0cXJ3JR2XAkw9DsV9+A9Ifb08wGZ1IQ X-Received: by 2002:a17:906:5f8f:: with SMTP id a15mr15039235eju.291.1598424043802; Tue, 25 Aug 2020 23:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598424043; cv=none; d=google.com; s=arc-20160816; b=IO9rA//WP8NvSDMVDD0UPA5VNBcNp3tIlh2dFrJ+0WG2krwkMCI2yDGRn2NqRFW7L2 xw/z+Ku8YXA3NzjJBwST4TYKgys1RFx3KAknKpfZTtXtS9sp4gqq/b/7CZBggxZ9Vdsl 4cw4fLPz70uYPjFYEPbR2Iiroxi4zU601w+FhuNdhzJG0IJSSNk4bQiNcEBNRBDCO4hT ApuNBIPlym/mp2zpvmxgX+gfmVkTrK0fcgdzQWw0AJwJccPqR0HjyBn+uZe8SeHXj+47 4AWA1qcU3jtDJ5qE+T2tfT4UUwEOVlTCR6ioNUlKZfEPrC9tU8Ofp9kvtNK8p8sizKmA bC1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hDQRRI78D3Sk/YTewL1Qk0xdUUz1zPK2EJmRrgeUM0s=; b=KOzEgkijfSdnQqQ2SBsw6fYQ08ofnXS33F9yhfS2bSmRBHpX07QRqLudSys5CXI9ZX UKv4aPrn2Vj92vTud57RMuyx6HX81xR3wQ3RWFHJ3jQygD32bpXAjHpbYz/4jOrp9rLB ou6qod0RqFp5MdMEPFe96o8DEDqjZPsYhvOxfQcMq3JW+3crrYTJ0GYgJEaTUQeDAQYQ tf8Vyx+mZih9OMll2eVqsZrumP/qeBVY0flBOSgu0NXeqmKqRApKEwIsw9kYOQ/qV8F+ 2gsSezJo2x9d3M/ZU36qBdrIWtUURNMqdSAuZKXF3tB/mqVsjcaDzotTOekGhLjOznMx KajA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vTGLn1x/"; 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 c9si841271edy.23.2020.08.25.23.40.21; Tue, 25 Aug 2020 23:40: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="vTGLn1x/"; 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 S1726786AbgHZGih (ORCPT + 99 others); Wed, 26 Aug 2020 02:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726875AbgHZGiP (ORCPT ); Wed, 26 Aug 2020 02:38:15 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EE6FC061574 for ; Tue, 25 Aug 2020 23:38:14 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id p186so370620vsa.10 for ; Tue, 25 Aug 2020 23:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hDQRRI78D3Sk/YTewL1Qk0xdUUz1zPK2EJmRrgeUM0s=; b=vTGLn1x/zJIY52K4Di+3Teh/ssAgCH5yCwousRZq+WecxuiBZEquiPQ9UNFYv6go+3 cxi9hrbf2PwEWTBq9ymWzvNM9qStJcOI/VzzqoFk3NpF4g3qH7J2F19ht/JJlu3ryxSN QQLSDGi9S/5vRxqgCcBcSrmgspZbBbXmmZfE8YjUe415ruvrb1/taSGkJjYKYCnCwmBy W7N5w2m83JU88vI4Y8ZBW1sRBlpZoDDr1BQl/dAiLyjyZNPvRccfwRVDjiW5oBZL5gCY PIaopB27colyHJy/KItN20mbxURukeTX37yvpDdatb1doKoHcDElNQX5XjOOpgJiSKl9 pByg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hDQRRI78D3Sk/YTewL1Qk0xdUUz1zPK2EJmRrgeUM0s=; b=Pf8I293H6eJAIvOqgvThR4ZEwXwu1He8kMnspSFVCnlkXaTkBa+P9HhHE5F1qnz30v MK1cFiiheGL6nQHGKretLN7N42UOgzY2egE9LBKopzfGbcqN9VABWwNWel8yJawmOFh4 X3Sy6tvYmnp6si2XMuVxLxBkC9VJUzZZ7i7Csm5ae36+Vz9k7liIpnKzobRhuYvhghZa u2hmF0k/LblfGm1nnaaDZd00eR/vS5DnzrdTl6HCtR9SPCz8z1r00cA84dEfcRuDxdS/ X6UkqCJ4e8BQVTd6chtOp1u/pnR838+YcEiyGxGKJHHfkZvJEkgIo2ruVzcXXGy1n5fB 5JPg== X-Gm-Message-State: AOAM531UoF9qP59+LBpe8n+8SDenBmUy/7W8fxiCQw3ljLbacwvyG4SD XmFV9JKNKxmvX3e1sJeQG1nsm2jRfWBefGcClSGHXA== X-Received: by 2002:a67:fb43:: with SMTP id e3mr7397682vsr.91.1598423892321; Tue, 25 Aug 2020 23:38:12 -0700 (PDT) MIME-Version: 1.0 References: <20200819104057.318230-1-ulf.hansson@linaro.org> <20200819104057.318230-4-ulf.hansson@linaro.org> <20200825161602.GE12523@codeaurora.org> In-Reply-To: <20200825161602.GE12523@codeaurora.org> From: Ulf Hansson Date: Wed, 26 Aug 2020 08:37:35 +0200 Message-ID: Subject: Re: [PATCH 3/3] PM / Domains: Add support for PM domain on/off notifiers for genpd To: Lina Iyer Cc: "Rafael J . Wysocki" , Kevin Hilman , Linux PM , Sudeep Holla , Lorenzo Pieralisi , Daniel Lezcano , Lukasz Luba , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Linux ARM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 25 Aug 2020 at 18:16, Lina Iyer wrote: > > On Wed, Aug 19 2020 at 04:41 -0600, Ulf Hansson wrote: > >A device may have specific HW constraints that must be obeyed to, before > >its corresponding PM domain (genpd) can be powered off - and vice verse at > >power on. These constraints can't be managed through the regular runtime PM > >based deployment for a device, because the access pattern for it, isn't > >always request based. In other words, using the runtime PM callbacks to > >deal with the constraints doesn't work for these cases. > > > >For these reasons, let's instead add a PM domain power on/off notification > >mechanism to genpd. To add/remove a notifier for a device, the device must > >already have been attached to the genpd, which also means that it needs to > >be a part of the PM domain topology. > > > >To add/remove a notifier, let's introduce two genpd specific functions: > > - dev_pm_genpd_add|remove_notifier() > > > >Note that, to further clarify when genpd power on/off notifiers may be > >used, one can compare with the existing CPU_CLUSTER_PM_ENTER|EXIT > >notifiers. In the long run, the genpd power on/off notifiers should be able > >to replace them, but that requires additional genpd based platform support > >for the current users. > > > >Signed-off-by: Ulf Hansson > >--- > > drivers/base/power/domain.c | 130 ++++++++++++++++++++++++++++++++++-- > > include/linux/pm_domain.h | 15 +++++ > > 2 files changed, 141 insertions(+), 4 deletions(-) > > > >diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > >index 4b787e1ff188..9cb85a5e8342 100644 > >--- a/drivers/base/power/domain.c > >+++ b/drivers/base/power/domain.c > >@@ -545,13 +545,21 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, > > if (!genpd->gov) > > genpd->state_idx = 0; > > > >+ /* Notify consumers that we are about to power off. */ > >+ ret = raw_notifier_call_chain(&genpd->power_notifiers, GENPD_STATE_OFF, > >+ NULL); > >+ if (ret) > >+ return ret; > >+ > > /* Don't power off, if a child domain is waiting to power on. */ > >- if (atomic_read(&genpd->sd_count) > 0) > >- return -EBUSY; > >+ if (atomic_read(&genpd->sd_count) > 0) { > >+ ret = -EBUSY; > >+ goto busy; > >+ } > > > > ret = _genpd_power_off(genpd, true); > > if (ret) > >- return ret; > >+ goto busy; > > > > genpd->status = GENPD_STATE_OFF; > > genpd_update_accounting(genpd); > >@@ -564,6 +572,9 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, > > } > > > > return 0; > >+busy: > >+ raw_notifier_call_chain(&genpd->power_notifiers, GENPD_STATE_ON, NULL); > It would be helpful to abstract these notification related calls into > functions of their own. So, for CPU PM domains, it would help to add > RCU_NONIDLE() around the notifiers, allowing the callbacks to add trace > functions. Thanks for the suggestion! It makes perfect sense to me - and would also be consistent with how CPU PM notifiers are managed, [,,,] Kind regards Uffe