All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: Libin Yang <libin.yang@intel.com>,
	alsa-devel@alsa-project.org,
	Mengdong Lin <mengdong.lin@intel.com>,
	Keyon Jie <yang.jie@linux.intel.com>,
	liam.r.girdwood@linux.intel.com, broonie@kernel.org
Subject: Re: [PATCH 05/14] ALSA: pci: Remove superfluous snd_pcm_suspend*() calls
Date: Mon, 28 Jan 2019 13:28:49 -0600	[thread overview]
Message-ID: <21711c90-595d-88b5-ec8e-f092e662c938@linux.intel.com> (raw)
In-Reply-To: <s5ho98fd6fd.wl-tiwai@suse.de>


>>> BTW, while checking these things, I noticed that there are three
>>> exceptional drivers: sound/soc/intel/atom/sst-mfld-platform-pcm.c,
>>> sound/soc/intel/haswell/sst-haswell-pcm.c, and
>>> sound/soc/samsung/tm2_wm5110.c.  (You can simply grep the external
>>> snd_soc_suspend call, and only these match.)
>>>
>>> The former two drivers look really weird: they do handle the PM only
>>> with PM prepare and complete callbacks, while snd_soc_suspend() and co
>>> are called internally from there.  The prepare and complete callbacks
>>> aren't designed for the complete suspend/resume tasks, so I'd say it's
>>> a quite abuse.
>> For the Atom/SST driver, I remember there was a need to set/restore
>> the DSP state with a specific command that wasn't handled with regular
>> controls - largely a work-around due to the firmware design.
>>
>> For the Haswell driver, there was also a need to preserve/restore
>> state and pause/stop pipelines (a recurring issue with the "Made for
>> Windows" firmware).
>>
>> These drivers are quite old now and it's not clear to me if they are
>> broken or if we are talking of an improvement. Could you clarify what
>> you view as "abuse"?
>>
>> a) is this the fact that there are prepare/complete callback for those
>> drivers, instead of others such as freeze, thaw, etc.
>>
>> b) the fact they they call snd_soc_suspend/resume directly?
>>
>> c) the fact that they suspend the PCM streams?
>>
>> d) all of the above (which is entirely possible).
> The purpose of PM prepare and complete devops aren't for actually do
> suspend and resume devices there, while these drivers call
> snd_soc_suspend() and snd_soc_resume() to perform the complete suspend
> / resume procedure.  That's not the way these callbacks are supposed
> to be used.
>
> The prepare callback is called before the suspend callback of *all*
> devices on the system.  Ditto for complete, it's called after the
> resume of all devices.
>
> I guess they use prepare/callback to assure some tasks to be performed
> always suspend and resume.  But it's still puzzling,
> e.g. sst_soc_prepare() has
>
> static int sst_soc_prepare(struct device *dev)
> {
> 	struct sst_data *drv = dev_get_drvdata(dev);
> 	struct snd_soc_pcm_runtime *rtd;
>
> 	if (!drv->soc_card)
> 		return 0;
>
> 	/* suspend all pcms first */
> 	snd_soc_suspend(drv->soc_card->dev);
> 	snd_soc_poweroff(drv->soc_card->dev);
>
> 	/* set the SSPs to idle */
> 	for_each_card_rtds(drv->soc_card, rtd) {
> 		struct snd_soc_dai *dai = rtd->cpu_dai;
>
> 		if (dai->active) {
> 			send_ssp_cmd(dai, dai->name, 0);
> 			sst_handle_vb_timer(dai, false);
> 		}
> 	}
>
> 	return 0;
> }
>
> ... and it calls snd_soc_poweroff() for suspend.  That's odd and
> likely superfluous.
>
> And, the last part ("set the SSPs to idle") can be moved to
> card->suspend_post hook, and then we can simply call
> snd_soc_suspend().  Or it can be moved to PM devops suspend_late.
>
> Similarly for sst_soc_complete(), the task "restart SSPs" can be moved
> to card->resume_pre hook or PM devops resume_pre.
>
>
> The rest is to make sure the device PM ops order, and that's the
> hardest part.
>
> Further looking at the code, we can see that several Intel ASoC
> drivers have device PM ops.
>
> sound/soc/intel/atom/sst/sst.c
> sound/soc/intel/haswell/sst-haswell-pcm.c
> sound/soc/intel/skylake/skl.c
> sound/soc/intel/atom/sst-mfld-platform-pcm.c
>
> ... and there are codecs.  We need to list up and define the suspend /
> resume call order.

I had an offline discussion with Vinod and here are the key points for 
the Atom/SST driver

- the DSP isn't completely modeled with DPCM, there are some pipeline 
management and commands that need to be send manually. This isn't 
necessarily a perfect design but the one that was defined in 2013

- the choice of the .prepare is intentional. The tasks are split between 
the SST device (ACPI or PCI) and the platform device it creates. The 
ACPI/PCI layer handles DSP boot, config, shutdown, fw load, and the 
platform driver handles PCM/pipelines. The PM starts with the .prepare 
done in the child before the .suspend done at a higher level.

For Haswell I have no idea, and I wonder if there are actually any 
devices using this driver. Even from Broadwell we only know of the Pixel 
2015 Chromebook and the Dell XPS 13 where the I2S mode is activated (and 
the latter is deactivated with an ACPI quirk), most devices use HDaudio. 
Even if we found someone at Intel with bandwidth, changing this part is 
going to be very difficult between lack of devices and initial 
teams/individual contributors who have moved on.

SOF will support all these platforms, it might be a better idea to spend 
time making sure we do the right thing with the newer drivers than try 
to fix things but actually introduce regressions in legacy code.

-Pierre

  reply	other threads:[~2019-01-28 19:28 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15 16:21 [PATCH 00/14] ALSA: PCM suspend cleanup Takashi Iwai
2019-01-15 16:21 ` [PATCH 01/14] ALSA: pcm: Suspend streams globally via device type PM ops Takashi Iwai
2019-01-28 18:11   ` Mark Brown
2019-01-15 16:21 ` [PATCH 02/14] ALSA: atiixp: Move PCM suspend/resume code into trigger callback Takashi Iwai
2019-01-15 16:21 ` [PATCH 03/14] ALSA: isa: Remove superfluous snd_pcm_suspend*() calls Takashi Iwai
2019-01-15 16:21 ` [PATCH 04/14] ALSA: drivers: " Takashi Iwai
2019-01-15 16:21 ` [PATCH 05/14] ALSA: pci: " Takashi Iwai
2019-01-15 16:49   ` Pierre-Louis Bossart
2019-01-15 17:01     ` Takashi Iwai
2019-01-15 20:42       ` Takashi Iwai
2019-01-16 15:50         ` Mark Brown
2019-01-16 15:52           ` Takashi Iwai
2019-01-16 16:32             ` Mark Brown
2019-01-17 15:55             ` Mark Brown
2019-01-17  2:21         ` Pierre-Louis Bossart
2019-01-17  8:39           ` Takashi Iwai
2019-01-28 19:28             ` Pierre-Louis Bossart [this message]
2019-01-15 16:21 ` [PATCH 06/14] ALSA: usb: " Takashi Iwai
2019-01-15 16:21 ` [PATCH 07/14] ALSA: x86: " Takashi Iwai
2019-01-15 16:21 ` [PATCH 08/14] ALSA: ppc: " Takashi Iwai
2019-01-15 16:21 ` [PATCH 09/14] ALSA: aoa: " Takashi Iwai
2019-01-15 16:21 ` [PATCH 10/14] ALSA: arm: " Takashi Iwai
2019-01-15 16:21 ` [PATCH 11/14] ALSA: pcmcia: " Takashi Iwai
2019-01-15 16:21 ` [PATCH 12/14] drm: bridge: dw-hdmi: " Takashi Iwai
2019-01-15 16:21 ` [PATCH 13/14] ALSA: doc: Update the description about PCM suspend procedure Takashi Iwai
2019-01-15 16:21 ` [PATCH 14/14] ALSA: pcm: Make snd_pcm_suspend() local static Takashi Iwai
2019-01-17  1:50   ` Yang, Libin
2019-01-17  7:43     ` Takashi Iwai
2019-01-17 14:53       ` Yang, Libin
2019-01-15 16:32 ` [PATCH 00/14] ALSA: PCM suspend cleanup Jaroslav Kysela
2019-01-17  1:47 ` Yang, Libin

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=21711c90-595d-88b5-ec8e-f092e662c938@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=libin.yang@intel.com \
    --cc=mengdong.lin@intel.com \
    --cc=tiwai@suse.de \
    --cc=yang.jie@linux.intel.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.