Skip to content

Commit

Permalink
shpchp: fix command completion check
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kenji Kaneshige authored and Greg Kroah-Hartman committed Oct 18, 2006
1 parent 094ed76 commit d1729cc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/pci/hotplug/shpchp_hpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,23 +302,27 @@ 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.
*/
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;
}

Expand All @@ -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) {
Expand Down

0 comments on commit d1729cc

Please sign in to comment.