* [PATCH 1/13] use cpu_relax() in busy loop
@ 2003-09-18 23:25 Chris Wright
2003-09-18 23:27 ` [PATCH 2/13] " Chris Wright
0 siblings, 1 reply; 21+ messages in thread
From: Chris Wright @ 2003-09-18 23:25 UTC (permalink / raw)
To: linux-kernel; +Cc: rmk, torvalds
Replace busy loop barrier() with cpu_relax().
This is bordering on a gratuitous change given the arm def'n of
cpu_relax(). But I was fixing up other busy loops, and my grep found
this one.
===== drivers/scsi/arm/acornscsi.c 1.35 vs edited =====
--- 1.35/drivers/scsi/arm/acornscsi.c Mon Aug 25 06:37:34 2003
+++ edited/drivers/scsi/arm/acornscsi.c Thu Sep 18 11:48:26 2003
@@ -319,7 +319,7 @@
local_save_flags(flags);
local_irq_enable();
- while (time_before(jiffies, target_jiffies)) barrier();
+ while (time_before(jiffies, target_jiffies)) cpu_relax();
local_irq_restore(flags);
}
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 2/13] use cpu_relax() in busy loop 2003-09-18 23:25 [PATCH 1/13] use cpu_relax() in busy loop Chris Wright @ 2003-09-18 23:27 ` Chris Wright 2003-09-18 23:29 ` [PATCH 3/13] " Chris Wright 2003-09-19 7:33 ` [PATCH 2/13] " Arjan van de Ven 0 siblings, 2 replies; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:27 UTC (permalink / raw) To: linux-kernel; +Cc: chas, torvalds [PATCH 2/13] use cpu_relax() in busy loop Replace busy loop nop with cpu_relax(). ===== drivers/atm/fore200e.c 1.19 vs edited ===== --- 1.19/drivers/atm/fore200e.c Tue Sep 2 11:07:59 2003 +++ edited/drivers/atm/fore200e.c Thu Sep 18 10:42:17 2003 @@ -248,7 +248,8 @@ fore200e_spin(int msecs) { unsigned long timeout = jiffies + MSECS(msecs); - while (time_before(jiffies, timeout)); + while (time_before(jiffies, timeout)) + cpu_relax(); } ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 3/13] use cpu_relax() in busy loop 2003-09-18 23:27 ` [PATCH 2/13] " Chris Wright @ 2003-09-18 23:29 ` Chris Wright 2003-09-18 23:31 ` [PATCH 4/13] " Chris Wright 2003-09-19 7:33 ` [PATCH 2/13] " Arjan van de Ven 1 sibling, 1 reply; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:29 UTC (permalink / raw) To: linux-kernel; +Cc: torvalds Replace busy loop nop with cpu_relax(). ===== drivers/block/ps2esdi.c 1.69 vs edited ===== --- 1.69/drivers/block/ps2esdi.c Wed Sep 10 18:18:39 2003 +++ edited/drivers/block/ps2esdi.c Thu Sep 18 10:45:34 2003 @@ -550,7 +550,8 @@ printk("%s: hard reset...\n", DEVICE_NAME); outb_p(CTRL_HARD_RESET, ESDI_CONTROL); expire = jiffies + 2*HZ; - while (time_before(jiffies, expire)); + while (time_before(jiffies, expire)) + cpu_relax(); outb_p(1, ESDI_CONTROL); } /* hard reset */ ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 4/13] use cpu_relax() in busy loop 2003-09-18 23:29 ` [PATCH 3/13] " Chris Wright @ 2003-09-18 23:31 ` Chris Wright 2003-09-18 23:33 ` [PATCH 5/13] " Chris Wright 2003-09-19 7:34 ` [PATCH 4/13] " Arjan van de Ven 0 siblings, 2 replies; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:31 UTC (permalink / raw) To: linux-kernel; +Cc: torvalds Replace busy loop nop with cpu_relax(). ===== drivers/cdrom/sonycd535.c 1.39 vs edited ===== --- 1.39/drivers/cdrom/sonycd535.c Tue Sep 9 07:41:30 2003 +++ edited/drivers/cdrom/sonycd535.c Thu Sep 18 10:52:41 2003 @@ -1526,7 +1526,8 @@ enable_interrupts(); outb(0, read_status_reg); /* does a reset? */ delay = jiffies + HZ/10; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); sony535_irq_used = probe_irq_off(irq_mask); disable_interrupts(); ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 5/13] use cpu_relax() in busy loop 2003-09-18 23:31 ` [PATCH 4/13] " Chris Wright @ 2003-09-18 23:33 ` Chris Wright 2003-09-18 23:34 ` [PATCH 6/13] " Chris Wright 2003-09-19 7:34 ` [PATCH 4/13] " Arjan van de Ven 1 sibling, 1 reply; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:33 UTC (permalink / raw) To: linux-kernel; +Cc: torvalds Replace busy loop nop with cpu_relax(). ===== drivers/char/isicom.c 1.25 vs edited ===== --- 1.25/drivers/char/isicom.c Mon Aug 18 10:39:47 2003 +++ edited/drivers/char/isicom.c Thu Sep 18 10:54:12 2003 @@ -153,12 +153,14 @@ inw(base+0x8); - for(i=jiffies+HZ/100;time_before(jiffies, i);); + for(i=jiffies+HZ/100;time_before(jiffies, i);) + cpu_relax(); outw(0,base+0x8); /* Reset */ for(j=1;j<=3;j++) { - for(i=jiffies+HZ;time_before(jiffies, i);); + for(i=jiffies+HZ;time_before(jiffies, i);) + cpu_relax(); printk("."); } signature=(inw(base+0x4)) & 0xff; ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 6/13] use cpu_relax() in busy loop 2003-09-18 23:33 ` [PATCH 5/13] " Chris Wright @ 2003-09-18 23:34 ` Chris Wright 2003-09-18 23:35 ` [PATCH 7/13] " Chris Wright 0 siblings, 1 reply; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:34 UTC (permalink / raw) To: linux-kernel; +Cc: torvalds Replace busy loop nop with cpu_relax(). ===== drivers/char/moxa.c 1.25 vs edited ===== --- 1.25/drivers/char/moxa.c Mon Jun 23 18:43:58 2003 +++ edited/drivers/char/moxa.c Thu Sep 18 10:56:00 2003 @@ -2758,7 +2758,8 @@ st = jiffies; et = st + tick; - while (time_before(jiffies, et)); + while (time_before(jiffies, et)) + cpu_relax(); } static void moxafunc(unsigned long ofsAddr, int cmd, ushort arg) ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 7/13] use cpu_relax() in busy loop 2003-09-18 23:34 ` [PATCH 6/13] " Chris Wright @ 2003-09-18 23:35 ` Chris Wright 2003-09-18 23:36 ` [PATCH 8/13] " Chris Wright 2003-09-19 7:37 ` [PATCH 7/13] " Arjan van de Ven 0 siblings, 2 replies; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:35 UTC (permalink / raw) To: linux-kernel; +Cc: jgarzik, torvalds Replace busy loop nop with cpu_relax(). Jeff, here's a batch for net drivers. They all look pretty straight forward. ===== drivers/net/3c501.c 1.19 vs edited ===== --- 1.19/drivers/net/3c501.c Tue Aug 26 13:21:28 2003 +++ edited/drivers/net/3c501.c Thu Sep 18 11:30:18 2003 @@ -251,7 +251,8 @@ outb(0x00, AX_CMD); delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); autoirq = probe_irq_off(irq_mask); if (autoirq == 0) ===== drivers/net/3c505.c 1.25 vs edited ===== --- 1.25/drivers/net/3c505.c Tue Aug 26 13:29:32 2003 +++ edited/drivers/net/3c505.c Thu Sep 18 11:32:26 2003 @@ -299,16 +299,20 @@ } outb_control(adapter->hcr_val | ATTN | DIR, dev); timeout = jiffies + 1*HZ/100; - while (time_before_eq(jiffies, timeout)); + while (time_before_eq(jiffies, timeout)) + cpu_relax(); outb_control(adapter->hcr_val & ~ATTN, dev); timeout = jiffies + 1*HZ/100; - while (time_before_eq(jiffies, timeout)); + while (time_before_eq(jiffies, timeout)) + cpu_relax(); outb_control(adapter->hcr_val | FLSH, dev); timeout = jiffies + 1*HZ/100; - while (time_before_eq(jiffies, timeout)); + while (time_before_eq(jiffies, timeout)) + cpu_relax(); outb_control(adapter->hcr_val & ~FLSH, dev); timeout = jiffies + 1*HZ/100; - while (time_before_eq(jiffies, timeout)); + while (time_before_eq(jiffies, timeout)) + cpu_relax(); outb_control(orig_hcr, dev); if (!start_receive(dev, &adapter->tx_pcb)) ===== drivers/net/acenic.c 1.39 vs edited ===== --- 1.39/drivers/net/acenic.c Thu Sep 4 00:36:29 2003 +++ edited/drivers/net/acenic.c Thu Sep 18 11:33:14 2003 @@ -1757,7 +1757,8 @@ * Wait for the firmware to spin up - max 3 seconds. */ myjif = jiffies + 3 * HZ; - while (time_before(jiffies, myjif) && !ap->fw_running); + while (time_before(jiffies, myjif) && !ap->fw_running) + cpu_relax(); if (!ap->fw_running) { printk(KERN_ERR "%s: Firmware NOT running!\n", dev->name); ===== drivers/net/eepro.c 1.19 vs edited ===== --- 1.19/drivers/net/eepro.c Tue Jul 15 10:01:29 2003 +++ edited/drivers/net/eepro.c Thu Sep 18 11:33:52 2003 @@ -904,7 +904,8 @@ eepro_diag(ioaddr); /* RESET the 82595 */ delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); if (*irqp == probe_irq_off(irq_mask)) /* It's a good IRQ line */ break; ===== drivers/net/ewrk3.c 1.26 vs edited ===== --- 1.26/drivers/net/ewrk3.c Tue Aug 19 20:53:15 2003 +++ edited/drivers/net/ewrk3.c Thu Sep 18 11:34:50 2003 @@ -579,7 +579,8 @@ irqnum = irq[((icr & IRQ_SEL) >> 4)]; delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); dev->irq = probe_irq_off(irq_mask); if ((dev->irq) && (irqnum == dev->irq)) { printk(" and uses IRQ%d.\n", dev->irq); ===== drivers/net/lance.c 1.18 vs edited ===== --- 1.18/drivers/net/lance.c Sun Apr 20 22:41:09 2003 +++ edited/drivers/net/lance.c Thu Sep 18 11:37:30 2003 @@ -554,7 +554,8 @@ outw(0x0041, ioaddr+LANCE_DATA); delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); dev->irq = probe_irq_off(irq_mask); if (dev->irq) printk(", probed IRQ %d", dev->irq); @@ -627,7 +628,8 @@ outw(0x0041, ioaddr+LANCE_DATA); delay = jiffies + HZ/25; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); dev->irq = probe_irq_off(irq_mask); if (dev->irq == 0) { printk(" Failed to detect the 7990 IRQ line.\n"); ===== drivers/net/ni5010.c 1.11 vs edited ===== --- 1.11/drivers/net/ni5010.c Sun Aug 31 16:14:15 2003 +++ edited/drivers/net/ni5010.c Thu Sep 18 11:40:18 2003 @@ -262,7 +262,8 @@ irq_mask = probe_irq_on(); trigger_irq(ioaddr); delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); dev->irq = probe_irq_off(irq_mask); PRINTK2((KERN_DEBUG "%s: I/O #6 passed!\n", dev->name)); ===== drivers/net/ni52.c 1.11 vs edited ===== --- 1.11/drivers/net/ni52.c Sun Apr 20 23:00:41 2003 +++ edited/drivers/net/ni52.c Thu Sep 18 11:42:57 2003 @@ -499,7 +499,8 @@ ni_attn586(); delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); dev->irq = probe_irq_off(irq_mask); if(!dev->irq) { ===== drivers/net/rrunner.c 1.21 vs edited ===== --- 1.21/drivers/net/rrunner.c Tue Aug 19 20:53:16 2003 +++ edited/drivers/net/rrunner.c Thu Sep 18 11:44:53 2003 @@ -721,7 +721,8 @@ * Give the FirmWare time to chew on the `get running' command. */ myjif = jiffies + 5 * HZ; - while (time_before(jiffies, myjif) && !rrpriv->fw_running); + while (time_before(jiffies, myjif) && !rrpriv->fw_running) + cpu_relax(); netif_start_queue(dev); ===== drivers/net/wan/sbni.c 1.22 vs edited ===== --- 1.22/drivers/net/wan/sbni.c Thu Sep 4 00:40:48 2003 +++ edited/drivers/net/wan/sbni.c Thu Sep 18 11:29:36 2003 @@ -343,7 +343,8 @@ outb( EN_INT | TR_REQ, ioaddr + CSR0 ); outb( PR_RES, ioaddr + CSR1 ); delay = jiffies + HZ/20; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); irq = probe_irq_off(irq_mask); outb( 0, ioaddr + CSR0 ); ===== drivers/net/wd.c 1.12 vs edited ===== --- 1.12/drivers/net/wd.c Thu Nov 21 14:06:13 2002 +++ edited/drivers/net/wd.c Thu Sep 18 11:45:49 2003 @@ -249,7 +249,8 @@ outb_p(0x00, nic_addr + EN0_RCNTHI); outb(E8390_RREAD+E8390_START, nic_addr); /* Trigger it... */ delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + while (time_before(jiffies, delay)) + cpu_relax(); dev->irq = probe_irq_off(irq_mask); outb_p(0x00, nic_addr+EN0_IMR); /* Mask all intrs. again. */ ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 8/13] use cpu_relax() in busy loop 2003-09-18 23:35 ` [PATCH 7/13] " Chris Wright @ 2003-09-18 23:36 ` Chris Wright 2003-09-18 23:37 ` [PATCH 9/13] " Chris Wright 2003-09-19 7:37 ` [PATCH 7/13] " Arjan van de Ven 1 sibling, 1 reply; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:36 UTC (permalink / raw) To: linux-kernel; +Cc: torvalds Replace busy loop rep_nop() with cpu_relax(). This is bordering on a gratuitous change given the i386 def'n of cpu_relax(). But I was fixing up other busy loops, and my grep found this one. ===== arch/i386/kernel/smpboot.c 1.64 vs edited ===== --- 1.64/arch/i386/kernel/smpboot.c Mon Aug 18 19:46:23 2003 +++ edited/arch/i386/kernel/smpboot.c Thu Sep 18 10:07:18 2003 @@ -378,7 +378,7 @@ */ if (cpu_isset(cpuid, cpu_callout_map)) break; - rep_nop(); + cpu_relax(); } if (!time_before(jiffies, timeout)) { ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 9/13] use cpu_relax() in busy loop 2003-09-18 23:36 ` [PATCH 8/13] " Chris Wright @ 2003-09-18 23:37 ` Chris Wright 2003-09-18 23:40 ` [PATCH 10/13] " Chris Wright 2003-09-20 7:37 ` [PATCH 9/13] " David S. Miller 0 siblings, 2 replies; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:37 UTC (permalink / raw) To: linux-kernel; +Cc: davem, torvalds Replace busy loop nop with cpu_relax(). ===== net/ipv4/ipconfig.c 1.29 vs edited ===== --- 1.29/net/ipv4/ipconfig.c Fri Aug 15 00:41:43 2003 +++ edited/net/ipv4/ipconfig.c Thu Sep 18 11:57:00 2003 @@ -1153,7 +1153,7 @@ /* Give hardware a chance to settle */ jiff = jiffies + CONF_PRE_OPEN; while (time_before(jiffies, jiff)) - ; + cpu_relax(); /* Setup all network devices */ if (ic_open_devs() < 0) @@ -1162,7 +1162,7 @@ /* Give drivers a chance to settle */ jiff = jiffies + CONF_POST_OPEN; while (time_before(jiffies, jiff)) - ; + cpu_relax(); /* * If the config information is insufficient (e.g., our IP address or ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 10/13] use cpu_relax() in busy loop 2003-09-18 23:37 ` [PATCH 9/13] " Chris Wright @ 2003-09-18 23:40 ` Chris Wright 2003-09-18 23:41 ` [PATCH 11/13] " Chris Wright 2003-09-20 7:37 ` [PATCH 9/13] " David S. Miller 1 sibling, 1 reply; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:40 UTC (permalink / raw) To: linux-kernel; +Cc: kai.germaschewski, torvalds Replace busy loop nop with cpu_relax(). ===== drivers/isdn/hardware/avm/avmcard.h 1.17 vs edited ===== --- 1.17/drivers/isdn/hardware/avm/avmcard.h Wed Sep 3 03:09:05 2003 +++ edited/drivers/isdn/hardware/avm/avmcard.h Thu Sep 18 11:17:09 2003 @@ -233,7 +233,8 @@ static inline unsigned char b1_get_byte(unsigned int base) { unsigned long stop = jiffies + 1 * HZ; /* maximum wait time 1 sec */ - while (!b1_rx_full(base) && time_before(jiffies, stop)); + while (!b1_rx_full(base) && time_before(jiffies, stop)) + cpu_relax(); if (b1_rx_full(base)) return inb(base + B1_READ); printk(KERN_CRIT "b1lli(0x%x): rx not full after 1 second\n", base); @@ -264,7 +265,8 @@ static inline int b1_save_put_byte(unsigned int base, unsigned char val) { unsigned long stop = jiffies + 2 * HZ; - while (!b1_tx_empty(base) && time_before(jiffies,stop)); + while (!b1_tx_empty(base) && time_before(jiffies,stop)) + cpu_relax(); if (!b1_tx_empty(base)) return -1; b1outp(base, B1_WRITE, val); return 0; ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 11/13] use cpu_relax() in busy loop 2003-09-18 23:40 ` [PATCH 10/13] " Chris Wright @ 2003-09-18 23:41 ` Chris Wright 2003-09-18 23:43 ` [PATCH 12/13] " Chris Wright 0 siblings, 1 reply; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:41 UTC (permalink / raw) To: linux-kernel; +Cc: kai.germaschewski, mac, torvalds [PATCH 11/13] use cpu_relax() in busy loop Replace busy loop nop with cpu_relax(). ===== drivers/isdn/eicon/linio.c 1.8 vs edited ===== --- 1.8/drivers/isdn/eicon/linio.c Mon Apr 21 03:58:37 2003 +++ edited/drivers/isdn/eicon/linio.c Thu Sep 18 11:14:48 2003 @@ -38,7 +38,8 @@ { unsigned long timeout = jiffies + ((ms * HZ) / 1000); - while (time_before(jiffies, timeout)); + while (time_before(jiffies, timeout)) + cpu_relax(); } int UxCardHandleGet(ux_diva_card_t **card, dia_card_t *cfg) ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 12/13] use cpu_relax() in busy loop 2003-09-18 23:41 ` [PATCH 11/13] " Chris Wright @ 2003-09-18 23:43 ` Chris Wright 2003-09-18 23:46 ` [PATCH 13/13] " Chris Wright 0 siblings, 1 reply; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:43 UTC (permalink / raw) To: linux-kernel; +Cc: torvalds Replace busy loop nop with cpu_relax(). ===== drivers/scsi/i91uscsi.c 1.6 vs edited ===== --- 1.6/drivers/scsi/i91uscsi.c Fri May 2 12:34:33 2003 +++ edited/drivers/scsi/i91uscsi.c Thu Sep 18 11:49:49 2003 @@ -212,7 +212,8 @@ { /* Pause for amount jiffies */ unsigned long the_time = jiffies + amount; - while (time_before_eq(jiffies, the_time)); + while (time_before_eq(jiffies, the_time)) + cpu_relax(); } /*-- forward reference --*/ ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 13/13] use cpu_relax() in busy loop 2003-09-18 23:43 ` [PATCH 12/13] " Chris Wright @ 2003-09-18 23:46 ` Chris Wright 0 siblings, 0 replies; 21+ messages in thread From: Chris Wright @ 2003-09-18 23:46 UTC (permalink / raw) To: linux-kernel; +Cc: ak, torvalds Replace busy loop rep_nop() with cpu_relax(). This is bordering on a gratuitous change given the x86_64 def'n of cpu_relax(). But I was fixing up other busy loops, and my grep found this one. ===== arch/x86_64/kernel/smpboot.c 1.21 vs edited ===== --- 1.21/arch/x86_64/kernel/smpboot.c Sat Aug 23 05:13:33 2003 +++ edited/arch/x86_64/kernel/smpboot.c Thu Sep 18 10:26:41 2003 @@ -282,7 +282,7 @@ */ if (cpu_isset(cpuid, cpu_callout_map)) break; - rep_nop(); + cpu_relax(); } if (!time_before(jiffies, timeout)) { ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 9/13] use cpu_relax() in busy loop 2003-09-18 23:37 ` [PATCH 9/13] " Chris Wright 2003-09-18 23:40 ` [PATCH 10/13] " Chris Wright @ 2003-09-20 7:37 ` David S. Miller 1 sibling, 0 replies; 21+ messages in thread From: David S. Miller @ 2003-09-20 7:37 UTC (permalink / raw) To: Chris Wright; +Cc: linux-kernel, torvalds On Thu, 18 Sep 2003 16:37:57 -0700 Chris Wright <chrisw@osdl.org> wrote: > Replace busy loop nop with cpu_relax(). Applied, thanks Chris. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 7/13] use cpu_relax() in busy loop 2003-09-18 23:35 ` [PATCH 7/13] " Chris Wright 2003-09-18 23:36 ` [PATCH 8/13] " Chris Wright @ 2003-09-19 7:37 ` Arjan van de Ven 2003-09-19 19:49 ` Chris Wright 1 sibling, 1 reply; 21+ messages in thread From: Arjan van de Ven @ 2003-09-19 7:37 UTC (permalink / raw) To: Chris Wright; +Cc: linux-kernel, jgarzik [-- Attachment #1: Type: text/plain, Size: 2405 bytes --] On Fri, 2003-09-19 at 01:35, Chris Wright wrote: > Replace busy loop nop with cpu_relax(). > > Jeff, here's a batch for net drivers. They all look pretty straight > forward. > > ===== drivers/net/3c501.c 1.19 vs edited ===== > --- 1.19/drivers/net/3c501.c Tue Aug 26 13:21:28 2003 > +++ edited/drivers/net/3c501.c Thu Sep 18 11:30:18 2003 > @@ -251,7 +251,8 @@ > outb(0x00, AX_CMD); > > delay = jiffies + HZ/50; > - while (time_before(jiffies, delay)) ; > + while (time_before(jiffies, delay)) > + cpu_relax(); > autoirq = probe_irq_off(irq_mask); mdelay() > > if (autoirq == 0) > ===== drivers/net/3c505.c 1.25 vs edited ===== > --- 1.25/drivers/net/3c505.c Tue Aug 26 13:29:32 2003 > +++ edited/drivers/net/3c505.c Thu Sep 18 11:32:26 2003 > @@ -299,16 +299,20 @@ > } > outb_control(adapter->hcr_val | ATTN | DIR, dev); > timeout = jiffies + 1*HZ/100; > - while (time_before_eq(jiffies, timeout)); > + while (time_before_eq(jiffies, timeout)) > + cpu_relax(); mdelay() > timeout = jiffies + 1*HZ/100; > - while (time_before_eq(jiffies, timeout)); > + while (time_before_eq(jiffies, timeout)) > + cpu_relax(); mdelay() > outb_control(adapter->hcr_val | FLSH, dev); > timeout = jiffies + 1*HZ/100; > - while (time_before_eq(jiffies, timeout)); > + while (time_before_eq(jiffies, timeout)) > + cpu_relax(); mdelay() > outb_control(adapter->hcr_val & ~FLSH, dev); > timeout = jiffies + 1*HZ/100; > - while (time_before_eq(jiffies, timeout)); > + while (time_before_eq(jiffies, timeout)) > + cpu_relax(); > mdelay() > ===== drivers/net/eepro.c 1.19 vs edited ===== > --- 1.19/drivers/net/eepro.c Tue Jul 15 10:01:29 2003 > +++ edited/drivers/net/eepro.c Thu Sep 18 11:33:52 2003 > @@ -904,7 +904,8 @@ > eepro_diag(ioaddr); /* RESET the 82595 */ > > delay = jiffies + HZ/50; > - while (time_before(jiffies, delay)) ; > + while (time_before(jiffies, delay)) > + cpu_relax(); mdelay() > ===== drivers/net/lance.c 1.18 vs edited ===== > --- 1.18/drivers/net/lance.c Sun Apr 20 22:41:09 2003 > +++ edited/drivers/net/lance.c Thu Sep 18 11:37:30 2003 > @@ -554,7 +554,8 @@ > outw(0x0041, ioaddr+LANCE_DATA); > > delay = jiffies + HZ/50; > - while (time_before(jiffies, delay)) ; > + while (time_before(jiffies, delay)) > + cpu_relax(); mdelay() [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 7/13] use cpu_relax() in busy loop 2003-09-19 7:37 ` [PATCH 7/13] " Arjan van de Ven @ 2003-09-19 19:49 ` Chris Wright 0 siblings, 0 replies; 21+ messages in thread From: Chris Wright @ 2003-09-19 19:49 UTC (permalink / raw) To: Arjan van de Ven; +Cc: Chris Wright, linux-kernel, jgarzik [PATCH 7/13] use cpu_relax() in busy loop, or mdelay instead of busy loop Replace busy loop nop with cpu_relax(), and just use mdelay where it's better. These look ok? -chris ===== drivers/net/3c501.c 1.19 vs edited ===== --- 1.19/drivers/net/3c501.c Tue Aug 26 13:21:28 2003 +++ edited/drivers/net/3c501.c Fri Sep 19 11:06:57 2003 @@ -123,6 +123,7 @@ #include <linux/config.h> /* for CONFIG_IP_MULTICAST */ #include <linux/spinlock.h> #include <linux/ethtool.h> +#include <linux/delay.h> #include <asm/uaccess.h> #include <asm/bitops.h> @@ -241,7 +242,7 @@ if (dev->irq < 2) { - unsigned long irq_mask, delay; + unsigned long irq_mask; irq_mask = probe_irq_on(); inb(RX_STATUS); /* Clear pending interrupts. */ @@ -250,8 +251,7 @@ outb(0x00, AX_CMD); - delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + mdelay(20); autoirq = probe_irq_off(irq_mask); if (autoirq == 0) ===== drivers/net/3c505.c 1.25 vs edited ===== --- 1.25/drivers/net/3c505.c Tue Aug 26 13:29:32 2003 +++ edited/drivers/net/3c505.c Fri Sep 19 11:13:10 2003 @@ -298,17 +298,13 @@ set_hsf(dev, HSF_PCB_NAK); } outb_control(adapter->hcr_val | ATTN | DIR, dev); - timeout = jiffies + 1*HZ/100; - while (time_before_eq(jiffies, timeout)); + mdelay(10); outb_control(adapter->hcr_val & ~ATTN, dev); - timeout = jiffies + 1*HZ/100; - while (time_before_eq(jiffies, timeout)); + mdelay(10); outb_control(adapter->hcr_val | FLSH, dev); - timeout = jiffies + 1*HZ/100; - while (time_before_eq(jiffies, timeout)); + mdelay(10); outb_control(adapter->hcr_val & ~FLSH, dev); - timeout = jiffies + 1*HZ/100; - while (time_before_eq(jiffies, timeout)); + mdelay(10); outb_control(orig_hcr, dev); if (!start_receive(dev, &adapter->tx_pcb)) ===== drivers/net/acenic.c 1.39 vs edited ===== --- 1.39/drivers/net/acenic.c Thu Sep 4 00:36:29 2003 +++ edited/drivers/net/acenic.c Fri Sep 19 11:38:34 2003 @@ -1757,7 +1757,8 @@ * Wait for the firmware to spin up - max 3 seconds. */ myjif = jiffies + 3 * HZ; - while (time_before(jiffies, myjif) && !ap->fw_running); + while (time_before(jiffies, myjif) && !ap->fw_running) + cpu_relax(); if (!ap->fw_running) { printk(KERN_ERR "%s: Firmware NOT running!\n", dev->name); ===== drivers/net/eepro.c 1.19 vs edited ===== --- 1.19/drivers/net/eepro.c Tue Jul 15 10:01:29 2003 +++ edited/drivers/net/eepro.c Fri Sep 19 11:18:47 2003 @@ -897,14 +897,12 @@ eepro_sw2bank0(ioaddr); /* Switch back to Bank 0 */ if (request_irq (*irqp, NULL, SA_SHIRQ, "bogus", dev) != EBUSY) { - unsigned long irq_mask, delay; + unsigned long irq_mask; /* Twinkle the interrupt, and check if it's seen */ irq_mask = probe_irq_on(); eepro_diag(ioaddr); /* RESET the 82595 */ - - delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + mdelay(20); if (*irqp == probe_irq_off(irq_mask)) /* It's a good IRQ line */ break; ===== drivers/net/ewrk3.c 1.26 vs edited ===== --- 1.26/drivers/net/ewrk3.c Tue Aug 19 20:53:15 2003 +++ edited/drivers/net/ewrk3.c Fri Sep 19 11:21:50 2003 @@ -564,7 +564,7 @@ if (dev->irq < 2) { #ifndef MODULE u_char irqnum; - unsigned long irq_mask, delay; + unsigned long irq_mask; irq_mask = probe_irq_on(); @@ -578,8 +578,7 @@ irqnum = irq[((icr & IRQ_SEL) >> 4)]; - delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + mdelay(20); dev->irq = probe_irq_off(irq_mask); if ((dev->irq) && (irqnum == dev->irq)) { printk(" and uses IRQ%d.\n", dev->irq); ===== drivers/net/lance.c 1.18 vs edited ===== --- 1.18/drivers/net/lance.c Sun Apr 20 22:41:09 2003 +++ edited/drivers/net/lance.c Fri Sep 19 11:25:56 2003 @@ -543,7 +543,7 @@ if (dev->irq >= 2) printk(" assigned IRQ %d", dev->irq); else if (lance_version != 0) { /* 7990 boards need DMA detection first. */ - unsigned long irq_mask, delay; + unsigned long irq_mask; /* To auto-IRQ we enable the initialization-done and DMA error interrupts. For ISA boards we get a DMA error, but VLB and PCI @@ -553,8 +553,7 @@ /* Trigger an initialization just for the interrupt. */ outw(0x0041, ioaddr+LANCE_DATA); - delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + mdelay(20); dev->irq = probe_irq_off(irq_mask); if (dev->irq) printk(", probed IRQ %d", dev->irq); @@ -621,13 +620,12 @@ if (lance_version == 0 && dev->irq == 0) { /* We may auto-IRQ now that we have a DMA channel. */ /* Trigger an initialization just for the interrupt. */ - unsigned long irq_mask, delay; + unsigned long irq_mask; irq_mask = probe_irq_on(); outw(0x0041, ioaddr+LANCE_DATA); - delay = jiffies + HZ/25; - while (time_before(jiffies, delay)) ; + mdelay(40); dev->irq = probe_irq_off(irq_mask); if (dev->irq == 0) { printk(" Failed to detect the 7990 IRQ line.\n"); ===== drivers/net/ni5010.c 1.11 vs edited ===== --- 1.11/drivers/net/ni5010.c Sun Aug 31 16:14:15 2003 +++ edited/drivers/net/ni5010.c Fri Sep 19 11:27:11 2003 @@ -255,14 +255,13 @@ if (dev->irq == 0xff) ; else if (dev->irq < 2) { - unsigned long irq_mask, delay; + unsigned long irq_mask; PRINTK2((KERN_DEBUG "%s: I/O #5 passed!\n", dev->name)); irq_mask = probe_irq_on(); trigger_irq(ioaddr); - delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + mdelay(20); dev->irq = probe_irq_off(irq_mask); PRINTK2((KERN_DEBUG "%s: I/O #6 passed!\n", dev->name)); ===== drivers/net/ni52.c 1.11 vs edited ===== --- 1.11/drivers/net/ni52.c Sun Apr 20 23:00:41 2003 +++ edited/drivers/net/ni52.c Fri Sep 19 11:29:49 2003 @@ -492,14 +492,13 @@ if(dev->irq < 2) { - unsigned long irq_mask, delay; + unsigned long irq_mask; irq_mask = probe_irq_on(); ni_reset586(); ni_attn586(); - delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + mdelay(20); dev->irq = probe_irq_off(irq_mask); if(!dev->irq) { ===== drivers/net/rrunner.c 1.21 vs edited ===== --- 1.21/drivers/net/rrunner.c Tue Aug 19 20:53:16 2003 +++ edited/drivers/net/rrunner.c Fri Sep 19 11:38:50 2003 @@ -721,7 +721,8 @@ * Give the FirmWare time to chew on the `get running' command. */ myjif = jiffies + 5 * HZ; - while (time_before(jiffies, myjif) && !rrpriv->fw_running); + while (time_before(jiffies, myjif) && !rrpriv->fw_running) + cpu_relax(); netif_start_queue(dev); ===== drivers/net/wan/sbni.c 1.22 vs edited ===== --- 1.22/drivers/net/wan/sbni.c Thu Sep 4 00:40:48 2003 +++ edited/drivers/net/wan/sbni.c Fri Sep 19 11:32:45 2003 @@ -53,6 +53,7 @@ #include <linux/skbuff.h> #include <linux/timer.h> #include <linux/init.h> +#include <linux/delay.h> #include <net/arp.h> @@ -337,13 +338,12 @@ outb( 0, ioaddr + CSR0 ); if( irq < 2 ) { - unsigned long irq_mask, delay; + unsigned long irq_mask; irq_mask = probe_irq_on(); outb( EN_INT | TR_REQ, ioaddr + CSR0 ); outb( PR_RES, ioaddr + CSR1 ); - delay = jiffies + HZ/20; - while (time_before(jiffies, delay)) ; + mdelay(50); irq = probe_irq_off(irq_mask); outb( 0, ioaddr + CSR0 ); ===== drivers/net/wd.c 1.12 vs edited ===== --- 1.12/drivers/net/wd.c Thu Nov 21 14:06:13 2002 +++ edited/drivers/net/wd.c Fri Sep 19 11:34:22 2003 @@ -235,7 +235,7 @@ int reg4 = inb(ioaddr+4); if (ancient || reg1 == 0xff) { /* Ack!! No way to read the IRQ! */ short nic_addr = ioaddr+WD_NIC_OFFSET; - unsigned long irq_mask, delay; + unsigned long irq_mask; /* We have an old-style ethercard that doesn't report its IRQ line. Do autoirq to find the IRQ line. Note that this IS NOT @@ -248,8 +248,7 @@ outb_p(0x00, nic_addr + EN0_RCNTLO); outb_p(0x00, nic_addr + EN0_RCNTHI); outb(E8390_RREAD+E8390_START, nic_addr); /* Trigger it... */ - delay = jiffies + HZ/50; - while (time_before(jiffies, delay)) ; + mdelay(20); dev->irq = probe_irq_off(irq_mask); outb_p(0x00, nic_addr+EN0_IMR); /* Mask all intrs. again. */ ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/13] use cpu_relax() in busy loop 2003-09-18 23:31 ` [PATCH 4/13] " Chris Wright 2003-09-18 23:33 ` [PATCH 5/13] " Chris Wright @ 2003-09-19 7:34 ` Arjan van de Ven 2003-09-19 19:48 ` Chris Wright 1 sibling, 1 reply; 21+ messages in thread From: Arjan van de Ven @ 2003-09-19 7:34 UTC (permalink / raw) To: Chris Wright; +Cc: linux-kernel, torvalds [-- Attachment #1: Type: text/plain, Size: 534 bytes --] On Fri, 2003-09-19 at 01:31, Chris Wright wrote: > Replace busy loop nop with cpu_relax(). > > ===== drivers/cdrom/sonycd535.c 1.39 vs edited ===== > --- 1.39/drivers/cdrom/sonycd535.c Tue Sep 9 07:41:30 2003 > +++ edited/drivers/cdrom/sonycd535.c Thu Sep 18 10:52:41 2003 > @@ -1526,7 +1526,8 @@ > enable_interrupts(); > outb(0, read_status_reg); /* does a reset? */ > delay = jiffies + HZ/10; > - while (time_before(jiffies, delay)) ; > + while (time_before(jiffies, delay)) > + cpu_relax(); mdelay ? [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/13] use cpu_relax() in busy loop 2003-09-19 7:34 ` [PATCH 4/13] " Arjan van de Ven @ 2003-09-19 19:48 ` Chris Wright 2003-09-19 19:54 ` Arjan van de Ven 0 siblings, 1 reply; 21+ messages in thread From: Chris Wright @ 2003-09-19 19:48 UTC (permalink / raw) To: Arjan van de Ven; +Cc: Chris Wright, linux-kernel, torvalds * Arjan van de Ven (arjanv@redhat.com) wrote: > > mdelay ? Yeah, good point. For these subsecond pauses mdelay() makes more sense. It'd be nice to get rid of long busy loops in general. Thanks for taking a look. -chris [PATCH 4/13] use mdelay() instead of busy loop Replace busy loop with mdelay(). ===== drivers/cdrom/sonycd535.c 1.39 vs edited ===== --- 1.39/drivers/cdrom/sonycd535.c Tue Sep 9 07:41:30 2003 +++ edited/drivers/cdrom/sonycd535.c Fri Sep 19 10:36:18 2003 @@ -129,6 +129,7 @@ #include <linux/mm.h> #include <linux/slab.h> #include <linux/init.h> +#include <linux/delay.h> #define REALLY_SLOW_IO #include <asm/system.h> @@ -1520,13 +1521,12 @@ /* A negative sony535_irq_used will attempt an autoirq. */ if (sony535_irq_used < 0) { - unsigned long irq_mask, delay; + unsigned long irq_mask; irq_mask = probe_irq_on(); enable_interrupts(); outb(0, read_status_reg); /* does a reset? */ - delay = jiffies + HZ/10; - while (time_before(jiffies, delay)) ; + mdelay(100); sony535_irq_used = probe_irq_off(irq_mask); disable_interrupts(); ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/13] use cpu_relax() in busy loop 2003-09-19 19:48 ` Chris Wright @ 2003-09-19 19:54 ` Arjan van de Ven 0 siblings, 0 replies; 21+ messages in thread From: Arjan van de Ven @ 2003-09-19 19:54 UTC (permalink / raw) To: Chris Wright; +Cc: Arjan van de Ven, linux-kernel, torvalds On Fri, Sep 19, 2003 at 12:48:45PM -0700, Chris Wright wrote: > * Arjan van de Ven (arjanv@redhat.com) wrote: > > > > mdelay ? > > Yeah, good point. For these subsecond pauses mdelay() makes more sense. > It'd be nice to get rid of long busy loops in general. yep; first step is making them grep-able by using mdelay ;) ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/13] use cpu_relax() in busy loop 2003-09-18 23:27 ` [PATCH 2/13] " Chris Wright 2003-09-18 23:29 ` [PATCH 3/13] " Chris Wright @ 2003-09-19 7:33 ` Arjan van de Ven 2003-09-19 19:49 ` Chris Wright 1 sibling, 1 reply; 21+ messages in thread From: Arjan van de Ven @ 2003-09-19 7:33 UTC (permalink / raw) To: Chris Wright; +Cc: linux-kernel, chas, torvalds [-- Attachment #1: Type: text/plain, Size: 694 bytes --] On Fri, 2003-09-19 at 01:27, Chris Wright wrote: > [PATCH 2/13] use cpu_relax() in busy loop > > Replace busy loop nop with cpu_relax(). > > ===== drivers/atm/fore200e.c 1.19 vs edited ===== > --- 1.19/drivers/atm/fore200e.c Tue Sep 2 11:07:59 2003 > +++ edited/drivers/atm/fore200e.c Thu Sep 18 10:42:17 2003 > @@ -248,7 +248,8 @@ > fore200e_spin(int msecs) > { > unsigned long timeout = jiffies + MSECS(msecs); > - while (time_before(jiffies, timeout)); > + while (time_before(jiffies, timeout)) > + cpu_relax(); > } ehmmm how about making this use mdelay instead ? (not to speak of maybe making it sleep, but that's a less obvious transformation) [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/13] use cpu_relax() in busy loop 2003-09-19 7:33 ` [PATCH 2/13] " Arjan van de Ven @ 2003-09-19 19:49 ` Chris Wright 0 siblings, 0 replies; 21+ messages in thread From: Chris Wright @ 2003-09-19 19:49 UTC (permalink / raw) To: Arjan van de Ven; +Cc: Chris Wright, linux-kernel, chas, torvalds, mitch * Arjan van de Ven (arjanv@redhat.com) wrote: > ehmmm how about making this use mdelay instead ? > (not to speak of maybe making it sleep, but that's a less obvious > transformation) I didn't want to change to sleep semantics of the call w/out better review of spinlocks held/irq disabled, etc. But, after feedback from Mitch, looks like these were only called during module init/exit. This look ok? thanks, -chris [PATCH 2/13] use schedule_timeout() instead of busy loop Replace fore200e_spin() busy loops with schedule_timeout(). ===== fore200e.c 1.19 vs edited ===== --- 1.19/drivers/atm/fore200e.c Tue Sep 2 11:07:59 2003 +++ edited/fore200e.c Fri Sep 19 12:24:15 2003 @@ -229,7 +229,8 @@ u32 hb1, hb2; hb1 = fore200e->bus->read(&fore200e->cp_queues->heartbeat); - fore200e_spin(10); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(10 * HZ/1000); hb2 = fore200e->bus->read(&fore200e->cp_queues->heartbeat); if (hb2 <= hb1) { @@ -244,14 +245,6 @@ #endif -static void -fore200e_spin(int msecs) -{ - unsigned long timeout = jiffies + MSECS(msecs); - while (time_before(jiffies, timeout)); -} - - static int fore200e_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int msecs) { @@ -551,7 +544,8 @@ fore200e_pca_reset(struct fore200e* fore200e) { writel(PCA200E_HCR_RESET, fore200e->regs.pca.hcr); - fore200e_spin(10); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(10 * HZ/1000); writel(0, fore200e->regs.pca.hcr); } @@ -831,7 +825,8 @@ fore200e_sba_reset(struct fore200e* fore200e) { fore200e->bus->write(SBA200E_HCR_RESET, fore200e->regs.sba.hcr); - fore200e_spin(10); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(10 * HZ/1000); fore200e->bus->write(0, fore200e->regs.sba.hcr); } ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2003-09-20 7:49 UTC | newest] Thread overview: 21+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-09-18 23:25 [PATCH 1/13] use cpu_relax() in busy loop Chris Wright 2003-09-18 23:27 ` [PATCH 2/13] " Chris Wright 2003-09-18 23:29 ` [PATCH 3/13] " Chris Wright 2003-09-18 23:31 ` [PATCH 4/13] " Chris Wright 2003-09-18 23:33 ` [PATCH 5/13] " Chris Wright 2003-09-18 23:34 ` [PATCH 6/13] " Chris Wright 2003-09-18 23:35 ` [PATCH 7/13] " Chris Wright 2003-09-18 23:36 ` [PATCH 8/13] " Chris Wright 2003-09-18 23:37 ` [PATCH 9/13] " Chris Wright 2003-09-18 23:40 ` [PATCH 10/13] " Chris Wright 2003-09-18 23:41 ` [PATCH 11/13] " Chris Wright 2003-09-18 23:43 ` [PATCH 12/13] " Chris Wright 2003-09-18 23:46 ` [PATCH 13/13] " Chris Wright 2003-09-20 7:37 ` [PATCH 9/13] " David S. Miller 2003-09-19 7:37 ` [PATCH 7/13] " Arjan van de Ven 2003-09-19 19:49 ` Chris Wright 2003-09-19 7:34 ` [PATCH 4/13] " Arjan van de Ven 2003-09-19 19:48 ` Chris Wright 2003-09-19 19:54 ` Arjan van de Ven 2003-09-19 7:33 ` [PATCH 2/13] " Arjan van de Ven 2003-09-19 19:49 ` Chris Wright
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox