aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>2006-09-28 18:51:21 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-10-18 14:36:11 -0400
commitd1729ccecd7ba9ceb6dca1c973dbfd87041d0637 (patch)
tree47be9a24701f8bda7ee6d833e1c914d1e5bdec13
parent094ed76e8988d46158b036ab150e0c22aff6db3a (diff)
shpchp: fix command completion check
This patch fixes the problem that shpchp driver could mis-detect command failures if the system was under heavy load. Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 446e9beff046..4826dd158deb 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -302,6 +302,12 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int sec)
302 add_timer(&php_ctlr->int_poll_timer); 302 add_timer(&php_ctlr->int_poll_timer);
303} 303}
304 304
305static inline int is_ctrl_busy(struct controller *ctrl)
306{
307 u16 cmd_status = shpc_readw(ctrl, CMD_STATUS);
308 return cmd_status & 0x1;
309}
310
305/* 311/*
306 * Returns 1 if SHPC finishes executing a command within 1 sec, 312 * Returns 1 if SHPC finishes executing a command within 1 sec,
307 * otherwise returns 0. 313 * otherwise returns 0.
@@ -309,16 +315,14 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int sec)
309static inline int shpc_poll_ctrl_busy(struct controller *ctrl) 315static inline int shpc_poll_ctrl_busy(struct controller *ctrl)
310{ 316{
311 int i; 317 int i;
312 u16 cmd_status = shpc_readw(ctrl, CMD_STATUS);
313 318
314 if (!(cmd_status & 0x1)) 319 if (!is_ctrl_busy(ctrl))
315 return 1; 320 return 1;
316 321
317 /* Check every 0.1 sec for a total of 1 sec */ 322 /* Check every 0.1 sec for a total of 1 sec */
318 for (i = 0; i < 10; i++) { 323 for (i = 0; i < 10; i++) {
319 msleep(100); 324 msleep(100);
320 cmd_status = shpc_readw(ctrl, CMD_STATUS); 325 if (!is_ctrl_busy(ctrl))
321 if (!(cmd_status & 0x1))
322 return 1; 326 return 1;
323 } 327 }
324 328
@@ -336,7 +340,7 @@ static inline int shpc_wait_cmd(struct controller *ctrl)
336 else 340 else
337 rc = wait_event_interruptible_timeout(ctrl->queue, 341 rc = wait_event_interruptible_timeout(ctrl->queue,
338 !ctrl->cmd_busy, timeout); 342 !ctrl->cmd_busy, timeout);
339 if (!rc) { 343 if (!rc && is_ctrl_busy(ctrl)) {
340 retval = -EIO; 344 retval = -EIO;
341 err("Command not completed in 1000 msec\n"); 345 err("Command not completed in 1000 msec\n");
342 } else if (rc < 0) { 346 } else if (rc < 0) {