public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/5] ASoC: dwc: Don't allow negative use counts
@ 2014-12-03 16:38 Andrew Jackson
  2014-12-03 17:25 ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Jackson @ 2014-12-03 16:38 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Rajeev Kumar, Liam Girdwood,
	Mark Brown, Liviu Dudau


Signed-off-by: Andrew Jackson <Andrew.Jackson@arm.com>
---
 sound/soc/dwc/designware_i2s.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
index 08f0229..f8946bd 100644
--- a/sound/soc/dwc/designware_i2s.c
+++ b/sound/soc/dwc/designware_i2s.c
@@ -280,7 +280,8 @@ static int dw_i2s_trigger(struct snd_pcm_substream *substream,
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		dev->active--;
+		if (dev->active > 0)
+			dev->active--;
 		i2s_stop(dev, substream);
 		break;
 	default:
-- 
1.7.1


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

* Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts
  2014-12-03 16:38 [PATCH 2/5] ASoC: dwc: Don't allow negative use counts Andrew Jackson
@ 2014-12-03 17:25 ` Mark Brown
  2014-12-04  6:40   ` rajeev kumar
  2014-12-04  9:00   ` Andrew Jackson
  0 siblings, 2 replies; 7+ messages in thread
From: Mark Brown @ 2014-12-03 17:25 UTC (permalink / raw)
  To: Andrew Jackson
  Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel@alsa-project.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Rajeev Kumar, Liam Girdwood,
	Liviu Dudau

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:

>  	case SNDRV_PCM_TRIGGER_STOP:
>  	case SNDRV_PCM_TRIGGER_SUSPEND:
>  	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
> -		dev->active--;
> +		if (dev->active > 0)
> +			dev->active--;

How is this triggering - this sounds like you're papering over some
other bug somewhere?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts
  2014-12-03 17:25 ` Mark Brown
@ 2014-12-04  6:40   ` rajeev kumar
  2014-12-04  6:43     ` rajeev kumar
  2014-12-04  9:00   ` Andrew Jackson
  1 sibling, 1 reply; 7+ messages in thread
From: rajeev kumar @ 2014-12-04  6:40 UTC (permalink / raw)
  To: Mark Brown
  Cc: Andrew Jackson, Jaroslav Kysela, Takashi Iwai,
	alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Liam Girdwood, Liviu Dudau

On Wed, Dec 3, 2014 at 10:55 PM, Mark Brown <broonie@kernel.org> wrote:
> On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:
>
>>       case SNDRV_PCM_TRIGGER_STOP:
>>       case SNDRV_PCM_TRIGGER_SUSPEND:
>>       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>> -             dev->active--;
>> +             if (dev->active > 0)
>> +                     dev->active--;
>
> How is this triggering - this sounds like you're papering over some
> other bug somewhere?

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

* Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts
  2014-12-04  6:40   ` rajeev kumar
@ 2014-12-04  6:43     ` rajeev kumar
  2014-12-04  9:07       ` Andrew Jackson
  0 siblings, 1 reply; 7+ messages in thread
From: rajeev kumar @ 2014-12-04  6:43 UTC (permalink / raw)
  To: Mark Brown
  Cc: Andrew Jackson, Jaroslav Kysela, Takashi Iwai,
	alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Liam Girdwood, Liviu Dudau

On Thu, Dec 4, 2014 at 12:10 PM, rajeev kumar
<rajeevkumar.linux@gmail.com> wrote:
> On Wed, Dec 3, 2014 at 10:55 PM, Mark Brown <broonie@kernel.org> wrote:
>> On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:
>>
>>>       case SNDRV_PCM_TRIGGER_STOP:
>>>       case SNDRV_PCM_TRIGGER_SUSPEND:
>>>       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>>> -             dev->active--;
>>> +             if (dev->active > 0)
>>> +                     dev->active--;
>>
>> How is this triggering - this sounds like you're papering over some
>> other bug somewhere?

This check can be removed as it is not going to triggered.

B'rgds
~Rajeev

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

* Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts
  2014-12-03 17:25 ` Mark Brown
  2014-12-04  6:40   ` rajeev kumar
@ 2014-12-04  9:00   ` Andrew Jackson
  2014-12-04 10:51     ` Mark Brown
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Jackson @ 2014-12-04  9:00 UTC (permalink / raw)
  To: Mark Brown
  Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel@alsa-project.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Rajeev Kumar, Liam Girdwood,
	Liviu Dudau

On 12/03/14 17:25, Mark Brown wrote:
> On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:
> 
>>  	case SNDRV_PCM_TRIGGER_STOP:
>>  	case SNDRV_PCM_TRIGGER_SUSPEND:
>>  	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>> -		dev->active--;
>> +		if (dev->active > 0)
>> +			dev->active--;
> 
> How is this triggering - this sounds like you're papering over some
> other bug somewhere?
> 

When I looked at the code paths I couldn't convince myself that STOP wouldn't be called more than once.  Then actuve would be negative and the device might not be restartable.  I didn't have a problem per se, it was just that it seemed to be something of a loophole.

   Andrew


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

* Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts
  2014-12-04  6:43     ` rajeev kumar
@ 2014-12-04  9:07       ` Andrew Jackson
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Jackson @ 2014-12-04  9:07 UTC (permalink / raw)
  To: rajeev kumar, Mark Brown
  Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel@alsa-project.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Liam Girdwood, Liviu Dudau

On 12/04/14 06:43, rajeev kumar wrote:
> On Thu, Dec 4, 2014 at 12:10 PM, rajeev kumar
> <rajeevkumar.linux@gmail.com> wrote:
>> On Wed, Dec 3, 2014 at 10:55 PM, Mark Brown <broonie@kernel.org> wrote:
>>> On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:
>>>
>>>>       case SNDRV_PCM_TRIGGER_STOP:
>>>>       case SNDRV_PCM_TRIGGER_SUSPEND:
>>>>       case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>>>> -             dev->active--;
>>>> +             if (dev->active > 0)
>>>> +                     dev->active--;
>>>
>>> How is this triggering - this sounds like you're papering over some
>>> other bug somewhere?
> 
> This check can be removed as it is not going to triggered.

As I said in my email to Mark, I couldn't convince myself that STOP/SUSPEND would only be called once so it seemed like a loophole which /might/ result in the device not functioning correctly.

If this can never happen, I'll drop the patch.

	Andrew

> B'rgds
> ~Rajeev
> 


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

* Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts
  2014-12-04  9:00   ` Andrew Jackson
@ 2014-12-04 10:51     ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-12-04 10:51 UTC (permalink / raw)
  To: Andrew Jackson
  Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel@alsa-project.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Rajeev Kumar, Liam Girdwood,
	Liviu Dudau

[-- Attachment #1: Type: text/plain, Size: 1011 bytes --]

On Thu, Dec 04, 2014 at 09:00:35AM +0000, Andrew Jackson wrote:
> On 12/03/14 17:25, Mark Brown wrote:
> > On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:

> >>  	case SNDRV_PCM_TRIGGER_STOP:
> >>  	case SNDRV_PCM_TRIGGER_SUSPEND:
> >>  	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
> >> -		dev->active--;
> >> +		if (dev->active > 0)
> >> +			dev->active--;

> > How is this triggering - this sounds like you're papering over some
> > other bug somewhere?

> When I looked at the code paths I couldn't convince myself that STOP
> wouldn't be called more than once.  Then actuve would be negative and
> the device might not be restartable.  I didn't have a problem per se,
> it was just that it seemed to be something of a loophole.

If you're just adding the check on the off chance that it might fire you
need to add a warning message as well - what your change does is make
the code look like it's supposed to have broken reference counting since
it has a check to silently fix up and ignore problems.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2014-12-04 10:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-03 16:38 [PATCH 2/5] ASoC: dwc: Don't allow negative use counts Andrew Jackson
2014-12-03 17:25 ` Mark Brown
2014-12-04  6:40   ` rajeev kumar
2014-12-04  6:43     ` rajeev kumar
2014-12-04  9:07       ` Andrew Jackson
2014-12-04  9:00   ` Andrew Jackson
2014-12-04 10:51     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox