alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map()
@ 2020-04-02 18:53 Hans de Goede
  2020-04-02 18:53 ` [PATCH 2/3] ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked Hans de Goede
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Hans de Goede @ 2020-04-02 18:53 UTC (permalink / raw)
  To: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Jie Yang,
	Mark Brown, flove, shumingf, Oder Chiou
  Cc: Hans de Goede, alsa-devel, Takashi Iwai

sst_send_slot_map() uses sst_fill_and_send_cmd_unlocked() because in some
places it is called with the drv->lock mutex already held.

So it must always be called with the mutex locked. This commit adds missing
locking in the sst_set_be_modules() code-path.

Fixes: 24c8d14192cc ("ASoC: Intel: mrfld: add DSP core controls")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 sound/soc/intel/atom/sst-atom-controls.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c
index baef461a99f1..2c3798034b1d 100644
--- a/sound/soc/intel/atom/sst-atom-controls.c
+++ b/sound/soc/intel/atom/sst-atom-controls.c
@@ -966,7 +966,9 @@ static int sst_set_be_modules(struct snd_soc_dapm_widget *w,
 	dev_dbg(c->dev, "Enter: widget=%s\n", w->name);
 
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		mutex_lock(&drv->lock);
 		ret = sst_send_slot_map(drv);
+		mutex_unlock(&drv->lock);
 		if (ret)
 			return ret;
 		ret = sst_send_pipe_module_params(w, k);
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked
  2020-04-02 18:53 [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Hans de Goede
@ 2020-04-02 18:53 ` Hans de Goede
  2020-04-03 13:40   ` Applied "ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked" to the asoc tree Mark Brown
  2020-04-02 18:53 ` [PATCH 3/3] ASoC: Intel: atom: Fix uninitialized variable compiler warning Hans de Goede
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2020-04-02 18:53 UTC (permalink / raw)
  To: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Jie Yang,
	Mark Brown, flove, shumingf, Oder Chiou
  Cc: Hans de Goede, alsa-devel, Takashi Iwai

sst_fill_and_send_cmd_unlocked must be called with the drv->lock mutex
locked already. In the past there have been cases where this was not the
case, add a WARN_ON to check for drv->lock being locked.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 sound/soc/intel/atom/sst-atom-controls.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c
index 2c3798034b1d..5bd2c2ec177b 100644
--- a/sound/soc/intel/atom/sst-atom-controls.c
+++ b/sound/soc/intel/atom/sst-atom-controls.c
@@ -50,6 +50,8 @@ static int sst_fill_and_send_cmd_unlocked(struct sst_data *drv,
 {
 	int ret = 0;
 
+	WARN_ON(!mutex_is_locked(&drv->lock));
+
 	ret = sst_fill_byte_control(drv, ipc_msg,
 				block, task_id, pipe_id, len, cmd_data);
 	if (ret < 0)
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] ASoC: Intel: atom: Fix uninitialized variable compiler warning
  2020-04-02 18:53 [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Hans de Goede
  2020-04-02 18:53 ` [PATCH 2/3] ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked Hans de Goede
@ 2020-04-02 18:53 ` Hans de Goede
  2020-04-03 13:40   ` Applied "ASoC: Intel: atom: Fix uninitialized variable compiler warning" to the asoc tree Mark Brown
  2020-04-02 19:25 ` [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Pierre-Louis Bossart
  2020-04-03 13:40 ` Applied "ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map()" to the asoc tree Mark Brown
  3 siblings, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2020-04-02 18:53 UTC (permalink / raw)
  To: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Jie Yang,
	Mark Brown, flove, shumingf, Oder Chiou
  Cc: Hans de Goede, alsa-devel, Takashi Iwai

GCC 10 gives a "variable might be used uninitialized" warning for the
block variable in sst_prepare_and_post_msg().

This is a false-positive warning, but lets fix it anyways.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 sound/soc/intel/atom/sst/sst_pvt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c
index 13db2854db3e..053c27707147 100644
--- a/sound/soc/intel/atom/sst/sst_pvt.c
+++ b/sound/soc/intel/atom/sst/sst_pvt.c
@@ -223,9 +223,9 @@ int sst_prepare_and_post_msg(struct intel_sst_drv *sst,
 		size_t mbox_data_len, const void *mbox_data, void **data,
 		bool large, bool fill_dsp, bool sync, bool response)
 {
+	struct sst_block *block = NULL;
 	struct ipc_post *msg = NULL;
 	struct ipc_dsp_hdr dsp_hdr;
-	struct sst_block *block;
 	int ret = 0, pvt_id;
 
 	pvt_id = sst_assign_pvt_id(sst);
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map()
  2020-04-02 18:53 [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Hans de Goede
  2020-04-02 18:53 ` [PATCH 2/3] ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked Hans de Goede
  2020-04-02 18:53 ` [PATCH 3/3] ASoC: Intel: atom: Fix uninitialized variable compiler warning Hans de Goede
@ 2020-04-02 19:25 ` Pierre-Louis Bossart
  2020-04-03 13:40 ` Applied "ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map()" to the asoc tree Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Pierre-Louis Bossart @ 2020-04-02 19:25 UTC (permalink / raw)
  To: Hans de Goede, Cezary Rojewski, Liam Girdwood, Jie Yang,
	Mark Brown, flove, shumingf, Oder Chiou
  Cc: alsa-devel, Takashi Iwai



On 4/2/20 1:53 PM, Hans de Goede wrote:
> sst_send_slot_map() uses sst_fill_and_send_cmd_unlocked() because in some
> places it is called with the drv->lock mutex already held.
> 
> So it must always be called with the mutex locked. This commit adds missing
> locking in the sst_set_be_modules() code-path.
> 
> Fixes: 24c8d14192cc ("ASoC: Intel: mrfld: add DSP core controls")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

2014 bug, nice!

for the series:

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

> ---
>   sound/soc/intel/atom/sst-atom-controls.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c
> index baef461a99f1..2c3798034b1d 100644
> --- a/sound/soc/intel/atom/sst-atom-controls.c
> +++ b/sound/soc/intel/atom/sst-atom-controls.c
> @@ -966,7 +966,9 @@ static int sst_set_be_modules(struct snd_soc_dapm_widget *w,
>   	dev_dbg(c->dev, "Enter: widget=%s\n", w->name);
>   
>   	if (SND_SOC_DAPM_EVENT_ON(event)) {
> +		mutex_lock(&drv->lock);
>   		ret = sst_send_slot_map(drv);
> +		mutex_unlock(&drv->lock);
>   		if (ret)
>   			return ret;
>   		ret = sst_send_pipe_module_params(w, k);
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Applied "ASoC: Intel: atom: Fix uninitialized variable compiler warning" to the asoc tree
  2020-04-02 18:53 ` [PATCH 3/3] ASoC: Intel: atom: Fix uninitialized variable compiler warning Hans de Goede
@ 2020-04-03 13:40   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2020-04-03 13:40 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Oder Chiou, alsa-devel, Takashi Iwai, Jie Yang, Cezary Rojewski,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown, shumingf, flove

The patch

   ASoC: Intel: atom: Fix uninitialized variable compiler warning

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From c515291d312760ff0ad1d4431f0fb29be5d0ef45 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Thu, 2 Apr 2020 20:53:59 +0200
Subject: [PATCH] ASoC: Intel: atom: Fix uninitialized variable compiler
 warning

GCC 10 gives a "variable might be used uninitialized" warning for the
block variable in sst_prepare_and_post_msg().

This is a false-positive warning, but lets fix it anyways.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200402185359.3424-3-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/atom/sst/sst_pvt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c
index 13db2854db3e..053c27707147 100644
--- a/sound/soc/intel/atom/sst/sst_pvt.c
+++ b/sound/soc/intel/atom/sst/sst_pvt.c
@@ -223,9 +223,9 @@ int sst_prepare_and_post_msg(struct intel_sst_drv *sst,
 		size_t mbox_data_len, const void *mbox_data, void **data,
 		bool large, bool fill_dsp, bool sync, bool response)
 {
+	struct sst_block *block = NULL;
 	struct ipc_post *msg = NULL;
 	struct ipc_dsp_hdr dsp_hdr;
-	struct sst_block *block;
 	int ret = 0, pvt_id;
 
 	pvt_id = sst_assign_pvt_id(sst);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Applied "ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked" to the asoc tree
  2020-04-02 18:53 ` [PATCH 2/3] ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked Hans de Goede
@ 2020-04-03 13:40   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2020-04-03 13:40 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Oder Chiou, alsa-devel, Takashi Iwai, Jie Yang, Cezary Rojewski,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown, shumingf, flove

The patch

   ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 0bb2be2d1b78f18ae68633b89ad49d84e0cb9bf6 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Thu, 2 Apr 2020 20:53:58 +0200
Subject: [PATCH] ASoC: Intel: atom: Check drv->lock is locked in
 sst_fill_and_send_cmd_unlocked

sst_fill_and_send_cmd_unlocked must be called with the drv->lock mutex
locked already. In the past there have been cases where this was not the
case, add a WARN_ON to check for drv->lock being locked.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200402185359.3424-2-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/atom/sst-atom-controls.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c
index df8f7994d3b7..69f3af4524ab 100644
--- a/sound/soc/intel/atom/sst-atom-controls.c
+++ b/sound/soc/intel/atom/sst-atom-controls.c
@@ -50,6 +50,8 @@ static int sst_fill_and_send_cmd_unlocked(struct sst_data *drv,
 {
 	int ret = 0;
 
+	WARN_ON(!mutex_is_locked(&drv->lock));
+
 	ret = sst_fill_byte_control(drv, ipc_msg,
 				block, task_id, pipe_id, len, cmd_data);
 	if (ret < 0)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Applied "ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map()" to the asoc tree
  2020-04-02 18:53 [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Hans de Goede
                   ` (2 preceding siblings ...)
  2020-04-02 19:25 ` [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Pierre-Louis Bossart
@ 2020-04-03 13:40 ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2020-04-03 13:40 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Oder Chiou, alsa-devel, Takashi Iwai, Jie Yang, Cezary Rojewski,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown, shumingf, flove

The patch

   ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map()

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 81630dc042af998b9f58cd8e2c29dab9777ea176 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Thu, 2 Apr 2020 20:53:57 +0200
Subject: [PATCH] ASoC: Intel: atom: Take the drv->lock mutex before calling
 sst_send_slot_map()

sst_send_slot_map() uses sst_fill_and_send_cmd_unlocked() because in some
places it is called with the drv->lock mutex already held.

So it must always be called with the mutex locked. This commit adds missing
locking in the sst_set_be_modules() code-path.

Fixes: 24c8d14192cc ("ASoC: Intel: mrfld: add DSP core controls")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200402185359.3424-1-hdegoede@redhat.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/atom/sst-atom-controls.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c
index f883c9340eee..df8f7994d3b7 100644
--- a/sound/soc/intel/atom/sst-atom-controls.c
+++ b/sound/soc/intel/atom/sst-atom-controls.c
@@ -966,7 +966,9 @@ static int sst_set_be_modules(struct snd_soc_dapm_widget *w,
 	dev_dbg(c->dev, "Enter: widget=%s\n", w->name);
 
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
+		mutex_lock(&drv->lock);
 		ret = sst_send_slot_map(drv);
+		mutex_unlock(&drv->lock);
 		if (ret)
 			return ret;
 		ret = sst_send_pipe_module_params(w, k);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-03 13:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 18:53 [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Hans de Goede
2020-04-02 18:53 ` [PATCH 2/3] ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked Hans de Goede
2020-04-03 13:40   ` Applied "ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked" to the asoc tree Mark Brown
2020-04-02 18:53 ` [PATCH 3/3] ASoC: Intel: atom: Fix uninitialized variable compiler warning Hans de Goede
2020-04-03 13:40   ` Applied "ASoC: Intel: atom: Fix uninitialized variable compiler warning" to the asoc tree Mark Brown
2020-04-02 19:25 ` [PATCH 1/3] ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map() Pierre-Louis Bossart
2020-04-03 13:40 ` Applied "ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map()" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).