Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Johan Hovold <johan+linaro@kernel.org>,
	Mark Brown <broonie@kernel.org>, Vinod Koul <vkoul@kernel.org>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>,
	Sanyog Kale <sanyog.r.kale@intel.com>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Banajit Goswami <bgoswami@quicinc.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Rander Wang <rander.wang@linux.intel.com>
Subject: Re: [PATCH 1/8] soundwire: fix enumeration completion
Date: Wed, 5 Jul 2023 14:53:17 +0200	[thread overview]
Message-ID: <907ad7a3-3384-c0c4-90a9-5beab4cc45e0@linux.intel.com> (raw)
In-Reply-To: <20230705123018.30903-2-johan+linaro@kernel.org>



On 7/5/23 14:30, Johan Hovold wrote:
> The soundwire subsystem uses two completion structures that allow
> drivers to wait for soundwire device to become enumerated on the bus and
> initialised by their drivers, respectively.
> 
> The code implementing the signalling is currently broken as it does not
> signal all current and future waiters and also uses the wrong
> reinitialisation function, which can potentially lead to memory
> corruption if there are still waiters on the queue.

That change sounds good, but I am not following the two paragraphs below.

> Not signalling future waiters specifically breaks sound card probe
> deferrals as codec drivers can not tell that the soundwire device is
> already attached when being reprobed. 

What makes you say that? There is a test in the probe and the codec
driver will absolutely be notified, see bus_type.c

	if (drv->ops && drv->ops->update_status) {
		ret = drv->ops->update_status(slave, slave->status);
		if (ret < 0)
			dev_warn(dev, "%s: update_status failed with status %d\n", __func__,
ret);
	}

> Some codec runtime PM
> implementations suffer from similar problems as waiting for enumeration
> during resume can also timeout despite the device already having been
> enumerated.

I am not following this either. Are you saying the wait_for_completion()
times out because of the init_completion/reinit_completion confusion, or
something else.

> Fixes: fb9469e54fa7 ("soundwire: bus: fix race condition with enumeration_complete signaling")
> Fixes: a90def068127 ("soundwire: bus: fix race condition with initialization_complete signaling")
> Cc: stable@vger.kernel.org      # 5.7
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Rander Wang <rander.wang@linux.intel.com>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
>  drivers/soundwire/bus.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> index 1ea6a64f8c4a..66e5dba919fa 100644
> --- a/drivers/soundwire/bus.c
> +++ b/drivers/soundwire/bus.c
> @@ -908,8 +908,8 @@ static void sdw_modify_slave_status(struct sdw_slave *slave,
>  			"initializing enumeration and init completion for Slave %d\n",
>  			slave->dev_num);
>  
> -		init_completion(&slave->enumeration_complete);
> -		init_completion(&slave->initialization_complete);
> +		reinit_completion(&slave->enumeration_complete);
> +		reinit_completion(&slave->initialization_complete);
>  
>  	} else if ((status == SDW_SLAVE_ATTACHED) &&
>  		   (slave->status == SDW_SLAVE_UNATTACHED)) {
> @@ -917,7 +917,7 @@ static void sdw_modify_slave_status(struct sdw_slave *slave,
>  			"signaling enumeration completion for Slave %d\n",
>  			slave->dev_num);
>  
> -		complete(&slave->enumeration_complete);
> +		complete_all(&slave->enumeration_complete);
>  	}
>  	slave->status = status;
>  	mutex_unlock(&bus->bus_lock);
> @@ -1941,7 +1941,7 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
>  				"signaling initialization completion for Slave %d\n",
>  				slave->dev_num);
>  
> -			complete(&slave->initialization_complete);
> +			complete_all(&slave->initialization_complete);
>  
>  			/*
>  			 * If the manager became pm_runtime active, the peripherals will be

  reply	other threads:[~2023-07-05 13:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 12:30 [PATCH 0/8] ASoC/soundwire/qdsp6/wcd: fix leaks and probe deferral Johan Hovold
2023-07-05 12:30 ` [PATCH 1/8] soundwire: fix enumeration completion Johan Hovold
2023-07-05 12:53   ` Pierre-Louis Bossart [this message]
2023-07-05 14:30     ` Johan Hovold
2023-07-05 14:44       ` Pierre-Louis Bossart
2023-07-05 12:30 ` [PATCH 2/8] ASoC: qdsp6: audioreach: fix topology probe deferral Johan Hovold
2023-07-06 11:09   ` Srinivas Kandagatla
2023-07-05 12:30 ` [PATCH 3/8] ASoC: codecs: wcd938x: fix missing clsh ctrl error handling Johan Hovold
2023-07-06 11:09   ` Srinivas Kandagatla
2023-07-05 12:30 ` [PATCH 4/8] ASoC: codecs: wcd938x: fix resource leaks on component remove Johan Hovold
2023-07-06 11:09   ` Srinivas Kandagatla
2023-07-05 12:30 ` [PATCH 5/8] ASoC: codecs: wcd934x: " Johan Hovold
2023-07-06 11:09   ` Srinivas Kandagatla
2023-07-05 12:30 ` [PATCH 6/8] ASoC: codecs: wcd-mbhc-v2: " Johan Hovold
2023-07-06 11:09   ` Srinivas Kandagatla
2023-07-05 12:30 ` [PATCH 7/8] ASoC: topology: suppress probe deferral errors Johan Hovold
2023-07-05 15:07   ` Amadeusz Sławiński
2023-07-06  6:14     ` Johan Hovold
2023-07-06  7:25       ` Amadeusz Sławiński
2023-07-10 12:01         ` Johan Hovold
2023-07-05 12:30 ` [PATCH 8/8] ASoC: core: " Johan Hovold
2023-07-10  8:53 ` (subset) [PATCH 0/8] ASoC/soundwire/qdsp6/wcd: fix leaks and probe deferral Vinod Koul
2023-07-11 20:44 ` Mark Brown

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=907ad7a3-3384-c0c4-90a9-5beab4cc45e0@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=johan+linaro@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=rander.wang@linux.intel.com \
    --cc=sanyog.r.kale@intel.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox