All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Jon Hunter <jonathanh@nvidia.com>
Cc: "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
	MANAGEM..." <alsa-devel@alsa-project.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Sameer Pujar <spujar@nvidia.com>,
	Linux PM <linux-pm@vger.kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	linux-tegra@vger.kernel.org,
	Thierry Reding <thierry.reding@gmail.com>,
	sharadg@nvidia.com, rlokhande@nvidia.com, mkumard@nvidia.com
Subject: Re: [PATCH v2] ALSA: hda/tegra: enable clock during probe
Date: Mon, 04 Feb 2019 11:13:49 +0100	[thread overview]
Message-ID: <s5ho97rrhcy.wl-tiwai@suse.de> (raw)
In-Reply-To: <80a45aa3-8a22-959c-0c73-03ad2d6b1f8c@nvidia.com>

On Mon, 04 Feb 2019 11:04:50 +0100,
Jon Hunter wrote:
> 
> 
> On 04/02/2019 08:16, Sameer Pujar wrote:
> 
> ...
> 
> > Objective is to have things working with or without CONFIG_PM enabled.
> > From previous comments and discussions it appears that there is mixed
> > response
> > for calling hda_tegra_runtime_resume() or runtime PM APIs in probe()
> > call. Need
> > to have consensus regarding the best practice to be followed, which
> > would eventually
> > can be used in other drivers too.
> > 
> > Rafael is suggesting to use CONFIG_PM check to do manual setup or
> > runtime PM setup in probe,
> > which would bring back the earlier above mentioned concern.
> > 
> > if (IS_ENABLED(CONFIG_PM)) {
> > do setup based on pm-runtime
> > } else {
> >     do manual setup
> > }
> > Both if/else might end up doing the same here.
> > Do we really need CONFIG_PM check here?
> > 
> > Instead does below proposal appear fine?
> > 
> > probe() {
> >     hda_tegra_enable_clock();
> > }
> > 
> > probe_work() {
> >     /* hda setup */
> >     . . .
> >     pm_runtime_set_active(); /* initial state as active */
> >     pm_runtime_enable();
> >     return;
> > }
> 
> I believe that this still does not work, because if there is a
> power-domain that needs to be turned on, this does not guarantee this.
> So I think that you need to call pm_runtime_get ...
> 
>  probe() {
>  	if (!IS_ENABLED(CONFIG_PM))
>  		hda_tegra_enable_clock();
>  }
> 
> 
>  probe_work() {
>     	/* hda setup */
>     	. . .
> 	pm_runtime_enable();
> 	pm_runtime_get_sync();
> 	return;
>  }
> 
> The alternative here could just be ...
> 
>  probe() {
> 	pm_runtime_enable();
>  	if (!pm_runtime_enabled())
>  		ret = hda_tegra_enable_clock();
> 	else
> 		ret = pm_runtime_get_sync();
> 
> 	if (ret < 0) {
> 		...
> 	}
>  }
> 
> Very similar to what I was saying to begin with but not call the
> pm_runtime_resume handler directly. Which I believe was Iwai-san's dislike.

Yes, exactly, what bothered me was really a nuance: calling
hda_tegra_runtime_resume() there makes the code misleading (or
confusing) as if the runtime PM were mandatory.

I hoped there could be some standard idiom for this expression, but
apparently there isn't any, so far...

Obviously the easiest option is to enforce the dependency on
CONFIG_PM.  Would there be any platform that needs to run without PM,
practically seen...?

But, now after lengthy discussions and the clarification of the
current situation, I have no strong opinion on this any longer.
So I leave the decision to you guys, and I'll apply it as-is.


thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Jon Hunter <jonathanh@nvidia.com>
Cc: Sameer Pujar <spujar@nvidia.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Thierry Reding <thierry.reding@gmail.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Jaroslav Kysela <perex@perex.cz>,
	"moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
	MANAGEM..."  <alsa-devel@alsa-project.org>, <mkumard@nvidia.com>,
	<rlokhande@nvidia.com>, <sharadg@nvidia.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	<linux-tegra@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>
Subject: Re: [PATCH v2] ALSA: hda/tegra: enable clock during probe
Date: Mon, 04 Feb 2019 11:13:49 +0100	[thread overview]
Message-ID: <s5ho97rrhcy.wl-tiwai@suse.de> (raw)
In-Reply-To: <80a45aa3-8a22-959c-0c73-03ad2d6b1f8c@nvidia.com>

On Mon, 04 Feb 2019 11:04:50 +0100,
Jon Hunter wrote:
> 
> 
> On 04/02/2019 08:16, Sameer Pujar wrote:
> 
> ...
> 
> > Objective is to have things working with or without CONFIG_PM enabled.
> > From previous comments and discussions it appears that there is mixed
> > response
> > for calling hda_tegra_runtime_resume() or runtime PM APIs in probe()
> > call. Need
> > to have consensus regarding the best practice to be followed, which
> > would eventually
> > can be used in other drivers too.
> > 
> > Rafael is suggesting to use CONFIG_PM check to do manual setup or
> > runtime PM setup in probe,
> > which would bring back the earlier above mentioned concern.
> > 
> > if (IS_ENABLED(CONFIG_PM)) {
> > do setup based on pm-runtime
> > } else {
> >     do manual setup
> > }
> > Both if/else might end up doing the same here.
> > Do we really need CONFIG_PM check here?
> > 
> > Instead does below proposal appear fine?
> > 
> > probe() {
> >     hda_tegra_enable_clock();
> > }
> > 
> > probe_work() {
> >     /* hda setup */
> >     . . .
> >     pm_runtime_set_active(); /* initial state as active */
> >     pm_runtime_enable();
> >     return;
> > }
> 
> I believe that this still does not work, because if there is a
> power-domain that needs to be turned on, this does not guarantee this.
> So I think that you need to call pm_runtime_get ...
> 
>  probe() {
>  	if (!IS_ENABLED(CONFIG_PM))
>  		hda_tegra_enable_clock();
>  }
> 
> 
>  probe_work() {
>     	/* hda setup */
>     	. . .
> 	pm_runtime_enable();
> 	pm_runtime_get_sync();
> 	return;
>  }
> 
> The alternative here could just be ...
> 
>  probe() {
> 	pm_runtime_enable();
>  	if (!pm_runtime_enabled())
>  		ret = hda_tegra_enable_clock();
> 	else
> 		ret = pm_runtime_get_sync();
> 
> 	if (ret < 0) {
> 		...
> 	}
>  }
> 
> Very similar to what I was saying to begin with but not call the
> pm_runtime_resume handler directly. Which I believe was Iwai-san's dislike.

Yes, exactly, what bothered me was really a nuance: calling
hda_tegra_runtime_resume() there makes the code misleading (or
confusing) as if the runtime PM were mandatory.

I hoped there could be some standard idiom for this expression, but
apparently there isn't any, so far...

Obviously the easiest option is to enforce the dependency on
CONFIG_PM.  Would there be any platform that needs to run without PM,
practically seen...?

But, now after lengthy discussions and the clarification of the
current situation, I have no strong opinion on this any longer.
So I leave the decision to you guys, and I'll apply it as-is.


thanks,

Takashi

  reply	other threads:[~2019-02-04 10:13 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25 11:06 [PATCH v2] ALSA: hda/tegra: enable clock during probe Sameer Pujar
2019-01-25 11:06 ` Sameer Pujar
2019-01-25 11:42 ` Jon Hunter
2019-01-25 11:42   ` Jon Hunter
2019-01-25 12:19   ` Sameer Pujar
2019-01-25 12:19     ` Sameer Pujar
2019-01-25 13:15     ` Jon Hunter
2019-01-25 13:15       ` Jon Hunter
2019-01-30 12:45 ` Jon Hunter
2019-01-30 12:45   ` Jon Hunter
2019-01-30 16:40   ` Takashi Iwai
2019-01-30 16:40     ` Takashi Iwai
2019-01-31  9:36     ` Sameer Pujar
2019-01-31  9:36       ` Sameer Pujar
2019-01-31 11:05     ` Thierry Reding
2019-01-31 11:21       ` Takashi Iwai
2019-01-31 11:46         ` Rafael J. Wysocki
2019-01-31 11:46           ` Rafael J. Wysocki
2019-01-31 11:50           ` Rafael J. Wysocki
2019-01-31 11:50             ` Rafael J. Wysocki
2019-01-31 11:59           ` Takashi Iwai
2019-01-31 11:59             ` Takashi Iwai
2019-01-31 12:10             ` Rafael J. Wysocki
2019-01-31 12:10               ` Rafael J. Wysocki
2019-01-31 14:21               ` Sameer Pujar
2019-01-31 14:21                 ` Sameer Pujar
2019-01-31 14:30               ` Thierry Reding
2019-01-31 14:30                 ` Thierry Reding
2019-01-31 23:24                 ` Rafael J. Wysocki
2019-01-31 23:24                   ` Rafael J. Wysocki
2019-02-04  8:16                   ` Sameer Pujar
2019-02-04  8:16                     ` Sameer Pujar
2019-02-04  8:51                     ` Thierry Reding
2019-02-04  8:51                       ` Thierry Reding
2019-02-04 10:04                     ` Jon Hunter
2019-02-04 10:04                       ` Jon Hunter
2019-02-04 10:13                       ` Takashi Iwai [this message]
2019-02-04 10:13                         ` Takashi Iwai
2019-02-05 11:34                       ` Rafael J. Wysocki
2019-02-05 11:34                         ` Rafael J. Wysocki
2019-02-04  8:45                   ` Thierry Reding
2019-02-04  8:45                     ` Thierry Reding
2019-02-04  9:53                     ` Jon Hunter
2019-02-04  9:53                       ` Jon Hunter
2019-02-04 11:05                       ` Thierry Reding
2019-02-04 11:05                         ` Thierry Reding
2019-02-04 12:03                         ` Dmitry Osipenko
2019-02-04 12:03                           ` Dmitry Osipenko
2019-02-04 14:00                           ` Thierry Reding
2019-02-04 14:00                             ` Thierry Reding
2019-02-04 14:28                             ` Dmitry Osipenko
2019-02-04 14:28                               ` Dmitry Osipenko
2019-02-04 16:17                               ` Thierry Reding
2019-02-04 16:17                                 ` Thierry Reding
2019-02-04 18:46                                 ` Dmitry Osipenko
2019-02-04 18:46                                   ` Dmitry Osipenko
2019-02-05 11:52                         ` Rafael J. Wysocki
2019-02-05 11:52                           ` Rafael J. Wysocki

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=s5ho97rrhcy.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mkumard@nvidia.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rlokhande@nvidia.com \
    --cc=sharadg@nvidia.com \
    --cc=spujar@nvidia.com \
    --cc=thierry.reding@gmail.com \
    /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.