All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/14] sound/pci: fix-up sleeping paths
@ 2005-07-09  0:03 ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:03 UTC (permalink / raw)
  To: perex, sailer, mulix, tiwai; +Cc: alsa-devel, linux-sound

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

Jaroslav, I realize that you are not the explicit maintainer for many of
these drivers, but I figured you would at least be able to {N,}ACK the
changes. I tried to add any Maintainers I could find to the recipient
list, and hope any I missed are on one of the two lists.  I'm sorry for
having put them into the same patchset, and if split patches would be
preferred, I can do that.

Description: Fix-up sleeping in sound/pci. These changes fall under the
following two categories:

	1) Replace schedule_timeout() with msleep() to guarantee the
	task delays as expected. This also involved replacing/removing
	custom sleep functions.
	2) Do not assume jiffies will only increment by one if you
	request a 1 jiffy sleep, i.e. use time_after/time_before in
	while loops.

Patch is compile-tested.

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

---

 ac97/ac97_codec.c      |   17 +++++++++--------
 ali5451/ali5451.c      |    4 ++--
 cs46xx/cs46xx_lib.c    |   15 +++++----------
 ens1370.c              |   12 +-----------
 es1968.c               |   14 ++++----------
 intel8x0.c             |    3 +--
 maestro3.c             |   22 +++++++---------------
 mixart/mixart.c        |    4 ++--
 rme9652/hdsp.c         |    6 ++----
 trident/trident_main.c |    3 +--
 via82xx.c              |   13 ++++++-------
 via82xx_modem.c        |   13 ++++++-------
 ymfpci/ymfpci_main.c   |    6 +++---
 13 files changed, 49 insertions(+), 83 deletions(-)

diff -urpN 2.6.13-rc2-kj/sound/pci/ac97/ac97_codec.c 2.6.13-rc2-kj-dev/sound/pci/ac97/ac97_codec.c
--- 2.6.13-rc2-kj/sound/pci/ac97/ac97_codec.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/ac97/ac97_codec.c	2005-07-08 12:27:19.000000000 -0700
@@ -2225,6 +2225,7 @@ void snd_ac97_restore_iec958(ac97_t *ac9
 void snd_ac97_resume(ac97_t *ac97)
 {
 	int i;
+	unsigned long end_time;
 
 	if (ac97->bus->ops->reset) {
 		ac97->bus->ops->reset(ac97);
@@ -2242,26 +2243,26 @@ void snd_ac97_resume(ac97_t *ac97)
 	snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]);
 	if (ac97_is_audio(ac97)) {
 		ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101);
-		for (i = HZ/10; i >= 0; i--) {
+		end_time = jiffies + msecs_to_jiffies(100);
+		do {
 			if (snd_ac97_read(ac97, AC97_MASTER) == 0x8101)
 				break;
 			set_current_state(TASK_UNINTERRUPTIBLE);
 			schedule_timeout(1);
-		}
+		} while (time_after_eq(end_time, jiffies));
 		/* FIXME: extra delay */
 		ac97->bus->ops->write(ac97, AC97_MASTER, 0x8000);
-		if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ/4);
-		}
+		if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000)
+			msleep(250);
 	} else {
-		for (i = HZ/10; i >= 0; i--) {
+		end_time = jiffies + msecs_to_jiffies(100);
+		do {
 			unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID);
 			if (val != 0xffff && (val & 1) != 0)
 				break;
 			set_current_state(TASK_UNINTERRUPTIBLE);
 			schedule_timeout(1);
-		}
+		} while (time_after_eq(end_time, jiffies));
 	}
 __reset_ready:
 
diff -urpN 2.6.13-rc2-kj/sound/pci/ali5451/ali5451.c 2.6.13-rc2-kj-dev/sound/pci/ali5451/ali5451.c
--- 2.6.13-rc2-kj/sound/pci/ali5451/ali5451.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/ali5451/ali5451.c	2005-07-08 12:28:38.000000000 -0700
@@ -399,7 +399,7 @@ static int snd_ali_codec_ready(	ali_t *c
 	unsigned long end_time;
 	unsigned int res;
 	
-	end_time = jiffies + 10 * (HZ >> 2);
+	end_time = jiffies + 10 * msecs_to_jiffies(250);
 	do {
 		res = snd_ali_5451_peek(codec,port);
 		if (! (res & 0x8000))
@@ -422,7 +422,7 @@ static int snd_ali_stimer_ready(ali_t *c
 	dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER);
 	dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
 
-	end_time = jiffies + 10 * (HZ >> 2);
+	end_time = jiffies + 10 * msecs_to_jiffies(250);
 	do {
 		dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
 		if (dwChk2 != dwChk1)
diff -urpN 2.6.13-rc2-kj/sound/pci/cs46xx/cs46xx_lib.c 2.6.13-rc2-kj-dev/sound/pci/cs46xx/cs46xx_lib.c
--- 2.6.13-rc2-kj/sound/pci/cs46xx/cs46xx_lib.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/cs46xx/cs46xx_lib.c	2005-07-06 22:04:35.000000000 -0700
@@ -2400,8 +2400,7 @@ static void snd_cs46xx_codec_reset (ac97
 		if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05)
 			return;
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/100);
+		msleep(10);
 	} while (time_after_eq(end_time, jiffies));
 
 	snd_printk("CS46xx secondary codec dont respond!\n");  
@@ -2435,8 +2434,7 @@ static int __devinit cs46xx_detect_codec
 			err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[codec]);
 			return err;
 		}
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/100);
+		msleep(10);
 	}
 	snd_printdd("snd_cs46xx: codec %d detection timeout\n", codec);
 	return -ENXIO;
@@ -3018,8 +3016,7 @@ static int snd_cs46xx_chip_init(cs46xx_t
 	/*
          *  Wait until the PLL has stabilized.
 	 */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ/10); /* 100ms */
+	msleep(100);
 
 	/*
 	 *  Turn on clocking of the core so that we can setup the serial ports.
@@ -3072,8 +3069,7 @@ static int snd_cs46xx_chip_init(cs46xx_t
 		 */
 		if (snd_cs46xx_peekBA0(chip, BA0_ACSTS) & ACSTS_CRDY)
 			goto ok1;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((HZ+99)/100);
+		msleep(10);
 	}
 
 
@@ -3122,8 +3118,7 @@ static int snd_cs46xx_chip_init(cs46xx_t
 		 */
 		if ((snd_cs46xx_peekBA0(chip, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) == (ACISV_ISV3 | ACISV_ISV4))
 			goto ok2;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((HZ+99)/100);
+		msleep(10);
 	}
 
 #ifndef CONFIG_SND_CS46XX_NEW_DSP
diff -urpN 2.6.13-rc2-kj/sound/pci/ens1370.c 2.6.13-rc2-kj-dev/sound/pci/ens1370.c
--- 2.6.13-rc2-kj/sound/pci/ens1370.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/ens1370.c	2005-07-06 22:05:18.000000000 -0700
@@ -2008,21 +2008,11 @@ static int __devinit snd_ensoniq_create(
 		if (pci->vendor == es1371_ac97_reset_hack[idx].vid &&
 		    pci->device == es1371_ac97_reset_hack[idx].did &&
 		    ensoniq->rev == es1371_ac97_reset_hack[idx].rev) {
-		        unsigned long tmo;
-			signed long tmo2;
-
 			ensoniq->cssr |= ES_1371_ST_AC97_RST;
 			outl(ensoniq->cssr, ES_REG(ensoniq, STATUS));
 			/* need to delay around 20ms(bleech) to give
 			some CODECs enough time to wakeup */
-			tmo = jiffies + (HZ / 50) + 1;
-			while (1) {
-				tmo2 = tmo - jiffies;
-				if (tmo2 <= 0)
-					break;
-				set_current_state(TASK_UNINTERRUPTIBLE);
-				schedule_timeout(tmo2);
-			}
+			msleep(20);
 			break;
 		}
 	/* AC'97 warm reset to start the bitclk */
diff -urpN 2.6.13-rc2-kj/sound/pci/es1968.c 2.6.13-rc2-kj-dev/sound/pci/es1968.c
--- 2.6.13-rc2-kj/sound/pci/es1968.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/es1968.c	2005-07-08 11:54:17.000000000 -0700
@@ -664,11 +664,6 @@ inline static u16 maestro_read(es1968_t 
 	return result;
 }
 
-#define big_mdelay(msec) do {\
-	set_current_state(TASK_UNINTERRUPTIBLE);\
-	schedule_timeout(((msec) * HZ + 999) / 1000);\
-} while (0)
-	
 /* Wait for the codec bus to be free */
 static int snd_es1968_ac97_wait(es1968_t *chip)
 {
@@ -1809,8 +1804,7 @@ static void __devinit es1968_measure_clo
 	snd_es1968_trigger_apu(chip, apu, ESM_APU_16BITLINEAR);
 	do_gettimeofday(&start_time);
 	spin_unlock_irq(&chip->reg_lock);
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ / 20); /* 50 msec */
+	msleep(50);
 	spin_lock_irq(&chip->reg_lock);
 	offset = __apu_get_register(chip, apu, 5);
 	do_gettimeofday(&stop_time);
@@ -2093,7 +2087,7 @@ static void snd_es1968_ac97_reset(es1968
 	outw(0x0000, ioaddr + 0x60);	/* write 0 to gpio 0 */
 	udelay(20);
 	outw(0x0001, ioaddr + 0x60);	/* write 1 to gpio 1 */
-	big_mdelay(20);
+	msleep(20);
 
 	outw(save_68 | 0x1, ioaddr + 0x68);	/* now restore .. */
 	outw((inw(ioaddr + 0x38) & 0xfffc) | 0x1, ioaddr + 0x38);
@@ -2109,7 +2103,7 @@ static void snd_es1968_ac97_reset(es1968
 	outw(0x0001, ioaddr + 0x60);	/* write 1 to gpio */
 	udelay(20);
 	outw(0x0009, ioaddr + 0x60);	/* write 9 to gpio */
-	big_mdelay(500);
+	msleep(500);
 	//outw(inw(ioaddr + 0x38) & 0xfffc, ioaddr + 0x38);
 	outw(inw(ioaddr + 0x3a) & 0xfffc, ioaddr + 0x3a);
 	outw(inw(ioaddr + 0x3c) & 0xfffc, ioaddr + 0x3c);
@@ -2135,7 +2129,7 @@ static void snd_es1968_ac97_reset(es1968
 
 		if (w > 10000) {
 			outb(inb(ioaddr + 0x37) | 0x08, ioaddr + 0x37);	/* do a software reset */
-			big_mdelay(500);	/* oh my.. */
+			msleep(500);	/* oh my.. */
 			outb(inb(ioaddr + 0x37) & ~0x08,
 				ioaddr + 0x37);
 			udelay(1);
diff -urpN 2.6.13-rc2-kj/sound/pci/intel8x0.c 2.6.13-rc2-kj-dev/sound/pci/intel8x0.c
--- 2.6.13-rc2-kj/sound/pci/intel8x0.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/intel8x0.c	2005-07-08 11:54:26.000000000 -0700
@@ -2451,8 +2451,7 @@ static void __devinit intel8x0_measure_a
 	}
 	do_gettimeofday(&start_time);
 	spin_unlock_irq(&chip->reg_lock);
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ / 20);
+	msleep(50);
 	spin_lock_irq(&chip->reg_lock);
 	/* check the position */
 	pos = ichdev->fragsize1;
diff -urpN 2.6.13-rc2-kj/sound/pci/maestro3.c 2.6.13-rc2-kj-dev/sound/pci/maestro3.c
--- 2.6.13-rc2-kj/sound/pci/maestro3.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/maestro3.c	2005-07-06 22:27:25.000000000 -0700
@@ -1050,11 +1050,6 @@ static struct m3_hv_quirk m3_hv_quirk_li
  * lowlevel functions
  */
 
-#define big_mdelay(msec) do {\
-	set_current_state(TASK_UNINTERRUPTIBLE);\
-	schedule_timeout(((msec) * HZ) / 1000);\
-} while (0)
-	
 inline static void snd_m3_outw(m3_t *chip, u16 value, unsigned long reg)
 {
 	outw(value, chip->iobase + reg);
@@ -1096,7 +1091,7 @@ static void snd_m3_assp_write(m3_t *chip
 static void snd_m3_assp_halt(m3_t *chip)
 {
 	chip->reset_state = snd_m3_inb(chip, DSP_PORT_CONTROL_REG_B) & ~REGB_STOP_CLOCK;
-	big_mdelay(10);
+	msleep(10);
 	snd_m3_outb(chip, chip->reset_state & ~REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B);
 }
 
@@ -2080,8 +2075,7 @@ static void snd_m3_ac97_reset(m3_t *chip
 		outw(0, io + GPIO_DATA);
 		outw(dir | GPO_PRIMARY_AC97, io + GPIO_DIRECTION);
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((delay1 * HZ) / 1000);
+		msleep(delay1);
 
 		outw(GPO_PRIMARY_AC97, io + GPIO_DATA);
 		udelay(5);
@@ -2089,8 +2083,7 @@ static void snd_m3_ac97_reset(m3_t *chip
 		outw(IO_SRAM_ENABLE | SERIAL_AC_LINK_ENABLE, io + RING_BUS_CTRL_A);
 		outw(~0, io + GPIO_MASK);
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((delay2 * HZ) / 1000);
+		msleep(delay2);
 
 		if (! snd_m3_try_read_vendor(chip))
 			break;
@@ -2108,9 +2101,9 @@ static void snd_m3_ac97_reset(m3_t *chip
 	 */
 	tmp = inw(io + RING_BUS_CTRL_A);
 	outw(RAC_SDFS_ENABLE|LAC_SDFS_ENABLE, io + RING_BUS_CTRL_A);
-	big_mdelay(20);
+	msleep(20);
 	outw(tmp, io + RING_BUS_CTRL_A);
-	big_mdelay(50);
+	msleep(50);
 #endif
 }
 
@@ -2135,8 +2128,7 @@ static int __devinit snd_m3_mixer(m3_t *
 
 	/* seems ac97 PCM needs initialization.. hack hack.. */
 	snd_ac97_write(chip->ac97, AC97_PCM, 0x8000 | (15 << 8) | 15);
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ / 10);
+	msleep(100);
 	snd_ac97_write(chip->ac97, AC97_PCM, 0);
 
 	memset(&id, 0, sizeof(id));
@@ -2589,7 +2581,7 @@ static int m3_suspend(snd_card_t *card, 
 	snd_pcm_suspend_all(chip->pcm);
 	snd_ac97_suspend(chip->ac97);
 
-	big_mdelay(10); /* give the assp a chance to idle.. */
+	msleep(10); /* give the assp a chance to idle.. */
 
 	snd_m3_assp_halt(chip);
 
diff -urpN 2.6.13-rc2-kj/sound/pci/mixart/mixart.c 2.6.13-rc2-kj-dev/sound/pci/mixart/mixart.c
--- 2.6.13-rc2-kj/sound/pci/mixart/mixart.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/mixart/mixart.c	2005-07-08 13:47:26.000000000 -0700
@@ -445,9 +445,9 @@ static int snd_mixart_trigger(snd_pcm_su
 
 static int mixart_sync_nonblock_events(mixart_mgr_t *mgr)
 {
-	int timeout = HZ;
+	unsigned long timeout = jiffies + HZ;
 	while (atomic_read(&mgr->msg_processed) > 0) {
-		if (! timeout--) {
+		if (time_after(jiffies, timeout)) {
 			snd_printk(KERN_ERR "mixart: cannot process nonblock events!\n");
 			return -EBUSY;
 		}
diff -urpN 2.6.13-rc2-kj/sound/pci/rme9652/hdsp.c 2.6.13-rc2-kj-dev/sound/pci/rme9652/hdsp.c
--- 2.6.13-rc2-kj/sound/pci/rme9652/hdsp.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/rme9652/hdsp.c	2005-07-06 22:55:11.000000000 -0700
@@ -678,8 +678,7 @@ static int snd_hdsp_load_firmware_from_c
 		}
 
 		if ((1000 / HZ) < 3000) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout((3000 * HZ + 999) / 1000);
+			ssleep(3);
 		} else {
 			mdelay(3000);
 		}
@@ -5036,8 +5035,7 @@ static int __devinit snd_hdsp_create(snd
 	if (!is_9652 && !is_9632) {
 		/* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */
  		if ((1000 / HZ) < 2000) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout((2000 * HZ + 999) / 1000);
+			ssleep(2);
 		} else {
 			mdelay(2000);
 		}
diff -urpN 2.6.13-rc2-kj/sound/pci/trident/trident_main.c 2.6.13-rc2-kj-dev/sound/pci/trident/trident_main.c
--- 2.6.13-rc2-kj/sound/pci/trident/trident_main.c	2005-07-06 07:57:08.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/trident/trident_main.c	2005-07-06 22:55:36.000000000 -0700
@@ -3152,8 +3152,7 @@ static int snd_trident_gameport_open(str
 	switch (mode) {
 		case GAMEPORT_MODE_COOKED:
 			outb(GAMEPORT_MODE_ADC, TRID_REG(chip, GAMEPORT_GCR));
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1 + 20 * HZ / 1000); /* 20msec */
+			msleep(20);
 			return 0;
 		case GAMEPORT_MODE_RAW:
 			outb(0, TRID_REG(chip, GAMEPORT_GCR));
diff -urpN 2.6.13-rc2-kj/sound/pci/via82xx.c 2.6.13-rc2-kj-dev/sound/pci/via82xx.c
--- 2.6.13-rc2-kj/sound/pci/via82xx.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/via82xx.c	2005-07-08 12:30:59.000000000 -0700
@@ -547,8 +547,7 @@ static void snd_via82xx_codec_wait(ac97_
 	int err;
 	err = snd_via82xx_codec_ready(chip, ac97->num);
 	/* here we need to wait fairly for long time.. */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ/2);
+	msleep(500);
 }
 
 static void snd_via82xx_codec_write(ac97_t *ac97,
@@ -1847,7 +1846,7 @@ static void __devinit snd_via82xx_proc_i
 static int snd_via82xx_chip_init(via82xx_t *chip)
 {
 	unsigned int val;
-	int max_count;
+	unsigned long end_time;
 	unsigned char pval;
 
 #if 0 /* broken on K7M? */
@@ -1889,14 +1888,14 @@ static int snd_via82xx_chip_init(via82xx
 	}
 
 	/* wait until codec ready */
-	max_count = ((3 * HZ) / 4) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	do {
 		pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
 		if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
 			break;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--max_count > 0);
+	} while (time_before(jiffies, end_time));
 
 	if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
 		snd_printk("AC'97 codec is not ready [0x%x]\n", val);
@@ -1905,7 +1904,7 @@ static int snd_via82xx_chip_init(via82xx
 	snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
 				 VIA_REG_AC97_SECONDARY_VALID |
 				 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
-	max_count = ((3 * HZ) / 4) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
 				 VIA_REG_AC97_SECONDARY_VALID |
 				 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
@@ -1916,7 +1915,7 @@ static int snd_via82xx_chip_init(via82xx
 		}
 		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--max_count > 0);
+	} while (time_before(jiffies, end_time));
 	/* This is ok, the most of motherboards have only one codec */
 
       __ac97_ok2:
diff -urpN 2.6.13-rc2-kj/sound/pci/via82xx_modem.c 2.6.13-rc2-kj-dev/sound/pci/via82xx_modem.c
--- 2.6.13-rc2-kj/sound/pci/via82xx_modem.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/via82xx_modem.c	2005-07-08 12:32:09.000000000 -0700
@@ -408,8 +408,7 @@ static void snd_via82xx_codec_wait(ac97_
 	int err;
 	err = snd_via82xx_codec_ready(chip, ac97->num);
 	/* here we need to wait fairly for long time.. */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ/2);
+	msleep(500);
 }
 
 static void snd_via82xx_codec_write(ac97_t *ac97,
@@ -923,7 +922,7 @@ static void __devinit snd_via82xx_proc_i
 static int snd_via82xx_chip_init(via82xx_t *chip)
 {
 	unsigned int val;
-	int max_count;
+	unsigned long end_time;
 	unsigned char pval;
 
 	pci_read_config_byte(chip->pci, VIA_MC97_CTRL, &pval);
@@ -962,14 +961,14 @@ static int snd_via82xx_chip_init(via82xx
 	}
 
 	/* wait until codec ready */
-	max_count = ((3 * HZ) / 4) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	do {
 		pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
 		if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
 			break;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--max_count > 0);
+	} while (time_before(jiffies, end_time));
 
 	if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
 		snd_printk("AC'97 codec is not ready [0x%x]\n", val);
@@ -977,7 +976,7 @@ static int snd_via82xx_chip_init(via82xx
 	snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
 				 VIA_REG_AC97_SECONDARY_VALID |
 				 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
-	max_count = ((3 * HZ) / 4) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
 				 VIA_REG_AC97_SECONDARY_VALID |
 				 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
@@ -988,7 +987,7 @@ static int snd_via82xx_chip_init(via82xx
 		}
 		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--max_count > 0);
+	} while (time_before(jiffies, end_time));
 	/* This is ok, the most of motherboards have only one codec */
 
       __ac97_ok2:
diff -urpN 2.6.13-rc2-kj/sound/pci/ymfpci/ymfpci_main.c 2.6.13-rc2-kj-dev/sound/pci/ymfpci/ymfpci_main.c
--- 2.6.13-rc2-kj/sound/pci/ymfpci/ymfpci_main.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/ymfpci/ymfpci_main.c	2005-07-08 12:33:00.000000000 -0700
@@ -84,16 +84,16 @@ static inline void snd_ymfpci_writel(ymf
 
 static int snd_ymfpci_codec_ready(ymfpci_t *chip, int secondary)
 {
-	signed long end_time;
+	unsigned long end_time;
 	u32 reg = secondary ? YDSXGR_SECSTATUSADR : YDSXGR_PRISTATUSADR;
 	
-	end_time = (jiffies + ((3 * HZ) / 4)) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	do {
 		if ((snd_ymfpci_readw(chip, reg) & 0x8000) == 0)
 			return 0;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (end_time - (signed long)jiffies >= 0);
+	} while (time_before(jiffies, end_time));
 	snd_printk("codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg));
 	return -EBUSY;
 }


-------------------------------------------------------
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

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

* [PATCH 1/14] sound/pci: fix-up sleeping paths
@ 2005-07-09  0:03 ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:03 UTC (permalink / raw)
  To: perex, sailer, mulix, tiwai; +Cc: alsa-devel, linux-sound

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

Jaroslav, I realize that you are not the explicit maintainer for many of
these drivers, but I figured you would at least be able to {N,}ACK the
changes. I tried to add any Maintainers I could find to the recipient
list, and hope any I missed are on one of the two lists.  I'm sorry for
having put them into the same patchset, and if split patches would be
preferred, I can do that.

Description: Fix-up sleeping in sound/pci. These changes fall under the
following two categories:

	1) Replace schedule_timeout() with msleep() to guarantee the
	task delays as expected. This also involved replacing/removing
	custom sleep functions.
	2) Do not assume jiffies will only increment by one if you
	request a 1 jiffy sleep, i.e. use time_after/time_before in
	while loops.

Patch is compile-tested.

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

---

 ac97/ac97_codec.c      |   17 +++++++++--------
 ali5451/ali5451.c      |    4 ++--
 cs46xx/cs46xx_lib.c    |   15 +++++----------
 ens1370.c              |   12 +-----------
 es1968.c               |   14 ++++----------
 intel8x0.c             |    3 +--
 maestro3.c             |   22 +++++++---------------
 mixart/mixart.c        |    4 ++--
 rme9652/hdsp.c         |    6 ++----
 trident/trident_main.c |    3 +--
 via82xx.c              |   13 ++++++-------
 via82xx_modem.c        |   13 ++++++-------
 ymfpci/ymfpci_main.c   |    6 +++---
 13 files changed, 49 insertions(+), 83 deletions(-)

diff -urpN 2.6.13-rc2-kj/sound/pci/ac97/ac97_codec.c 2.6.13-rc2-kj-dev/sound/pci/ac97/ac97_codec.c
--- 2.6.13-rc2-kj/sound/pci/ac97/ac97_codec.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/ac97/ac97_codec.c	2005-07-08 12:27:19.000000000 -0700
@@ -2225,6 +2225,7 @@ void snd_ac97_restore_iec958(ac97_t *ac9
 void snd_ac97_resume(ac97_t *ac97)
 {
 	int i;
+	unsigned long end_time;
 
 	if (ac97->bus->ops->reset) {
 		ac97->bus->ops->reset(ac97);
@@ -2242,26 +2243,26 @@ void snd_ac97_resume(ac97_t *ac97)
 	snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]);
 	if (ac97_is_audio(ac97)) {
 		ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101);
-		for (i = HZ/10; i >= 0; i--) {
+		end_time = jiffies + msecs_to_jiffies(100);
+		do {
 			if (snd_ac97_read(ac97, AC97_MASTER) = 0x8101)
 				break;
 			set_current_state(TASK_UNINTERRUPTIBLE);
 			schedule_timeout(1);
-		}
+		} while (time_after_eq(end_time, jiffies));
 		/* FIXME: extra delay */
 		ac97->bus->ops->write(ac97, AC97_MASTER, 0x8000);
-		if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ/4);
-		}
+		if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000)
+			msleep(250);
 	} else {
-		for (i = HZ/10; i >= 0; i--) {
+		end_time = jiffies + msecs_to_jiffies(100);
+		do {
 			unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID);
 			if (val != 0xffff && (val & 1) != 0)
 				break;
 			set_current_state(TASK_UNINTERRUPTIBLE);
 			schedule_timeout(1);
-		}
+		} while (time_after_eq(end_time, jiffies));
 	}
 __reset_ready:
 
diff -urpN 2.6.13-rc2-kj/sound/pci/ali5451/ali5451.c 2.6.13-rc2-kj-dev/sound/pci/ali5451/ali5451.c
--- 2.6.13-rc2-kj/sound/pci/ali5451/ali5451.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/ali5451/ali5451.c	2005-07-08 12:28:38.000000000 -0700
@@ -399,7 +399,7 @@ static int snd_ali_codec_ready(	ali_t *c
 	unsigned long end_time;
 	unsigned int res;
 	
-	end_time = jiffies + 10 * (HZ >> 2);
+	end_time = jiffies + 10 * msecs_to_jiffies(250);
 	do {
 		res = snd_ali_5451_peek(codec,port);
 		if (! (res & 0x8000))
@@ -422,7 +422,7 @@ static int snd_ali_stimer_ready(ali_t *c
 	dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER);
 	dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
 
-	end_time = jiffies + 10 * (HZ >> 2);
+	end_time = jiffies + 10 * msecs_to_jiffies(250);
 	do {
 		dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
 		if (dwChk2 != dwChk1)
diff -urpN 2.6.13-rc2-kj/sound/pci/cs46xx/cs46xx_lib.c 2.6.13-rc2-kj-dev/sound/pci/cs46xx/cs46xx_lib.c
--- 2.6.13-rc2-kj/sound/pci/cs46xx/cs46xx_lib.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/cs46xx/cs46xx_lib.c	2005-07-06 22:04:35.000000000 -0700
@@ -2400,8 +2400,7 @@ static void snd_cs46xx_codec_reset (ac97
 		if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) = 0x8a05)
 			return;
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ/100);
+		msleep(10);
 	} while (time_after_eq(end_time, jiffies));
 
 	snd_printk("CS46xx secondary codec dont respond!\n");  
@@ -2435,8 +2434,7 @@ static int __devinit cs46xx_detect_codec
 			err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97[codec]);
 			return err;
 		}
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ/100);
+		msleep(10);
 	}
 	snd_printdd("snd_cs46xx: codec %d detection timeout\n", codec);
 	return -ENXIO;
@@ -3018,8 +3016,7 @@ static int snd_cs46xx_chip_init(cs46xx_t
 	/*
          *  Wait until the PLL has stabilized.
 	 */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ/10); /* 100ms */
+	msleep(100);
 
 	/*
 	 *  Turn on clocking of the core so that we can setup the serial ports.
@@ -3072,8 +3069,7 @@ static int snd_cs46xx_chip_init(cs46xx_t
 		 */
 		if (snd_cs46xx_peekBA0(chip, BA0_ACSTS) & ACSTS_CRDY)
 			goto ok1;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((HZ+99)/100);
+		msleep(10);
 	}
 
 
@@ -3122,8 +3118,7 @@ static int snd_cs46xx_chip_init(cs46xx_t
 		 */
 		if ((snd_cs46xx_peekBA0(chip, BA0_ACISV) & (ACISV_ISV3 | ACISV_ISV4)) = (ACISV_ISV3 | ACISV_ISV4))
 			goto ok2;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((HZ+99)/100);
+		msleep(10);
 	}
 
 #ifndef CONFIG_SND_CS46XX_NEW_DSP
diff -urpN 2.6.13-rc2-kj/sound/pci/ens1370.c 2.6.13-rc2-kj-dev/sound/pci/ens1370.c
--- 2.6.13-rc2-kj/sound/pci/ens1370.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/ens1370.c	2005-07-06 22:05:18.000000000 -0700
@@ -2008,21 +2008,11 @@ static int __devinit snd_ensoniq_create(
 		if (pci->vendor = es1371_ac97_reset_hack[idx].vid &&
 		    pci->device = es1371_ac97_reset_hack[idx].did &&
 		    ensoniq->rev = es1371_ac97_reset_hack[idx].rev) {
-		        unsigned long tmo;
-			signed long tmo2;
-
 			ensoniq->cssr |= ES_1371_ST_AC97_RST;
 			outl(ensoniq->cssr, ES_REG(ensoniq, STATUS));
 			/* need to delay around 20ms(bleech) to give
 			some CODECs enough time to wakeup */
-			tmo = jiffies + (HZ / 50) + 1;
-			while (1) {
-				tmo2 = tmo - jiffies;
-				if (tmo2 <= 0)
-					break;
-				set_current_state(TASK_UNINTERRUPTIBLE);
-				schedule_timeout(tmo2);
-			}
+			msleep(20);
 			break;
 		}
 	/* AC'97 warm reset to start the bitclk */
diff -urpN 2.6.13-rc2-kj/sound/pci/es1968.c 2.6.13-rc2-kj-dev/sound/pci/es1968.c
--- 2.6.13-rc2-kj/sound/pci/es1968.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/es1968.c	2005-07-08 11:54:17.000000000 -0700
@@ -664,11 +664,6 @@ inline static u16 maestro_read(es1968_t 
 	return result;
 }
 
-#define big_mdelay(msec) do {\
-	set_current_state(TASK_UNINTERRUPTIBLE);\
-	schedule_timeout(((msec) * HZ + 999) / 1000);\
-} while (0)
-	
 /* Wait for the codec bus to be free */
 static int snd_es1968_ac97_wait(es1968_t *chip)
 {
@@ -1809,8 +1804,7 @@ static void __devinit es1968_measure_clo
 	snd_es1968_trigger_apu(chip, apu, ESM_APU_16BITLINEAR);
 	do_gettimeofday(&start_time);
 	spin_unlock_irq(&chip->reg_lock);
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ / 20); /* 50 msec */
+	msleep(50);
 	spin_lock_irq(&chip->reg_lock);
 	offset = __apu_get_register(chip, apu, 5);
 	do_gettimeofday(&stop_time);
@@ -2093,7 +2087,7 @@ static void snd_es1968_ac97_reset(es1968
 	outw(0x0000, ioaddr + 0x60);	/* write 0 to gpio 0 */
 	udelay(20);
 	outw(0x0001, ioaddr + 0x60);	/* write 1 to gpio 1 */
-	big_mdelay(20);
+	msleep(20);
 
 	outw(save_68 | 0x1, ioaddr + 0x68);	/* now restore .. */
 	outw((inw(ioaddr + 0x38) & 0xfffc) | 0x1, ioaddr + 0x38);
@@ -2109,7 +2103,7 @@ static void snd_es1968_ac97_reset(es1968
 	outw(0x0001, ioaddr + 0x60);	/* write 1 to gpio */
 	udelay(20);
 	outw(0x0009, ioaddr + 0x60);	/* write 9 to gpio */
-	big_mdelay(500);
+	msleep(500);
 	//outw(inw(ioaddr + 0x38) & 0xfffc, ioaddr + 0x38);
 	outw(inw(ioaddr + 0x3a) & 0xfffc, ioaddr + 0x3a);
 	outw(inw(ioaddr + 0x3c) & 0xfffc, ioaddr + 0x3c);
@@ -2135,7 +2129,7 @@ static void snd_es1968_ac97_reset(es1968
 
 		if (w > 10000) {
 			outb(inb(ioaddr + 0x37) | 0x08, ioaddr + 0x37);	/* do a software reset */
-			big_mdelay(500);	/* oh my.. */
+			msleep(500);	/* oh my.. */
 			outb(inb(ioaddr + 0x37) & ~0x08,
 				ioaddr + 0x37);
 			udelay(1);
diff -urpN 2.6.13-rc2-kj/sound/pci/intel8x0.c 2.6.13-rc2-kj-dev/sound/pci/intel8x0.c
--- 2.6.13-rc2-kj/sound/pci/intel8x0.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/intel8x0.c	2005-07-08 11:54:26.000000000 -0700
@@ -2451,8 +2451,7 @@ static void __devinit intel8x0_measure_a
 	}
 	do_gettimeofday(&start_time);
 	spin_unlock_irq(&chip->reg_lock);
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ / 20);
+	msleep(50);
 	spin_lock_irq(&chip->reg_lock);
 	/* check the position */
 	pos = ichdev->fragsize1;
diff -urpN 2.6.13-rc2-kj/sound/pci/maestro3.c 2.6.13-rc2-kj-dev/sound/pci/maestro3.c
--- 2.6.13-rc2-kj/sound/pci/maestro3.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/maestro3.c	2005-07-06 22:27:25.000000000 -0700
@@ -1050,11 +1050,6 @@ static struct m3_hv_quirk m3_hv_quirk_li
  * lowlevel functions
  */
 
-#define big_mdelay(msec) do {\
-	set_current_state(TASK_UNINTERRUPTIBLE);\
-	schedule_timeout(((msec) * HZ) / 1000);\
-} while (0)
-	
 inline static void snd_m3_outw(m3_t *chip, u16 value, unsigned long reg)
 {
 	outw(value, chip->iobase + reg);
@@ -1096,7 +1091,7 @@ static void snd_m3_assp_write(m3_t *chip
 static void snd_m3_assp_halt(m3_t *chip)
 {
 	chip->reset_state = snd_m3_inb(chip, DSP_PORT_CONTROL_REG_B) & ~REGB_STOP_CLOCK;
-	big_mdelay(10);
+	msleep(10);
 	snd_m3_outb(chip, chip->reset_state & ~REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B);
 }
 
@@ -2080,8 +2075,7 @@ static void snd_m3_ac97_reset(m3_t *chip
 		outw(0, io + GPIO_DATA);
 		outw(dir | GPO_PRIMARY_AC97, io + GPIO_DIRECTION);
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((delay1 * HZ) / 1000);
+		msleep(delay1);
 
 		outw(GPO_PRIMARY_AC97, io + GPIO_DATA);
 		udelay(5);
@@ -2089,8 +2083,7 @@ static void snd_m3_ac97_reset(m3_t *chip
 		outw(IO_SRAM_ENABLE | SERIAL_AC_LINK_ENABLE, io + RING_BUS_CTRL_A);
 		outw(~0, io + GPIO_MASK);
 
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout((delay2 * HZ) / 1000);
+		msleep(delay2);
 
 		if (! snd_m3_try_read_vendor(chip))
 			break;
@@ -2108,9 +2101,9 @@ static void snd_m3_ac97_reset(m3_t *chip
 	 */
 	tmp = inw(io + RING_BUS_CTRL_A);
 	outw(RAC_SDFS_ENABLE|LAC_SDFS_ENABLE, io + RING_BUS_CTRL_A);
-	big_mdelay(20);
+	msleep(20);
 	outw(tmp, io + RING_BUS_CTRL_A);
-	big_mdelay(50);
+	msleep(50);
 #endif
 }
 
@@ -2135,8 +2128,7 @@ static int __devinit snd_m3_mixer(m3_t *
 
 	/* seems ac97 PCM needs initialization.. hack hack.. */
 	snd_ac97_write(chip->ac97, AC97_PCM, 0x8000 | (15 << 8) | 15);
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ / 10);
+	msleep(100);
 	snd_ac97_write(chip->ac97, AC97_PCM, 0);
 
 	memset(&id, 0, sizeof(id));
@@ -2589,7 +2581,7 @@ static int m3_suspend(snd_card_t *card, 
 	snd_pcm_suspend_all(chip->pcm);
 	snd_ac97_suspend(chip->ac97);
 
-	big_mdelay(10); /* give the assp a chance to idle.. */
+	msleep(10); /* give the assp a chance to idle.. */
 
 	snd_m3_assp_halt(chip);
 
diff -urpN 2.6.13-rc2-kj/sound/pci/mixart/mixart.c 2.6.13-rc2-kj-dev/sound/pci/mixart/mixart.c
--- 2.6.13-rc2-kj/sound/pci/mixart/mixart.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/mixart/mixart.c	2005-07-08 13:47:26.000000000 -0700
@@ -445,9 +445,9 @@ static int snd_mixart_trigger(snd_pcm_su
 
 static int mixart_sync_nonblock_events(mixart_mgr_t *mgr)
 {
-	int timeout = HZ;
+	unsigned long timeout = jiffies + HZ;
 	while (atomic_read(&mgr->msg_processed) > 0) {
-		if (! timeout--) {
+		if (time_after(jiffies, timeout)) {
 			snd_printk(KERN_ERR "mixart: cannot process nonblock events!\n");
 			return -EBUSY;
 		}
diff -urpN 2.6.13-rc2-kj/sound/pci/rme9652/hdsp.c 2.6.13-rc2-kj-dev/sound/pci/rme9652/hdsp.c
--- 2.6.13-rc2-kj/sound/pci/rme9652/hdsp.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/rme9652/hdsp.c	2005-07-06 22:55:11.000000000 -0700
@@ -678,8 +678,7 @@ static int snd_hdsp_load_firmware_from_c
 		}
 
 		if ((1000 / HZ) < 3000) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout((3000 * HZ + 999) / 1000);
+			ssleep(3);
 		} else {
 			mdelay(3000);
 		}
@@ -5036,8 +5035,7 @@ static int __devinit snd_hdsp_create(snd
 	if (!is_9652 && !is_9632) {
 		/* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */
  		if ((1000 / HZ) < 2000) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout((2000 * HZ + 999) / 1000);
+			ssleep(2);
 		} else {
 			mdelay(2000);
 		}
diff -urpN 2.6.13-rc2-kj/sound/pci/trident/trident_main.c 2.6.13-rc2-kj-dev/sound/pci/trident/trident_main.c
--- 2.6.13-rc2-kj/sound/pci/trident/trident_main.c	2005-07-06 07:57:08.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/trident/trident_main.c	2005-07-06 22:55:36.000000000 -0700
@@ -3152,8 +3152,7 @@ static int snd_trident_gameport_open(str
 	switch (mode) {
 		case GAMEPORT_MODE_COOKED:
 			outb(GAMEPORT_MODE_ADC, TRID_REG(chip, GAMEPORT_GCR));
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(1 + 20 * HZ / 1000); /* 20msec */
+			msleep(20);
 			return 0;
 		case GAMEPORT_MODE_RAW:
 			outb(0, TRID_REG(chip, GAMEPORT_GCR));
diff -urpN 2.6.13-rc2-kj/sound/pci/via82xx.c 2.6.13-rc2-kj-dev/sound/pci/via82xx.c
--- 2.6.13-rc2-kj/sound/pci/via82xx.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/via82xx.c	2005-07-08 12:30:59.000000000 -0700
@@ -547,8 +547,7 @@ static void snd_via82xx_codec_wait(ac97_
 	int err;
 	err = snd_via82xx_codec_ready(chip, ac97->num);
 	/* here we need to wait fairly for long time.. */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ/2);
+	msleep(500);
 }
 
 static void snd_via82xx_codec_write(ac97_t *ac97,
@@ -1847,7 +1846,7 @@ static void __devinit snd_via82xx_proc_i
 static int snd_via82xx_chip_init(via82xx_t *chip)
 {
 	unsigned int val;
-	int max_count;
+	unsigned long end_time;
 	unsigned char pval;
 
 #if 0 /* broken on K7M? */
@@ -1889,14 +1888,14 @@ static int snd_via82xx_chip_init(via82xx
 	}
 
 	/* wait until codec ready */
-	max_count = ((3 * HZ) / 4) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	do {
 		pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
 		if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
 			break;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--max_count > 0);
+	} while (time_before(jiffies, end_time));
 
 	if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
 		snd_printk("AC'97 codec is not ready [0x%x]\n", val);
@@ -1905,7 +1904,7 @@ static int snd_via82xx_chip_init(via82xx
 	snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
 				 VIA_REG_AC97_SECONDARY_VALID |
 				 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
-	max_count = ((3 * HZ) / 4) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
 				 VIA_REG_AC97_SECONDARY_VALID |
 				 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
@@ -1916,7 +1915,7 @@ static int snd_via82xx_chip_init(via82xx
 		}
 		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--max_count > 0);
+	} while (time_before(jiffies, end_time));
 	/* This is ok, the most of motherboards have only one codec */
 
       __ac97_ok2:
diff -urpN 2.6.13-rc2-kj/sound/pci/via82xx_modem.c 2.6.13-rc2-kj-dev/sound/pci/via82xx_modem.c
--- 2.6.13-rc2-kj/sound/pci/via82xx_modem.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/via82xx_modem.c	2005-07-08 12:32:09.000000000 -0700
@@ -408,8 +408,7 @@ static void snd_via82xx_codec_wait(ac97_
 	int err;
 	err = snd_via82xx_codec_ready(chip, ac97->num);
 	/* here we need to wait fairly for long time.. */
-	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(HZ/2);
+	msleep(500);
 }
 
 static void snd_via82xx_codec_write(ac97_t *ac97,
@@ -923,7 +922,7 @@ static void __devinit snd_via82xx_proc_i
 static int snd_via82xx_chip_init(via82xx_t *chip)
 {
 	unsigned int val;
-	int max_count;
+	unsigned long end_time;
 	unsigned char pval;
 
 	pci_read_config_byte(chip->pci, VIA_MC97_CTRL, &pval);
@@ -962,14 +961,14 @@ static int snd_via82xx_chip_init(via82xx
 	}
 
 	/* wait until codec ready */
-	max_count = ((3 * HZ) / 4) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	do {
 		pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
 		if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
 			break;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--max_count > 0);
+	} while (time_before(jiffies, end_time));
 
 	if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
 		snd_printk("AC'97 codec is not ready [0x%x]\n", val);
@@ -977,7 +976,7 @@ static int snd_via82xx_chip_init(via82xx
 	snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
 				 VIA_REG_AC97_SECONDARY_VALID |
 				 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
-	max_count = ((3 * HZ) / 4) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
 				 VIA_REG_AC97_SECONDARY_VALID |
 				 (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT));
@@ -988,7 +987,7 @@ static int snd_via82xx_chip_init(via82xx
 		}
 		set_current_state(TASK_INTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (--max_count > 0);
+	} while (time_before(jiffies, end_time));
 	/* This is ok, the most of motherboards have only one codec */
 
       __ac97_ok2:
diff -urpN 2.6.13-rc2-kj/sound/pci/ymfpci/ymfpci_main.c 2.6.13-rc2-kj-dev/sound/pci/ymfpci/ymfpci_main.c
--- 2.6.13-rc2-kj/sound/pci/ymfpci/ymfpci_main.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/pci/ymfpci/ymfpci_main.c	2005-07-08 12:33:00.000000000 -0700
@@ -84,16 +84,16 @@ static inline void snd_ymfpci_writel(ymf
 
 static int snd_ymfpci_codec_ready(ymfpci_t *chip, int secondary)
 {
-	signed long end_time;
+	unsigned long end_time;
 	u32 reg = secondary ? YDSXGR_SECSTATUSADR : YDSXGR_PRISTATUSADR;
 	
-	end_time = (jiffies + ((3 * HZ) / 4)) + 1;
+	end_time = jiffies + msecs_to_jiffies(750);
 	do {
 		if ((snd_ymfpci_readw(chip, reg) & 0x8000) = 0)
 			return 0;
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(1);
-	} while (end_time - (signed long)jiffies >= 0);
+	} while (time_before(jiffies, end_time));
 	snd_printk("codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg));
 	return -EBUSY;
 }

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

* [PATCH 2/14] sound/ppc: fix-up sleeping paths
  2005-07-09  0:03 ` Nishanth Aravamudan
@ 2005-07-09  0:04   ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:04 UTC (permalink / raw)
  To: perex; +Cc: alsa-devel, linux-sound

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 ppc-specific sound
drivers. If you would prefer split patches instead of the large
patchset, I can do that.

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

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

---

 awacs.c   |    6 +++---
 pmac.h    |    5 -----
 tumbler.c |   16 ++++++++--------
 3 files changed, 11 insertions(+), 16 deletions(-)

diff -urpN 2.6.13-rc2-kj/sound/ppc/awacs.c 2.6.13-rc2-kj-dev/sound/ppc/awacs.c
--- 2.6.13-rc2-kj/sound/ppc/awacs.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/ppc/awacs.c	2005-07-06 22:26:24.000000000 -0700
@@ -103,7 +103,7 @@ static void screamer_recalibrate(pmac_t 
 	snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]);
 	if (chip->manufacturer == 0x1)
 		/* delay for broken crystal part */
-		big_mdelay(750);
+		msleep(750);
 	snd_pmac_awacs_write_noreg(chip, 1,
 				   chip->awacs_reg[1] | MASK_RECALIBRATE | MASK_CMUTE | MASK_AMUTE);
 	snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]);
@@ -653,10 +653,10 @@ static void snd_pmac_awacs_resume(pmac_t
 {
 	if (machine_is_compatible("PowerBook3,1")
 	    || machine_is_compatible("PowerBook3,2")) {
-		big_mdelay(100);
+		msleep(100);
 		snd_pmac_awacs_write_reg(chip, 1,
 			chip->awacs_reg[1] & ~MASK_PAROUT);
-		big_mdelay(300);
+		msleep(300);
 	}
 
 	awacs_restore_all_regs(chip);
diff -urpN 2.6.13-rc2-kj/sound/ppc/pmac.h 2.6.13-rc2-kj-dev/sound/ppc/pmac.h
--- 2.6.13-rc2-kj/sound/ppc/pmac.h	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/ppc/pmac.h	2005-07-06 22:25:57.000000000 -0700
@@ -212,9 +212,4 @@ int snd_pmac_boolean_mono_info(snd_kcont
 
 int snd_pmac_add_automute(pmac_t *chip);
 
-#define big_mdelay(msec) do {\
-	set_current_state(TASK_UNINTERRUPTIBLE);\
-	schedule_timeout(((msec) * HZ + 999) / 1000);\
-} while (0)
-
 #endif /* __PMAC_H */
diff -urpN 2.6.13-rc2-kj/sound/ppc/tumbler.c 2.6.13-rc2-kj-dev/sound/ppc/tumbler.c
--- 2.6.13-rc2-kj/sound/ppc/tumbler.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/ppc/tumbler.c	2005-07-06 22:26:47.000000000 -0700
@@ -945,7 +945,7 @@ static void device_change_handler(void *
 			check_mute(chip, &mix->line_mute, 0, mix->auto_mute_notify,
 				   chip->lineout_sw_ctl);
 		if (mix->anded_reset)
-			big_mdelay(10);
+			msleep(10);
 		check_mute(chip, &mix->amp_mute, 1, mix->auto_mute_notify,
 			   chip->speaker_sw_ctl);
 		mix->drc_enable = 0;
@@ -954,7 +954,7 @@ static void device_change_handler(void *
 		check_mute(chip, &mix->amp_mute, 0, mix->auto_mute_notify,
 			   chip->speaker_sw_ctl);
 		if (mix->anded_reset)
-			big_mdelay(10);
+			msleep(10);
 		check_mute(chip, &mix->hp_mute, 1, mix->auto_mute_notify,
 			   chip->master_sw_ctl);
 		if (mix->line_mute.addr != 0)
@@ -1109,22 +1109,22 @@ static void tumbler_reset_audio(pmac_t *
 		DBG("(I) codec anded reset !\n");
 		write_audio_gpio(&mix->hp_mute, 0);
 		write_audio_gpio(&mix->amp_mute, 0);
-		big_mdelay(200);
+		msleep(200);
 		write_audio_gpio(&mix->hp_mute, 1);
 		write_audio_gpio(&mix->amp_mute, 1);
-		big_mdelay(100);
+		msleep(100);
 		write_audio_gpio(&mix->hp_mute, 0);
 		write_audio_gpio(&mix->amp_mute, 0);
-		big_mdelay(100);
+		msleep(100);
 	} else {
 		DBG("(I) codec normal reset !\n");
 
 		write_audio_gpio(&mix->audio_reset, 0);
-		big_mdelay(200);
+		msleep(200);
 		write_audio_gpio(&mix->audio_reset, 1);
-		big_mdelay(100);
+		msleep(100);
 		write_audio_gpio(&mix->audio_reset, 0);
-		big_mdelay(100);
+		msleep(100);
 	}
 }


-------------------------------------------------------
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

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

* [PATCH 2/14] sound/ppc: fix-up sleeping paths
@ 2005-07-09  0:04   ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:04 UTC (permalink / raw)
  To: perex; +Cc: alsa-devel, linux-sound

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 ppc-specific sound
drivers. If you would prefer split patches instead of the large
patchset, I can do that.

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

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

---

 awacs.c   |    6 +++---
 pmac.h    |    5 -----
 tumbler.c |   16 ++++++++--------
 3 files changed, 11 insertions(+), 16 deletions(-)

diff -urpN 2.6.13-rc2-kj/sound/ppc/awacs.c 2.6.13-rc2-kj-dev/sound/ppc/awacs.c
--- 2.6.13-rc2-kj/sound/ppc/awacs.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/ppc/awacs.c	2005-07-06 22:26:24.000000000 -0700
@@ -103,7 +103,7 @@ static void screamer_recalibrate(pmac_t 
 	snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]);
 	if (chip->manufacturer = 0x1)
 		/* delay for broken crystal part */
-		big_mdelay(750);
+		msleep(750);
 	snd_pmac_awacs_write_noreg(chip, 1,
 				   chip->awacs_reg[1] | MASK_RECALIBRATE | MASK_CMUTE | MASK_AMUTE);
 	snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]);
@@ -653,10 +653,10 @@ static void snd_pmac_awacs_resume(pmac_t
 {
 	if (machine_is_compatible("PowerBook3,1")
 	    || machine_is_compatible("PowerBook3,2")) {
-		big_mdelay(100);
+		msleep(100);
 		snd_pmac_awacs_write_reg(chip, 1,
 			chip->awacs_reg[1] & ~MASK_PAROUT);
-		big_mdelay(300);
+		msleep(300);
 	}
 
 	awacs_restore_all_regs(chip);
diff -urpN 2.6.13-rc2-kj/sound/ppc/pmac.h 2.6.13-rc2-kj-dev/sound/ppc/pmac.h
--- 2.6.13-rc2-kj/sound/ppc/pmac.h	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/ppc/pmac.h	2005-07-06 22:25:57.000000000 -0700
@@ -212,9 +212,4 @@ int snd_pmac_boolean_mono_info(snd_kcont
 
 int snd_pmac_add_automute(pmac_t *chip);
 
-#define big_mdelay(msec) do {\
-	set_current_state(TASK_UNINTERRUPTIBLE);\
-	schedule_timeout(((msec) * HZ + 999) / 1000);\
-} while (0)
-
 #endif /* __PMAC_H */
diff -urpN 2.6.13-rc2-kj/sound/ppc/tumbler.c 2.6.13-rc2-kj-dev/sound/ppc/tumbler.c
--- 2.6.13-rc2-kj/sound/ppc/tumbler.c	2005-07-06 07:57:20.000000000 -0700
+++ 2.6.13-rc2-kj-dev/sound/ppc/tumbler.c	2005-07-06 22:26:47.000000000 -0700
@@ -945,7 +945,7 @@ static void device_change_handler(void *
 			check_mute(chip, &mix->line_mute, 0, mix->auto_mute_notify,
 				   chip->lineout_sw_ctl);
 		if (mix->anded_reset)
-			big_mdelay(10);
+			msleep(10);
 		check_mute(chip, &mix->amp_mute, 1, mix->auto_mute_notify,
 			   chip->speaker_sw_ctl);
 		mix->drc_enable = 0;
@@ -954,7 +954,7 @@ static void device_change_handler(void *
 		check_mute(chip, &mix->amp_mute, 0, mix->auto_mute_notify,
 			   chip->speaker_sw_ctl);
 		if (mix->anded_reset)
-			big_mdelay(10);
+			msleep(10);
 		check_mute(chip, &mix->hp_mute, 1, mix->auto_mute_notify,
 			   chip->master_sw_ctl);
 		if (mix->line_mute.addr != 0)
@@ -1109,22 +1109,22 @@ static void tumbler_reset_audio(pmac_t *
 		DBG("(I) codec anded reset !\n");
 		write_audio_gpio(&mix->hp_mute, 0);
 		write_audio_gpio(&mix->amp_mute, 0);
-		big_mdelay(200);
+		msleep(200);
 		write_audio_gpio(&mix->hp_mute, 1);
 		write_audio_gpio(&mix->amp_mute, 1);
-		big_mdelay(100);
+		msleep(100);
 		write_audio_gpio(&mix->hp_mute, 0);
 		write_audio_gpio(&mix->amp_mute, 0);
-		big_mdelay(100);
+		msleep(100);
 	} else {
 		DBG("(I) codec normal reset !\n");
 
 		write_audio_gpio(&mix->audio_reset, 0);
-		big_mdelay(200);
+		msleep(200);
 		write_audio_gpio(&mix->audio_reset, 1);
-		big_mdelay(100);
+		msleep(100);
 		write_audio_gpio(&mix->audio_reset, 0);
-		big_mdelay(100);
+		msleep(100);
 	}
 }

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

* [PATCH 3/14] sound/usb: fix-up sleeping paths
  2005-07-09  0:03 ` Nishanth Aravamudan
@ 2005-07-09  0:04   ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:04 UTC (permalink / raw)
  To: perex; +Cc: alsa-devel, linux-sound

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

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

* [PATCH 3/14] sound/usb: fix-up sleeping paths
@ 2005-07-09  0:04   ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:04 UTC (permalink / raw)
  To: perex; +Cc: alsa-devel, linux-sound

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;
 				}

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

* Re: [PATCH 1/14] sound/pci: fix-up sleeping paths
  2005-07-09  0:03 ` Nishanth Aravamudan
                   ` (2 preceding siblings ...)
  (?)
@ 2005-07-09  0:06 ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:06 UTC (permalink / raw)
  To: perex, sailer, mulix, tiwai; +Cc: alsa-devel, linux-sound, Kernel-Janitors

On 08.07.2005 [17:03:24 -0700], Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>

<snip>

> Description: Fix-up sleeping in sound/pci. These changes fall under the
> following two categories:

Very sorry, forgot to CC: kernel-janitors.

Thanks,
Nish


-------------------------------------------------------
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

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

* [KJ] Re: [PATCH 1/14] sound/pci: fix-up sleeping paths
  2005-07-09  0:03 ` Nishanth Aravamudan
@ 2005-07-09  0:06 ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:06 UTC (permalink / raw)
  To: kernel-janitors

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

On 08.07.2005 [17:03:24 -0700], Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>

<snip>

> Description: Fix-up sleeping in sound/pci. These changes fall under the
> following two categories:

Very sorry, forgot to CC: kernel-janitors.

Thanks,
Nish

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [PATCH 1/14] sound/pci: fix-up sleeping paths
@ 2005-07-09  0:06 ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:06 UTC (permalink / raw)
  To: kernel-janitors

On 08.07.2005 [17:03:24 -0700], Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>

<snip>

> Description: Fix-up sleeping in sound/pci. These changes fall under the
> following two categories:

Very sorry, forgot to CC: kernel-janitors.

Thanks,
Nish

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

* Re: [PATCH 2/14] sound/ppc: fix-up sleeping paths
  2005-07-09  0:04   ` Nishanth Aravamudan
  (?)
@ 2005-07-09  0:07   ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:07 UTC (permalink / raw)
  To: perex; +Cc: alsa-devel, linux-sound, Kernel-Janitors

On 08.07.2005 [17:04:05 -0700], Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>

<snip>

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

Forgot to CC: Kernel-Janitors.

Thanks,
Nish


-------------------------------------------------------
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

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

* [KJ] Re: [PATCH 2/14] sound/ppc: fix-up sleeping paths
  2005-07-09  0:04   ` Nishanth Aravamudan
@ 2005-07-09  0:07 ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:07 UTC (permalink / raw)
  To: kernel-janitors

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

On 08.07.2005 [17:04:05 -0700], Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>

<snip>

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

Forgot to CC: Kernel-Janitors.

Thanks,
Nish

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [PATCH 2/14] sound/ppc: fix-up sleeping paths
@ 2005-07-09  0:07 ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:07 UTC (permalink / raw)
  To: kernel-janitors

On 08.07.2005 [17:04:05 -0700], Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>

<snip>

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

Forgot to CC: Kernel-Janitors.

Thanks,
Nish

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

* Re: [PATCH 3/14] sound/usb: fix-up sleeping paths
  2005-07-09  0:04   ` Nishanth Aravamudan
  (?)
@ 2005-07-09  0:08   ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:08 UTC (permalink / raw)
  To: perex; +Cc: alsa-devel, linux-sound, Kernel-Janitors

On 08.07.2005 [17:04:39 -0700], Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>

<snip>

> 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.

Sorry, forgot to CC: Kernel-Janitors.

Thanks,
Nish


-------------------------------------------------------
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

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

* [KJ] Re: [PATCH 3/14] sound/usb: fix-up sleeping paths
  2005-07-09  0:04   ` Nishanth Aravamudan
@ 2005-07-09  0:08 ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:08 UTC (permalink / raw)
  To: kernel-janitors

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

On 08.07.2005 [17:04:39 -0700], Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>

<snip>

> 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.

Sorry, forgot to CC: Kernel-Janitors.

Thanks,
Nish

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [PATCH 3/14] sound/usb: fix-up sleeping paths
@ 2005-07-09  0:08 ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:08 UTC (permalink / raw)
  To: kernel-janitors

On 08.07.2005 [17:04:39 -0700], Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>

<snip>

> 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.

Sorry, forgot to CC: Kernel-Janitors.

Thanks,
Nish

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

* [KJ] [PATCH 7/14] mips: replace timespectojiffies() with
  2005-07-09  0:03 ` Nishanth Aravamudan
@ 2005-07-09  0:11   ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:11 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips, Kernel-Janitors

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

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

Description: Replace custom timespectojiffies() function with generic
standard one.

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

---

 irixsig.c |   14 +-------------
 1 files changed, 1 insertion(+), 13 deletions(-)

diff -urp 2.6.13-rc2-kj/arch/mips/kernel/irixsig.c 2.6.13-rc2-kj-dev/arch/mips/kernel/irixsig.c
--- 2.6.13-rc2-kj/arch/mips/kernel/irixsig.c	2005-07-06 07:57:02.000000000 -0700
+++ 2.6.13-rc2-kj-dev/arch/mips/kernel/irixsig.c	2005-07-06 13:30:34.000000000 -0700
@@ -441,18 +441,6 @@ struct irix5_siginfo {
 	} stuff;
 };
 
-static inline unsigned long timespectojiffies(struct timespec *value)
-{
-	unsigned long sec = (unsigned) value->tv_sec;
-	long nsec = value->tv_nsec;
-
-	if (sec > (LONG_MAX / HZ))
-		return LONG_MAX;
-	nsec += 1000000000L / HZ - 1;
-	nsec /= 1000000000L / HZ;
-	return HZ * sec + nsec;
-}
-
 asmlinkage int irix_sigpoll_sys(unsigned long *set, struct irix5_siginfo *info,
 				struct timespec *tp)
 {
@@ -490,7 +478,7 @@ asmlinkage int irix_sigpoll_sys(unsigned
 			error = -EINVAL;
 			goto out;
 		}
-		expire = timespectojiffies(tp)+(tp->tv_sec||tp->tv_nsec);
+		expire = timespec_to_jiffies(tp)+(tp->tv_sec||tp->tv_nsec);
 	}
 
 	while(1) {

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [PATCH 7/14] mips: replace timespectojiffies() with timespec_to_jiffies()
@ 2005-07-09  0:11   ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:11 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips, Kernel-Janitors

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

Description: Replace custom timespectojiffies() function with generic
standard one.

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

---

 irixsig.c |   14 +-------------
 1 files changed, 1 insertion(+), 13 deletions(-)

diff -urp 2.6.13-rc2-kj/arch/mips/kernel/irixsig.c 2.6.13-rc2-kj-dev/arch/mips/kernel/irixsig.c
--- 2.6.13-rc2-kj/arch/mips/kernel/irixsig.c	2005-07-06 07:57:02.000000000 -0700
+++ 2.6.13-rc2-kj-dev/arch/mips/kernel/irixsig.c	2005-07-06 13:30:34.000000000 -0700
@@ -441,18 +441,6 @@ struct irix5_siginfo {
 	} stuff;
 };
 
-static inline unsigned long timespectojiffies(struct timespec *value)
-{
-	unsigned long sec = (unsigned) value->tv_sec;
-	long nsec = value->tv_nsec;
-
-	if (sec > (LONG_MAX / HZ))
-		return LONG_MAX;
-	nsec += 1000000000L / HZ - 1;
-	nsec /= 1000000000L / HZ;
-	return HZ * sec + nsec;
-}
-
 asmlinkage int irix_sigpoll_sys(unsigned long *set, struct irix5_siginfo *info,
 				struct timespec *tp)
 {
@@ -490,7 +478,7 @@ asmlinkage int irix_sigpoll_sys(unsigned
 			error = -EINVAL;
 			goto out;
 		}
-		expire = timespectojiffies(tp)+(tp->tv_sec||tp->tv_nsec);
+		expire = timespec_to_jiffies(tp)+(tp->tv_sec||tp->tv_nsec);
 	}
 
 	while(1) {

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

* [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of
  2005-07-09  0:03 ` Nishanth Aravamudan
@ 2005-07-09  0:14   ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:14 UTC (permalink / raw)
  To: James.Bottomley; +Cc: Kernel-Janitors, linux-scsi

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

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

Description: Replace schedule_timeout() with msleep() to guarantee the
task delays as expected.

Patch is compile-tested.

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

---

 lpfc_scsi.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff -urp 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c
--- 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 07:57:19.000000000 -0700
+++ 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 19:20:41.000000000 -0700
@@ -24,6 +24,7 @@
 
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_device.h>
@@ -885,8 +886,7 @@ __lpfc_abort_handler(struct scsi_cmnd *c
 		while (cmnd->host_scribble)
 		{
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(LPFC_ABORT_WAIT*HZ);
+			msleep(LPFC_ABORT_WAIT * 1000);
 			spin_lock_irq(phba->host->host_lock);
 			if (++loop_count
 			    > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT)
@@ -952,8 +952,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 
 		if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout( HZ/2);
+			msleep(500);
 			spin_lock_irq(phba->host->host_lock);
 		}
 		if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE))
@@ -1011,8 +1010,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 				       cmnd->device->id, cmnd->device->lun,
 				       LPFC_CTX_LUN))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		msleep(LPFC_RESET_WAIT * 1000);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt
@@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
 				&phba->sli.ring[phba->sli.fcp_ring],
 				0, 0, LPFC_CTX_HOST))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		msleep(LPFC_RESET_WAIT * HZ);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of schedule_timeout()
@ 2005-07-09  0:14   ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:14 UTC (permalink / raw)
  To: James.Bottomley; +Cc: Kernel-Janitors, linux-scsi

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

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

Description: Replace schedule_timeout() with msleep() to guarantee the
task delays as expected.

Patch is compile-tested.

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

---

 lpfc_scsi.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff -urp 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c
--- 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 07:57:19.000000000 -0700
+++ 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 19:20:41.000000000 -0700
@@ -24,6 +24,7 @@
 
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_device.h>
@@ -885,8 +886,7 @@ __lpfc_abort_handler(struct scsi_cmnd *c
 		while (cmnd->host_scribble)
 		{
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(LPFC_ABORT_WAIT*HZ);
+			msleep(LPFC_ABORT_WAIT * 1000);
 			spin_lock_irq(phba->host->host_lock);
 			if (++loop_count
 			    > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT)
@@ -952,8 +952,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 
 		if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout( HZ/2);
+			msleep(500);
 			spin_lock_irq(phba->host->host_lock);
 		}
 		if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE))
@@ -1011,8 +1010,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 				       cmnd->device->id, cmnd->device->lun,
 				       LPFC_CTX_LUN))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		msleep(LPFC_RESET_WAIT * 1000);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt
@@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
 				&phba->sli.ring[phba->sli.fcp_ring],
 				0, 0, LPFC_CTX_HOST))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		msleep(LPFC_RESET_WAIT * HZ);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] [PATCH 12/14] scsi/osst: use msleep() instead of
  2005-07-09  0:03 ` Nishanth Aravamudan
@ 2005-07-09  0:15   ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:15 UTC (permalink / raw)
  To: osst; +Cc: Kernel-Janitors, linux-scsi

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

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

Description: Replace schedule_timeout() with msleep() to guarantee the
task delays as expected.

Patch is compile-tested.

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

---

 osst.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff -urp 2.6.13-rc2-kj/drivers/scsi/osst.c 2.6.13-rc2-kj-dev/drivers/scsi/osst.c
--- 2.6.13-rc2-kj/drivers/scsi/osst.c	2005-07-06 07:57:19.000000000 -0700
+++ 2.6.13-rc2-kj-dev/drivers/scsi/osst.c	2005-07-06 19:21:03.000000000 -0700
@@ -862,8 +862,7 @@ static int osst_recover_wait_frame(struc
 				retval = osst_write_error_recovery(STp, aSRpnt, 0);
 				break;
 			}
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout (HZ / OSST_POLL_PER_SEC);
+			msleep(1000 / OSST_POLL_PER_SEC);
 
 			STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24;
 			memset(cmd, 0, MAX_COMMAND_SIZE);
@@ -1558,8 +1557,7 @@ static int osst_reposition_and_retry(str
 			osst_set_frame_position(STp, aSRpnt, frame + skip, 1);
 			flag = 0;
 			attempts--;
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(HZ / 10);
+			msleep(100);
 		}
 		if (osst_get_frame_position(STp, aSRpnt) < 0) {		/* additional write error */
 #if DEBUG
@@ -1620,8 +1618,7 @@ static int osst_reposition_and_retry(str
 			debugging = 0;
 		}
 #endif
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ / 10);
+		msleep(100);
 	}
 	printk(KERN_ERR "%s:E: Failed to find valid tape media\n", name);
 #if DEBUG

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] [PATCH 12/14] scsi/osst: use msleep() instead of schedule_timeout()
@ 2005-07-09  0:15   ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:15 UTC (permalink / raw)
  To: osst; +Cc: Kernel-Janitors, linux-scsi

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

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

Description: Replace schedule_timeout() with msleep() to guarantee the
task delays as expected.

Patch is compile-tested.

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

---

 osst.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff -urp 2.6.13-rc2-kj/drivers/scsi/osst.c 2.6.13-rc2-kj-dev/drivers/scsi/osst.c
--- 2.6.13-rc2-kj/drivers/scsi/osst.c	2005-07-06 07:57:19.000000000 -0700
+++ 2.6.13-rc2-kj-dev/drivers/scsi/osst.c	2005-07-06 19:21:03.000000000 -0700
@@ -862,8 +862,7 @@ static int osst_recover_wait_frame(struc
 				retval = osst_write_error_recovery(STp, aSRpnt, 0);
 				break;
 			}
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout (HZ / OSST_POLL_PER_SEC);
+			msleep(1000 / OSST_POLL_PER_SEC);
 
 			STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24;
 			memset(cmd, 0, MAX_COMMAND_SIZE);
@@ -1558,8 +1557,7 @@ static int osst_reposition_and_retry(str
 			osst_set_frame_position(STp, aSRpnt, frame + skip, 1);
 			flag = 0;
 			attempts--;
-			set_current_state(TASK_INTERRUPTIBLE);
-			schedule_timeout(HZ / 10);
+			msleep(100);
 		}
 		if (osst_get_frame_position(STp, aSRpnt) < 0) {		/* additional write error */
 #if DEBUG
@@ -1620,8 +1618,7 @@ static int osst_reposition_and_retry(str
 			debugging = 0;
 		}
 #endif
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ / 10);
+		msleep(100);
 	}
 	printk(KERN_ERR "%s:E: Failed to find valid tape media\n", name);
 #if DEBUG

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] [PATCH 13/14] scsi/qla2xxx: use msleep{,
  2005-07-09  0:03 ` Nishanth Aravamudan
@ 2005-07-09  0:16   ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:16 UTC (permalink / raw)
  To: andrew.vasquez; +Cc: Kernel-Janitors, linux-scsi

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

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

Description: Replace schedule_timeout() with
msleep()/msleep_interruptible() as appropriate, to guarantee the task
delays as expected.

Patch is compile-tested.

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

---

 qla_os.c |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff -urp 2.6.13-rc2-kj/drivers/scsi/qla2xxx/qla_os.c 2.6.13-rc2-kj-dev/drivers/scsi/qla2xxx/qla_os.c
--- 2.6.13-rc2-kj/drivers/scsi/qla2xxx/qla_os.c	2005-07-08 13:01:12.000000000 -0700
+++ 2.6.13-rc2-kj-dev/drivers/scsi/qla2xxx/qla_os.c	2005-07-06 19:27:01.000000000 -0700
@@ -347,14 +347,13 @@ qc_fail_command:
 static int
 qla2x00_eh_wait_on_command(scsi_qla_host_t *ha, struct scsi_cmnd *cmd)
 {
-#define ABORT_POLLING_PERIOD	HZ
-#define ABORT_WAIT_ITER		((10 * HZ) / (ABORT_POLLING_PERIOD))
+#define ABORT_POLLING_PERIOD	1000
+#define ABORT_WAIT_ITER		((10 * 1000) / (ABORT_POLLING_PERIOD))
 	unsigned long wait_iter = ABORT_WAIT_ITER;
 	int ret = QLA_SUCCESS;
 
 	while (CMD_SP(cmd)) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(ABORT_POLLING_PERIOD);
+		msleep(ABORT_POLLING_PERIOD);
 
 		if (--wait_iter)
 			break;
@@ -1693,7 +1692,7 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
 {
 	struct list_head	*fcpl, *fcptemp;
 	fc_port_t	*fcport;
-	unsigned long	wtime;/* max wait time if mbx cmd is busy. */
+	unsigned int	wtime;/* max wait time if mbx cmd is busy. */
 
 	if (ha == NULL) {
 		/* error */
@@ -1702,11 +1701,9 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
 	}
 
 	/* Make sure all other threads are stopped. */
-	wtime = 60 * HZ;
-	while (ha->dpc_wait && wtime) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		wtime = schedule_timeout(wtime);
-	}
+	wtime = 60 * 1000;
+	while (ha->dpc_wait && wtime)
+		wtime = msleep_interruptible(wtime);
 
 	/* free ioctl memory */
 	qla2x00_free_ioctl_mem(ha);
@@ -2250,15 +2247,15 @@ qla2x00_timer(scsi_qla_host_t *ha)
 int
 qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout)
 {
-	const unsigned int step = HZ/10;
+	const unsigned int step = 100; /* msecs */
+	unsigned int iterations = jiffies_to_msecs(timeout)/100;
 
 	do {
 		if (!down_trylock(sema))
 			return 0;
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (schedule_timeout(step))
+		if (msleep_interruptible(step))
 			break;
-	} while ((timeout -= step) > 0);
+	} while (--iterations >= 0);
 
 	return -ETIMEDOUT;
 }

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] [PATCH 13/14] scsi/qla2xxx: use msleep{, interruptible}() instead of schedule_timeout()
@ 2005-07-09  0:16   ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-09  0:16 UTC (permalink / raw)
  To: andrew.vasquez; +Cc: Kernel-Janitors, linux-scsi

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

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

Description: Replace schedule_timeout() with
msleep()/msleep_interruptible() as appropriate, to guarantee the task
delays as expected.

Patch is compile-tested.

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

---

 qla_os.c |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff -urp 2.6.13-rc2-kj/drivers/scsi/qla2xxx/qla_os.c 2.6.13-rc2-kj-dev/drivers/scsi/qla2xxx/qla_os.c
--- 2.6.13-rc2-kj/drivers/scsi/qla2xxx/qla_os.c	2005-07-08 13:01:12.000000000 -0700
+++ 2.6.13-rc2-kj-dev/drivers/scsi/qla2xxx/qla_os.c	2005-07-06 19:27:01.000000000 -0700
@@ -347,14 +347,13 @@ qc_fail_command:
 static int
 qla2x00_eh_wait_on_command(scsi_qla_host_t *ha, struct scsi_cmnd *cmd)
 {
-#define ABORT_POLLING_PERIOD	HZ
-#define ABORT_WAIT_ITER		((10 * HZ) / (ABORT_POLLING_PERIOD))
+#define ABORT_POLLING_PERIOD	1000
+#define ABORT_WAIT_ITER		((10 * 1000) / (ABORT_POLLING_PERIOD))
 	unsigned long wait_iter = ABORT_WAIT_ITER;
 	int ret = QLA_SUCCESS;
 
 	while (CMD_SP(cmd)) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(ABORT_POLLING_PERIOD);
+		msleep(ABORT_POLLING_PERIOD);
 
 		if (--wait_iter)
 			break;
@@ -1693,7 +1692,7 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
 {
 	struct list_head	*fcpl, *fcptemp;
 	fc_port_t	*fcport;
-	unsigned long	wtime;/* max wait time if mbx cmd is busy. */
+	unsigned int	wtime;/* max wait time if mbx cmd is busy. */
 
 	if (ha == NULL) {
 		/* error */
@@ -1702,11 +1701,9 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
 	}
 
 	/* Make sure all other threads are stopped. */
-	wtime = 60 * HZ;
-	while (ha->dpc_wait && wtime) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		wtime = schedule_timeout(wtime);
-	}
+	wtime = 60 * 1000;
+	while (ha->dpc_wait && wtime)
+		wtime = msleep_interruptible(wtime);
 
 	/* free ioctl memory */
 	qla2x00_free_ioctl_mem(ha);
@@ -2250,15 +2247,15 @@ qla2x00_timer(scsi_qla_host_t *ha)
 int
 qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout)
 {
-	const unsigned int step = HZ/10;
+	const unsigned int step = 100; /* msecs */
+	unsigned int iterations = jiffies_to_msecs(timeout)/100;
 
 	do {
 		if (!down_trylock(sema))
 			return 0;
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (schedule_timeout(step))
+		if (msleep_interruptible(step))
 			break;
-	} while ((timeout -= step) > 0);
+	} while (--iterations >= 0);
 
 	return -ETIMEDOUT;
 }

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of
  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     ` Domen Puncer
  -1 siblings, 0 replies; 29+ messages in thread
From: Domen Puncer @ 2005-07-10 16:20 UTC (permalink / raw)
  To: Nishanth Aravamudan; +Cc: James.Bottomley, Kernel-Janitors, linux-scsi

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

On 08/07/05 17:14 -0700, Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>
> 
> Description: Replace schedule_timeout() with msleep() to guarantee the
> task delays as expected.
> 
> Patch is compile-tested.
> 
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> 
> ---
> 
>  lpfc_scsi.c |   13 +++++--------
>  1 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff -urp 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c
> --- 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 07:57:19.000000000 -0700
> +++ 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 19:20:41.000000000 -0700
...
> @@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
>  				&phba->sli.ring[phba->sli.fcp_ring],
>  				0, 0, LPFC_CTX_HOST))) {
>  		spin_unlock_irq(phba->host->host_lock);
> -		set_current_state(TASK_UNINTERRUPTIBLE);
> -		schedule_timeout(LPFC_RESET_WAIT*HZ);
> +		msleep(LPFC_RESET_WAIT * HZ);

					^^ ??
I assume you meant 1000.

>  		spin_lock_irq(phba->host->host_lock);
>  
>  		if (++loopcnt

> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors


[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of schedule_timeout()
@ 2005-07-10 16:20     ` Domen Puncer
  0 siblings, 0 replies; 29+ messages in thread
From: Domen Puncer @ 2005-07-10 16:20 UTC (permalink / raw)
  To: Nishanth Aravamudan; +Cc: James.Bottomley, Kernel-Janitors, linux-scsi

On 08/07/05 17:14 -0700, Nishanth Aravamudan wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>
> 
> Description: Replace schedule_timeout() with msleep() to guarantee the
> task delays as expected.
> 
> Patch is compile-tested.
> 
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> 
> ---
> 
>  lpfc_scsi.c |   13 +++++--------
>  1 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff -urp 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c
> --- 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 07:57:19.000000000 -0700
> +++ 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 19:20:41.000000000 -0700
...
> @@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
>  				&phba->sli.ring[phba->sli.fcp_ring],
>  				0, 0, LPFC_CTX_HOST))) {
>  		spin_unlock_irq(phba->host->host_lock);
> -		set_current_state(TASK_UNINTERRUPTIBLE);
> -		schedule_timeout(LPFC_RESET_WAIT*HZ);
> +		msleep(LPFC_RESET_WAIT * HZ);

					^^ ??
I assume you meant 1000.

>  		spin_lock_irq(phba->host->host_lock);
>  
>  		if (++loopcnt

> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors


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

* Re: [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of
  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       ` Nishanth Aravamudan
  -1 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-11  5:38 UTC (permalink / raw)
  To: Domen Puncer; +Cc: James.Bottomley, Kernel-Janitors, linux-scsi

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

On 10.07.2005 [18:20:10 +0200], Domen Puncer wrote:
> On 08/07/05 17:14 -0700, Nishanth Aravamudan wrote:
> > From: Nishanth Aravamudan <nacc@us.ibm.com>
> > 
> > Description: Replace schedule_timeout() with msleep() to guarantee the
> > task delays as expected.
> > 
> > Patch is compile-tested.
> > 
> > Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> > 
> > ---
> > 
> >  lpfc_scsi.c |   13 +++++--------
> >  1 files changed, 5 insertions(+), 8 deletions(-)
> > 
> > diff -urp 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c
> > --- 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 07:57:19.000000000 -0700
> > +++ 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 19:20:41.000000000 -0700
> ...
> > @@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
> >  				&phba->sli.ring[phba->sli.fcp_ring],
> >  				0, 0, LPFC_CTX_HOST))) {
> >  		spin_unlock_irq(phba->host->host_lock);
> > -		set_current_state(TASK_UNINTERRUPTIBLE);
> > -		schedule_timeout(LPFC_RESET_WAIT*HZ);
> > +		msleep(LPFC_RESET_WAIT * HZ);
> 
> 					^^ ??
> I assume you meant 1000.

Gah! You are right. Fixed below. Thanks, Domen!

-Nish

Description: Replace schedule_timeout() with msleep() to guarantee the
task delays as expected.

Patch is compile-tested.

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

---

 lpfc_scsi.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff -urp 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c
--- 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 07:57:19.000000000 -0700
+++ 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 19:20:41.000000000 -0700
@@ -24,6 +24,7 @@
 
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_device.h>
@@ -885,8 +886,7 @@ __lpfc_abort_handler(struct scsi_cmnd *c
 		while (cmnd->host_scribble)
 		{
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(LPFC_ABORT_WAIT*HZ);
+			msleep(LPFC_ABORT_WAIT * 1000);
 			spin_lock_irq(phba->host->host_lock);
 			if (++loop_count
 			    > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT)
@@ -952,8 +952,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 
 		if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout( HZ/2);
+			msleep(500);
 			spin_lock_irq(phba->host->host_lock);
 		}
 		if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE))
@@ -1011,8 +1010,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 				       cmnd->device->id, cmnd->device->lun,
 				       LPFC_CTX_LUN))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		msleep(LPFC_RESET_WAIT * 1000);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt
@@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
 				&phba->sli.ring[phba->sli.fcp_ring],
 				0, 0, LPFC_CTX_HOST))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		msleep(LPFC_RESET_WAIT * 1000);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH 11/14] scsi/lpfc_scsi: use msleep() instead of schedule_timeout()
@ 2005-07-11  5:38       ` Nishanth Aravamudan
  0 siblings, 0 replies; 29+ messages in thread
From: Nishanth Aravamudan @ 2005-07-11  5:38 UTC (permalink / raw)
  To: Domen Puncer; +Cc: James.Bottomley, Kernel-Janitors, linux-scsi

On 10.07.2005 [18:20:10 +0200], Domen Puncer wrote:
> On 08/07/05 17:14 -0700, Nishanth Aravamudan wrote:
> > From: Nishanth Aravamudan <nacc@us.ibm.com>
> > 
> > Description: Replace schedule_timeout() with msleep() to guarantee the
> > task delays as expected.
> > 
> > Patch is compile-tested.
> > 
> > Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> > 
> > ---
> > 
> >  lpfc_scsi.c |   13 +++++--------
> >  1 files changed, 5 insertions(+), 8 deletions(-)
> > 
> > diff -urp 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c
> > --- 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 07:57:19.000000000 -0700
> > +++ 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 19:20:41.000000000 -0700
> ...
> > @@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
> >  				&phba->sli.ring[phba->sli.fcp_ring],
> >  				0, 0, LPFC_CTX_HOST))) {
> >  		spin_unlock_irq(phba->host->host_lock);
> > -		set_current_state(TASK_UNINTERRUPTIBLE);
> > -		schedule_timeout(LPFC_RESET_WAIT*HZ);
> > +		msleep(LPFC_RESET_WAIT * HZ);
> 
> 					^^ ??
> I assume you meant 1000.

Gah! You are right. Fixed below. Thanks, Domen!

-Nish

Description: Replace schedule_timeout() with msleep() to guarantee the
task delays as expected.

Patch is compile-tested.

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

---

 lpfc_scsi.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff -urp 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c
--- 2.6.13-rc2-kj/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 07:57:19.000000000 -0700
+++ 2.6.13-rc2-kj-dev/drivers/scsi/lpfc/lpfc_scsi.c	2005-07-06 19:20:41.000000000 -0700
@@ -24,6 +24,7 @@
 
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_device.h>
@@ -885,8 +886,7 @@ __lpfc_abort_handler(struct scsi_cmnd *c
 		while (cmnd->host_scribble)
 		{
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(LPFC_ABORT_WAIT*HZ);
+			msleep(LPFC_ABORT_WAIT * 1000);
 			spin_lock_irq(phba->host->host_lock);
 			if (++loop_count
 			    > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT)
@@ -952,8 +952,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 
 		if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
 			spin_unlock_irq(phba->host->host_lock);
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout( HZ/2);
+			msleep(500);
 			spin_lock_irq(phba->host->host_lock);
 		}
 		if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE))
@@ -1011,8 +1010,7 @@ __lpfc_reset_lun_handler(struct scsi_cmn
 				       cmnd->device->id, cmnd->device->lun,
 				       LPFC_CTX_LUN))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		msleep(LPFC_RESET_WAIT * 1000);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt
@@ -1110,8 +1108,7 @@ __lpfc_reset_bus_handler(struct scsi_cmn
 				&phba->sli.ring[phba->sli.fcp_ring],
 				0, 0, LPFC_CTX_HOST))) {
 		spin_unlock_irq(phba->host->host_lock);
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(LPFC_RESET_WAIT*HZ);
+		msleep(LPFC_RESET_WAIT * 1000);
 		spin_lock_irq(phba->host->host_lock);
 
 		if (++loopcnt

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

* [KJ] Re: [PATCH 7/14] mips: replace timespectojiffies() with
  2005-07-09  0:11   ` [PATCH 7/14] mips: replace timespectojiffies() with timespec_to_jiffies() Nishanth Aravamudan
@ 2005-07-11 14:12     ` Ralf Baechle
  -1 siblings, 0 replies; 29+ messages in thread
From: Ralf Baechle @ 2005-07-11 14:12 UTC (permalink / raw)
  To: Nishanth Aravamudan; +Cc: linux-mips, Kernel-Janitors

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

On Fri, Jul 08, 2005 at 05:11:27PM -0700, Nishanth Aravamudan wrote:

> Description: Replace custom timespectojiffies() function with generic
> standard one.

Applied.  Thanks,

  Ralf

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [PATCH 7/14] mips: replace timespectojiffies() with timespec_to_jiffies()
@ 2005-07-11 14:12     ` Ralf Baechle
  0 siblings, 0 replies; 29+ messages in thread
From: Ralf Baechle @ 2005-07-11 14:12 UTC (permalink / raw)
  To: Nishanth Aravamudan; +Cc: linux-mips, Kernel-Janitors

On Fri, Jul 08, 2005 at 05:11:27PM -0700, Nishanth Aravamudan wrote:

> Description: Replace custom timespectojiffies() function with generic
> standard one.

Applied.  Thanks,

  Ralf

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

end of thread, other threads:[~2005-07-11 14:12 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 3/14] sound/usb: " Nishanth Aravamudan
2005-07-09  0:04   ` 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

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.