All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sridharan, Ranjani" <ranjani.sridharan@intel.com>
To: Daniel Baluta <daniel.baluta@oss.nxp.com>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
	ulf.hansson@linaro.org,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	pavel@ucw.cz, festevam@gmail.com, khilman@kernel.org,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	linux-imx@nxp.com, "Brown, Len" <len.brown@intel.com>,
	linux-pm@vger.kernel.org, s.hauer@pengutronix.de,
	paul.olaru@nxp.com, Daniel Baluta <daniel.baluta@nxp.com>,
	linux-arm-kernel@lists.infradead.org, aisheng.dong@nxp.com,
	Daniel Baluta <daniel.baluta@gmail.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	shengjiu.wang@nxp.com, rjw@rjwysocki.net,
	linux-kernel@vger.kernel.org, kernel@pengutronix.de,
	shawnguo@kernel.org
Subject: Re: [RFC PATCH 1/2] PM / domains: Introduce multi PM domains helpers
Date: Mon, 2 Mar 2020 13:23:52 -0800	[thread overview]
Message-ID: <CAFQqKeU8YF+aZVTafj3ZiPvNUsx3nK-8cdr8eJUm=_9_2TkRQg@mail.gmail.com> (raw)
In-Reply-To: <20200302205700.29746-2-daniel.baluta@oss.nxp.com>

On Mon, Mar 2, 2020 at 12:59 PM Daniel Baluta <daniel.baluta@oss.nxp.com>
wrote:

> From: Daniel Baluta <daniel.baluta@nxp.com>
>
> This patch introduces helpers support for multi PM domains.
>
> API consists of:
>
> 1) dev_multi_pm_attach - powers up all PM domains associated with a given
> device. Because we can attach one PM domain per device, we create
> virtual devices (children of initial device) and associate PM domains
> one per virtual device.
>
> 2) dev_multi_pm_detach - detaches all virtual devices from PM domains
> attached with.
>
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
>  drivers/base/power/common.c | 93 +++++++++++++++++++++++++++++++++++++
>  include/linux/pm_domain.h   | 19 ++++++++
>  2 files changed, 112 insertions(+)
>
> diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
> index bbddb267c2e6..a90cc6b476e4 100644
> --- a/drivers/base/power/common.c
> +++ b/drivers/base/power/common.c
> @@ -228,3 +228,96 @@ void dev_pm_domain_set(struct device *dev, struct
> dev_pm_domain *pd)
>         device_pm_check_callbacks(dev);
>  }
>  EXPORT_SYMBOL_GPL(dev_pm_domain_set);
> +
> +/**
> + * dev_multi_pm_attach - power up device associated power domains
> + * @dev: The device used to lookup the PM domains
> + *
> + * Parse device's OF node to find all PM domains specifiers. For each
> power
> + * domain found, create a virtual device and associate it with the
> + * current power domain.
> + *
> + * This function should typically be invoked by a driver during the
> + * probe phase, in the case its device requires power management through
> + * multiple PM domains.
> + *
> + * Returns a pointer to @dev_multi_pm_domain_data if successfully
> attached PM
> + * domains, NULL if 0 or 1 PM domains specified, else an ERR_PTR() in
> case of
> + * failures.
> + */
> +struct dev_multi_pm_domain_data *dev_multi_pm_attach(struct device *dev)
> +{
> +       struct dev_multi_pm_domain_data *mpd, *retp;
> +       int num_domains;
> +       int i;
> +
> +       num_domains = of_count_phandle_with_args(dev->of_node,
> "power-domains",
> +                                                "#power-domain-cells");
> +       if (num_domains < 2)
>
Hi Daniel,

Just out of curiosity, should it be an error when num_domains is 1? Is it
an error because the expectation is that the caller would use
dev_pm_domain_attach() in that case?

+               return NULL;
> +
> +       mpd = devm_kzalloc(dev, GFP_KERNEL, sizeof(*mpd));
> +       if (!mpd)
> +               return ERR_PTR(-ENOMEM);
> +
> +       mpd->dev = dev;
> +       mpd->num_domains = num_domains;
> +
> +       mpd->virt_devs = devm_kmalloc_array(dev, mpd->num_domains,
> +                                           sizeof(*mpd->virt_devs),
> +                                           GFP_KERNEL);
> +       if (!mpd->virt_devs)
> +               return ERR_PTR(-ENOMEM);
> +
> +       mpd->links = devm_kmalloc_array(dev, mpd->num_domains,
> +                                       sizeof(*mpd->links), GFP_KERNEL);
> +       if (!mpd->links)
> +               return ERR_PTR(-ENOMEM);
> +
> +       for (i = 0; i < mpd->num_domains; i++) {
> +               mpd->virt_devs[i] = dev_pm_domain_attach_by_id(dev, i);
> +               if (IS_ERR(mpd->virt_devs[i])) {
> +                       retp = (struct dev_multi_pm_domain_data *)
> +                               mpd->virt_devs[i];
>
Should retp be PTR_ERR(mpd->virt_devs[i]) here?
Thanks,
Ranjani

  reply	other threads:[~2020-03-02 21:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 20:56 [RFC PATCH 0/2] Introduce multi PM domains helpers Daniel Baluta
2020-03-02 20:56 ` Daniel Baluta
2020-03-02 20:56 ` Daniel Baluta
2020-03-02 20:56 ` [RFC PATCH 1/2] PM / domains: " Daniel Baluta
2020-03-02 20:56   ` Daniel Baluta
2020-03-02 20:56   ` Daniel Baluta
2020-03-02 21:23   ` Sridharan, Ranjani [this message]
2020-03-03 13:29     ` Daniel Baluta
2020-03-03 13:29       ` Daniel Baluta
2020-03-03 13:29       ` Daniel Baluta
2020-03-03  5:36   ` kbuild test robot
2020-03-03  6:08   ` kbuild test robot
2020-03-03  8:14   ` kbuild test robot
2020-03-02 20:57 ` [RFC PATCH 2/2] ASoC: SOF: Use " Daniel Baluta
2020-03-02 20:57   ` Daniel Baluta
2020-03-02 20:57   ` Daniel Baluta
2020-03-02 21:26   ` Sridharan, Ranjani
2020-03-03 13:17     ` Daniel Baluta
2020-03-03 13:17       ` Daniel Baluta
2020-03-03 13:17       ` Daniel Baluta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFQqKeU8YF+aZVTafj3ZiPvNUsx3nK-8cdr8eJUm=_9_2TkRQg@mail.gmail.com' \
    --to=ranjani.sridharan@intel.com \
    --cc=aisheng.dong@nxp.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=daniel.baluta@gmail.com \
    --cc=daniel.baluta@nxp.com \
    --cc=daniel.baluta@oss.nxp.com \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=khilman@kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=paul.olaru@nxp.com \
    --cc=pavel@ucw.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=shengjiu.wang@nxp.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.