diff mbox

[14/15] ALSA: line6: Give up hwdep spinlock temporarily during read operation

Message ID 1470942147-19848-15-git-send-email-dev@andree.sk (mailing list archive)
State New, archived
Headers show

Commit Message

Andrej Krutak Aug. 11, 2016, 7:02 p.m. UTC
Without it, the code hits the 'might_sleep while atomic' debug warning.

Signed-off-by: Andrej Krutak <dev@andree.sk>
---
 sound/usb/line6/driver.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Takashi Iwai Aug. 12, 2016, 8:46 a.m. UTC | #1
On Thu, 11 Aug 2016 21:02:26 +0200,
Andrej Krutak wrote:
> 
> Without it, the code hits the 'might_sleep while atomic' debug warning.
> 
> Signed-off-by: Andrej Krutak <dev@andree.sk>

This also should have been folded into patch 9.


Takashi
diff mbox

Patch

diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
index 142e0e3..286b6e1 100644
--- a/sound/usb/line6/driver.c
+++ b/sound/usb/line6/driver.c
@@ -600,6 +600,10 @@  line6_hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count,
 		goto end;
 	}
 
+	/* Release lock while copying the stuff. Since there is only one reader,
+	 * the data is going nowhere, so this should be safe. */
+	spin_unlock(&line6->buffer_circular.read_lock);
+
 	if (copy_to_user(buf,
 		&line6->buffer_circular.data[tail * LINE6_MESSAGE_MAXLEN],
 		line6->buffer_circular.data_len[tail])
@@ -610,6 +614,7 @@  line6_hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count,
 		rv = line6->buffer_circular.data_len[tail];
 	}
 
+	spin_lock(&line6->buffer_circular.read_lock);
 	smp_store_release(&line6->buffer_circular.tail,
 				(tail + 1) & (LINE6_MESSAGE_MAXCOUNT - 1));