All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoc: hdmi-codec: remove HDMI device unregister
@ 2017-02-08  9:47 Vincent Abriou
  2017-02-08 10:40 ` Philipp Zabel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vincent Abriou @ 2017-02-08  9:47 UTC (permalink / raw)
  To: alsa-devel
  Cc: Kuninori Morimoto, Arnaud Pouliquen, Takashi Iwai, Jyri Sarha,
	Liam Girdwood, Mark Brown, Philipp Zabel, Vincent Abriou

While unregistering the hdmi-codec, the hdmi device list must be
cleaned up. It avoid kernel page fault when registering again the
hdmi-codec.

Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>

Signed-off-by: Vincent Abriou <vincent.abriou@st.com>
---
v2:
 - add mutex to protect hdmi_device_list from concurrent accesses
 - use of internal dev variable in the hdmi_codec_remove function

 sound/soc/codecs/hdmi-codec.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index dc6715a..8c5ae1f 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -32,6 +32,7 @@ struct hdmi_device {
 };
 #define pos_to_hdmi_device(pos)	container_of((pos), struct hdmi_device, list)
 LIST_HEAD(hdmi_device_list);
+static DEFINE_MUTEX(hdmi_mutex);
 
 #define DAI_NAME_SIZE 16
 
@@ -794,6 +795,7 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	hd = NULL;
+	mutex_lock(&hdmi_mutex);
 	list_for_each(pos, &hdmi_device_list) {
 		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
 
@@ -805,13 +807,16 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 
 	if (!hd) {
 		hd = devm_kzalloc(dev, sizeof(*hd), GFP_KERNEL);
-		if (!hd)
+		if (!hd) {
+			mutex_unlock(&hdmi_mutex);
 			return -ENOMEM;
+		}
 
 		hd->dev = dev->parent;
 
 		list_add_tail(&hd->list, &hdmi_device_list);
 	}
+	mutex_unlock(&hdmi_mutex);
 
 	if (hd->cnt >= ARRAY_SIZE(hdmi_dai_name)) {
 		dev_err(dev, "too many hdmi codec are deteced\n");
@@ -853,11 +858,25 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 
 static int hdmi_codec_remove(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
+	struct list_head *pos;
 	struct hdmi_codec_priv *hcp;
 
-	hcp = dev_get_drvdata(&pdev->dev);
+	mutex_lock(&hdmi_mutex);
+	list_for_each(pos, &hdmi_device_list) {
+		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
+
+		if (tmp->dev == dev->parent) {
+			list_del(pos);
+			break;
+		}
+	}
+	mutex_unlock(&hdmi_mutex);
+
+	hcp = dev_get_drvdata(dev);
 	kfree(hcp->chmap_info);
-	snd_soc_unregister_codec(&pdev->dev);
+	snd_soc_unregister_codec(dev);
+
 	return 0;
 }
 
-- 
2.7.4

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

* Re: [PATCH v2] ASoc: hdmi-codec: remove HDMI device unregister
  2017-02-08  9:47 [PATCH v2] ASoc: hdmi-codec: remove HDMI device unregister Vincent Abriou
@ 2017-02-08 10:40 ` Philipp Zabel
  2017-02-08 18:33 ` Mark Brown
  2017-02-08 18:34 ` Applied "ASoC: hdmi-codec: remove HDMI device unregister" to the asoc tree Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Philipp Zabel @ 2017-02-08 10:40 UTC (permalink / raw)
  To: Vincent Abriou
  Cc: alsa-devel, Kuninori Morimoto, Arnaud Pouliquen, Takashi Iwai,
	Jyri Sarha, Liam Girdwood, Mark Brown

On Wed, 2017-02-08 at 10:47 +0100, Vincent Abriou wrote:
> While unregistering the hdmi-codec, the hdmi device list must be
> cleaned up. It avoid kernel page fault when registering again the
> hdmi-codec.
> 
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Arnaud Pouliquen <arnaud.pouliquen@st.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> 
> Signed-off-by: Vincent Abriou <vincent.abriou@st.com>
> ---
> v2:
>  - add mutex to protect hdmi_device_list from concurrent accesses
>  - use of internal dev variable in the hdmi_codec_remove function
> 
>  sound/soc/codecs/hdmi-codec.c | 25 ++++++++++++++++++++++---
>  1 file changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
> index dc6715a..8c5ae1f 100644
> --- a/sound/soc/codecs/hdmi-codec.c
> +++ b/sound/soc/codecs/hdmi-codec.c
> @@ -32,6 +32,7 @@ struct hdmi_device {
>  };
>  #define pos_to_hdmi_device(pos)	container_of((pos), struct hdmi_device, list)
>  LIST_HEAD(hdmi_device_list);
> +static DEFINE_MUTEX(hdmi_mutex);
>  
>  #define DAI_NAME_SIZE 16
>  
> @@ -794,6 +795,7 @@ static int hdmi_codec_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	hd = NULL;
> +	mutex_lock(&hdmi_mutex);
>  	list_for_each(pos, &hdmi_device_list) {
>  		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
>  
> @@ -805,13 +807,16 @@ static int hdmi_codec_probe(struct platform_device *pdev)
>  
>  	if (!hd) {
>  		hd = devm_kzalloc(dev, sizeof(*hd), GFP_KERNEL);
> -		if (!hd)
> +		if (!hd) {
> +			mutex_unlock(&hdmi_mutex);
>  			return -ENOMEM;
> +		}
>  
>  		hd->dev = dev->parent;
>  
>  		list_add_tail(&hd->list, &hdmi_device_list);
>  	}
> +	mutex_unlock(&hdmi_mutex);
>  
>  	if (hd->cnt >= ARRAY_SIZE(hdmi_dai_name)) {
>  		dev_err(dev, "too many hdmi codec are deteced\n");
> @@ -853,11 +858,25 @@ static int hdmi_codec_probe(struct platform_device *pdev)
>  
>  static int hdmi_codec_remove(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;
> +	struct list_head *pos;
>  	struct hdmi_codec_priv *hcp;
>  
> -	hcp = dev_get_drvdata(&pdev->dev);
> +	mutex_lock(&hdmi_mutex);
> +	list_for_each(pos, &hdmi_device_list) {
> +		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
> +
> +		if (tmp->dev == dev->parent) {
> +			list_del(pos);
> +			break;
> +		}
> +	}
> +	mutex_unlock(&hdmi_mutex);
> +
> +	hcp = dev_get_drvdata(dev);
>  	kfree(hcp->chmap_info);
> -	snd_soc_unregister_codec(&pdev->dev);
> +	snd_soc_unregister_codec(dev);
> +
>  	return 0;
>  }

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

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

* Re: [PATCH v2] ASoc: hdmi-codec: remove HDMI device unregister
  2017-02-08  9:47 [PATCH v2] ASoc: hdmi-codec: remove HDMI device unregister Vincent Abriou
  2017-02-08 10:40 ` Philipp Zabel
@ 2017-02-08 18:33 ` Mark Brown
  2017-02-08 18:34 ` Applied "ASoC: hdmi-codec: remove HDMI device unregister" to the asoc tree Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2017-02-08 18:33 UTC (permalink / raw)
  To: Vincent Abriou
  Cc: alsa-devel, Kuninori Morimoto, Arnaud Pouliquen, Takashi Iwai,
	Jyri Sarha, Liam Girdwood, Philipp Zabel


[-- Attachment #1.1: Type: text/plain, Size: 499 bytes --]

On Wed, Feb 08, 2017 at 10:47:01AM +0100, Vincent Abriou wrote:
> While unregistering the hdmi-codec, the hdmi device list must be
> cleaned up. It avoid kernel page fault when registering again the
> hdmi-codec.

Please submit patches using subject lines reflecting the style for the
subsystem.  This makes it easier for people to identify relevant
patches.  Look at what existing commits in the area you're changing are
doing and make sure your subject lines visually resemble what they're
doing.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Applied "ASoC: hdmi-codec: remove HDMI device unregister" to the asoc tree
  2017-02-08  9:47 [PATCH v2] ASoc: hdmi-codec: remove HDMI device unregister Vincent Abriou
  2017-02-08 10:40 ` Philipp Zabel
  2017-02-08 18:33 ` Mark Brown
@ 2017-02-08 18:34 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2017-02-08 18:34 UTC (permalink / raw)
  To: Vincent Abriou
  Cc: alsa-devel, Kuninori Morimoto, Arnaud Pouliquen, Takashi Iwai,
	Jyri Sarha, Liam Girdwood, Mark Brown, Philipp Zabel

The patch

   ASoC: hdmi-codec: remove HDMI device unregister

has been applied to the asoc tree at

   git://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 8480ac567959eecdc694cf4f9c02d6fa687384b6 Mon Sep 17 00:00:00 2001
From: Vincent Abriou <vincent.abriou@st.com>
Date: Wed, 8 Feb 2017 10:47:01 +0100
Subject: [PATCH] ASoC: hdmi-codec: remove HDMI device unregister

While unregistering the hdmi-codec, the hdmi device list must be
cleaned up. It avoid kernel page fault when registering again the
hdmi-codec.

Signed-off-by: Vincent Abriou <vincent.abriou@st.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/hdmi-codec.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index dc6715a804a1..8c5ae1fc23a9 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -32,6 +32,7 @@ struct hdmi_device {
 };
 #define pos_to_hdmi_device(pos)	container_of((pos), struct hdmi_device, list)
 LIST_HEAD(hdmi_device_list);
+static DEFINE_MUTEX(hdmi_mutex);
 
 #define DAI_NAME_SIZE 16
 
@@ -794,6 +795,7 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	hd = NULL;
+	mutex_lock(&hdmi_mutex);
 	list_for_each(pos, &hdmi_device_list) {
 		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
 
@@ -805,13 +807,16 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 
 	if (!hd) {
 		hd = devm_kzalloc(dev, sizeof(*hd), GFP_KERNEL);
-		if (!hd)
+		if (!hd) {
+			mutex_unlock(&hdmi_mutex);
 			return -ENOMEM;
+		}
 
 		hd->dev = dev->parent;
 
 		list_add_tail(&hd->list, &hdmi_device_list);
 	}
+	mutex_unlock(&hdmi_mutex);
 
 	if (hd->cnt >= ARRAY_SIZE(hdmi_dai_name)) {
 		dev_err(dev, "too many hdmi codec are deteced\n");
@@ -853,11 +858,25 @@ static int hdmi_codec_probe(struct platform_device *pdev)
 
 static int hdmi_codec_remove(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
+	struct list_head *pos;
 	struct hdmi_codec_priv *hcp;
 
-	hcp = dev_get_drvdata(&pdev->dev);
+	mutex_lock(&hdmi_mutex);
+	list_for_each(pos, &hdmi_device_list) {
+		struct hdmi_device *tmp = pos_to_hdmi_device(pos);
+
+		if (tmp->dev == dev->parent) {
+			list_del(pos);
+			break;
+		}
+	}
+	mutex_unlock(&hdmi_mutex);
+
+	hcp = dev_get_drvdata(dev);
 	kfree(hcp->chmap_info);
-	snd_soc_unregister_codec(&pdev->dev);
+	snd_soc_unregister_codec(dev);
+
 	return 0;
 }
 
-- 
2.11.0

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

end of thread, other threads:[~2017-02-08 18:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-08  9:47 [PATCH v2] ASoc: hdmi-codec: remove HDMI device unregister Vincent Abriou
2017-02-08 10:40 ` Philipp Zabel
2017-02-08 18:33 ` Mark Brown
2017-02-08 18:34 ` Applied "ASoC: hdmi-codec: remove HDMI device unregister" 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.