All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Ryan Lee <RyanS.Lee@maximintegrated.com>,
	Mark Brown <broonie@kernel.org>
Cc: "lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"perex@perex.cz" <perex@perex.cz>,
	"tiwai@suse.com" <tiwai@suse.com>,
	"yung-chuan.liao@linux.intel.com"
	<yung-chuan.liao@linux.intel.com>,
	"guennadi.liakhovetski@linux.intel.com" 
	<guennadi.liakhovetski@linux.intel.com>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"sathya.prakash.m.r@intel.com" <sathya.prakash.m.r@intel.com>,
	"ryan.lee.maxim@gmail.com" <ryan.lee.maxim@gmail.com>
Subject: Re: [EXTERNAL] Re: [PATCH] ASoC: max98373: Mark cache dirty before entering sleep
Date: Mon, 27 Sep 2021 14:34:09 -0500	[thread overview]
Message-ID: <c5031731-dd58-ff7a-857e-b9e1b748d3b2@linux.intel.com> (raw)
In-Reply-To: <SJ0PR11MB5661814BCC6B79EDE1B0967AE7A79@SJ0PR11MB5661.namprd11.prod.outlook.com>


>> Instead of changing the suspend sequence, can we please try to modify the
>> max98373_io_init() routine to unconditionally flag the cache as dirty, maybe
>> this points to a problem with the management of the
>> max98373->first_hw_init flag.
> 
> max98373_io_init() is not called because ' sdw_slave_status' remains
> ' SDW_SLAVE_ATTACHED' and 'max98373->hw_init' is already true.
> Removing 'if (max98373->hw_init || status != SDW_SLAVE_ATTACHED)'
> condition in max98373_update_status() function instead of adding
> regcache_mark_dirty() into max98373_suspend() can be an alternative way.
> I think it is all about where regcache_mark_dirty() is called from.
> The difference is that max98373_io_init() really do the software reset and
> do amp initialization again which could be an overhead.

that description is aligned with my analysis that there's something very
wrong happening here, it's not just a simple miss in the regmap handling
but a major conceptual bug or misunderstanding in the way reset is handled.

First, there's the spec: on a reset initiated by the host or if the
device loses sync for ANY reason, its status cannot remain ATTACHED.
There's got to be a 16-frame period at least where the device has to
monitor the sync pattern and cannot drive anything on the bus.

Then there's the hardware behavior on resume: on resume by default the
Intel host will toggle the data pin for at least 4096 frames, which by
spec means severe reset.

And last, there's the software init: we also force the status as
UNATTACHED in drivers/soundwire/intel.c:

	/*
	 * make sure all Slaves are tagged as UNATTACHED and provide
	 * reason for reinitialization
	 */
	sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET);

But we've also seen the opposite effect of an amplifier reporting
attached but losing sync immediately after the end of enumeration and
never coming back on the bus, see issue
https://github.com/thesofproject/linux/issues/3063

In other words, we need to check what really happens on resume and why
the amplifier keeps reporting its status as ATTACHED despite the spec
requirements and software init, or loses this status after
enumeration....Something really does not add-up, again it's not just a
regmap management issue.





WARNING: multiple messages have this Message-ID (diff)
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Ryan Lee <RyanS.Lee@maximintegrated.com>,
	Mark Brown <broonie@kernel.org>
Cc: "guennadi.liakhovetski@linux.intel.com"
	<guennadi.liakhovetski@linux.intel.com>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"ryan.lee.maxim@gmail.com" <ryan.lee.maxim@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"tiwai@suse.com" <tiwai@suse.com>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"sathya.prakash.m.r@intel.com" <sathya.prakash.m.r@intel.com>,
	"yung-chuan.liao@linux.intel.com"
	<yung-chuan.liao@linux.intel.com>
Subject: Re: [EXTERNAL] Re: [PATCH] ASoC: max98373: Mark cache dirty before entering sleep
Date: Mon, 27 Sep 2021 14:34:09 -0500	[thread overview]
Message-ID: <c5031731-dd58-ff7a-857e-b9e1b748d3b2@linux.intel.com> (raw)
In-Reply-To: <SJ0PR11MB5661814BCC6B79EDE1B0967AE7A79@SJ0PR11MB5661.namprd11.prod.outlook.com>


>> Instead of changing the suspend sequence, can we please try to modify the
>> max98373_io_init() routine to unconditionally flag the cache as dirty, maybe
>> this points to a problem with the management of the
>> max98373->first_hw_init flag.
> 
> max98373_io_init() is not called because ' sdw_slave_status' remains
> ' SDW_SLAVE_ATTACHED' and 'max98373->hw_init' is already true.
> Removing 'if (max98373->hw_init || status != SDW_SLAVE_ATTACHED)'
> condition in max98373_update_status() function instead of adding
> regcache_mark_dirty() into max98373_suspend() can be an alternative way.
> I think it is all about where regcache_mark_dirty() is called from.
> The difference is that max98373_io_init() really do the software reset and
> do amp initialization again which could be an overhead.

that description is aligned with my analysis that there's something very
wrong happening here, it's not just a simple miss in the regmap handling
but a major conceptual bug or misunderstanding in the way reset is handled.

First, there's the spec: on a reset initiated by the host or if the
device loses sync for ANY reason, its status cannot remain ATTACHED.
There's got to be a 16-frame period at least where the device has to
monitor the sync pattern and cannot drive anything on the bus.

Then there's the hardware behavior on resume: on resume by default the
Intel host will toggle the data pin for at least 4096 frames, which by
spec means severe reset.

And last, there's the software init: we also force the status as
UNATTACHED in drivers/soundwire/intel.c:

	/*
	 * make sure all Slaves are tagged as UNATTACHED and provide
	 * reason for reinitialization
	 */
	sdw_clear_slave_status(bus, SDW_UNATTACH_REQUEST_MASTER_RESET);

But we've also seen the opposite effect of an amplifier reporting
attached but losing sync immediately after the end of enumeration and
never coming back on the bus, see issue
https://github.com/thesofproject/linux/issues/3063

In other words, we need to check what really happens on resume and why
the amplifier keeps reporting its status as ATTACHED despite the spec
requirements and software init, or loses this status after
enumeration....Something really does not add-up, again it's not just a
regmap management issue.





  reply	other threads:[~2021-09-27 19:34 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24 22:13 [PATCH] ASoC: max98373: Mark cache dirty before entering sleep Ryan Lee
2021-09-27 14:54 ` Pierre-Louis Bossart
2021-09-27 16:01   ` [EXTERNAL] " Ryan Lee
2021-09-27 16:01     ` Ryan Lee
2021-09-27 16:06     ` Mark Brown
2021-09-27 16:06       ` Mark Brown
2021-09-27 16:48       ` Pierre-Louis Bossart
2021-09-27 16:48         ` Pierre-Louis Bossart
2021-09-27 17:10         ` Mark Brown
2021-09-27 17:10           ` Mark Brown
2021-09-27 17:23           ` Pierre-Louis Bossart
2021-09-27 17:23             ` Pierre-Louis Bossart
2021-09-27 17:29             ` Mark Brown
2021-09-27 17:29               ` Mark Brown
2021-09-28 16:43             ` Ryan Lee
2021-09-28 16:43               ` Ryan Lee
2021-09-28 18:15               ` Pierre-Louis Bossart
2021-09-28 18:15                 ` Pierre-Louis Bossart
2021-09-27 18:44         ` Ryan Lee
2021-09-27 18:44           ` Ryan Lee
2021-09-27 19:34           ` Pierre-Louis Bossart [this message]
2021-09-27 19:34             ` Pierre-Louis Bossart
2021-09-27 22:43             ` Ryan Lee
2021-09-27 22:43               ` Ryan Lee
2021-09-30  6:21             ` Ryan Lee
2021-09-30  6:21               ` Ryan Lee
2021-09-30 13:29               ` Pierre-Louis Bossart
2021-09-30 13:29                 ` Pierre-Louis Bossart
2021-09-30 23:31               ` Ryan Lee
2021-09-30 23:31                 ` Ryan Lee
2021-09-30 23:53                 ` Pierre-Louis Bossart
2021-09-30 23:53                   ` Pierre-Louis Bossart

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=c5031731-dd58-ff7a-857e-b9e1b748d3b2@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=RyanS.Lee@maximintegrated.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=guennadi.liakhovetski@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=ryan.lee.maxim@gmail.com \
    --cc=sathya.prakash.m.r@intel.com \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@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.