Commit 24c78a4e authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

[ATM]: [ambassador] use msleep() instead of schedule_timeout()

Signed-off-by: default avatarNishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: default avatarDomen Puncer <domen@coderock.org>
Signed-off-by: default avatarChas Williams <chas@cmf.nrl.navy.mil>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 74bf8d12
...@@ -574,7 +574,6 @@ static int command_do (amb_dev * dev, command * cmd) { ...@@ -574,7 +574,6 @@ static int command_do (amb_dev * dev, command * cmd) {
amb_cq * cq = &dev->cq; amb_cq * cq = &dev->cq;
volatile amb_cq_ptrs * ptrs = &cq->ptrs; volatile amb_cq_ptrs * ptrs = &cq->ptrs;
command * my_slot; command * my_slot;
unsigned long timeout;
PRINTD (DBG_FLOW|DBG_CMD, "command_do %p", dev); PRINTD (DBG_FLOW|DBG_CMD, "command_do %p", dev);
...@@ -599,20 +598,14 @@ static int command_do (amb_dev * dev, command * cmd) { ...@@ -599,20 +598,14 @@ static int command_do (amb_dev * dev, command * cmd) {
// mail the command // mail the command
wr_mem (dev, offsetof(amb_mem, mb.adapter.cmd_address), virt_to_bus (ptrs->in)); wr_mem (dev, offsetof(amb_mem, mb.adapter.cmd_address), virt_to_bus (ptrs->in));
// prepare to wait for cq->pending milliseconds
// effectively one centisecond on i386
timeout = (cq->pending*HZ+999)/1000;
if (cq->pending > cq->high) if (cq->pending > cq->high)
cq->high = cq->pending; cq->high = cq->pending;
spin_unlock (&cq->lock); spin_unlock (&cq->lock);
while (timeout) { // these comments were in a while-loop before, msleep removes the loop
// go to sleep // go to sleep
// PRINTD (DBG_CMD, "wait: sleeping %lu for command", timeout); // PRINTD (DBG_CMD, "wait: sleeping %lu for command", timeout);
set_current_state(TASK_UNINTERRUPTIBLE); msleep(cq->pending);
timeout = schedule_timeout (timeout);
}
// wait for my slot to be reached (all waiters are here or above, until...) // wait for my slot to be reached (all waiters are here or above, until...)
while (ptrs->out != my_slot) { while (ptrs->out != my_slot) {
...@@ -1799,12 +1792,11 @@ static int __init do_loader_command (volatile loader_block * lb, ...@@ -1799,12 +1792,11 @@ static int __init do_loader_command (volatile loader_block * lb,
// dump_loader_block (lb); // dump_loader_block (lb);
wr_mem (dev, offsetof(amb_mem, doorbell), virt_to_bus (lb) & ~onegigmask); wr_mem (dev, offsetof(amb_mem, doorbell), virt_to_bus (lb) & ~onegigmask);
timeout = command_timeouts[cmd] * HZ/100; timeout = command_timeouts[cmd] * 10;
while (!lb->result || lb->result == cpu_to_be32 (COMMAND_IN_PROGRESS)) while (!lb->result || lb->result == cpu_to_be32 (COMMAND_IN_PROGRESS))
if (timeout) { if (timeout) {
set_current_state(TASK_UNINTERRUPTIBLE); timeout = msleep_interruptible(timeout);
timeout = schedule_timeout (timeout);
} else { } else {
PRINTD (DBG_LOAD|DBG_ERR, "command %d timed out", cmd); PRINTD (DBG_LOAD|DBG_ERR, "command %d timed out", cmd);
dump_registers (dev); dump_registers (dev);
...@@ -1814,10 +1806,10 @@ static int __init do_loader_command (volatile loader_block * lb, ...@@ -1814,10 +1806,10 @@ static int __init do_loader_command (volatile loader_block * lb,
if (cmd == adapter_start) { if (cmd == adapter_start) {
// wait for start command to acknowledge... // wait for start command to acknowledge...
timeout = HZ/10; timeout = 100;
while (rd_plain (dev, offsetof(amb_mem, doorbell))) while (rd_plain (dev, offsetof(amb_mem, doorbell)))
if (timeout) { if (timeout) {
timeout = schedule_timeout (timeout); timeout = msleep_interruptible(timeout);
} else { } else {
PRINTD (DBG_LOAD|DBG_ERR, "start command did not clear doorbell, res=%08x", PRINTD (DBG_LOAD|DBG_ERR, "start command did not clear doorbell, res=%08x",
be32_to_cpu (lb->result)); be32_to_cpu (lb->result));
...@@ -1932,17 +1924,12 @@ static int amb_reset (amb_dev * dev, int diags) { ...@@ -1932,17 +1924,12 @@ static int amb_reset (amb_dev * dev, int diags) {
if (diags) { if (diags) {
unsigned long timeout; unsigned long timeout;
// 4.2 second wait // 4.2 second wait
timeout = HZ*42/10; msleep(4200);
while (timeout) {
set_current_state(TASK_UNINTERRUPTIBLE);
timeout = schedule_timeout (timeout);
}
// half second time-out // half second time-out
timeout = HZ/2; timeout = 500;
while (!rd_plain (dev, offsetof(amb_mem, mb.loader.ready))) while (!rd_plain (dev, offsetof(amb_mem, mb.loader.ready)))
if (timeout) { if (timeout) {
set_current_state(TASK_UNINTERRUPTIBLE); timeout = msleep_interruptible(timeout);
timeout = schedule_timeout (timeout);
} else { } else {
PRINTD (DBG_LOAD|DBG_ERR, "reset timed out"); PRINTD (DBG_LOAD|DBG_ERR, "reset timed out");
return -ETIMEDOUT; return -ETIMEDOUT;
...@@ -2056,14 +2043,12 @@ static int __init amb_talk (amb_dev * dev) { ...@@ -2056,14 +2043,12 @@ static int __init amb_talk (amb_dev * dev) {
wr_mem (dev, offsetof(amb_mem, doorbell), virt_to_bus (&a)); wr_mem (dev, offsetof(amb_mem, doorbell), virt_to_bus (&a));
// 2.2 second wait (must not touch doorbell during 2 second DMA test) // 2.2 second wait (must not touch doorbell during 2 second DMA test)
timeout = HZ*22/10; msleep(2200);
while (timeout)
timeout = schedule_timeout (timeout);
// give the adapter another half second? // give the adapter another half second?
timeout = HZ/2; timeout = 500;
while (rd_plain (dev, offsetof(amb_mem, doorbell))) while (rd_plain (dev, offsetof(amb_mem, doorbell)))
if (timeout) { if (timeout) {
timeout = schedule_timeout (timeout); timeout = msleep_interruptible(timeout);
} else { } else {
PRINTD (DBG_INIT|DBG_ERR, "adapter init timed out"); PRINTD (DBG_INIT|DBG_ERR, "adapter init timed out");
return -ETIMEDOUT; return -ETIMEDOUT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment