Skip to contentSkip to conversation

net/g96100eth: replace gt96100_delay() with msleep_interruptible()

PATCH In review [email protected] 3 participants 6 messages Oct 30, 2004 – Nov 5, 2004

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 10/18 net/g96100eth: replace gt96100_delay() with msleep_interruptible()

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.

---

 linux-2.6.10-rc1-max/drivers/net/gt96100eth.c |   19 ++++---------------
 1 files changed, 4 insertions(+), 15 deletions(-)
drivers/net/gt96100eth.c renamed from drivers/net/gt96100eth.c~msleep_interruptible-drivers_net_gt96100eth +4 -15
diff -puN drivers/net/gt96100eth.c~msleep_interruptible-drivers_net_gt96100eth drivers/net/gt96100eth.c
@@ -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__);

_

#1 lore raw

drivers/net/gt96100eth.c abort(struct net_device *dev, u32 abort_ · line 522

Quoted 8 lines · [email protected] wrote:
drivers/net/gt96100eth.c renamed from drivers/net/gt96100eth.c~msleep_interruptible-drivers_net_gt96100eth +1 -1
@@ -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.

#2 lore raw

PATCH 1/1 net/gt96100eth: replace gt96100_delay() with msleep_interruptible()

Quoted 8 lines · Jeff Garzik
Quoted 7 lines · [email protected] wrote:
(quoted diff) +1 -1
@@ -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);
 
Quoted 5 lines

Review abort(struct net_device *dev, u32 abort_ · line 522

Quoted 1 line
(quoted diff) +0 -0
 		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.

drivers/net/gt96100eth.c +5 -16
@@ -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__);

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw

Re: [PATCH] net/gt96100eth: replace gt96100_delay() with msleep_interruptible()

Quoted 38 lines · Nishanth Aravamudan
Quoted 9 lines · Jeff Garzik
Quoted 7 lines · [email protected] wrote:
drivers/net/gt96100eth.c +1 -1
@@ -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);
 
Quoted 4 lines

Review abort(struct net_device *dev, u32 abort_ · line 522

Quoted 1 line
(quoted diff) +0 -0
 		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.

drivers/net/gt96100eth.c +0 -1
@@ -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);

drivers/net/gt96100eth.c static void dmafree(size_t size, void *v · line 192

Quoted 10 lines
drivers/net/gt96100eth.c +0 -7
@@ -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 ?

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#4 lore raw

Re: [PATCH] net/gt96100eth: replace gt96100_delay() with msleep_interruptible()

Quoted 55 lines · Jeff Garzik
Quoted 41 lines · Nishanth Aravamudan
Quoted 9 lines · Jeff Garzik
Quoted 7 lines · [email protected] wrote:
(quoted diff) +1 -1
@@ -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);
 
Quoted 5 lines

Review abort(struct net_device *dev, u32 abort_ · line 522

Quoted 1 line
(quoted diff) +0 -0
 		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.

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

(quoted diff) +0 -1
@@ -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);

Review static void dmafree(size_t size, void *v · line 192

Quoted 10 lines
(quoted diff) +0 -7
@@ -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

Quoted 1 line

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!

Quoted 1 line

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.

drivers/net/gt96100eth.c +3 -5
@@ -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) {
#5 lore raw

[KJ] Re: [PATCH] net/gt96100eth: replace gt96100_delay() with

In reply to Jeff Garzik
Quoted 55 lines · Jeff Garzik
Quoted 41 lines · Nishanth Aravamudan
Quoted 9 lines · Jeff Garzik
Quoted 7 lines · [email protected] wrote:
(quoted diff) +1 -1
@@ -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);
 
Quoted 5 lines

Review abort(struct net_device *dev, u32 abort_ · line 522

Quoted 1 line
(quoted diff) +0 -0
 		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.

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

(quoted diff) +0 -1
@@ -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);

Review static void dmafree(size_t size, void *v · line 192

Quoted 10 lines
(quoted diff) +0 -7
@@ -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

Quoted 1 line

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!

Quoted 1 line

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.

drivers/net/gt96100eth.c +3 -5
@@ -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) {

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors