Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 17500
b: refs/heads/master
c: bd62e27
h: refs/heads/master
v: v3
  • Loading branch information
Kenji Kaneshige authored and Greg Kroah-Hartman committed Jan 9, 2006
1 parent 97a5f8b commit 74a7065
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 38 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f467f6187fc60c954a9509b3a3e17ef89a4f6f22
refs/heads/master: bd62e271401c5ebf33a0dd24d89baf706f213251
1 change: 1 addition & 0 deletions trunk/drivers/pci/hotplug/shpchp.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct controller {
u32 cap_offset;
unsigned long mmio_base;
unsigned long mmio_size;
volatile int cmd_busy;
};

struct hotplug_params {
Expand Down
37 changes: 0 additions & 37 deletions trunk/drivers/pci/hotplug/shpchp_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot,
up(&ctrl->crit_sect);
return WRONG_BUS_FREQUENCY;
}
wait_for_ctrl_irq (ctrl);

if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
Expand Down Expand Up @@ -330,9 +329,6 @@ static int board_added(struct slot *p_slot)
up(&ctrl->crit_sect);
return -1;
}

/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

rc = p_slot->hpc_ops->check_cmd_status(ctrl);
if (rc) {
Expand All @@ -352,7 +348,6 @@ static int board_added(struct slot *p_slot)
up(&ctrl->crit_sect);
return WRONG_BUS_FREQUENCY;
}
wait_for_ctrl_irq (ctrl);

if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
Expand All @@ -367,7 +362,6 @@ static int board_added(struct slot *p_slot)
up(&ctrl->crit_sect);
return rc;
}
wait_for_ctrl_irq (ctrl);

if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
Expand Down Expand Up @@ -494,7 +488,6 @@ static int board_added(struct slot *p_slot)
up(&ctrl->crit_sect);
return rc;
}
wait_for_ctrl_irq (ctrl);

if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
Expand Down Expand Up @@ -532,9 +525,6 @@ static int board_added(struct slot *p_slot)

p_slot->hpc_ops->green_led_on(p_slot);

/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

/* Done with exclusive hardware access */
up(&ctrl->crit_sect);

Expand All @@ -552,8 +542,6 @@ static int board_added(struct slot *p_slot)
up(&ctrl->crit_sect);
return rc;
}
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

rc = p_slot->hpc_ops->check_cmd_status(ctrl);
if (rc) {
Expand Down Expand Up @@ -603,8 +591,6 @@ static int remove_board(struct slot *p_slot)
up(&ctrl->crit_sect);
return rc;
}
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

rc = p_slot->hpc_ops->check_cmd_status(ctrl);
if (rc) {
Expand All @@ -621,8 +607,6 @@ static int remove_board(struct slot *p_slot)
up(&ctrl->crit_sect);
return rc;
}
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

/* Done with exclusive hardware access */
up(&ctrl->crit_sect);
Expand Down Expand Up @@ -676,9 +660,6 @@ static void shpchp_pushbutton_thread (unsigned long slot)

p_slot->hpc_ops->green_led_off(p_slot);

/* Wait for the command to complete */
wait_for_ctrl_irq (p_slot->ctrl);

/* Done with exclusive hardware access */
up(&p_slot->ctrl->crit_sect);
}
Expand Down Expand Up @@ -790,14 +771,9 @@ static void interrupt_event_handler(struct controller *ctrl)
down(&ctrl->crit_sect);

p_slot->hpc_ops->green_led_on(p_slot);
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

p_slot->hpc_ops->set_attention_status(p_slot, 0);

/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

/* Done with exclusive hardware access */
up(&ctrl->crit_sect);
break;
Expand All @@ -806,12 +782,8 @@ static void interrupt_event_handler(struct controller *ctrl)
down(&ctrl->crit_sect);

p_slot->hpc_ops->green_led_off(p_slot);
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

p_slot->hpc_ops->set_attention_status(p_slot, 0);
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

/* Done with exclusive hardware access */
up(&ctrl->crit_sect);
Expand Down Expand Up @@ -845,14 +817,9 @@ static void interrupt_event_handler(struct controller *ctrl)

/* blink green LED and turn off amber */
p_slot->hpc_ops->green_led_blink(p_slot);
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

p_slot->hpc_ops->set_attention_status(p_slot, 0);

/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

/* Done with exclusive hardware access */
up(&ctrl->crit_sect);

Expand All @@ -870,12 +837,8 @@ static void interrupt_event_handler(struct controller *ctrl)
down(&ctrl->crit_sect);

p_slot->hpc_ops->set_attention_status(p_slot, 1);
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

p_slot->hpc_ops->green_led_off(p_slot);
/* Wait for the command to complete */
wait_for_ctrl_irq (ctrl);

/* Done with exclusive hardware access */
up(&ctrl->crit_sect);
Expand Down
26 changes: 26 additions & 0 deletions trunk/drivers/pci/hotplug/shpchp_hpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,25 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds)
return;
}

static inline int shpc_wait_cmd(struct controller *ctrl)
{
int retval = 0;
unsigned int timeout_msec = shpchp_poll_mode ? 2000 : 1000;
unsigned long timeout = msecs_to_jiffies(timeout_msec);
int rc = wait_event_interruptible_timeout(ctrl->queue,
!ctrl->cmd_busy, timeout);
if (!rc) {
retval = -EIO;
err("Command not completed in %d msec\n", timeout_msec);
} else if (rc < 0) {
retval = -EINTR;
info("Command was interrupted by a signal\n");
}
ctrl->cmd_busy = 0;

return retval;
}

static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
{
struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
Expand Down Expand Up @@ -314,8 +333,14 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
/* To make sure the Controller Busy bit is 0 before we send out the
* command.
*/
slot->ctrl->cmd_busy = 1;
writew(temp_word, php_ctlr->creg + CMD);

/*
* Wait for command completion.
*/
retval = shpc_wait_cmd(slot->ctrl);

DBG_LEAVE_ROUTINE
return retval;
}
Expand Down Expand Up @@ -1064,6 +1089,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE);
temp_dword &= 0xfffdffff;
writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE);
ctrl->cmd_busy = 0;
wake_up_interruptible(&ctrl->queue);
}

Expand Down

0 comments on commit 74a7065

Please sign in to comment.