aboutsummaryrefslogtreecommitdiff
path: root/drivers/pci/hotplug/shpchp_hpc.c
diff options
context:
space:
mode:
authorKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>2006-09-28 15:51:21 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2006-10-18 11:36:11 -0700
commitd1729ccecd7ba9ceb6dca1c973dbfd87041d0637 (patch)
tree47be9a24701f8bda7ee6d833e1c914d1e5bdec13 /drivers/pci/hotplug/shpchp_hpc.c
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>
Diffstat (limited to 'drivers/pci/hotplug/shpchp_hpc.c')
-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 446e9beff04..4826dd158de 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)
add_timer(&php_ctlr->int_poll_timer);
}
+static inline int is_ctrl_busy(struct controller *ctrl)
+{
+ u16 cmd_status = shpc_readw(ctrl, CMD_STATUS);
+ return cmd_status & 0x1;
+}
+
/*
* Returns 1 if SHPC finishes executing a command within 1 sec,
* otherwise returns 0.
@@ -309,16 +315,14 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int sec)
static inline int shpc_poll_ctrl_busy(struct controller *ctrl)
{
int i;
- u16 cmd_status = shpc_readw(ctrl, CMD_STATUS);
- if (!(cmd_status & 0x1))
+ if (!is_ctrl_busy(ctrl))
return 1;
/* Check every 0.1 sec for a total of 1 sec */
for (i = 0; i < 10; i++) {
msleep(100);
- cmd_status = shpc_readw(ctrl, CMD_STATUS);
- if (!(cmd_status & 0x1))
+ if (!is_ctrl_busy(ctrl))
return 1;
}
@@ -336,7 +340,7 @@ static inline int shpc_wait_cmd(struct controller *ctrl)
else
rc = wait_event_interruptible_timeout(ctrl->queue,
!ctrl->cmd_busy, timeout);
- if (!rc) {
+ if (!rc && is_ctrl_busy(ctrl)) {
retval = -EIO;
err("Command not completed in 1000 msec\n");
} else if (rc < 0) {