All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Aravamudan <nacc@us.ibm.com>
To: perex@suse.cz
Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org
Subject: [PATCH 3/14] sound/usb: fix-up sleeping paths
Date: Fri, 8 Jul 2005 17:04:39 -0700	[thread overview]
Message-ID: <20050709000439.GF2596@us.ibm.com> (raw)
In-Reply-To: <20050709000324.GD2596@us.ibm.com>

From: Nishanth Aravamudan <nacc@us.ibm.com>

Jaroslav, I realize that you are not the explicit maintainer for any of
these drivers, but I figured you would at least be able to {N,}ACK the
changes. I didn't find any entry in MAINTAINERS for usb-specific sound
drivers. If you would prefer split patches instead of the large
patchset, I can do that.

Description: Fix-up sleeping in sound/usb. Replace big_mdelay() with
msleep() to guarantee the task delays as expected. This also involved
replacing/removing custom sleep functions.

Patch is compile-tested.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>

---

 usbaudio.c            |    4 ++--
 usx2y/usX2Yhwdep.c    |    3 +--
 usx2y/usx2yhwdeppcm.c |    6 ++----
 3 files changed, 5 insertions(+), 8 deletions(-)

diff -urpN 2.6.13-rc2-kj/sound/usb/usbaudio.c 2.6.13-rc2-kj-dev/sound/usb/usbaudio.c
--- 2.6.13-rc2-kj/sound/usb/usbaudio.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/usb/usbaudio.c	2005-07-08 12:33:55.000000000 -0700
@@ -790,7 +790,7 @@ static int start_urbs(snd_usb_substream_
  */
 static int wait_clear_urbs(snd_usb_substream_t *subs)
 {
-	int timeout = HZ;
+	unsigned long end_time = jiffies + msecs_to_jiffies(1000);
 	unsigned int i;
 	int alive;
 
@@ -810,7 +810,7 @@ static int wait_clear_urbs(snd_usb_subst
 			break;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--timeout > 0);
+	} while (time_before(jiffies, end_time));
 	if (alive)
 		snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive);
 	return 0;
diff -urpN 2.6.13-rc2-kj/sound/usb/usx2y/usX2Yhwdep.c 2.6.13-rc2-kj-dev/sound/usb/usx2y/usX2Yhwdep.c
--- 2.6.13-rc2-kj/sound/usb/usx2y/usX2Yhwdep.c	2005-07-06 07:57:08.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/usb/usx2y/usX2Yhwdep.c	2005-07-06 22:56:43.000000000 -0700
@@ -232,8 +232,7 @@ static int snd_usX2Y_hwdep_dsp_load(snd_
 	if (err)
 		return err;
 	if (dsp->index == 1) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/4);			// give the device some time 
+		msleep(250);				// give the device some time
 		err = usX2Y_AsyncSeq04_init(priv);
 		if (err) {
 			snd_printk("usX2Y_AsyncSeq04_init error \n");
diff -urpN 2.6.13-rc2-kj/sound/usb/usx2y/usx2yhwdeppcm.c 2.6.13-rc2-kj-dev/sound/usb/usx2y/usx2yhwdeppcm.c
--- 2.6.13-rc2-kj/sound/usb/usx2y/usx2yhwdeppcm.c	2005-03-01 23:38:11.000000000 -0800
+++ 2.6.13-rc2-kj-dev/sound/usb/usx2y/usx2yhwdeppcm.c	2005-07-06 22:58:50.000000000 -0700
@@ -50,6 +50,7 @@
    Currently rawusb dma pcm buffer transport (this file) is only available to snd-usb-usx2y. 
 */
 
+#include <linux/delay.h>
 #include "usbusx2yaudio.c"
 
 #if defined(USX2Y_NRPACKS_VARIABLE) || (!defined(USX2Y_NRPACKS_VARIABLE) &&  USX2Y_NRPACKS == 1)
@@ -520,11 +521,8 @@ static int snd_usX2Y_usbpcm_prepare(snd_
 		usX2Y->hwdep_pcm_shm->playback_iso_start = -1;
 		if (atomic_read(&subs->state) < state_PREPARED) {
 			while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > usX2Y->hwdep_pcm_shm->captured_iso_frames) {
-				signed long timeout;
 				snd_printd("Wait: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", usX2Y_iso_frames_per_buffer(runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames);
-				set_current_state(TASK_INTERRUPTIBLE);
-				timeout = schedule_timeout(HZ/100 + 1);
-				if (signal_pending(current)) {
+				if (msleep_interruptible(10)) {
 					err = -ERESTARTSYS;
 					goto up_prepare_mutex;
 				}


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar

WARNING: multiple messages have this Message-ID (diff)
From: Nishanth Aravamudan <nacc@us.ibm.com>
To: perex@suse.cz
Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org
Subject: [PATCH 3/14] sound/usb: fix-up sleeping paths
Date: Sat, 09 Jul 2005 00:04:39 +0000	[thread overview]
Message-ID: <20050709000439.GF2596@us.ibm.com> (raw)
In-Reply-To: <20050709000324.GD2596@us.ibm.com>

From: Nishanth Aravamudan <nacc@us.ibm.com>

Jaroslav, I realize that you are not the explicit maintainer for any of
these drivers, but I figured you would at least be able to {N,}ACK the
changes. I didn't find any entry in MAINTAINERS for usb-specific sound
drivers. If you would prefer split patches instead of the large
patchset, I can do that.

Description: Fix-up sleeping in sound/usb. Replace big_mdelay() with
msleep() to guarantee the task delays as expected. This also involved
replacing/removing custom sleep functions.

Patch is compile-tested.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>

---

 usbaudio.c            |    4 ++--
 usx2y/usX2Yhwdep.c    |    3 +--
 usx2y/usx2yhwdeppcm.c |    6 ++----
 3 files changed, 5 insertions(+), 8 deletions(-)

diff -urpN 2.6.13-rc2-kj/sound/usb/usbaudio.c 2.6.13-rc2-kj-dev/sound/usb/usbaudio.c
--- 2.6.13-rc2-kj/sound/usb/usbaudio.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/usb/usbaudio.c	2005-07-08 12:33:55.000000000 -0700
@@ -790,7 +790,7 @@ static int start_urbs(snd_usb_substream_
  */
 static int wait_clear_urbs(snd_usb_substream_t *subs)
 {
-	int timeout = HZ;
+	unsigned long end_time = jiffies + msecs_to_jiffies(1000);
 	unsigned int i;
 	int alive;
 
@@ -810,7 +810,7 @@ static int wait_clear_urbs(snd_usb_subst
 			break;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--timeout > 0);
+	} while (time_before(jiffies, end_time));
 	if (alive)
 		snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive);
 	return 0;
diff -urpN 2.6.13-rc2-kj/sound/usb/usx2y/usX2Yhwdep.c 2.6.13-rc2-kj-dev/sound/usb/usx2y/usX2Yhwdep.c
--- 2.6.13-rc2-kj/sound/usb/usx2y/usX2Yhwdep.c	2005-07-06 07:57:08.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/usb/usx2y/usX2Yhwdep.c	2005-07-06 22:56:43.000000000 -0700
@@ -232,8 +232,7 @@ static int snd_usX2Y_hwdep_dsp_load(snd_
 	if (err)
 		return err;
 	if (dsp->index = 1) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/4);			// give the device some time 
+		msleep(250);				// give the device some time
 		err = usX2Y_AsyncSeq04_init(priv);
 		if (err) {
 			snd_printk("usX2Y_AsyncSeq04_init error \n");
diff -urpN 2.6.13-rc2-kj/sound/usb/usx2y/usx2yhwdeppcm.c 2.6.13-rc2-kj-dev/sound/usb/usx2y/usx2yhwdeppcm.c
--- 2.6.13-rc2-kj/sound/usb/usx2y/usx2yhwdeppcm.c	2005-03-01 23:38:11.000000000 -0800
+++ 2.6.13-rc2-kj-dev/sound/usb/usx2y/usx2yhwdeppcm.c	2005-07-06 22:58:50.000000000 -0700
@@ -50,6 +50,7 @@
    Currently rawusb dma pcm buffer transport (this file) is only available to snd-usb-usx2y. 
 */
 
+#include <linux/delay.h>
 #include "usbusx2yaudio.c"
 
 #if defined(USX2Y_NRPACKS_VARIABLE) || (!defined(USX2Y_NRPACKS_VARIABLE) &&  USX2Y_NRPACKS = 1)
@@ -520,11 +521,8 @@ static int snd_usX2Y_usbpcm_prepare(snd_
 		usX2Y->hwdep_pcm_shm->playback_iso_start = -1;
 		if (atomic_read(&subs->state) < state_PREPARED) {
 			while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > usX2Y->hwdep_pcm_shm->captured_iso_frames) {
-				signed long timeout;
 				snd_printd("Wait: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", usX2Y_iso_frames_per_buffer(runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames);
-				set_current_state(TASK_INTERRUPTIBLE);
-				timeout = schedule_timeout(HZ/100 + 1);
-				if (signal_pending(current)) {
+				if (msleep_interruptible(10)) {
 					err = -ERESTARTSYS;
 					goto up_prepare_mutex;
 				}

  parent reply	other threads:[~2005-07-09  0:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-09  0:03 [PATCH 1/14] sound/pci: fix-up sleeping paths Nishanth Aravamudan
2005-07-09  0:03 ` Nishanth Aravamudan
2005-07-09  0:04 ` [PATCH 2/14] sound/ppc: " Nishanth Aravamudan
2005-07-09  0:04   ` Nishanth Aravamudan
2005-07-09  0:07   ` Nishanth Aravamudan
2005-07-09  0:04 ` Nishanth Aravamudan [this message]
2005-07-09  0:04   ` [PATCH 3/14] sound/usb: " Nishanth Aravamudan
2005-07-09  0:08   ` Nishanth Aravamudan
2005-07-09  0:06 ` [PATCH 1/14] sound/pci: " Nishanth Aravamudan
2005-07-09  0:11 ` [KJ] [PATCH 7/14] mips: replace timespectojiffies() with Nishanth Aravamudan
2005-07-09  0:11   ` [PATCH 7/14] mips: replace timespectojiffies() with timespec_to_jiffies() Nishanth Aravamudan
2005-07-11 14:12   ` [KJ] Re: [PATCH 7/14] mips: replace timespectojiffies() with Ralf Baechle
2005-07-11 14:12     ` [PATCH 7/14] mips: replace timespectojiffies() with timespec_to_jiffies() Ralf Baechle
2005-07-09  0:14 ` [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of Nishanth Aravamudan
2005-07-09  0:14   ` [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of schedule_timeout() Nishanth Aravamudan
2005-07-10 16:20   ` [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of Domen Puncer
2005-07-10 16:20     ` [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of schedule_timeout() Domen Puncer
2005-07-11  5:38     ` [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of Nishanth Aravamudan
2005-07-11  5:38       ` [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of schedule_timeout() Nishanth Aravamudan
2005-07-09  0:15 ` [KJ] [PATCH 12/14] scsi/osst: use msleep() instead of Nishanth Aravamudan
2005-07-09  0:15   ` [KJ] [PATCH 12/14] scsi/osst: use msleep() instead of schedule_timeout() Nishanth Aravamudan
2005-07-09  0:16 ` [KJ] [PATCH 13/14] scsi/qla2xxx: use msleep{, Nishanth Aravamudan
2005-07-09  0:16   ` [KJ] [PATCH 13/14] scsi/qla2xxx: use msleep{, interruptible}() instead of schedule_timeout() Nishanth Aravamudan
  -- strict thread matches above, loose matches on Subject: below --
2005-07-09  0:06 [KJ] Re: [PATCH 1/14] sound/pci: fix-up sleeping paths Nishanth Aravamudan
2005-07-09  0:06 ` Nishanth Aravamudan
2005-07-09  0:07 [KJ] Re: [PATCH 2/14] sound/ppc: " Nishanth Aravamudan
2005-07-09  0:07 ` Nishanth Aravamudan
2005-07-09  0:08 [KJ] Re: [PATCH 3/14] sound/usb: " Nishanth Aravamudan
2005-07-09  0:08 ` Nishanth Aravamudan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050709000439.GF2596@us.ibm.com \
    --to=nacc@us.ibm.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.