Skip to contentSkip to conversation

ALSA: compress offfload fixes

PATCH In review Vinod Koul 3 participants 40 messages Aug 27, 2013

Subsystems (3)
lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

cover ALSA: compress offfload fixes

Hi Takashi,

Here is the patch series which fixes various issues being reported by users (out of tree sadly)

The first three and and last one are marked to stable as would like these to be fixed in older kernels as well. It would be good if you can send them as fixes to linus for 3.11.

Rest can go in the merge window

Fixes:
- using lock for all operation was a very bad idead. This is bad as some of the ioctls like drain, partial drain can be time consuming and thus prevent any
other operation while these are ongoing like Pause, Stop or timestamp query, so fix this be removing bunch of ioctls not to use device lock.
- Now we dont have lock for pointer updates so this maybe racy, so use lock for doing lowest level calculation.
- As disscused on our sample rate problem, lets move to use rate values and I will fix the lib too. Since the driver are not upstream the impact of this
change wont be huge.
- Plus few fix like use snprintf, state chacks for pause, write etc..

Vinod Koul (9):
ALSA: Compress - dont use lock for all ioctls
ALSA: compress: use mutex in drain
ASoC: compress: dont aquire lock for draining states
ALSA: compress: use snprint instread of sprintf
ALSA: compres: wakeup the poll thread on pause
ALSA: compress: dont write when stream is paused
ALSA: compress: allow write when stream is setup
ALSA: compress: call pointer callback and updates under a lock
ALSA: compress: use rate values for passing sampling rates

 include/sound/compress_driver.h       |    2 +
 include/uapi/sound/compress_offload.h |    2 +-
 sound/core/compress_offload.c         |  140 +++++++++++++++++++++++++-------
 sound/soc/soc-compress.c              |   10 +++
 4 files changed, 122 insertions(+), 32 deletions(-)

Thanks
~Vinod

author
#1 lore raw

PATCH 1/9 ALSA: Compress - dont use lock for all ioctls

Some simple ioctls like timsetamp query, capabities query can be done anytime and should not be under the stream lock. Move these to snd_compress_simple_iotcls() which is invoked without lock held

While at it, improve readblity a bit by sprinkling some empty lines

---
 sound/core/compress_offload.c |   79 ++++++++++++++++++++++++++++++-----------
 1 files changed, 58 insertions(+), 21 deletions(-)
sound/core/compress_offload.c +58 -21
index 99db892..868aefd 100644
@@ -729,70 +729,107 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
 	return retval;
 }
 
-static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
+static int snd_compress_simple_ioctls(struct file *file,
+				struct snd_compr_stream *stream,
+				unsigned int cmd, unsigned long arg)
 {
-	struct snd_compr_file *data = f->private_data;
-	struct snd_compr_stream *stream;
 	int retval = -ENOTTY;
 
-	if (snd_BUG_ON(!data))
-		return -EFAULT;
-	stream = &data->stream;
-	if (snd_BUG_ON(!stream))
-		return -EFAULT;
-	mutex_lock(&stream->device->lock);
 	switch (_IOC_NR(cmd)) {
 	case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION):
 		put_user(SNDRV_COMPRESS_VERSION,
 				(int __user *)arg) ? -EFAULT : 0;
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_GET_CAPS):
 		retval = snd_compr_get_caps(stream, arg);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS):
 		retval = snd_compr_get_codec_caps(stream, arg);
 		break;
+
+	case _IOC_NR(SNDRV_COMPRESS_TSTAMP):
+		retval = snd_compr_tstamp(stream, arg);
+		break;
+
+	case _IOC_NR(SNDRV_COMPRESS_AVAIL):
+		retval = snd_compr_ioctl_avail(stream, arg);
+		break;
+
+		/* drain and partial drain need special handling
+	 * we need to drop the locks here as the streams would get blocked on the
+	 * dsp to get drained. The locking would be handled in respective
+	 * function here
+	 */
+	case _IOC_NR(SNDRV_COMPRESS_DRAIN):
+		retval = snd_compr_drain(stream);
+		break;
+
+	case _IOC_NR(SNDRV_COMPRESS_PARTIAL_DRAIN):
+		retval = snd_compr_partial_drain(stream);
+		break;
+	}
+
+	return retval;
+}
+
+static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
+{
+	struct snd_compr_file *data = f->private_data;
+	struct snd_compr_stream *stream;
+	int retval = -ENOTTY;
+
+	if (snd_BUG_ON(!data))
+		return -EFAULT;
+	stream = &data->stream;
+	if (snd_BUG_ON(!stream))
+		return -EFAULT;
+
+	mutex_lock(&stream->device->lock);
+	switch (_IOC_NR(cmd)) {
 	case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS):
 		retval = snd_compr_set_params(stream, arg);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_GET_PARAMS):
 		retval = snd_compr_get_params(stream, arg);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_SET_METADATA):
 		retval = snd_compr_set_metadata(stream, arg);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_GET_METADATA):
 		retval = snd_compr_get_metadata(stream, arg);
 		break;
-	case _IOC_NR(SNDRV_COMPRESS_TSTAMP):
-		retval = snd_compr_tstamp(stream, arg);
-		break;
-	case _IOC_NR(SNDRV_COMPRESS_AVAIL):
-		retval = snd_compr_ioctl_avail(stream, arg);
-		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_PAUSE):
 		retval = snd_compr_pause(stream);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_RESUME):
 		retval = snd_compr_resume(stream);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_START):
 		retval = snd_compr_start(stream);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_STOP):
 		retval = snd_compr_stop(stream);
 		break;
-	case _IOC_NR(SNDRV_COMPRESS_DRAIN):
-		retval = snd_compr_drain(stream);
-		break;
-	case _IOC_NR(SNDRV_COMPRESS_PARTIAL_DRAIN):
-		retval = snd_compr_partial_drain(stream);
-		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_NEXT_TRACK):
 		retval = snd_compr_next_track(stream);
 		break;
 
+	default:
+		mutex_unlock(&stream->device->lock);
+		return snd_compress_simple_ioctls(f, stream, cmd, arg);
+
 	}
+
 	mutex_unlock(&stream->device->lock);
 	return retval;
 }
Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH 1/9] ALSA: Compress - dont use lock for all ioctls

At Tue, 27 Aug 2013 12:10:31 +0530,

Quoted 9 lines · Vinod Koul

Some simple ioctls like timsetamp query, capabities query can be done anytime and should not be under the stream lock. Move these to snd_compress_simple_iotcls() which is invoked without lock held

While at it, improve readblity a bit by sprinkling some empty lines

Why it's needed for stable? Fixing any real bugs?

Quoted 121 lines
---
 sound/core/compress_offload.c |   79 ++++++++++++++++++++++++++++++-----------
 1 files changed, 58 insertions(+), 21 deletions(-)
sound/core/compress_offload.c +52 -19
index 99db892..868aefd 100644
@@ -729,70 +729,107 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
 	return retval;
 }
 
-static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
+static int snd_compress_simple_ioctls(struct file *file,
+				struct snd_compr_stream *stream,
+				unsigned int cmd, unsigned long arg)
 {
-	struct snd_compr_file *data = f->private_data;
-	struct snd_compr_stream *stream;
 	int retval = -ENOTTY;
 
-	if (snd_BUG_ON(!data))
-		return -EFAULT;
-	stream = &data->stream;
-	if (snd_BUG_ON(!stream))
-		return -EFAULT;
-	mutex_lock(&stream->device->lock);
 	switch (_IOC_NR(cmd)) {
 	case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION):
 		put_user(SNDRV_COMPRESS_VERSION,
 				(int __user *)arg) ? -EFAULT : 0;
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_GET_CAPS):
 		retval = snd_compr_get_caps(stream, arg);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS):
 		retval = snd_compr_get_codec_caps(stream, arg);
 		break;
+
+	case _IOC_NR(SNDRV_COMPRESS_TSTAMP):
+		retval = snd_compr_tstamp(stream, arg);
+		break;
+
+	case _IOC_NR(SNDRV_COMPRESS_AVAIL):
+		retval = snd_compr_ioctl_avail(stream, arg);
+		break;
+
+		/* drain and partial drain need special handling
+	 * we need to drop the locks here as the streams would get blocked on the
+	 * dsp to get drained. The locking would be handled in respective
+	 * function here
+	 */
+	case _IOC_NR(SNDRV_COMPRESS_DRAIN):
+		retval = snd_compr_drain(stream);
+		break;
+
+	case _IOC_NR(SNDRV_COMPRESS_PARTIAL_DRAIN):
+		retval = snd_compr_partial_drain(stream);
+		break;
+	}
+
+	return retval;
+}
+
+static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
+{
+	struct snd_compr_file *data = f->private_data;
+	struct snd_compr_stream *stream;
+	int retval = -ENOTTY;
+
+	if (snd_BUG_ON(!data))
+		return -EFAULT;
+	stream = &data->stream;
+	if (snd_BUG_ON(!stream))
+		return -EFAULT;
+
+	mutex_lock(&stream->device->lock);
+	switch (_IOC_NR(cmd)) {
 	case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS):
 		retval = snd_compr_set_params(stream, arg);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_GET_PARAMS):
 		retval = snd_compr_get_params(stream, arg);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_SET_METADATA):
 		retval = snd_compr_set_metadata(stream, arg);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_GET_METADATA):
 		retval = snd_compr_get_metadata(stream, arg);
 		break;
-	case _IOC_NR(SNDRV_COMPRESS_TSTAMP):
-		retval = snd_compr_tstamp(stream, arg);
-		break;
-	case _IOC_NR(SNDRV_COMPRESS_AVAIL):
-		retval = snd_compr_ioctl_avail(stream, arg);
-		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_PAUSE):
 		retval = snd_compr_pause(stream);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_RESUME):
 		retval = snd_compr_resume(stream);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_START):
 		retval = snd_compr_start(stream);
 		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_STOP):
 		retval = snd_compr_stop(stream);
 		break;
-	case _IOC_NR(SNDRV_COMPRESS_DRAIN):
-		retval = snd_compr_drain(stream);
-		break;
-	case _IOC_NR(SNDRV_COMPRESS_PARTIAL_DRAIN):

sound/core/compress_offload.c static int snd_compr_partial_drain(struct snd_compr_stream *stream) · line 829

Quoted 10 lines
sound/core/compress_offload.c +4 -2
-		retval = snd_compr_partial_drain(stream);
-		break;
+
 	case _IOC_NR(SNDRV_COMPRESS_NEXT_TRACK):
 		retval = snd_compr_next_track(stream);
 		break;
 
+	default:
+		mutex_unlock(&stream->device->lock);
+		return snd_compress_simple_ioctls(f, stream, cmd, arg);

In this code, it still locks/unlocks shortly unnecessarily. It should be rather like:

	switch (_IOC_NR(cmd)) {
 	case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION):
		...
 	case _IOC_NR(SNDRV_COMPRESS_GET_CAPS):
		....	
	default:
		retval = snd_compress_locked_ioctls(f, stream, cmd, arg);
	}

Takashi

author
#3 lore raw

Re: [PATCH 1/9] ALSA: Compress - dont use lock for all ioctls

Quoted 7 lines · Takashi Iwai

At Tue, 27 Aug 2013 12:10:31 +0530,

Quoted 5 lines · Vinod Koul

Some simple ioctls like timsetamp query, capabities query can be done anytime and should not be under the stream lock. Move these to snd_compress_simple_iotcls() which is invoked without lock held

Quoted 6 lines
Quoted 4 lines

While at it, improve readblity a bit by sprinkling some empty lines

Why it's needed for stable? Fixing any real bugs?

yup, users are complaining that while streams are draining they can't read timstamps. Also one case where a user hit pause didnt go thru as lock preveted the pause to be executed..

Since 3.10 is next LTS kernel, I forsee lots of folks using taht for a while so makes sense to fix there as well

Quoted 11 lines

sound/core/compress_offload.c static int snd_compr_partial_drain(struct snd_compr_stream *stream) · line 829

Quoted 3 lines
sound/core/compress_offload.c +3 -0
+	default:
+		mutex_unlock(&stream->device->lock);
+		return snd_compress_simple_ioctls(f, stream, cmd, arg);

In this code, it still locks/unlocks shortly unnecessarily. It should be rather like:

	switch (_IOC_NR(cmd)) {
sound/core/compress_offload.c +0 -0
 	case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION):
...
 	case _IOC_NR(SNDRV_COMPRESS_GET_CAPS):
....
Quoted 3 lines
	default:
		retval = snd_compress_locked_ioctls(f, stream, cmd, arg);
	}

Hmmm, okay no point in blocking. I will reverse the flow

~Vinod

#4 lore raw

Re: [PATCH 1/9] ALSA: Compress - dont use lock for all ioctls

At Tue, 27 Aug 2013 15:14:15 +0530,

Quoted 11 lines · Vinod Koul
Quoted 9 lines · Takashi Iwai

At Tue, 27 Aug 2013 12:10:31 +0530,

Quoted 7 lines · Vinod Koul

Some simple ioctls like timsetamp query, capabities query can be done anytime and should not be under the stream lock. Move these to snd_compress_simple_iotcls() which is invoked without lock held

While at it, improve readblity a bit by sprinkling some empty lines

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Why it's needed for stable? Fixing any real bugs?

yup, users are complaining that while streams are draining they can't read timstamps. Also one case where a user hit pause didnt go thru as lock preveted the pause to be executed..

Then write the problems more clearly. I saw no such information in the changelog.

Quoted 2 lines

Since 3.10 is next LTS kernel, I forsee lots of folks using taht for a while so makes sense to fix there as well

Depends on the fix and the problem. The fact that this can't be tested only with 3.10 kernel (no real driver exists), I doubt it's worth. Stable kernels aren't for out-of-tree drivers.

And, if you really target to the stable tree, don't put any unnecessary changes like white space fixes. Read stable_kernel_rules.txt once more.

thanks,

Takashi

Quoted 20 lines
Quoted 11 lines

sound/core/compress_offload.c static int snd_compr_partial_drain(struct snd_compr_stream *stream) · line 829

Quoted 3 lines
sound/core/compress_offload.c +3 -0
+	default:
+		mutex_unlock(&stream->device->lock);
+		return snd_compress_simple_ioctls(f, stream, cmd, arg);

In this code, it still locks/unlocks shortly unnecessarily. It should be rather like:

	switch (_IOC_NR(cmd)) {
sound/core/compress_offload.c +0 -0
 	case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION):
...
 	case _IOC_NR(SNDRV_COMPRESS_GET_CAPS):
....
Quoted 3 lines
	default:
		retval = snd_compress_locked_ioctls(f, stream, cmd, arg);
	}

Hmmm, okay no point in blocking. I will reverse the flow

~Vinod

author
#5 lore raw

PATCH 2/9 ALSA: compress: use mutex in drain

In reply to Vinod Koul

Since we dont have lock over the function, we need to aquire mutex when checking and modfying states in drain and partial_drain handlers

---
 sound/core/compress_offload.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
sound/core/compress_offload.c +19 -3
index 868aefd..e640f8c 100644
@@ -676,18 +676,29 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
 	return retval;
 }
 
+/* this fn is called without lock being held and we change stream states here
+ * so while using the stream state auquire the lock but relase before invoking
+ * DSP as the call will possibly take a while
+ */
 static int snd_compr_drain(struct snd_compr_stream *stream)
 {
 	int retval;
 
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
-		return -EPERM;
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		retval = -EPERM;
+		goto ret;
+	}
+	mutex_unlock(&stream->device->lock);
 	retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);
+	mutex_lock(&stream->device->lock);
 	if (!retval) {
 		stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
 		wake_up(&stream->runtime->sleep);
 	}
+ret:
+	mutex_unlock(&stream->device->lock);
 	return retval;
 }
 
@@ -716,9 +727,14 @@ static int snd_compr_next_track(struct snd_compr_stream *stream)
 static int snd_compr_partial_drain(struct snd_compr_stream *stream)
 {
 	int retval;
+
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		mutex_unlock(&stream->device->lock);
 		return -EPERM;
+	}
+	mutex_unlock(&stream->device->lock);
 	/* stream can be drained only when next track has been signalled */
 	if (stream->next_track == false)
 		return -EPERM;
Signature · 1 line
1.7.0.4
#6 lore raw

Re: [PATCH 2/9] ALSA: compress: use mutex in drain

At Tue, 27 Aug 2013 12:10:32 +0530,

Quoted 26 lines · Vinod Koul

Since we dont have lock over the function, we need to aquire mutex when checking and modfying states in drain and partial_drain handlers

---
 sound/core/compress_offload.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
sound/core/compress_offload.c +4 -0
index 868aefd..e640f8c 100644
@@ -676,18 +676,29 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
 	return retval;
 }
 
+/* this fn is called without lock being held and we change stream states here
+ * so while using the stream state auquire the lock but relase before invoking
+ * DSP as the call will possibly take a while
+ */
 static int snd_compr_drain(struct snd_compr_stream *stream)
 {
 	int retval;
 

sound/core/compress_offload.c static int snd_compr_stop(struct snd_compr_stream *stream) · line 694

Quoted 10 lines
sound/core/compress_offload.c +6 -2
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
-		return -EPERM;
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		retval = -EPERM;
+		goto ret;
+	}
+	mutex_unlock(&stream->device->lock);
 	retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);

Why release the lock here? The trigger callback is called within this mutex lock in other places.

Takashi

Quoted 29 lines
sound/core/compress_offload.c +9 -1
+	mutex_lock(&stream->device->lock);
 	if (!retval) {
 		stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
 		wake_up(&stream->runtime->sleep);
 	}
+ret:
+	mutex_unlock(&stream->device->lock);
 	return retval;
 }
 
@@ -716,9 +727,14 @@ static int snd_compr_next_track(struct snd_compr_stream *stream)
 static int snd_compr_partial_drain(struct snd_compr_stream *stream)
 {
 	int retval;
+
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		mutex_unlock(&stream->device->lock);
 		return -EPERM;
+	}
+	mutex_unlock(&stream->device->lock);
 	/* stream can be drained only when next track has been signalled */
 	if (stream->next_track == false)
 		return -EPERM;
Signature · 1 line
1.7.0.4
author
#7 lore raw

Re: [PATCH 2/9] ALSA: compress: use mutex in drain

Quoted 28 lines · Takashi Iwai

At Tue, 27 Aug 2013 12:10:32 +0530,

Quoted 26 lines · Vinod Koul

Since we dont have lock over the function, we need to aquire mutex when checking and modfying states in drain and partial_drain handlers

---
 sound/core/compress_offload.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
sound/core/compress_offload.c +4 -0
index 868aefd..e640f8c 100644
@@ -676,18 +676,29 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
 	return retval;
 }
 
+/* this fn is called without lock being held and we change stream states here
+ * so while using the stream state auquire the lock but relase before invoking
+ * DSP as the call will possibly take a while
+ */
 static int snd_compr_drain(struct snd_compr_stream *stream)
 {
 	int retval;
 
Quoted 13 lines

sound/core/compress_offload.c static int snd_compr_stop(struct snd_compr_stream *stream) · line 694

Quoted 10 lines
sound/core/compress_offload.c +6 -2
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
-		return -EPERM;
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		retval = -EPERM;
+		goto ret;
+	}
+	mutex_unlock(&stream->device->lock);
 	retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);

Why release the lock here? The trigger callback is called within this mutex lock in other places.

This is the main part :)

Since the drain states will take a while (order of few seconds) to execute so we will be blocked. Thats why we cant have lock here. The point of lock is to sync the stream states here. We are not modfying anything. During drain and partial drain we need to allow other trigger ops like pause, stop tog o thru so drop the lock here for these two ops only!

~Vinod

#8 lore raw

Re: [PATCH 2/9] ALSA: compress: use mutex in drain

At Tue, 27 Aug 2013 15:17:41 +0530,

Quoted 43 lines · Vinod Koul
Quoted 28 lines · Takashi Iwai

At Tue, 27 Aug 2013 12:10:32 +0530,

Quoted 26 lines · Vinod Koul

Since we dont have lock over the function, we need to aquire mutex when checking and modfying states in drain and partial_drain handlers

---
 sound/core/compress_offload.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
sound/core/compress_offload.c +4 -0
index 868aefd..e640f8c 100644
@@ -676,18 +676,29 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
 	return retval;
 }
 
+/* this fn is called without lock being held and we change stream states here
+ * so while using the stream state auquire the lock but relase before invoking
+ * DSP as the call will possibly take a while
+ */
 static int snd_compr_drain(struct snd_compr_stream *stream)
 {
 	int retval;
 
Quoted 13 lines

sound/core/compress_offload.c static int snd_compr_stop(struct snd_compr_stream *stream) · line 694

Quoted 10 lines
sound/core/compress_offload.c +6 -2
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
-		return -EPERM;
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		retval = -EPERM;
+		goto ret;
+	}
+	mutex_unlock(&stream->device->lock);
 	retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);

Why release the lock here? The trigger callback is called within this mutex lock in other places.

Quoted 4 lines

This is the main part :)

Since the drain states will take a while (order of few seconds) to execute so we will be blocked. Thats why we cant have lock here.

What's about other places calling the trigger ops within lock? You can't mix things.

Quoted 2 lines

The point of lock is to sync
the stream states here.

Without the lock, it's racy. What if another thread calls the same function at the same time?

Quoted 3 lines

We are not modfying anything. During drain and partial
drain we need to allow other trigger ops like pause, stop tog o thru so drop the lock here for these two ops only!

Well, the biggest problem is that there is no proper design for which ops take a lock and which not. The trigger callback is basically to trigger the action. There should be no long-time blocking there. (Otherwise you'll definitely loose a gunfight :)

Takashi

author
#9 lore raw

Re: [PATCH 2/9] ALSA: compress: use mutex in drain

Quoted 30 lines · Takashi Iwai

At Tue, 27 Aug 2013 15:17:41 +0530,

Quoted 28 lines · Vinod Koul
Quoted 27 lines · Takashi Iwai
Quoted 14 lines
sound/core/compress_offload.c +4 -0
@@ -676,18 +676,29 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
 	return retval;
 }
 
+/* this fn is called without lock being held and we change stream states here
+ * so while using the stream state auquire the lock but relase before invoking
+ * DSP as the call will possibly take a while
+ */
 static int snd_compr_drain(struct snd_compr_stream *stream)
 {
 	int retval;
 

sound/core/compress_offload.c static int snd_compr_stop(struct snd_compr_stream *stream) · line 694

Quoted 10 lines
sound/core/compress_offload.c +6 -2
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
-		return -EPERM;
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		retval = -EPERM;
+		goto ret;
+	}
+	mutex_unlock(&stream->device->lock);
 	retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);

Why release the lock here? The trigger callback is called within this mutex lock in other places.

Quoted 7 lines
Quoted 4 lines

This is the main part :)

Since the drain states will take a while (order of few seconds) to execute so we will be blocked. Thats why we cant have lock here.

What's about other places calling the trigger ops within lock? You can't mix things.

Well i was going to treat drain only as exception to this. The issue here is during the long drain other triggers are perfectly valid cases

Quoted 6 lines
Quoted 3 lines

The point of lock is to sync
the stream states here.

Without the lock, it's racy. What if another thread calls the same function at the same time?

that part can be checked by seeing if we are already draining.

Quoted 9 lines
Quoted 4 lines

We are not modfying anything. During drain and partial
drain we need to allow other trigger ops like pause, stop tog o thru so drop the lock here for these two ops only!

Well, the biggest problem is that there is no proper design for which ops take a lock and which not. The trigger callback is basically to trigger the action. There should be no long-time blocking there. (Otherwise you'll definitely loose a gunfight :)

The reason for blocked implementation is to treat return of the call as notifcation that draining is completed.

For example user has written all the buffers, lets says worth 3 secs and now has triggered drain. User needs to wait till drain is complete before closing the device etc. So he waits on drain to compelete..

Do you have a better way to manage this?

~Vinod

#10 lore raw

Re: [PATCH 2/9] ALSA: compress: use mutex in drain

At Tue, 27 Aug 2013 15:46:14 +0530,

Quoted 34 lines · Vinod Koul
Quoted 32 lines · Takashi Iwai

At Tue, 27 Aug 2013 15:17:41 +0530,

Quoted 30 lines · Vinod Koul
Quoted 14 lines · Takashi Iwai
Quoted 14 lines
sound/core/compress_offload.c +4 -0
@@ -676,18 +676,29 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
 	return retval;
 }
 
+/* this fn is called without lock being held and we change stream states here
+ * so while using the stream state auquire the lock but relase before invoking
+ * DSP as the call will possibly take a while
+ */
 static int snd_compr_drain(struct snd_compr_stream *stream)
 {
 	int retval;
 
Quoted 13 lines

sound/core/compress_offload.c static int snd_compr_stop(struct snd_compr_stream *stream) · line 694

Quoted 10 lines
sound/core/compress_offload.c +6 -2
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
-		return -EPERM;
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		retval = -EPERM;
+		goto ret;
+	}
+	mutex_unlock(&stream->device->lock);
 	retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);

Why release the lock here? The trigger callback is called within this mutex lock in other places.

This is the main part :)

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Since the drain states will take a while (order of few seconds) to execute so we will be blocked. Thats why we cant have lock here.

What's about other places calling the trigger ops within lock? You can't mix things.

Well i was going to treat drain only as exception to this. The issue here is during the long drain other triggers are perfectly valid cases

An ops callback must be defined either to be locked or unlocked. Calling in the unlocked context only for some case doesn't sound right.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

The point of lock is to sync
the stream states here.

Without the lock, it's racy. What if another thread calls the same function at the same time?

that part can be checked by seeing if we are already draining.

But how? The place you're calling trigger is unlocked. Suppose another thread calling trigger_stop just between mutex_unlock() and stream->ops->trigger(DRAIN) call in the above. The state check doesn't work there.

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

We are not modfying anything. During drain and partial
drain we need to allow other trigger ops like pause, stop tog o thru so drop the lock here for these two ops only!

Well, the biggest problem is that there is no proper design for which ops take a lock and which not. The trigger callback is basically to trigger the action. There should be no long-time blocking there. (Otherwise you'll definitely loose a gunfight :)

Quoted 8 lines

The reason for blocked implementation is to treat return of the call as notifcation that draining is completed.

For example user has written all the buffers, lets says worth 3 secs and now has triggered drain. User needs to wait till drain is complete before closing the device etc. So he waits on drain to compelete..

Do you have a better way to manage this?

Split the drain action in two parts, trigger and synchronization:

	lock();
	...
	trigger(pause);
	while (!pause_finished) {
		unlock();
		schedule_or_sleep_or_whatever();
		lock();
	}
	...
	unlock();

Takashi

author
#11 lore raw

Re: [PATCH 2/9] ALSA: compress: use mutex in drain

Quoted 26 lines · Takashi Iwai
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Quoted 8 lines
Quoted 8 lines
sound/core/compress_offload.c +4 -0
+/* this fn is called without lock being held and we change stream states here
+ * so while using the stream state auquire the lock but relase before invoking
+ * DSP as the call will possibly take a while
+ */
 static int snd_compr_drain(struct snd_compr_stream *stream)
 {
 	int retval;
Quoted 13 lines

sound/core/compress_offload.c static int snd_compr_stop(struct snd_compr_stream *stream) · line 694

Quoted 10 lines
sound/core/compress_offload.c +6 -2
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
-		return -EPERM;
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		retval = -EPERM;
+		goto ret;
+	}
+	mutex_unlock(&stream->device->lock);
 	retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);

Why release the lock here? The trigger callback is called within this mutex lock in other places.

This is the main part :)

Since the drain states will take a while (order of few seconds) to execute so we will be blocked. Thats why we cant have lock here.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

What's about other places calling the trigger ops within lock? You can't mix things.

Well i was going to treat drain only as exception to this. The issue here is during the long drain other triggers are perfectly valid cases

An ops callback must be defined either to be locked or unlocked. Calling in the unlocked context only for some case doesn't sound right.

well all the callbacks except drain is called with lock held from framework...

Quoted 11 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

The point of lock is to sync
the stream states here.

Without the lock, it's racy. What if another thread calls the same function at the same time?

that part can be checked by seeing if we are already draining.

But how? The place you're calling trigger is unlocked. Suppose another thread calling trigger_stop just between mutex_unlock() and stream->ops->trigger(DRAIN) call in the above. The state check doesn't work there.

the framework does this with lock held and then calls the driver something like this will ensure this while making sync right...

	mutex_lock(&lock);
	if (state == DRAINING) {
		mutex_unlock(&lock);
		return -EPERM;
	} else
		state = DRAINING;
	mutex_unlock(&lock);

	ops->drain(substream);

	mutex_lock(&lock);
	state = DRAINED;
	mutex_unlock(&lock);
Quoted 20 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

We are not modfying anything. During drain and partial
drain we need to allow other trigger ops like pause, stop tog o thru so drop the lock here for these two ops only!

Well, the biggest problem is that there is no proper design for which ops take a lock and which not. The trigger callback is basically to trigger the action. There should be no long-time blocking there. (Otherwise you'll definitely loose a gunfight :)

Quoted 8 lines

The reason for blocked implementation is to treat return of the call as notifcation that draining is completed.

For example user has written all the buffers, lets says worth 3 secs and now has triggered drain. User needs to wait till drain is complete before closing the device etc. So he waits on drain to compelete..

Do you have a better way to manage this?

Split the drain action in two parts, trigger and synchronization:

Quoted 10 lines
	lock();
	...
	trigger(pause);
	while (!pause_finished) {
		unlock();
		schedule_or_sleep_or_whatever();
		lock();
	}
	...
	unlock();

okay, i guess above is on same lines...

~Vinod

#12 lore raw

Re: [PATCH 2/9] ALSA: compress: use mutex in drain

At Tue, 27 Aug 2013 18:39:22 +0530,

Quoted 30 lines · Vinod Koul
Quoted 28 lines · Takashi Iwai
Quoted 28 lines
Quoted 28 lines
Quoted 21 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +4 -0
+/* this fn is called without lock being held and we change stream states here
+ * so while using the stream state auquire the lock but relase before invoking
+ * DSP as the call will possibly take a while
+ */
 static int snd_compr_drain(struct snd_compr_stream *stream)
 {
 	int retval;
Quoted 13 lines

Review

Quoted 10 lines
(quoted diff) +6 -2
+	mutex_lock(&stream->device->lock);
 	if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
-			stream->runtime->state == SNDRV_PCM_STATE_SETUP)
-		return -EPERM;
+			stream->runtime->state == SNDRV_PCM_STATE_SETUP) {
+		retval = -EPERM;
+		goto ret;
+	}
+	mutex_unlock(&stream->device->lock);
 	retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);

Why release the lock here? The trigger callback is called within this mutex lock in other places.

Quoted 4 lines

This is the main part :)

Since the drain states will take a while (order of few seconds) to execute so we will be blocked. Thats why we cant have lock here.

What's about other places calling the trigger ops within lock? You can't mix things.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

Well i was going to treat drain only as exception to this. The issue here is during the long drain other triggers are perfectly valid cases

An ops callback must be defined either to be locked or unlocked. Calling in the unlocked context only for some case doesn't sound right.

well all the callbacks except drain is called with lock held from framework...

You're calling the same ops with and without the lock. I'd understand better if you created a new ops for drain, but in the current patch, it's still the same ops...

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

The point of lock is to sync
the stream states here.

Without the lock, it's racy. What if another thread calls the same function at the same time?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

that part can be checked by seeing if we are already draining.

But how? The place you're calling trigger is unlocked. Suppose another thread calling trigger_stop just between mutex_unlock() and stream->ops->trigger(DRAIN) call in the above. The state check doesn't work there.

the framework does this with lock held and then calls the driver something like this will ensure this while making sync right...

It's still racy. In your code below:

Quoted 7 lines
	mutex_lock(&lock);
	if (state == DRAINING) {
		mutex_unlock(&lock);
		return -EPERM;
	} else
		state = DRAINING;
	mutex_unlock(&lock);

Suppose that another thread calls stop at this point before ops->drain() is called. It'll change the state to STOP, call ops->trigger(STOP). And ops->drain() (or ops->trigger(DRAIN)) may be called at the same time because there is no protection without knowing that it's being stopped.

Quoted 5 lines
	ops->drain(substream);

	mutex_lock(&lock);
	state = DRAINED;
	mutex_unlock(&lock);

Takashi

Quoted 34 lines
Quoted 19 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

We are not modfying anything. During drain and partial
drain we need to allow other trigger ops like pause, stop tog o thru so drop the lock here for these two ops only!

Well, the biggest problem is that there is no proper design for which ops take a lock and which not. The trigger callback is basically to trigger the action. There should be no long-time blocking there. (Otherwise you'll definitely loose a gunfight :)

Quoted 8 lines

The reason for blocked implementation is to treat return of the call as notifcation that draining is completed.

For example user has written all the buffers, lets says worth 3 secs and now has triggered drain. User needs to wait till drain is complete before closing the device etc. So he waits on drain to compelete..

Do you have a better way to manage this?

Split the drain action in two parts, trigger and synchronization:

Quoted 10 lines
	lock();
	...
	trigger(pause);
	while (!pause_finished) {
		unlock();
		schedule_or_sleep_or_whatever();
		lock();
	}
	...
	unlock();

okay, i guess above is on same lines...

~Vinod

author
#13 lore raw

Re: [PATCH 2/9] ALSA: compress: use mutex in drain

Quoted 8 lines · Takashi Iwai
Quoted 4 lines
Quoted 3 lines

An ops callback must be defined either to be locked or unlocked. Calling in the unlocked context only for some case doesn't sound right.

well all the callbacks except drain is called with lock held from framework...

You're calling the same ops with and without the lock. I'd understand better if you created a new ops for drain, but in the current patch, it's still the same ops...

yup but cant different callbacks in the ops have different conditions. Anyway all except drain ones are supposed to NOT block.

Quoted 25 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

The point of lock is to sync
the stream states here.

Without the lock, it's racy. What if another thread calls the same function at the same time?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

that part can be checked by seeing if we are already draining.

But how? The place you're calling trigger is unlocked. Suppose another thread calling trigger_stop just between mutex_unlock() and stream->ops->trigger(DRAIN) call in the above. The state check doesn't work there.

the framework does this with lock held and then calls the driver something like this will ensure this while making sync right...

It's still racy. In your code below:

Quoted 7 lines
	mutex_lock(&lock);
	if (state == DRAINING) {
		mutex_unlock(&lock);
		return -EPERM;
	} else
		state = DRAINING;
	mutex_unlock(&lock);
Quoted 5 lines

Suppose that another thread calls stop at this point before ops->drain() is called. It'll change the state to STOP, call ops->trigger(STOP). And ops->drain() (or ops->trigger(DRAIN)) may be called at the same time because there is no protection without knowing that it's being stopped.

yup...

Quoted 39 lines
Quoted 6 lines
	ops->drain(substream);

	mutex_lock(&lock);
	state = DRAINED;
	mutex_unlock(&lock);

Takashi

Quoted 29 lines
Quoted 29 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

We are not modfying anything. During drain and partial
drain we need to allow other trigger ops like pause, stop tog o thru so drop the lock here for these two ops only!

Well, the biggest problem is that there is no proper design for which ops take a lock and which not. The trigger callback is basically to trigger the action. There should be no long-time blocking there. (Otherwise you'll definitely loose a gunfight :)

Quoted 8 lines

The reason for blocked implementation is to treat return of the call as notifcation that draining is completed.

For example user has written all the buffers, lets says worth 3 secs and now has triggered drain. User needs to wait till drain is complete before closing the device etc. So he waits on drain to compelete..

Do you have a better way to manage this?

Split the drain action in two parts, trigger and synchronization:

	lock();
	...
	trigger(pause);
	while (!pause_finished) {
		unlock();
		schedule_or_sleep_or_whatever();
		lock();
	}
	...
	unlock();

with this am thinking of handling it differently now on the above lines and split the drain action and drain blocking parts. Trigger and action.

How about making the drain and partial drain triggers calls NOT blocking. This will take care of sync issues etc.

But we also need to have notification for when drain completes.

IMO this can be handled in two ways
a) like in above we sleep and wake up on notification from driver. Driver can call the drain_complete() which wakes up and we return to user
b) we call the driver for drain and then call blocking new callback which returns when action is complete

~Vinod

author
#14 lore raw

PATCH 3/9 ASoC: compress: dont aquire lock for draining states

In reply to Vinod Koul

Both draining and partial draning states will take a while getting executed. The lock aquired will block the other operations like pause, stop etc which are perfectly valid cmds during these states. So dont use mutex while invoking DSP for these ops

---
 sound/soc/soc-compress.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
sound/soc/soc-compress.c +10 -0
index 06a8000..800ee89 100644
@@ -171,6 +171,16 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	int ret = 0;
 
+	/* for partial drain and drain cmd dont aquire lock while invoking DSP.
+	 * These calls will be blocked till these operation can complete while
+	 * will be a while. And during that app can invoke STOP, PAUSE etc
+	 */
+	if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN || cmd == SND_COMPR_TRIGGER_DRAIN) {
+		if (platform->driver->compr_ops &&
+					platform->driver->compr_ops->trigger)
+			return platform->driver->compr_ops->trigger(cstream, cmd);
+	}
+
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
 	if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
Signature · 1 line
1.7.0.4
author
#15 lore raw

PATCH 4/9 ALSA: compress: use snprint instread of sprintf

In reply to Vinod Koul

To prevent possiblity of exceeding buffer size

---
 sound/core/compress_offload.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/core/compress_offload.c +1 -1
index e640f8c..1e722c2 100644
@@ -871,7 +871,7 @@ static int snd_compress_dev_register(struct snd_device *device)
 		return -EBADFD;
 	compr = device->device_data;
 
-	sprintf(str, "comprC%iD%i", compr->card->number, compr->device);
+	snprintf(str, sizeof(str), "comprC%iD%i", compr->card->number, compr->device);
 	pr_debug("reg %s for device %s, direction %d\n", str, compr->name,
 			compr->direction);
 	/* register compressed device */
Signature · 1 line
1.7.0.4
author
#16 lore raw

PATCH 5/9 ALSA: compres: wakeup the poll thread on pause

In reply to Vinod Koul

this allows the poll to be unblocked, if it is blocked and yeilds the control of userthread blocked

---
 sound/core/compress_offload.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
sound/core/compress_offload.c +4 -1
index 1e722c2..417a456 100644
@@ -629,9 +629,12 @@ static int snd_compr_pause(struct snd_compr_stream *stream)
 
 	if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING)
 		return -EPERM;
+
 	retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_PAUSE_PUSH);
-	if (!retval)
+	if (!retval) {
 		stream->runtime->state = SNDRV_PCM_STATE_PAUSED;
+		wake_up(&stream->runtime->sleep);
+	}
 	return retval;
 }
 
Signature · 1 line
1.7.0.4
author
#17 lore raw

PATCH 6/9 ALSA: compress: dont write when stream is paused

In reply to Vinod Koul

and return bytes written as 0 and not error

---
 sound/core/compress_offload.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
sound/core/compress_offload.c +9 -1
index 417a456..fb570c8 100644
@@ -256,7 +256,7 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf,
 	struct snd_compr_file *data = f->private_data;
 	struct snd_compr_stream *stream;
 	size_t avail;
-	int retval;
+	int retval = 0;
 
 	if (snd_BUG_ON(!data))
 		return -EFAULT;
@@ -264,6 +264,14 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf,
 	stream = &data->stream;
 	mutex_lock(&stream->device->lock);
 	/* write is allowed when stream is running or has been steup */
+	 /*
+	  * if the stream is in paused state, return the
+	  * number of bytes consumed as 0
+	  */
+	if (stream->runtime->state == SNDRV_PCM_STATE_PAUSED) {
+		mutex_unlock(&stream->device->lock);
+		return retval;
+	}
 	if (stream->runtime->state != SNDRV_PCM_STATE_SETUP &&
 			stream->runtime->state != SNDRV_PCM_STATE_RUNNING) {
 		mutex_unlock(&stream->device->lock);
Signature · 1 line
1.7.0.4
author
#18 lore raw

PATCH 7/9 ALSA: compress: allow write when stream is setup

In reply to Vinod Koul

We should allow write and thus poll as well when stream has been prepared. This allows usermode to write buffers ahead of time

---
 sound/core/compress_offload.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
sound/core/compress_offload.c +5 -4
index fb570c8..898a1d9 100644
@@ -263,7 +263,6 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf,
 
 	stream = &data->stream;
 	mutex_lock(&stream->device->lock);
-	/* write is allowed when stream is running or has been steup */
 	 /*
 	  * if the stream is in paused state, return the
 	  * number of bytes consumed as 0
@@ -272,8 +271,11 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf,
 		mutex_unlock(&stream->device->lock);
 		return retval;
 	}
+
+	/* write is allowed when stream is running or prepared or in setup */
 	if (stream->runtime->state != SNDRV_PCM_STATE_SETUP &&
-			stream->runtime->state != SNDRV_PCM_STATE_RUNNING) {
+			stream->runtime->state != SNDRV_PCM_STATE_RUNNING &&
+			stream->runtime->state != SNDRV_PCM_STATE_PREPARED) {
 		mutex_unlock(&stream->device->lock);
 		return -EBADFD;
 	}
@@ -380,8 +382,7 @@ static unsigned int snd_compr_poll(struct file *f, poll_table *wait)
 		return -EFAULT;
 
 	mutex_lock(&stream->device->lock);
-	if (stream->runtime->state == SNDRV_PCM_STATE_PAUSED ||
-			stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
+	if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
 		retval = -EBADFD;
 		goto out;
 	}
Signature · 1 line
1.7.0.4
author
#19 lore raw

PATCH 8/9 ALSA: compress: call pointer callback and updates under a lock

In reply to Vinod Koul

to prevent racy claculations as multiple threads can invoke and update values

While at it give some emptylines in code to improve readablity

---
 include/sound/compress_driver.h |    2 ++
 sound/core/compress_offload.c   |   13 +++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
include/sound/compress_driver.h +2 -0
index 9031a26..30258f3 100644
@@ -48,6 +48,7 @@ struct snd_compr_ops;
  *	the ring buffer
  * @total_bytes_transferred: cumulative bytes transferred by offload DSP
  * @sleep: poll sleep
+ * @pointer_lock: lock used for buffer pointer update
  */
 struct snd_compr_runtime {
 	snd_pcm_state_t state;
@@ -60,6 +61,7 @@ struct snd_compr_runtime {
 	u64 total_bytes_transferred;
 	wait_queue_head_t sleep;
 	void *private_data;
+	struct mutex pointer_lock;
 };
 
 /**
sound/core/compress_offload.c +13 -0
index 898a1d9..01b179f 100644
@@ -122,6 +122,7 @@ static int snd_compr_open(struct inode *inode, struct file *f)
 		return -ENOMEM;
 	}
 	runtime->state = SNDRV_PCM_STATE_OPEN;
+	mutex_init(&runtime->pointer_lock);
 	init_waitqueue_head(&runtime->sleep);
 	data->stream.runtime = runtime;
 	f->private_data = (void *)data;
@@ -151,13 +152,21 @@ static int snd_compr_update_tstamp(struct snd_compr_stream *stream,
 {
 	if (!stream->ops->pointer)
 		return -ENOTSUPP;
+
+	mutex_lock(&stream->runtime->pointer_lock);
+
 	stream->ops->pointer(stream, tstamp);
+
 	pr_debug("dsp consumed till %d total %d bytes\n",
 		tstamp->byte_offset, tstamp->copied_total);
+
 	if (stream->direction == SND_COMPRESS_PLAYBACK)
 		stream->runtime->total_bytes_transferred = tstamp->copied_total;
 	else
 		stream->runtime->total_bytes_available = tstamp->copied_total;
+
+	mutex_unlock(&stream->runtime->pointer_lock);
+
 	return 0;
 }
 
@@ -165,7 +174,9 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
 		struct snd_compr_avail *avail)
 {
 	memset(avail, 0, sizeof(*avail));
+
 	snd_compr_update_tstamp(stream, &avail->tstamp);
+
 	/* Still need to return avail even if tstamp can't be filled in */
 
 	if (stream->runtime->total_bytes_available == 0 &&
@@ -174,9 +185,11 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
 		pr_debug("detected init and someone forgot to do a write\n");
 		return stream->runtime->buffer_size;
 	}
+
 	pr_debug("app wrote %lld, DSP consumed %lld\n",
 			stream->runtime->total_bytes_available,
 			stream->runtime->total_bytes_transferred);
+
 	if (stream->runtime->total_bytes_available ==
 				stream->runtime->total_bytes_transferred) {
 		if (stream->direction == SND_COMPRESS_PLAYBACK) {
Signature · 1 line
1.7.0.4
#20 lore raw

Re: [PATCH 8/9] ALSA: compress: call pointer callback and updates under a lock

At Tue, 27 Aug 2013 12:10:38 +0530,

Quoted 2 lines · Vinod Koul

to prevent racy claculations as multiple threads can invoke and update values

Why a new lock? Can't it be the same lock?

Takashi

Quoted 87 lines

While at it give some emptylines in code to improve readablity

---
 include/sound/compress_driver.h |    2 ++
 sound/core/compress_offload.c   |   13 +++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
include/sound/compress_driver.h +2 -0
index 9031a26..30258f3 100644
@@ -48,6 +48,7 @@ struct snd_compr_ops;
  *	the ring buffer
  * @total_bytes_transferred: cumulative bytes transferred by offload DSP
  * @sleep: poll sleep
+ * @pointer_lock: lock used for buffer pointer update
  */
 struct snd_compr_runtime {
 	snd_pcm_state_t state;
@@ -60,6 +61,7 @@ struct snd_compr_runtime {
 	u64 total_bytes_transferred;
 	wait_queue_head_t sleep;
 	void *private_data;
+	struct mutex pointer_lock;
 };
 
 /**
sound/core/compress_offload.c +13 -0
index 898a1d9..01b179f 100644
@@ -122,6 +122,7 @@ static int snd_compr_open(struct inode *inode, struct file *f)
 		return -ENOMEM;
 	}
 	runtime->state = SNDRV_PCM_STATE_OPEN;
+	mutex_init(&runtime->pointer_lock);
 	init_waitqueue_head(&runtime->sleep);
 	data->stream.runtime = runtime;
 	f->private_data = (void *)data;
@@ -151,13 +152,21 @@ static int snd_compr_update_tstamp(struct snd_compr_stream *stream,
 {
 	if (!stream->ops->pointer)
 		return -ENOTSUPP;
+
+	mutex_lock(&stream->runtime->pointer_lock);
+
 	stream->ops->pointer(stream, tstamp);
+
 	pr_debug("dsp consumed till %d total %d bytes\n",
 		tstamp->byte_offset, tstamp->copied_total);
+
 	if (stream->direction == SND_COMPRESS_PLAYBACK)
 		stream->runtime->total_bytes_transferred = tstamp->copied_total;
 	else
 		stream->runtime->total_bytes_available = tstamp->copied_total;
+
+	mutex_unlock(&stream->runtime->pointer_lock);
+
 	return 0;
 }
 
@@ -165,7 +174,9 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
 		struct snd_compr_avail *avail)
 {
 	memset(avail, 0, sizeof(*avail));
+
 	snd_compr_update_tstamp(stream, &avail->tstamp);
+
 	/* Still need to return avail even if tstamp can't be filled in */
 
 	if (stream->runtime->total_bytes_available == 0 &&
@@ -174,9 +185,11 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
 		pr_debug("detected init and someone forgot to do a write\n");
 		return stream->runtime->buffer_size;
 	}
+
 	pr_debug("app wrote %lld, DSP consumed %lld\n",
 			stream->runtime->total_bytes_available,
 			stream->runtime->total_bytes_transferred);
+
 	if (stream->runtime->total_bytes_available ==
 				stream->runtime->total_bytes_transferred) {
 		if (stream->direction == SND_COMPRESS_PLAYBACK) {
Signature · 1 line
1.7.0.4
author
#21 lore raw

Re: [PATCH 8/9] ALSA: compress: call pointer callback and updates under a lock

Quoted 6 lines · Takashi Iwai

At Tue, 27 Aug 2013 12:10:38 +0530,

Quoted 2 lines · Vinod Koul

to prevent racy claculations as multiple threads can invoke and update values

Why a new lock? Can't it be the same lock?

Pointer query and updates IMO should be independent of the trigger ops. I dont see a reason why we should blcok pointers while we are pausing...

~Vinod

#22 lore raw

Re: [PATCH 8/9] ALSA: compress: call pointer callback and updates under a lock

At Tue, 27 Aug 2013 15:18:59 +0530,

Quoted 10 lines · Vinod Koul
Quoted 6 lines · Takashi Iwai

At Tue, 27 Aug 2013 12:10:38 +0530,

Quoted 2 lines · Vinod Koul

to prevent racy claculations as multiple threads can invoke and update values

Why a new lock? Can't it be the same lock?

Pointer query and updates IMO should be independent of the trigger ops. I dont see a reason why we should blcok pointers while we are pausing...

What happens if the trigger or reset is called during your taking the timestamp?

Takashi

author
#23 lore raw

PATCH 9/9 ALSA: compress: use rate values for passing sampling rates

In reply to Vinod Koul

Clarify that its better to use the rate values like 8000, 12000, 11025, 44100, 48000 etc to send sampling rate values to driver. The changes kernel ABI but no drivers exist upstream so okay to change now
Tinycompress to be fixed as well

For this change bump the API version as well

---
 include/uapi/sound/compress_offload.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/uapi/sound/compress_offload.h +1 -1
index d630163..cad87ff 100644
@@ -62,7 +62,7 @@ struct snd_compr_params {
  *	progress. It shall not be used for timing estimates.
  * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio
  * output/input. This field should be used for A/V sync or time estimates.
- * @sampling_rate: sampling rate of audio
+ * @sampling_rate: sampling rate value of audio,  eg 12000, 48000
  */
 struct snd_compr_tstamp {
 	__u32 byte_offset;
Signature · 1 line
1.7.0.4
#24 lore raw

Re: [PATCH 9/9] ALSA: compress: use rate values for passing sampling rates

At Tue, 27 Aug 2013 12:10:39 +0530,

Quoted 7 lines · Vinod Koul

Clarify that its better to use the rate values like 8000, 12000, 11025, 44100, 48000 etc to send sampling rate values to driver. The changes kernel ABI but no drivers exist upstream so okay to change now
Tinycompress to be fixed as well

For this change bump the API version as well

I see no corresponding changes at all...

Quoted 2 lines

Again, why it must be to stable?

Takashi

Quoted 20 lines
---
 include/uapi/sound/compress_offload.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/uapi/sound/compress_offload.h +1 -1
index d630163..cad87ff 100644
@@ -62,7 +62,7 @@ struct snd_compr_params {
  *	progress. It shall not be used for timing estimates.
  * @pcm_io_frames: Frames rendered or received by DSP into a mixer or an audio
  * output/input. This field should be used for A/V sync or time estimates.
- * @sampling_rate: sampling rate of audio
+ * @sampling_rate: sampling rate value of audio,  eg 12000, 48000
  */
 struct snd_compr_tstamp {
 	__u32 byte_offset;
Signature · 1 line
1.7.0.4
maintainer
#25 lore raw

Re: [PATCH 9/9] ALSA: compress: use rate values for passing sampling rates

In reply to Vinod Koul
Quoted 7 lines · Vinod Koul

Clarify that its better to use the rate values like 8000, 12000, 11025, 44100, 48000 etc to send sampling rate values to driver. The changes kernel ABI but no drivers exist upstream so okay to change now
Tinycompress to be fixed as well

- * @sampling_rate: sampling rate of audio
+ * @sampling_rate: sampling rate value of audio, eg 12000, 48000

It's not clear why this is a change in the ABI - the values written and the types don't change. Personally I'd not change the ABI - it's a bit late now that the code has been in the kernel for several releases.

author
#26 lore raw

Re: [PATCH 9/9] ALSA: compress: use rate values for passing sampling rates

Quoted 6 lines · Mark Brown
Quoted 4 lines · Vinod Koul

Clarify that its better to use the rate values like 8000, 12000, 11025, 44100, 48000 etc to send sampling rate values to driver. The changes kernel ABI but no drivers exist upstream so okay to change now
Tinycompress to be fixed as well

Quoted 6 lines
Quoted 2 lines

- * @sampling_rate: sampling rate of audio
+ * @sampling_rate: sampling rate value of audio, eg 12000, 48000

It's not clear why this is a change in the ABI - the values written and the types don't change. Personally I'd not change the ABI - it's a bit late now that the code has been in the kernel for several releases.

the problem is the meaning of sampling_rate. It was SND_PCM_RATE_XXX. It was a lack of foresight on my side, we should have done values which we are changing now to handle rates not defined here.

But since none of drivers are upstream, impact is IMO managble. I was planning to communicate this along with tinycompress fixes to all folks who i know are using this :)

~Vinod

maintainer
#27 lore raw

Re: [PATCH 9/9] ALSA: compress: use rate values for passing sampling rates

Quoted 10 lines · Vinod Koul
Quoted 6 lines
Quoted 2 lines

- * @sampling_rate: sampling rate of audio
+ * @sampling_rate: sampling rate value of audio, eg 12000, 48000

It's not clear why this is a change in the ABI - the values written and the types don't change. Personally I'd not change the ABI - it's a bit late now that the code has been in the kernel for several releases.

the problem is the meaning of sampling_rate. It was SND_PCM_RATE_XXX. It was a lack of foresight on my side, we should have done values which we are changing now to handle rates not defined here.

Given that the documentation didn't mention the constants and there's no example users I'm not sure this is actually a change at all...

#28 lore raw
In reply to Vinod Koul

At Tue, 27 Aug 2013 12:10:30 +0530,

Quoted 9 lines · Vinod Koul

Hi Takashi,

Here is the patch series which fixes various issues being reported by users (out of tree sadly)

The first three and and last one are marked to stable as would like these to be fixed in older kernels as well. It would be good if you can send them as fixes to linus for 3.11.

Sorry, no go. If it's only about out-of-tree drivers, it's even questionable whether it worth for stable kernel, because we have no real test case for our own.

Quoted 7 lines

Rest can go in the merge window

Fixes:
- using lock for all operation was a very bad idead. This is bad as some of the ioctls like drain, partial drain can be time consuming and thus prevent any
other operation while these are ongoing like Pause, Stop or timestamp query, so fix this be removing bunch of ioctls not to use device lock.

Although not all of them need locks, it's easier to manage in most cases to perform in the lock. For drain or such operation, you can simply unlock and re-lock in the call itself, as your patch in the series does.

Quoted 2 lines

- Now we dont have lock for pointer updates so this maybe racy, so use lock for doing lowest level calculation.

Similarly, introducing yet another lock would just choke you neck.

Quoted 3 lines

- As disscused on our sample rate problem, lets move to use rate values and I will fix the lib too. Since the driver are not upstream the impact of this
change wont be huge.

I see no code touching sampling_rate field.

Quoted 1 line

- Plus few fix like use snprintf, state chacks for pause, write etc..

I don't like to merge irrelevant space changes into a patch if it's a fix patch, especially if it's targeted to stable. The fix is the fix. Please separate.

thanks,

Takashi

Quoted 21 lines

Vinod Koul (9):
ALSA: Compress - dont use lock for all ioctls
ALSA: compress: use mutex in drain
ASoC: compress: dont aquire lock for draining states
ALSA: compress: use snprint instread of sprintf
ALSA: compres: wakeup the poll thread on pause
ALSA: compress: dont write when stream is paused
ALSA: compress: allow write when stream is setup
ALSA: compress: call pointer callback and updates under a lock
ALSA: compress: use rate values for passing sampling rates

 include/sound/compress_driver.h       |    2 +
 include/uapi/sound/compress_offload.h |    2 +-
 sound/core/compress_offload.c         |  140 +++++++++++++++++++++++++-------
 sound/soc/soc-compress.c              |   10 +++
 4 files changed, 122 insertions(+), 32 deletions(-)

Thanks
~Vinod

author
#29 lore raw
Quoted 8 lines · Takashi Iwai

At Tue, 27 Aug 2013 12:10:30 +0530,

Quoted 6 lines · Vinod Koul

Hi Takashi,

Here is the patch series which fixes various issues being reported by users (out of tree sadly)

Quoted 7 lines
Quoted 3 lines

The first three and and last one are marked to stable as would like these to be fixed in older kernels as well. It would be good if you can send them as fixes to linus for 3.11.

Sorry, no go. If it's only about out-of-tree drivers, it's even questionable whether it worth for stable kernel, because we have no real test case for our own.

Since lot of embedded folks will be on 3.10 then would have been nicer if it went to stable. I know users will backport, but if a kernel provided the desired functionalty then would have been great.

Quoted 11 lines
Quoted 5 lines

Fixes:
- using lock for all operation was a very bad idead. This is bad as some of the ioctls like drain, partial drain can be time consuming and thus prevent any
other operation while these are ongoing like Pause, Stop or timestamp query, so fix this be removing bunch of ioctls not to use device lock.

Although not all of them need locks, it's easier to manage in most cases to perform in the lock. For drain or such operation, you can simply unlock and re-lock in the call itself, as your patch in the series does.a

Quoted 4 lines
Quoted 2 lines

- Now we dont have lock for pointer updates so this maybe racy, so use lock for doing lowest level calculation.

Similarly, introducing yet another lock would just choke you neck.

Well i thought that pointer updates are orthogonal to other triggers so there is no issue if we seprate the two. How do you think in long run will this impact..?

Quoted 5 lines
Quoted 3 lines

- As disscused on our sample rate problem, lets move to use rate values and I will fix the lib too. Since the driver are not upstream the impact of this
change wont be huge.

I see no code touching sampling_rate field.

Yes its passed directly to the drivers, where tehy use values to prgram decoders. Only meaning of the field is changing now.

Quoted 5 lines
Quoted 1 line

- Plus few fix like use snprintf, state chacks for pause, write etc..

I don't like to merge irrelevant space changes into a patch if it's a fix patch, especially if it's targeted to stable. The fix is the fix. Please separate.

Sure makes sense...

So do you want these to be sent to stable or not. I would prefer to be sent

Thanks
~Vinod

#30 lore raw

At Tue, 27 Aug 2013 15:39:55 +0530,

Quoted 14 lines · Vinod Koul
Quoted 12 lines · Takashi Iwai

At Tue, 27 Aug 2013 12:10:30 +0530,

Quoted 9 lines · Vinod Koul

Hi Takashi,

Here is the patch series which fixes various issues being reported by users (out of tree sadly)

The first three and and last one are marked to stable as would like these to be fixed in older kernels as well. It would be good if you can send them as fixes to linus for 3.11.

Quoted 5 lines
Quoted 3 lines

Sorry, no go. If it's only about out-of-tree drivers, it's even questionable whether it worth for stable kernel, because we have no real test case for our own.

Since lot of embedded folks will be on 3.10 then would have been nicer if it went to stable.

"It'd be nice" doesn't satisfy the condition for stable kernels, unfortunately.

Quoted 14 lines

I know users will backport, but if a kernel provided the desired functionalty then would have been great.

Quoted 11 lines
Quoted 5 lines

Fixes:
- using lock for all operation was a very bad idead. This is bad as some of the ioctls like drain, partial drain can be time consuming and thus prevent any
other operation while these are ongoing like Pause, Stop or timestamp query, so fix this be removing bunch of ioctls not to use device lock.

Although not all of them need locks, it's easier to manage in most cases to perform in the lock. For drain or such operation, you can simply unlock and re-lock in the call itself, as your patch in the series does.a

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

- Now we dont have lock for pointer updates so this maybe racy, so use lock for doing lowest level calculation.

Similarly, introducing yet another lock would just choke you neck.

Well i thought that pointer updates are orthogonal to other triggers so there is no issue if we seprate the two. How do you think in long run will this impact..?

If both locks can be never called in nested way, then it'd work. But if the locks can be nested, better to avoid as much as possible. Put in that way: what if the time for critical section via stream->device->lock is short enough (it should be)?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

- As disscused on our sample rate problem, lets move to use rate values and I will fix the lib too. Since the driver are not upstream the impact of this
change wont be huge.

I see no code touching sampling_rate field.

Yes its passed directly to the drivers, where tehy use values to program decoders. Only meaning of the field is changing now.

So you're proposing a patch just changing the comment in the header file as a stable fix patch? Please reread stable_kernel_rules.txt once again.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

- Plus few fix like use snprintf, state chacks for pause, write etc..

I don't like to merge irrelevant space changes into a patch if it's a fix patch, especially if it's targeted to stable. The fix is the fix. Please separate.

Sure makes sense...

So do you want these to be sent to stable or not. I would prefer to be sent

This pretty depends on how it can be "fixed"...

Takashi

maintainer
#31 lore raw
Quoted 7 lines · Takashi Iwai
Quoted 2 lines · Vinod Koul

Since lot of embedded folks will be on 3.10 then would have been nicer if it went to stable.

"It'd be nice" doesn't satisfy the condition for stable kernels, unfortunately.

On the other hand if there's an issue which essentially every user is most likely going to end up backporting a fix for it seems reasonable to consider getting that resolved. Personally I'd be a lot more conservative than Vinod with this one and only consider the fix for blocking during drain. The current series seems rather invasive though.

author
#32 lore raw
Quoted 6 lines · Mark Brown
Quoted 4 lines · Takashi Iwai
Quoted 2 lines · Vinod Koul

Since lot of embedded folks will be on 3.10 then would have been nicer if it went to stable.

Quoted 8 lines
Quoted 2 lines

"It'd be nice" doesn't satisfy the condition for stable kernels, unfortunately.

On the other hand if there's an issue which essentially every user is most likely going to end up backporting a fix for it seems reasonable to consider getting that resolved. Personally I'd be a lot more conservative than Vinod with this one and only consider the fix for blocking during drain. The current series seems rather invasive though.

Not all are marked for stable. Only thecouple to fix locking problem and defination of sampling_rate. Rest will go thru usual cycle, though I suspect with folks in embedded will take complete series.

~Vinod

author
#33 lore raw
In reply to Takashi Iwai
Quoted 11 lines · Takashi Iwai
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

- As disscused on our sample rate problem, lets move to use rate values and I will fix the lib too. Since the driver are not upstream the impact of this
change wont be huge.

I see no code touching sampling_rate field.

Yes its passed directly to the drivers, where tehy use values to program decoders. Only meaning of the field is changing now.

So you're proposing a patch just changing the comment in the header file as a stable fix patch? Please reread stable_kernel_rules.txt once again.

Yes along with header version so that tinycompress can cope with it.

The meaning of the value is changing here...

~Vinod

#34 lore raw

At Tue, 27 Aug 2013 18:44:38 +0530,

Quoted 6 lines · Vinod Koul
Quoted 4 lines · Takashi Iwai
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

- As disscused on our sample rate problem, lets move to use rate values and I will fix the lib too. Since the driver are not upstream the impact of this
change wont be huge.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I see no code touching sampling_rate field.

Yes its passed directly to the drivers, where tehy use values to program decoders. Only meaning of the field is changing now.

So you're proposing a patch just changing the comment in the header file as a stable fix patch? Please reread stable_kernel_rules.txt once again.

Yes along with header version so that tinycompress can cope with it.

I've seen nothing but changing the comment in the patch. What's missing?

Quoted 1 line

The meaning of the value is changing here...

Again, is this a bug fix? Stable patches are only for bug fixes.

Takashi

author
#35 lore raw
Quoted 15 lines · Takashi Iwai

At Tue, 27 Aug 2013 18:44:38 +0530,

Quoted 13 lines · Vinod Koul
Quoted 11 lines · Takashi Iwai
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

- As disscused on our sample rate problem, lets move to use rate values and I will fix the lib too. Since the driver are not upstream the impact of this
change wont be huge.

I see no code touching sampling_rate field.

Yes its passed directly to the drivers, where tehy use values to program decoders. Only meaning of the field is changing now.

So you're proposing a patch just changing the comment in the header file as a stable fix patch? Please reread stable_kernel_rules.txt once again.

Quoted 8 lines
Quoted 1 line

Yes along with header version so that tinycompress can cope with it.

I've seen nothing but changing the comment in the patch. What's missing?

Quoted 1 line

The meaning of the value is changing here...

Again, is this a bug fix? Stable patches are only for bug fixes.

yup... we can't do 12K, 24K decoding without this. We actually found when folks tried aac with 12K

~Vinod

#36 lore raw

At Tue, 27 Aug 2013 19:00:30 +0530,

Quoted 19 lines · Vinod Koul
Quoted 17 lines · Takashi Iwai

At Tue, 27 Aug 2013 18:44:38 +0530,

Quoted 14 lines · Vinod Koul
Quoted 11 lines · Takashi Iwai
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

- As disscused on our sample rate problem, lets move to use rate values and I will fix the lib too. Since the driver are not upstream the impact of this
change wont be huge.

I see no code touching sampling_rate field.

Yes its passed directly to the drivers, where tehy use values to program decoders. Only meaning of the field is changing now.

So you're proposing a patch just changing the comment in the header file as a stable fix patch? Please reread stable_kernel_rules.txt once again.

Yes along with header version so that tinycompress can cope with it.

Quoted 8 lines
Quoted 6 lines

I've seen nothing but changing the comment in the patch. What's missing?

Quoted 1 line

The meaning of the value is changing here...

Again, is this a bug fix? Stable patches are only for bug fixes.

yup... we can't do 12K, 24K decoding without this. We actually found when folks tried aac with 12K

I understand it, but my question is what fixes your patch except for the comment in the header file? In other words, by changing the comment text, what will be fixed in the end?

Takashi

author
#37 lore raw
Quoted 3 lines · Takashi Iwai

I understand it, but my question is what fixes your patch except for the comment in the header file? In other words, by changing the comment text, what will be fixed in the end?

the meaning and API version which tinycompress will use to send right values..

~Vinod

#38 lore raw

At Tue, 27 Aug 2013 19:11:46 +0530,

Quoted 6 lines · Vinod Koul
Quoted 3 lines · Takashi Iwai

I understand it, but my question is what fixes your patch except for the comment in the header file? In other words, by changing the comment text, what will be fixed in the end?

the meaning and API version which tinycompress will use to send right values..

It's just a comment text, which itself is nothing bug a explanation, and doesn't define the actual behavior. And there is no code in the upstream tree regarding this field, so no place to "fix" there.

Moreover, tinycompress library should be self-contained so that it can be compiled without the kernel source tree.

Takashi

author
#39 lore raw
Quoted 7 lines · Takashi Iwai

At Tue, 27 Aug 2013 19:11:46 +0530,

Quoted 5 lines · Vinod Koul
Quoted 3 lines · Takashi Iwai

I understand it, but my question is what fixes your patch except for the comment in the header file? In other words, by changing the comment text, what will be fixed in the end?

Quoted 8 lines
Quoted 1 line

the meaning and API version which tinycompress will use to send right values..

It's just a comment text, which itself is nothing bug a explanation, and doesn't define the actual behavior. And there is no code in the upstream tree regarding this field, so no place to "fix" there.

Moreover, tinycompress library should be self-contained so that it can be compiled without the kernel source tree.

yes it is and can be compiled without kernel sources...

~Vinod