All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: soc-pcm: fixup try_module_get()/module_put() timing
@ 2019-05-20  1:42 Kuninori Morimoto
  2019-05-20 13:29 ` Pierre-Louis Bossart
  2019-05-21 21:04 ` Applied "ASoC: soc-pcm: fixup try_module_get()/module_put() timing" to the asoc tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2019-05-20  1:42 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Ranjani Sridharan, Pierre-Louis Bossart


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc_pcm_components_open/close() try to call
try_module_get()/module_put() based on
component->driver->module_get_upon_open.

Here, the purpose why we need to call these functions are to
checking module reference.
Thus, we need to call try_module_open() even though it doesn't
have .open callback.

The same reason, we need to call module_put() even though it
doesn't have .close

This patch calls try_module_get()/module_put() regardless of
.open/.close

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

 - merge both try_module_get()/module_put() patch into 1

 sound/soc/soc-pcm.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 7737e00..e24eab3 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -440,10 +440,6 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
 		component = rtdcom->component;
 		*last = component;
 
-		if (!component->driver->ops ||
-		    !component->driver->ops->open)
-			continue;
-
 		if (component->driver->module_get_upon_open &&
 		    !try_module_get(component->dev->driver->owner)) {
 			dev_err(component->dev,
@@ -452,6 +448,10 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
 			return -ENODEV;
 		}
 
+		if (!component->driver->ops ||
+		    !component->driver->ops->open)
+			continue;
+
 		ret = component->driver->ops->open(substream);
 		if (ret < 0) {
 			dev_err(component->dev,
@@ -477,11 +477,9 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream,
 		if (component == last)
 			break;
 
-		if (!component->driver->ops ||
-		    !component->driver->ops->close)
-			continue;
-
-		component->driver->ops->close(substream);
+		if (component->driver->ops &&
+		    component->driver->ops->close)
+			component->driver->ops->close(substream);
 
 		if (component->driver->module_get_upon_open)
 			module_put(component->dev->driver->owner);
-- 
2.7.4

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

* Re: [PATCH v2] ASoC: soc-pcm: fixup try_module_get()/module_put() timing
  2019-05-20  1:42 [PATCH v2] ASoC: soc-pcm: fixup try_module_get()/module_put() timing Kuninori Morimoto
@ 2019-05-20 13:29 ` Pierre-Louis Bossart
  2019-05-21 21:04 ` Applied "ASoC: soc-pcm: fixup try_module_get()/module_put() timing" to the asoc tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2019-05-20 13:29 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA, Ranjani Sridharan



On 5/19/19 8:42 PM, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> soc_pcm_components_open/close() try to call
> try_module_get()/module_put() based on
> component->driver->module_get_upon_open.
> 
> Here, the purpose why we need to call these functions are to
> checking module reference.
> Thus, we need to call try_module_open() even though it doesn't
> have .open callback.
> 
> The same reason, we need to call module_put() even though it
> doesn't have .close
> 
> This patch calls try_module_get()/module_put() regardless of
> .open/.close
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>


LGTM, this removes the assumptions on the implementation of .open and 
.close.

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

Thanks!

> ---
> v1 -> v2
> 
>   - merge both try_module_get()/module_put() patch into 1
> 
>   sound/soc/soc-pcm.c | 16 +++++++---------
>   1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index 7737e00..e24eab3 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -440,10 +440,6 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
>   		component = rtdcom->component;
>   		*last = component;
>   
> -		if (!component->driver->ops ||
> -		    !component->driver->ops->open)
> -			continue;
> -
>   		if (component->driver->module_get_upon_open &&
>   		    !try_module_get(component->dev->driver->owner)) {
>   			dev_err(component->dev,
> @@ -452,6 +448,10 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
>   			return -ENODEV;
>   		}
>   
> +		if (!component->driver->ops ||
> +		    !component->driver->ops->open)
> +			continue;
> +
>   		ret = component->driver->ops->open(substream);
>   		if (ret < 0) {
>   			dev_err(component->dev,
> @@ -477,11 +477,9 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream,
>   		if (component == last)
>   			break;
>   
> -		if (!component->driver->ops ||
> -		    !component->driver->ops->close)
> -			continue;
> -
> -		component->driver->ops->close(substream);
> +		if (component->driver->ops &&
> +		    component->driver->ops->close)
> +			component->driver->ops->close(substream);
>   
>   		if (component->driver->module_get_upon_open)
>   			module_put(component->dev->driver->owner);
> 

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

* Applied "ASoC: soc-pcm: fixup try_module_get()/module_put() timing" to the asoc tree
  2019-05-20  1:42 [PATCH v2] ASoC: soc-pcm: fixup try_module_get()/module_put() timing Kuninori Morimoto
  2019-05-20 13:29 ` Pierre-Louis Bossart
@ 2019-05-21 21:04 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2019-05-21 21:04 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Linux-ALSA, Mark Brown, Pierre-Louis Bossart, Ranjani Sridharan

The patch

   ASoC: soc-pcm: fixup try_module_get()/module_put() timing

has been applied to the asoc tree at

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

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 428306c3b3fe107b1d059ceecf6fda09a1fcedf5 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Mon, 20 May 2019 10:42:39 +0900
Subject: [PATCH] ASoC: soc-pcm: fixup try_module_get()/module_put() timing

soc_pcm_components_open/close() try to call
try_module_get()/module_put() based on
component->driver->module_get_upon_open.

Here, the purpose why we need to call these functions are to
checking module reference.
Thus, we need to call try_module_open() even though it doesn't
have .open callback.

The same reason, we need to call module_put() even though it
doesn't have .close

This patch calls try_module_get()/module_put() regardless of
.open/.close

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-pcm.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 74c7d38af2c6..4a7096a22b28 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -458,10 +458,6 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
 		component = rtdcom->component;
 		*last = component;
 
-		if (!component->driver->ops ||
-		    !component->driver->ops->open)
-			continue;
-
 		if (component->driver->module_get_upon_open &&
 		    !try_module_get(component->dev->driver->owner)) {
 			dev_err(component->dev,
@@ -470,6 +466,10 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
 			return -ENODEV;
 		}
 
+		if (!component->driver->ops ||
+		    !component->driver->ops->open)
+			continue;
+
 		ret = component->driver->ops->open(substream);
 		if (ret < 0) {
 			dev_err(component->dev,
@@ -495,11 +495,9 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream,
 		if (component == last)
 			break;
 
-		if (!component->driver->ops ||
-		    !component->driver->ops->close)
-			continue;
-
-		component->driver->ops->close(substream);
+		if (component->driver->ops &&
+		    component->driver->ops->close)
+			component->driver->ops->close(substream);
 
 		if (component->driver->module_get_upon_open)
 			module_put(component->dev->driver->owner);
-- 
2.20.1

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

end of thread, other threads:[~2019-05-21 21:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-20  1:42 [PATCH v2] ASoC: soc-pcm: fixup try_module_get()/module_put() timing Kuninori Morimoto
2019-05-20 13:29 ` Pierre-Louis Bossart
2019-05-21 21:04 ` Applied "ASoC: soc-pcm: fixup try_module_get()/module_put() timing" to the asoc tree Mark Brown

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.