ehea: converting msleeps to waitqueue on check_sqs() function
authorBreno Leitao <leitao@linux.vnet.ibm.com>
Tue, 5 Oct 2010 13:16:23 +0000 (13:16 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Oct 2010 03:10:55 +0000 (20:10 -0700)
Removing the msleep() call in check_sqs() function, and replacing by a wait queue.

Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ehea/ehea.h
drivers/net/ehea/ehea_main.c

index 5bae7daf40fbdd319098608a35044ccacfd03b19..1321cb6401cfc9fd2a68ed0ba524a6fc83c17a32 100644 (file)
@@ -492,6 +492,7 @@ struct ehea_port {
        u8 autoneg;
        u8 num_def_qps;
        wait_queue_head_t swqe_avail_wq;
+       wait_queue_head_t restart_wq;
 };
 
 struct port_res_cfg {
index 7897bdf76e66bb4acb3749a4b53d13dc36f43239..15401af30108bfc26ef4b307f2d6b85acb917055 100644 (file)
@@ -786,6 +786,7 @@ static void reset_sq_restart_flag(struct ehea_port *port)
                struct ehea_port_res *pr = &port->port_res[i];
                pr->sq_restart_flag = 0;
        }
+       wake_up(&port->restart_wq);
 }
 
 static void check_sqs(struct ehea_port *port)
@@ -796,6 +797,7 @@ static void check_sqs(struct ehea_port *port)
 
        for (i = 0; i < port->num_def_qps + port->num_add_tx_qps; i++) {
                struct ehea_port_res *pr = &port->port_res[i];
+               int ret;
                k = 0;
                swqe = ehea_get_swqe(pr->qp, &swqe_index);
                memset(swqe, 0, SWQE_HEADER_SIZE);
@@ -809,13 +811,14 @@ static void check_sqs(struct ehea_port *port)
 
                ehea_post_swqe(pr->qp, swqe);
 
-               while (pr->sq_restart_flag == 0) {
-                       msleep(5);
-                       if (++k == 100) {
-                               ehea_error("HW/SW queues out of sync");
-                               ehea_schedule_port_reset(pr->port);
-                               return;
-                       }
+               ret = wait_event_timeout(port->restart_wq,
+                                        pr->sq_restart_flag == 0,
+                                        msecs_to_jiffies(100));
+
+               if (!ret) {
+                       ehea_error("HW/SW queues out of sync");
+                       ehea_schedule_port_reset(pr->port);
+                       return;
                }
        }
 }
@@ -2654,6 +2657,7 @@ static int ehea_open(struct net_device *dev)
        }
 
        init_waitqueue_head(&port->swqe_avail_wq);
+       init_waitqueue_head(&port->restart_wq);
 
        mutex_unlock(&port->port_lock);