All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: Tegra: tegra_pcm_deallocate_dma_buffer: Don't OOPS
@ 2011-08-04 22:44 Stephen Warren
       [not found] ` <1312497884-1599-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2011-08-08 15:43 ` [PATCH 1/3] ASoC: Tegra: tegra_pcm_deallocate_dma_buffer: Don't OOPS Liam Girdwood
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Warren @ 2011-08-04 22:44 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren

Not all PCM devices have all sub-streams. Specifically, the SPDIF driver
only supports playback and hence has no capture substream. Check whether
a substream exists before dereferencing it, when de-allocating DMA
buffers in tegra_pcm_deallocate_dma_buffer.

Signed-off-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 sound/soc/tegra/tegra_pcm.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
index ff86e5e..c7cfd96 100644
--- a/sound/soc/tegra/tegra_pcm.c
+++ b/sound/soc/tegra/tegra_pcm.c
@@ -309,9 +309,14 @@ static int tegra_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
 
 static void tegra_pcm_deallocate_dma_buffer(struct snd_pcm *pcm, int stream)
 {
-	struct snd_pcm_substream *substream = pcm->streams[stream].substream;
-	struct snd_dma_buffer *buf = &substream->dma_buffer;
+	struct snd_pcm_substream *substream;
+	struct snd_dma_buffer *buf;
+
+	substream = pcm->streams[stream].substream;
+	if (!substream)
+		return;
 
+	buf = &substream->dma_buffer;
 	if (!buf->area)
 		return;
 
-- 
1.7.0.4

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

* [PATCH 2/3] ASoC: Tegra: WM8903: Allow re-insertion of module
       [not found] ` <1312497884-1599-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-08-04 22:44   ` Stephen Warren
       [not found]     ` <1312497884-1599-2-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2011-08-04 22:44   ` [PATCH 3/3] ASoC: WM8903: Free IRQ on device removal Stephen Warren
  1 sibling, 1 reply; 7+ messages in thread
From: Stephen Warren @ 2011-08-04 22:44 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren

Two issues were preventing module snd-soc-tegra-wm8903.ko from being
removed and re-inserted:

a) The speaker-enable GPIO is hosted by the WM8903 chip. This GPIO must
   be freed before snd_soc_unregister_card() is called, because that
   triggers wm8903.c:wm8903_remove(), which calls gpiochip_remove(), which
   then fails if any of the GPIOs are in use. To solve this, free all GPIOs
   first, so the code doesn't care where they come from.

b) We need to call snd_soc_jack_free_gpios() to match the call to
   snd_soc_jack_add_gpios() during initialization. Without this, the
   call to snd_soc_jack_add_gpios() fails during any subsequent modprobe
   and initialization, since the GPIO and IRQ are already registered. In
   turn, this causes the headphone state not to be monitored, so the
   headphone is assumed not to be plugged in, and the audio path to it is
   never enabled.

Signed-off-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 sound/soc/tegra/tegra_wm8903.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index a42e9ac..661373c 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -56,6 +56,7 @@
 #define GPIO_HP_MUTE    BIT(1)
 #define GPIO_INT_MIC_EN BIT(2)
 #define GPIO_EXT_MIC_EN BIT(3)
+#define GPIO_HP_DET     BIT(4)
 
 struct tegra_wm8903 {
 	struct tegra_asoc_utils_data util_data;
@@ -304,6 +305,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
 		snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack,
 					1,
 					&tegra_wm8903_hp_jack_gpio);
+		machine->gpio_requested |= GPIO_HP_DET;
 	}
 
 	snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
@@ -429,10 +431,10 @@ static int __devexit tegra_wm8903_driver_remove(struct platform_device *pdev)
 	struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
 	struct tegra_wm8903_platform_data *pdata = machine->pdata;
 
-	snd_soc_unregister_card(card);
-
-	tegra_asoc_utils_fini(&machine->util_data);
-
+	if (machine->gpio_requested & GPIO_HP_DET)
+		snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack,
+					1,
+					&tegra_wm8903_hp_jack_gpio);
 	if (machine->gpio_requested & GPIO_EXT_MIC_EN)
 		gpio_free(pdata->gpio_ext_mic_en);
 	if (machine->gpio_requested & GPIO_INT_MIC_EN)
@@ -441,6 +443,11 @@ static int __devexit tegra_wm8903_driver_remove(struct platform_device *pdev)
 		gpio_free(pdata->gpio_hp_mute);
 	if (machine->gpio_requested & GPIO_SPKR_EN)
 		gpio_free(pdata->gpio_spkr_en);
+	machine->gpio_requested = 0;
+
+	snd_soc_unregister_card(card);
+
+	tegra_asoc_utils_fini(&machine->util_data);
 
 	kfree(machine);
 
-- 
1.7.0.4

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

* [PATCH 3/3] ASoC: WM8903: Free IRQ on device removal
       [not found] ` <1312497884-1599-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2011-08-04 22:44   ` [PATCH 2/3] ASoC: Tegra: WM8903: Allow re-insertion of module Stephen Warren
@ 2011-08-04 22:44   ` Stephen Warren
  1 sibling, 0 replies; 7+ messages in thread
From: Stephen Warren @ 2011-08-04 22:44 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren

Without this, request_irq on subsequent device initialization fails, and
the codec cannot be used.

Signed-off-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 sound/soc/codecs/wm8903.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index 43e3d76..4ad8ebd 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -2046,8 +2046,13 @@ static int wm8903_probe(struct snd_soc_codec *codec)
 /* power down chip */
 static int wm8903_remove(struct snd_soc_codec *codec)
 {
+	struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec);
+
 	wm8903_free_gpio(codec);
 	wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF);
+	if (wm8903->irq)
+		free_irq(wm8903->irq, codec);
+
 	return 0;
 }
 
-- 
1.7.0.4

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

* Re: [PATCH 1/3] ASoC: Tegra: tegra_pcm_deallocate_dma_buffer: Don't OOPS
  2011-08-04 22:44 [PATCH 1/3] ASoC: Tegra: tegra_pcm_deallocate_dma_buffer: Don't OOPS Stephen Warren
       [not found] ` <1312497884-1599-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-08-08 15:43 ` Liam Girdwood
  1 sibling, 0 replies; 7+ messages in thread
From: Liam Girdwood @ 2011-08-08 15:43 UTC (permalink / raw)
  To: Stephen Warren; +Cc: linux-tegra, alsa-devel, Mark Brown

On Fri, 2011-08-05 at 00:44 +0200, Stephen Warren wrote:
> Not all PCM devices have all sub-streams. Specifically, the SPDIF driver
> only supports playback and hence has no capture substream. Check whether
> a substream exists before dereferencing it, when de-allocating DMA
> buffers in tegra_pcm_deallocate_dma_buffer.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---

All 

Acked-by: Liam Girdwood <lrg@ti.com>

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

* Re: [PATCH 2/3] ASoC: Tegra: WM8903: Allow re-insertion of module
       [not found]     ` <1312497884-1599-2-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-08-09  0:43       ` Mark Brown
       [not found]         ` <20110809004346.GA22795-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2011-08-09  0:43 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Liam Girdwood, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Thu, Aug 04, 2011 at 04:44:43PM -0600, Stephen Warren wrote:
> Two issues were preventing module snd-soc-tegra-wm8903.ko from being
> removed and re-inserted:

I've applied all three but please be a bit clearer with your patch
descriptions - this isn't a patch for WM8903 at all, it's a patch for
the tegra-wm8903 machine driver.

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

* RE: [PATCH 2/3] ASoC: Tegra: WM8903: Allow re-insertion of module
       [not found]         ` <20110809004346.GA22795-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
@ 2011-08-09 15:36           ` Stephen Warren
       [not found]             ` <74CDBE0F657A3D45AFBB94109FB122FF04A068726C-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Warren @ 2011-08-09 15:36 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

Mark Brown wrote at Monday, August 08, 2011 6:44 PM:
> On Thu, Aug 04, 2011 at 04:44:43PM -0600, Stephen Warren wrote:
> > Two issues were preventing module snd-soc-tegra-wm8903.ko from being
> > removed and re-inserted:
> 
> I've applied all three but please be a bit clearer with your patch
> descriptions - this isn't a patch for WM8903 at all, it's a patch for
> the tegra-wm8903 machine driver.

OK, but what's the correct tag then? I explicitly wrote Tegra in the
commit subject and not just WM8903...

Thanks.

-- 
nvpublic

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

* Re: [PATCH 2/3] ASoC: Tegra: WM8903: Allow re-insertion of module
       [not found]             ` <74CDBE0F657A3D45AFBB94109FB122FF04A068726C-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
@ 2011-08-09 15:38               ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2011-08-09 15:38 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Liam Girdwood, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Tue, Aug 09, 2011 at 08:36:36AM -0700, Stephen Warren wrote:
> Mark Brown wrote at Monday, August 08, 2011 6:44 PM:

> > I've applied all three but please be a bit clearer with your patch
> > descriptions - this isn't a patch for WM8903 at all, it's a patch for
> > the tegra-wm8903 machine driver.

> OK, but what's the correct tag then? I explicitly wrote Tegra in the
> commit subject and not just WM8903...

Something like "Fix reload of Tegra WM8903 machine driver".

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

end of thread, other threads:[~2011-08-09 15:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-04 22:44 [PATCH 1/3] ASoC: Tegra: tegra_pcm_deallocate_dma_buffer: Don't OOPS Stephen Warren
     [not found] ` <1312497884-1599-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-08-04 22:44   ` [PATCH 2/3] ASoC: Tegra: WM8903: Allow re-insertion of module Stephen Warren
     [not found]     ` <1312497884-1599-2-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-08-09  0:43       ` Mark Brown
     [not found]         ` <20110809004346.GA22795-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-08-09 15:36           ` Stephen Warren
     [not found]             ` <74CDBE0F657A3D45AFBB94109FB122FF04A068726C-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-08-09 15:38               ` Mark Brown
2011-08-04 22:44   ` [PATCH 3/3] ASoC: WM8903: Free IRQ on device removal Stephen Warren
2011-08-08 15:43 ` [PATCH 1/3] ASoC: Tegra: tegra_pcm_deallocate_dma_buffer: Don't OOPS Liam Girdwood

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.