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




Any comments would be appreciated.

Description: Use msleep_interruptible() instead of gt96100_delay() so
that the task delays as expected. Remove the prototype and definition of
gt96100_delay(). As I currently understand it, the check for interrupt
context is not necessary in gt96100_delay(), as such a sleep will be
caught within the scheduler.

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/gt96100eth.c |   19 ++++---------------
 1 files changed, 4 insertions(+), 15 deletions(-)

diff -puN drivers/net/gt96100eth.c~msleep_interruptible-drivers_net_gt96100eth drivers/net/gt96100eth.c
--- linux-2.6.10-rc1/drivers/net/gt96100eth.c~msleep_interruptible-drivers_net_gt96100eth	2004-10-24 17:05:12.000000000 +0200
+++ linux-2.6.10-rc1-max/drivers/net/gt96100eth.c	2004-10-24 17:05:12.000000000 +0200
@@ -59,7 +59,6 @@
 // prototypes
 static void* dmaalloc(size_t size, dma_addr_t *dma_handle);
 static void dmafree(size_t size, void *vaddr);
-static void gt96100_delay(int msec);
 static int gt96100_add_hash_entry(struct net_device *dev,
 				  unsigned char* addr);
 static void read_mib_counters(struct gt96100_private *gp);
@@ -183,16 +182,6 @@ static void dmafree(size_t size, void *v
 	free_pages((unsigned long)vaddr, get_order(size));
 }
 
-static void gt96100_delay(int ms)
-{
-	if (in_interrupt())
-		return;
-	else {
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(ms*HZ/1000);
-	}
-}
-
 static int
 parse_mac_addr(struct net_device *dev, char* macstr)
 {
@@ -238,7 +227,7 @@ read_MII(int phy_addr, u32 reg)
 	// wait for last operation to complete
 	while (GT96100_READ(GT96100_ETH_SMI_REG) & smirBusy) {
 		// snooze for 1 msec and check again
-		gt96100_delay(1);
+		msleep_interruptible(1);
 
 		if (--timedout == 0) {
 			printk(KERN_ERR "%s: busy timeout!!\n", __FUNCTION__);
@@ -252,7 +241,7 @@ read_MII(int phy_addr, u32 reg)
 	// wait for read to complete
 	while (!((smir = GT96100_READ(GT96100_ETH_SMI_REG)) & smirReadValid)) {
 		// snooze for 1 msec and check again
-		gt96100_delay(1);
+		msleep_interruptible(1);
 	
 		if (--timedout == 0) {
 			printk(KERN_ERR "%s: timeout!!\n", __FUNCTION__);
@@ -304,7 +293,7 @@ write_MII(int phy_addr, u32 reg, u16 dat
 	// wait for last operation to complete
 	while (GT96100_READ(GT96100_ETH_SMI_REG) & smirBusy) {
 		// snooze for 1 msec and check again
-		gt96100_delay(1);
+		msleep_interruptible(1);
 	
 		if (--timedout == 0) {
 			printk(KERN_ERR "%s: busy timeout!!\n", __FUNCTION__);
@@ -528,7 +517,7 @@ abort(struct net_device *dev, u32 abort_
 	// wait for abort to complete
 	while (GT96100ETH_READ(gp, GT96100_ETH_SDMA_COMM) & abort_bits) {
 		// snooze for 20 msec and check again
-		gt96100_delay(1);
+		msleep_interruptible(20);
 	
 		if (--timedout == 0) {
 			err("%s: timeout!!\n", __FUNCTION__);
_

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

* Re: [patch 10/18]  net/g96100eth: replace  gt96100_delay() with msleep_interruptible()
  2004-10-30 22:42 [patch 10/18] net/g96100eth: replace gt96100_delay() with msleep_interruptible() janitor
@ 2004-10-31 11:06 ` Jeff Garzik
  2004-11-01 19:08   ` [PATCH] net/gt96100eth: " Nishanth Aravamudan
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2004-10-31 11:06 UTC (permalink / raw)
  To: janitor; +Cc: netdev, nacc

janitor@sternwelten.at wrote:
> @@ -528,7 +517,7 @@ abort(struct net_device *dev, u32 abort_
>  	// wait for abort to complete
>  	while (GT96100ETH_READ(gp, GT96100_ETH_SDMA_COMM) & abort_bits) {
>  		// snooze for 20 msec and check again
> -		gt96100_delay(1);
> +		msleep_interruptible(20);
>  	
>  		if (--timedout == 0) {


don't change the behavior of the driver, even if it disagrees with the 
comment.

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

* [PATCH]  net/gt96100eth: replace gt96100_delay() with msleep_interruptible()
  2004-10-31 11:06 ` Jeff Garzik
@ 2004-11-01 19:08   ` Nishanth Aravamudan
  2004-11-05  7:47     ` Jeff Garzik
  0 siblings, 1 reply; 5+ messages in thread
From: Nishanth Aravamudan @ 2004-11-01 19:08 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev, kernel-janitors

On Sun, Oct 31, 2004 at 06:06:23AM -0500, Jeff Garzik wrote:
> janitor@sternwelten.at wrote:
> >@@ -528,7 +517,7 @@ abort(struct net_device *dev, u32 abort_
> > 	// wait for abort to complete
> > 	while (GT96100ETH_READ(gp, GT96100_ETH_SDMA_COMM) & abort_bits) {
> > 		// snooze for 20 msec and check again
> >-		gt96100_delay(1);
> >+		msleep_interruptible(20);
> > 	
> > 		if (--timedout == 0) {
> 
> 
> don't change the behavior of the driver, even if it disagrees with the 
> comment.

Ok, please find the corrected patch below.

Description: Uses msleep_interruptible() instead of gt96100_delay()
to guarantee the task delays as expected. Removes prototype and
definition of now unused gt96100_delay() function. Corrects one comment
to correspond to the code.

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


--- 2.6.10-rc1-vanilla/drivers/net/gt96100eth.c	2004-10-30 15:33:30.000000000 -0700
+++ 2.6.10-rc1/drivers/net/gt96100eth.c	2004-11-01 11:05:37.000000000 -0800
@@ -59,7 +59,6 @@
 // prototypes
 static void* dmaalloc(size_t size, dma_addr_t *dma_handle);
 static void dmafree(size_t size, void *vaddr);
-static void gt96100_delay(int msec);
 static int gt96100_add_hash_entry(struct net_device *dev,
 				  unsigned char* addr);
 static void read_mib_counters(struct gt96100_private *gp);
@@ -183,16 +182,6 @@ static void dmafree(size_t size, void *v
 	free_pages((unsigned long)vaddr, get_order(size));
 }
 
-static void gt96100_delay(int ms)
-{
-	if (in_interrupt())
-		return;
-	else {
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(ms*HZ/1000);
-	}
-}
-
 static int
 parse_mac_addr(struct net_device *dev, char* macstr)
 {
@@ -238,7 +227,7 @@ read_MII(int phy_addr, u32 reg)
 	// wait for last operation to complete
 	while (GT96100_READ(GT96100_ETH_SMI_REG) & smirBusy) {
 		// snooze for 1 msec and check again
-		gt96100_delay(1);
+		msleep_interruptible(1);
 
 		if (--timedout == 0) {
 			printk(KERN_ERR "%s: busy timeout!!\n", __FUNCTION__);
@@ -252,7 +241,7 @@ read_MII(int phy_addr, u32 reg)
 	// wait for read to complete
 	while (!((smir = GT96100_READ(GT96100_ETH_SMI_REG)) & smirReadValid)) {
 		// snooze for 1 msec and check again
-		gt96100_delay(1);
+		msleep_interruptible(1);
 	
 		if (--timedout == 0) {
 			printk(KERN_ERR "%s: timeout!!\n", __FUNCTION__);
@@ -304,7 +293,7 @@ write_MII(int phy_addr, u32 reg, u16 dat
 	// wait for last operation to complete
 	while (GT96100_READ(GT96100_ETH_SMI_REG) & smirBusy) {
 		// snooze for 1 msec and check again
-		gt96100_delay(1);
+		msleep_interruptible(1);
 	
 		if (--timedout == 0) {
 			printk(KERN_ERR "%s: busy timeout!!\n", __FUNCTION__);
@@ -527,8 +516,8 @@ abort(struct net_device *dev, u32 abort_
 
 	// wait for abort to complete
 	while (GT96100ETH_READ(gp, GT96100_ETH_SDMA_COMM) & abort_bits) {
-		// snooze for 20 msec and check again
-		gt96100_delay(1);
+		// snooze for 1 msec and check again
+		msleep_interruptible(1);
 	
 		if (--timedout == 0) {
 			err("%s: timeout!!\n", __FUNCTION__);

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

* Re: [PATCH]  net/gt96100eth: replace gt96100_delay() with msleep_interruptible()
  2004-11-01 19:08   ` [PATCH] net/gt96100eth: " Nishanth Aravamudan
@ 2004-11-05  7:47     ` Jeff Garzik
  2004-11-05 17:46       ` Nishanth Aravamudan
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2004-11-05  7:47 UTC (permalink / raw)
  To: Nishanth Aravamudan; +Cc: netdev, kernel-janitors

Nishanth Aravamudan wrote:
> On Sun, Oct 31, 2004 at 06:06:23AM -0500, Jeff Garzik wrote:
> 
>>janitor@sternwelten.at wrote:
>>
>>>@@ -528,7 +517,7 @@ abort(struct net_device *dev, u32 abort_
>>>	// wait for abort to complete
>>>	while (GT96100ETH_READ(gp, GT96100_ETH_SDMA_COMM) & abort_bits) {
>>>		// snooze for 20 msec and check again
>>>-		gt96100_delay(1);
>>>+		msleep_interruptible(20);
>>>	
>>>		if (--timedout == 0) {
>>
>>
>>don't change the behavior of the driver, even if it disagrees with the 
>>comment.
> 
> 
> Ok, please find the corrected patch below.
> 
> Description: Uses msleep_interruptible() instead of gt96100_delay()
> to guarantee the task delays as expected. Removes prototype and
> definition of now unused gt96100_delay() function. Corrects one comment
> to correspond to the code.
> 
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> 
> 
> --- 2.6.10-rc1-vanilla/drivers/net/gt96100eth.c	2004-10-30 15:33:30.000000000 -0700
> +++ 2.6.10-rc1/drivers/net/gt96100eth.c	2004-11-01 11:05:37.000000000 -0800
> @@ -59,7 +59,6 @@
>  // prototypes
>  static void* dmaalloc(size_t size, dma_addr_t *dma_handle);
>  static void dmafree(size_t size, void *vaddr);
> -static void gt96100_delay(int msec);
>  static int gt96100_add_hash_entry(struct net_device *dev,
>  				  unsigned char* addr);
>  static void read_mib_counters(struct gt96100_private *gp);
> @@ -183,16 +182,6 @@ static void dmafree(size_t size, void *v
>  	free_pages((unsigned long)vaddr, get_order(size));
>  }
>  
> -static void gt96100_delay(int ms)
> -{
> -	if (in_interrupt())
> -		return;
> -	else {
> -		current->state = TASK_INTERRUPTIBLE;
> -		schedule_timeout(ms*HZ/1000);

I'm still worried about this patch, because

1) in_interrupt() check disappears, and

2) does driver already include linux/delay.h ?

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

* Re: [PATCH]  net/gt96100eth: replace gt96100_delay() with msleep_interruptible()
  2004-11-05  7:47     ` Jeff Garzik
@ 2004-11-05 17:46       ` Nishanth Aravamudan
  0 siblings, 0 replies; 5+ messages in thread
From: Nishanth Aravamudan @ 2004-11-05 17:46 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev, kernel-janitors

On Fri, Nov 05, 2004 at 02:47:02AM -0500, Jeff Garzik wrote:
> Nishanth Aravamudan wrote:
> >On Sun, Oct 31, 2004 at 06:06:23AM -0500, Jeff Garzik wrote:
> >
> >>janitor@sternwelten.at wrote:
> >>
> >>>@@ -528,7 +517,7 @@ abort(struct net_device *dev, u32 abort_
> >>>	// wait for abort to complete
> >>>	while (GT96100ETH_READ(gp, GT96100_ETH_SDMA_COMM) & abort_bits) {
> >>>		// snooze for 20 msec and check again
> >>>-		gt96100_delay(1);
> >>>+		msleep_interruptible(20);
> >>>	
> >>>		if (--timedout == 0) {
> >>
> >>
> >>don't change the behavior of the driver, even if it disagrees with the 
> >>comment.
> >
> >
> >Ok, please find the corrected patch below.
> >
> >Description: Uses msleep_interruptible() instead of gt96100_delay()
> >to guarantee the task delays as expected. Removes prototype and
> >definition of now unused gt96100_delay() function. Corrects one comment
> >to correspond to the code.
> >
> >Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> >
> >
> >--- 2.6.10-rc1-vanilla/drivers/net/gt96100eth.c	2004-10-30 
> >15:33:30.000000000 -0700
> >+++ 2.6.10-rc1/drivers/net/gt96100eth.c	2004-11-01 
> >11:05:37.000000000 -0800
> >@@ -59,7 +59,6 @@
> > // prototypes
> > static void* dmaalloc(size_t size, dma_addr_t *dma_handle);
> > static void dmafree(size_t size, void *vaddr);
> >-static void gt96100_delay(int msec);
> > static int gt96100_add_hash_entry(struct net_device *dev,
> > 				  unsigned char* addr);
> > static void read_mib_counters(struct gt96100_private *gp);
> >@@ -183,16 +182,6 @@ static void dmafree(size_t size, void *v
> > 	free_pages((unsigned long)vaddr, get_order(size));
> > }
> > 
> >-static void gt96100_delay(int ms)
> >-{
> >-	if (in_interrupt())
> >-		return;
> >-	else {
> >-		current->state = TASK_INTERRUPTIBLE;
> >-		schedule_timeout(ms*HZ/1000);
> 
> I'm still worried about this patch, because
> 
> 1) in_interrupt() check disappears, and

This is true... I have changed the patch significantly, leaving the
gt96100_delay() function intact and simply replacing the else result
with msleep_interruptible(). Does this newer patch look better to you?
Thanks for all the input!

> 2) does driver already include linux/delay.h ?

Yes, it does.



Description: Uses msleep_interruptible() instead of schedule_timeout()
in the gt96100_delay() function. Corrects one comment to correspond to
the code.

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


--- 2.6.10-rc1-vanilla/drivers/net/gt96100eth.c	2004-11-05 09:42:37.000000000 -0800
+++ 2.6.10-rc1/drivers/net/gt96100eth.c	2004-11-05 09:45:48.000000000 -0800
@@ -187,10 +187,8 @@ static void gt96100_delay(int ms)
 {
 	if (in_interrupt())
 		return;
-	else {
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(ms*HZ/1000);
-	}
+	else
+		msleep_interruptible(ms);
 }
 
 static int
@@ -527,7 +525,7 @@ abort(struct net_device *dev, u32 abort_
 
 	// wait for abort to complete
 	while (GT96100ETH_READ(gp, GT96100_ETH_SDMA_COMM) & abort_bits) {
-		// snooze for 20 msec and check again
+		// snooze for 1 msec and check again
 		gt96100_delay(1);
 	
 		if (--timedout == 0) {

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

end of thread, other threads:[~2004-11-05 17:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-30 22:42 [patch 10/18] net/g96100eth: replace gt96100_delay() with msleep_interruptible() janitor
2004-10-31 11:06 ` Jeff Garzik
2004-11-01 19:08   ` [PATCH] net/gt96100eth: " Nishanth Aravamudan
2004-11-05  7:47     ` Jeff Garzik
2004-11-05 17:46       ` 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).