public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Shenghao Ding <shenghao-ding@ti.com>,
	robh+dt@kernel.org, lgirdwood@gmail.com, perex@perex.cz,
	kevin-lu@ti.com, 13916275206@139.com,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	liam.r.girdwood@intel.com, mengdong.lin@intel.com,
	baojun.xu@ti.com, thomas.gfeller@q-drop.com, peeyush@ti.com,
	navada@ti.com, broonie@kernel.org, gentuser@gmail.com
Subject: Re: [PATCH v3 1/2] ALSA: hda/tas2781: Add tas2781 HDA driver
Date: Mon, 21 Aug 2023 16:57:26 +0200	[thread overview]
Message-ID: <871qfw78a1.wl-tiwai@suse.de> (raw)
In-Reply-To: <146f393a-665b-110b-b55b-d3452c3123e8@linux.intel.com>

On Mon, 21 Aug 2023 16:43:31 +0200,
Pierre-Louis Bossart wrote:
> 
> 
> >>> +static void tas2781_hda_playback_hook(struct device *dev, int action)
> >>> +{
> >>> +	struct tasdevice_priv *tas_priv = dev_get_drvdata(dev);
> >>> +
> >>> +	dev_dbg(tas_priv->dev, "%s: action = %d\n", __func__, action);
> >>> +	switch (action) {
> >>> +	case HDA_GEN_PCM_ACT_OPEN:
> >>> +		pm_runtime_get_sync(dev);
> >>
> >> test if this actually works?
> > 
> > To be fair, most of driver codes don't check it, including the
> > HD-audio core.  (Actually, over 900 of 1300 calls have no check in the
> > whole tree.)
> > 
> > It implies that forcing the check in each place is moot; rather the
> > helper needs to be coded not to fail, IMO.
> 
> Maybe that's true for HDaudio, for the SoundWire parts we absolutely
> need to detect if the resume worked. There are more steps involved, the
> clock-stop mode entry/exit, context restoration, re-enumeration, etc.
> 
> I think it'd be a mistake to sit on our hands and assume the world is
> perfect. We have to track cases where the codec isn't properly resumed
> and prevent it from accessing resources that are just unavailable.

Yeah, I don't mean that it's wrong or bad to have the check.  The
check should be there.

But, I feel that it's time to rather switch to the proper call.
Basically pm_runtime_resume_and_get() is the better alternative
(except for its long naming), and we may think of converting the
whole.

> >>> +static int tas2781_system_suspend(struct device *dev)
> >>> +{
> >>> +	struct tasdevice_priv *tas_priv = dev_get_drvdata(dev);
> >>> +	int ret;
> >>> +
> >>> +	dev_dbg(tas_priv->dev, "System Suspend\n");
> >>> +
> >>> +	ret = pm_runtime_force_suspend(dev);
> >>> +	if (ret)
> >>> +		return ret;
> >>
> >> that's usually the other way around, for system suspend you either want
> >> the device to be pm_runtime active, or if it's already suspended do nothing.
> >>
> >> This is very odd to me.
> > 
> > This is a normal procedure, as stated in pm_runtime_force_suspend()
> > definition:
> > 
> > /**
> >  * pm_runtime_force_suspend - Force a device into suspend state if needed.
> > ....
> >  * Typically this function may be invoked from a system suspend callback to make
> >  * sure the device is put into low power state and it should only be used during
> >  * system-wide PM transitions to sleep states.  It assumes that the analogous
> >  * pm_runtime_force_resume() will be used to resume the device.
> 
> It's possible that it's fine for HDaudio, it wouldn't work in all cases
> for SoundWire where we have to make sure all pm_runtime suspended
> devices are brought back to D0 and then the regular system suspend
> happens. That's mainly because pm_runtime suspend relies on clock stop
> and system suspend does not.
> 
> In other words, this isn't a generic solution at all.

Well, I suppose rather that soundwire is an exception :)

For majority of devices, the system suspend/resume is nothing but
pm_runtime_force_*() calls.  e.g. take a look at
DEFINE_RUNTIME_DEV_PM_OPS() in linux/pm_runtime.h.


Takashi

  reply	other threads:[~2023-08-21 14:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18  8:55 [PATCH v3 1/2] ALSA: hda/tas2781: Add tas2781 HDA driver Shenghao Ding
2023-08-18  8:55 ` [PATCH v3 2/2] " Shenghao Ding
2023-08-18 16:00   ` Pierre-Louis Bossart
2023-08-18 17:01     ` Andy Shevchenko
2023-08-20  9:16       ` Takashi Iwai
2023-08-21  9:06         ` Andy Shevchenko
2023-08-21  9:14           ` Takashi Iwai
2023-08-21  9:26             ` Andy Shevchenko
2023-08-18 16:30 ` [PATCH v3 1/2] " Pierre-Louis Bossart
2023-08-20  9:35   ` Takashi Iwai
2023-08-21 14:43     ` Pierre-Louis Bossart
2023-08-21 14:57       ` Takashi Iwai [this message]
2023-08-21 15:04         ` Pierre-Louis Bossart
  -- strict thread matches above, loose matches on Subject: below --
2023-08-17  8:26 Shenghao Ding
2023-08-17 13:39 ` kernel test robot

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=871qfw78a1.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=13916275206@139.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=baojun.xu@ti.com \
    --cc=broonie@kernel.org \
    --cc=gentuser@gmail.com \
    --cc=kevin-lu@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=liam.r.girdwood@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mengdong.lin@intel.com \
    --cc=navada@ti.com \
    --cc=peeyush@ti.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=robh+dt@kernel.org \
    --cc=shenghao-ding@ti.com \
    --cc=thomas.gfeller@q-drop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox