netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 15/18]  net/ibmtr: replace  schedule_timeout() with msleep()/msleep_interruptible()
@ 2004-10-30 22:43 janitor
  2004-10-31 11:03 ` Jeff Garzik
  0 siblings, 1 reply; 4+ messages in thread
From: janitor @ 2004-10-30 22:43 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev, janitor, nacc




Any comments would be appreciated.

Description: Use msleep() / msleep_interruptible() [as appropriate]
instead of schedule_timeout() to guarantee the task delays as expected.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Maximilian Attems <janitor@sternwelten.at>

---

 linux-2.6.10-rc1-max/drivers/net/tokenring/ibmtr.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff -puN drivers/net/tokenring/ibmtr.c~msleep+msleep_interruptible-drivers_net_tokenring_ibmtr drivers/net/tokenring/ibmtr.c
--- linux-2.6.10-rc1/drivers/net/tokenring/ibmtr.c~msleep+msleep_interruptible-drivers_net_tokenring_ibmtr	2004-10-24 17:05:34.000000000 +0200
+++ linux-2.6.10-rc1-max/drivers/net/tokenring/ibmtr.c	2004-10-24 17:05:34.000000000 +0200
@@ -108,6 +108,7 @@ in the event that chatty debug messages 
 #define IBMTR_DEBUG_MESSAGES 0
 
 #include <linux/module.h>
+#include <linux/delay.h>
 
 #ifdef PCMCIA		/* required for ibmtr_cs.c to build */
 #undef MODULE		/* yes, really */
@@ -317,7 +318,7 @@ static void ibmtr_cleanup_card(struct ne
 	if (dev->base_addr) {
 		outb(0,dev->base_addr+ADAPTRESET);
 		
-		schedule_timeout(TR_RST_TIME); /* wait 50ms */
+		msleep(jiffies_to_msecs(TR_RST_TIME)); /* wait 50ms */
 
 		outb(0,dev->base_addr+ADAPTRESETREL);
 	}
@@ -858,8 +859,7 @@ static int tok_init_card(struct net_devi
 	writeb(~INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_RESET + ISRP_EVEN);
 	outb(0, PIOaddr + ADAPTRESET);
 
-	current->state=TASK_UNINTERRUPTIBLE;
-	schedule_timeout(TR_RST_TIME); /* wait 50ms */
+	msleep(jiffies_to_msecs(TR_RST_TIME));		/* wait 50ms */
 
 	outb(0, PIOaddr + ADAPTRESETREL);
 #ifdef ENABLE_PAGING
@@ -912,9 +912,8 @@ static int tok_open(struct net_device *d
 			DPRINTK("Adapter is up and running\n");
 			return 0;
 		}
-		current->state=TASK_INTERRUPTIBLE;
-		i=schedule_timeout(TR_RETRY_INTERVAL); /* wait 30 seconds */
-		if(i!=0) break; /*prob. a signal, like the i>24*HZ case above */
+		if(msleep_interruptible(jiffies_to_msecs(TR_RETRY_INTERVAL)))
+			break; /*prob. a signal, like the i>24*HZ case above */
 	}
 	outb(0, dev->base_addr + ADAPTRESET);/* kill pending interrupts*/
 	DPRINTK("TERMINATED via signal\n");	/*BMS useful */
_

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

* Re: [patch 15/18]  net/ibmtr: replace  schedule_timeout() with msleep()/msleep_interruptible()
  2004-10-30 22:43 [patch 15/18] net/ibmtr: replace schedule_timeout() with msleep()/msleep_interruptible() janitor
@ 2004-10-31 11:03 ` Jeff Garzik
  2004-11-01 19:22   ` [PATCH] linux/ibmtr.h: add constants for appropriate delays Nishanth Aravamudan
  2004-11-01 19:27   ` [PATCH] net/ibmtr: replace schedule_timeout() with msleep()/msleep_interruptible() Nishanth Aravamudan
  0 siblings, 2 replies; 4+ messages in thread
From: Jeff Garzik @ 2004-10-31 11:03 UTC (permalink / raw)
  To: janitor; +Cc: netdev, nacc

janitor@sternwelten.at wrote:
> Any comments would be appreciated.
> 
> Description: Use msleep() / msleep_interruptible() [as appropriate]
> instead of schedule_timeout() to guarantee the task delays as expected.
> 
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> Signed-off-by: Maximilian Attems <janitor@sternwelten.at>
> 
> ---
> 
>  linux-2.6.10-rc1-max/drivers/net/tokenring/ibmtr.c |   11 +++++------
>  1 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff -puN drivers/net/tokenring/ibmtr.c~msleep+msleep_interruptible-drivers_net_tokenring_ibmtr drivers/net/tokenring/ibmtr.c
> --- linux-2.6.10-rc1/drivers/net/tokenring/ibmtr.c~msleep+msleep_interruptible-drivers_net_tokenring_ibmtr	2004-10-24 17:05:34.000000000 +0200
> +++ linux-2.6.10-rc1-max/drivers/net/tokenring/ibmtr.c	2004-10-24 17:05:34.000000000 +0200
> @@ -108,6 +108,7 @@ in the event that chatty debug messages 
>  #define IBMTR_DEBUG_MESSAGES 0
>  
>  #include <linux/module.h>
> +#include <linux/delay.h>
>  
>  #ifdef PCMCIA		/* required for ibmtr_cs.c to build */
>  #undef MODULE		/* yes, really */
> @@ -317,7 +318,7 @@ static void ibmtr_cleanup_card(struct ne
>  	if (dev->base_addr) {
>  		outb(0,dev->base_addr+ADAPTRESET);
>  		
> -		schedule_timeout(TR_RST_TIME); /* wait 50ms */
> +		msleep(jiffies_to_msecs(TR_RST_TIME)); /* wait 50ms */
>  
>  		outb(0,dev->base_addr+ADAPTRESETREL);
>  	}
> @@ -858,8 +859,7 @@ static int tok_init_card(struct net_devi
>  	writeb(~INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_RESET + ISRP_EVEN);
>  	outb(0, PIOaddr + ADAPTRESET);
>  
> -	current->state=TASK_UNINTERRUPTIBLE;
> -	schedule_timeout(TR_RST_TIME); /* wait 50ms */
> +	msleep(jiffies_to_msecs(TR_RST_TIME));		/* wait 50ms */
>  
>  	outb(0, PIOaddr + ADAPTRESETREL);
>  #ifdef ENABLE_PAGING
> @@ -912,9 +912,8 @@ static int tok_open(struct net_device *d
>  			DPRINTK("Adapter is up and running\n");
>  			return 0;
>  		}
> -		current->state=TASK_INTERRUPTIBLE;
> -		i=schedule_timeout(TR_RETRY_INTERVAL); /* wait 30 seconds */
> -		if(i!=0) break; /*prob. a signal, like the i>24*HZ case above */
> +		if(msleep_interruptible(jiffies_to_msecs(TR_RETRY_INTERVAL)))
> +			break; /*prob. a signal, like the i>24*HZ case above */
>  	}
>  	outb(0, dev->base_addr + ADAPTRESET);/* kill pending interrupts*/
>  	DPRINTK("TERMINATED via signal\n");	/*BMS useful */

It makes more sense to convert the constants to msecs in the source 
code, instead of converting them at runtime.

	Jeff

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

* [PATCH] linux/ibmtr.h: add constants for appropriate delays
  2004-10-31 11:03 ` Jeff Garzik
@ 2004-11-01 19:22   ` Nishanth Aravamudan
  2004-11-01 19:27   ` [PATCH] net/ibmtr: replace schedule_timeout() with msleep()/msleep_interruptible() Nishanth Aravamudan
  1 sibling, 0 replies; 4+ messages in thread
From: Nishanth Aravamudan @ 2004-11-01 19:22 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: kernel-janitors, netdev

On Sun, Oct 31, 2004 at 06:03:07AM -0500, Jeff Garzik wrote:
> janitor@sternwelten.at wrote:
> >Any comments would be appreciated.
> >
> >Description: Use msleep() / msleep_interruptible() [as appropriate]
> >instead of schedule_timeout() to guarantee the task delays as expected.
> >
> >Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> >Signed-off-by: Maximilian Attems <janitor@sternwelten.at>
> >
> >---
> >
> > linux-2.6.10-rc1-max/drivers/net/tokenring/ibmtr.c |   11 +++++------
> > 1 files changed, 5 insertions(+), 6 deletions(-)

<snip>

> >-		schedule_timeout(TR_RST_TIME); /* wait 50ms */
> >+		msleep(jiffies_to_msecs(TR_RST_TIME)); /* wait 50ms */

<snip>

> >-	current->state=TASK_UNINTERRUPTIBLE;
> >-	schedule_timeout(TR_RST_TIME); /* wait 50ms */
> >+	msleep(jiffies_to_msecs(TR_RST_TIME));		/* wait 50ms */

<snip>

> >-		current->state=TASK_INTERRUPTIBLE;
> >-		i=schedule_timeout(TR_RETRY_INTERVAL); /* wait 30 seconds */
> >-		if(i!=0) break; /*prob. a signal, like the i>24*HZ case 
> >above */
> >+		if(msleep_interruptible(jiffies_to_msecs(TR_RETRY_INTERVAL)))
> >+			break; /*prob. a signal, like the i>24*HZ case above 

<snip>

> It makes more sense to convert the constants to msecs in the source 
> code, instead of converting them at runtime.

This required changing both the .h and .c files, the first of which is
attached below.

Description: Adds constant definitions for timeout variables in terms of
milliseconds to avoid run-time constant conversion.

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

--- 2.6.10-rc1-vanilla/include/linux/ibmtr.h	2004-10-30 15:34:03.000000000 -0700
+++ 2.6.10-rc1/include/linux/ibmtr.h	2004-11-01 11:13:41.000000000 -0800
@@ -6,8 +6,10 @@
 
 /* ported to the Alpha architecture 02/20/96 (just used the HZ macro) */
 
-#define TR_RETRY_INTERVAL	(30*HZ)	/* 500 on PC = 5 s */
-#define TR_RST_TIME		(HZ/20) /* 5 on PC = 50 ms */
+#define TR_RETRY_INTERVAL	(30*HZ)	/* 500 on PC = 5 s (in jiffies) */
+#define TR_RETRY_INTERVAL	(30000) /* 500 on PC = 5 s */
+#define TR_RST_TIME		(HZ/20) /* 5 on PC = 50 ms (in jiffies) */
+#define TR_RST_TIME_MS		(50)    /* 5 on PC = 50 ms */
 #define TR_BUSY_INTERVAL	(HZ/5)	/* 5 on PC = 200 ms */
 #define TR_SPIN_INTERVAL	(3*HZ)	/* 3 seconds before init timeout */
 

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

* [PATCH] net/ibmtr: replace schedule_timeout() with msleep()/msleep_interruptible()
  2004-10-31 11:03 ` Jeff Garzik
  2004-11-01 19:22   ` [PATCH] linux/ibmtr.h: add constants for appropriate delays Nishanth Aravamudan
@ 2004-11-01 19:27   ` Nishanth Aravamudan
  1 sibling, 0 replies; 4+ messages in thread
From: Nishanth Aravamudan @ 2004-11-01 19:27 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: kernel-janitors, netdev

On Sun, Oct 31, 2004 at 06:03:07AM -0500, Jeff Garzik wrote:
> janitor@sternwelten.at wrote:
> >Any comments would be appreciated.
> >
> >Description: Use msleep() / msleep_interruptible() [as appropriate]
> >instead of schedule_timeout() to guarantee the task delays as expected.
> >
> >Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> >Signed-off-by: Maximilian Attems <janitor@sternwelten.at>
> >
> >---
> >
> > linux-2.6.10-rc1-max/drivers/net/tokenring/ibmtr.c |   11 +++++------
> > 1 files changed, 5 insertions(+), 6 deletions(-)
> >
> >-		schedule_timeout(TR_RST_TIME); /* wait 50ms */
> >+		msleep(jiffies_to_msecs(TR_RST_TIME)); /* wait 50ms */

<snip>

> >-	current->state=TASK_UNINTERRUPTIBLE;
> >-	schedule_timeout(TR_RST_TIME); /* wait 50ms */
> >+	msleep(jiffies_to_msecs(TR_RST_TIME));		/* wait 50ms */

<snip>

> >-		current->state=TASK_INTERRUPTIBLE;
> >-		i=schedule_timeout(TR_RETRY_INTERVAL); /* wait 30 seconds */
> >-		if(i!=0) break; /*prob. a signal, like the i>24*HZ case 
> >above */
> >+		if(msleep_interruptible(jiffies_to_msecs(TR_RETRY_INTERVAL)))
> >+			break; /*prob. a signal, like the i>24*HZ case above 

<snip>

> It makes more sense to convert the constants to msecs in the source 
> code, instead of converting them at runtime.

Here is the patch to ibmtr.c which completes these changes...

Description: Uses msleep()/msleep_interruptible() [as appropriate] to
guarantee the task delays as expected. This patch depends on the
corresponding addition of the millisecond-unit constants to ibmtr.h.

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


--- 2.6.10-rc1-vanilla/drivers/net/tokenring/ibmtr.c	2004-10-30 15:33:28.000000000 -0700
+++ 2.6.10-rc1/drivers/net/tokenring/ibmtr.c	2004-11-01 11:18:10.000000000 -0800
@@ -130,6 +130,7 @@ in the event that chatty debug messages 
 #include <linux/ip.h>
 #include <linux/trdevice.h>
 #include <linux/ibmtr.h>
+#include <linux/delay.h>
 
 #include <net/checksum.h>
 
@@ -317,7 +318,7 @@ static void ibmtr_cleanup_card(struct ne
 	if (dev->base_addr) {
 		outb(0,dev->base_addr+ADAPTRESET);
 		
-		schedule_timeout(TR_RST_TIME); /* wait 50ms */
+		msleep(TR_RST_TIME_MS);
 
 		outb(0,dev->base_addr+ADAPTRESETREL);
 	}
@@ -858,8 +859,7 @@ static int tok_init_card(struct net_devi
 	writeb(~INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_RESET + ISRP_EVEN);
 	outb(0, PIOaddr + ADAPTRESET);
 
-	current->state=TASK_UNINTERRUPTIBLE;
-	schedule_timeout(TR_RST_TIME); /* wait 50ms */
+	msleep(TR_RST_TIME_MS);
 
 	outb(0, PIOaddr + ADAPTRESETREL);
 #ifdef ENABLE_PAGING
@@ -912,9 +912,8 @@ static int tok_open(struct net_device *d
 			DPRINTK("Adapter is up and running\n");
 			return 0;
 		}
-		current->state=TASK_INTERRUPTIBLE;
-		i=schedule_timeout(TR_RETRY_INTERVAL); /* wait 30 seconds */
-		if(i!=0) break; /*prob. a signal, like the i>24*HZ case above */
+		if(msleep_interruptible(TR_RETRY_INTERVAL_MS)) break;
+				/*prob. a signal, like the i>24*HZ case above */
 	}
 	outb(0, dev->base_addr + ADAPTRESET);/* kill pending interrupts*/
 	DPRINTK("TERMINATED via signal\n");	/*BMS useful */

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

end of thread, other threads:[~2004-11-01 19:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-30 22:43 [patch 15/18] net/ibmtr: replace schedule_timeout() with msleep()/msleep_interruptible() janitor
2004-10-31 11:03 ` Jeff Garzik
2004-11-01 19:22   ` [PATCH] linux/ibmtr.h: add constants for appropriate delays Nishanth Aravamudan
2004-11-01 19:27   ` [PATCH] net/ibmtr: replace schedule_timeout() with msleep()/msleep_interruptible() Nishanth Aravamudan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).