* [PATCH 1/2] ehea: using wait queues instead of msleep on ehea_flush_sq
@ 2010-10-05 23:16 leitao
2010-10-05 23:16 ` [PATCH 2/2] ehea: converting msleeps to waitqueue on check_sqs() function leitao
2010-10-06 3:14 ` [PATCH 1/2] ehea: using wait queues instead of msleep on ehea_flush_sq David Miller
0 siblings, 2 replies; 4+ messages in thread
From: leitao @ 2010-10-05 23:16 UTC (permalink / raw)
To: davem; +Cc: netdev, Breno Leitao
This patch just remove a msleep loop and change to wait queue,
making the code cleaner.
Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
Acked-by: David Howells <dhowells@redhat.com>
---
drivers/net/ehea/ehea.h | 1 +
drivers/net/ehea/ehea_main.c | 19 ++++++++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 1846623..5bae7da 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -491,6 +491,7 @@ struct ehea_port {
u8 full_duplex;
u8 autoneg;
u8 num_def_qps;
+ wait_queue_head_t swqe_avail_wq;
};
struct port_res_cfg {
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index a333b42..4a3d33b 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -890,6 +890,7 @@ static struct ehea_cqe *ehea_proc_cqes(struct ehea_port_res *pr, int my_quota)
pr->queue_stopped = 0;
}
spin_unlock_irqrestore(&pr->netif_queue, flags);
+ wake_up(&pr->port->swqe_avail_wq);
return cqe;
}
@@ -2654,6 +2655,8 @@ static int ehea_open(struct net_device *dev)
netif_start_queue(dev);
}
+ init_waitqueue_head(&port->swqe_avail_wq);
+
mutex_unlock(&port->port_lock);
return ret;
@@ -2726,13 +2729,15 @@ static void ehea_flush_sq(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 swqe_max = pr->sq_skba_size - 2 - pr->swqe_ll_count;
- int k = 0;
- while (atomic_read(&pr->swqe_avail) < swqe_max) {
- msleep(5);
- if (++k == 20) {
- ehea_error("WARNING: sq not flushed completely");
- break;
- }
+ int ret;
+
+ ret = wait_event_timeout(port->swqe_avail_wq,
+ atomic_read(&pr->swqe_avail) >= swqe_max,
+ msecs_to_jiffies(100));
+
+ if (!ret) {
+ ehea_error("WARNING: sq not flushed completely");
+ break;
}
}
}
--
1.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ehea: converting msleeps to waitqueue on check_sqs() function
2010-10-05 23:16 [PATCH 1/2] ehea: using wait queues instead of msleep on ehea_flush_sq leitao
@ 2010-10-05 23:16 ` leitao
2010-10-06 3:15 ` David Miller
2010-10-06 3:14 ` [PATCH 1/2] ehea: using wait queues instead of msleep on ehea_flush_sq David Miller
1 sibling, 1 reply; 4+ messages in thread
From: leitao @ 2010-10-05 23:16 UTC (permalink / raw)
To: davem; +Cc: netdev, Breno Leitao
Removing the msleep() call in check_sqs() function, and replacing by a wait queue.
Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
---
drivers/net/ehea/ehea.h | 1 +
drivers/net/ehea/ehea_main.c | 18 +++++++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 5bae7da..1321cb6 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -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 {
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 4a3d33b..0471cae 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -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;
}
}
@@ -2656,6 +2659,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);
--
1.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ehea: using wait queues instead of msleep on ehea_flush_sq
2010-10-05 23:16 [PATCH 1/2] ehea: using wait queues instead of msleep on ehea_flush_sq leitao
2010-10-05 23:16 ` [PATCH 2/2] ehea: converting msleeps to waitqueue on check_sqs() function leitao
@ 2010-10-06 3:14 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2010-10-06 3:14 UTC (permalink / raw)
To: leitao; +Cc: netdev
From: leitao@linux.vnet.ibm.com
Date: Tue, 5 Oct 2010 19:16:22 -0400
> This patch just remove a msleep loop and change to wait queue,
> making the code cleaner.
>
> Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
> Acked-by: David Howells <dhowells@redhat.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ehea: converting msleeps to waitqueue on check_sqs() function
2010-10-05 23:16 ` [PATCH 2/2] ehea: converting msleeps to waitqueue on check_sqs() function leitao
@ 2010-10-06 3:15 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-10-06 3:15 UTC (permalink / raw)
To: leitao; +Cc: netdev
From: leitao@linux.vnet.ibm.com
Date: Tue, 5 Oct 2010 19:16:23 -0400
> Removing the msleep() call in check_sqs() function, and replacing by a wait queue.
>
> Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-06 3:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-05 23:16 [PATCH 1/2] ehea: using wait queues instead of msleep on ehea_flush_sq leitao
2010-10-05 23:16 ` [PATCH 2/2] ehea: converting msleeps to waitqueue on check_sqs() function leitao
2010-10-06 3:15 ` David Miller
2010-10-06 3:14 ` [PATCH 1/2] ehea: using wait queues instead of msleep on ehea_flush_sq David Miller
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).