diff options
author | Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> | 2008-04-25 17:39:06 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2008-04-25 17:39:06 -0400 |
commit | ae416e6b2936fdb70aeee6eb9066115d4521daa6 (patch) | |
tree | 697673ed483f1d39e654b54081eb5306df41e91a /drivers/pci/hotplug/pciehp_ctrl.c | |
parent | c27fb883dffe11aa4cb35ecea1fa1832ba45d4da (diff) |
pciehp: Fix wrong slot capability check
Current pciehp saves only 8bits of Slot Capability registers in
ctrl->ctrlcap. But it refers more than 8bit for checking EMI capability.
It is clearly a bug and EMI would never work. To fix this problem,
this patch saves full Slot Capability contens in ctrl->slot_cap. It also
reduce the redundant reads of Slot Capability register. And this pach
also cleans up the macros to check the slot capabilitys (e.g. MRL_SENS(),
and so on).
Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/hotplug/pciehp_ctrl.c')
-rw-r--r-- | drivers/pci/hotplug/pciehp_ctrl.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 0c481f7d2ab3..0a7aa628e955 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -178,7 +178,7 @@ u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl) | |||
178 | static void set_slot_off(struct controller *ctrl, struct slot * pslot) | 178 | static void set_slot_off(struct controller *ctrl, struct slot * pslot) |
179 | { | 179 | { |
180 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ | 180 | /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ |
181 | if (POWER_CTRL(ctrl->ctrlcap)) { | 181 | if (POWER_CTRL(ctrl)) { |
182 | if (pslot->hpc_ops->power_off_slot(pslot)) { | 182 | if (pslot->hpc_ops->power_off_slot(pslot)) { |
183 | err("%s: Issue of Slot Power Off command failed\n", | 183 | err("%s: Issue of Slot Power Off command failed\n", |
184 | __func__); | 184 | __func__); |
@@ -186,10 +186,10 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) | |||
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | if (PWR_LED(ctrl->ctrlcap)) | 189 | if (PWR_LED(ctrl)) |
190 | pslot->hpc_ops->green_led_off(pslot); | 190 | pslot->hpc_ops->green_led_off(pslot); |
191 | 191 | ||
192 | if (ATTN_LED(ctrl->ctrlcap)) { | 192 | if (ATTN_LED(ctrl)) { |
193 | if (pslot->hpc_ops->set_attention_status(pslot, 1)) { | 193 | if (pslot->hpc_ops->set_attention_status(pslot, 1)) { |
194 | err("%s: Issue of Set Attention Led command failed\n", | 194 | err("%s: Issue of Set Attention Led command failed\n", |
195 | __func__); | 195 | __func__); |
@@ -214,14 +214,14 @@ static int board_added(struct slot *p_slot) | |||
214 | __func__, p_slot->device, | 214 | __func__, p_slot->device, |
215 | ctrl->slot_device_offset, p_slot->hp_slot); | 215 | ctrl->slot_device_offset, p_slot->hp_slot); |
216 | 216 | ||
217 | if (POWER_CTRL(ctrl->ctrlcap)) { | 217 | if (POWER_CTRL(ctrl)) { |
218 | /* Power on slot */ | 218 | /* Power on slot */ |
219 | retval = p_slot->hpc_ops->power_on_slot(p_slot); | 219 | retval = p_slot->hpc_ops->power_on_slot(p_slot); |
220 | if (retval) | 220 | if (retval) |
221 | return retval; | 221 | return retval; |
222 | } | 222 | } |
223 | 223 | ||
224 | if (PWR_LED(ctrl->ctrlcap)) | 224 | if (PWR_LED(ctrl)) |
225 | p_slot->hpc_ops->green_led_blink(p_slot); | 225 | p_slot->hpc_ops->green_led_blink(p_slot); |
226 | 226 | ||
227 | /* Wait for ~1 second */ | 227 | /* Wait for ~1 second */ |
@@ -254,7 +254,7 @@ static int board_added(struct slot *p_slot) | |||
254 | */ | 254 | */ |
255 | if (pcie_mch_quirk) | 255 | if (pcie_mch_quirk) |
256 | pci_fixup_device(pci_fixup_final, ctrl->pci_dev); | 256 | pci_fixup_device(pci_fixup_final, ctrl->pci_dev); |
257 | if (PWR_LED(ctrl->ctrlcap)) | 257 | if (PWR_LED(ctrl)) |
258 | p_slot->hpc_ops->green_led_on(p_slot); | 258 | p_slot->hpc_ops->green_led_on(p_slot); |
259 | 259 | ||
260 | return 0; | 260 | return 0; |
@@ -279,7 +279,7 @@ static int remove_board(struct slot *p_slot) | |||
279 | 279 | ||
280 | dbg("In %s, hp_slot = %d\n", __func__, p_slot->hp_slot); | 280 | dbg("In %s, hp_slot = %d\n", __func__, p_slot->hp_slot); |
281 | 281 | ||
282 | if (POWER_CTRL(ctrl->ctrlcap)) { | 282 | if (POWER_CTRL(ctrl)) { |
283 | /* power off slot */ | 283 | /* power off slot */ |
284 | retval = p_slot->hpc_ops->power_off_slot(p_slot); | 284 | retval = p_slot->hpc_ops->power_off_slot(p_slot); |
285 | if (retval) { | 285 | if (retval) { |
@@ -289,7 +289,7 @@ static int remove_board(struct slot *p_slot) | |||
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | if (PWR_LED(ctrl->ctrlcap)) | 292 | if (PWR_LED(ctrl)) |
293 | /* turn off Green LED */ | 293 | /* turn off Green LED */ |
294 | p_slot->hpc_ops->green_led_off(p_slot); | 294 | p_slot->hpc_ops->green_led_off(p_slot); |
295 | 295 | ||
@@ -327,7 +327,7 @@ static void pciehp_power_thread(struct work_struct *work) | |||
327 | case POWERON_STATE: | 327 | case POWERON_STATE: |
328 | mutex_unlock(&p_slot->lock); | 328 | mutex_unlock(&p_slot->lock); |
329 | if (pciehp_enable_slot(p_slot) && | 329 | if (pciehp_enable_slot(p_slot) && |
330 | PWR_LED(p_slot->ctrl->ctrlcap)) | 330 | PWR_LED(p_slot->ctrl)) |
331 | p_slot->hpc_ops->green_led_off(p_slot); | 331 | p_slot->hpc_ops->green_led_off(p_slot); |
332 | mutex_lock(&p_slot->lock); | 332 | mutex_lock(&p_slot->lock); |
333 | p_slot->state = STATIC_STATE; | 333 | p_slot->state = STATIC_STATE; |
@@ -409,9 +409,9 @@ static void handle_button_press_event(struct slot *p_slot) | |||
409 | "press.\n", p_slot->name); | 409 | "press.\n", p_slot->name); |
410 | } | 410 | } |
411 | /* blink green LED and turn off amber */ | 411 | /* blink green LED and turn off amber */ |
412 | if (PWR_LED(ctrl->ctrlcap)) | 412 | if (PWR_LED(ctrl)) |
413 | p_slot->hpc_ops->green_led_blink(p_slot); | 413 | p_slot->hpc_ops->green_led_blink(p_slot); |
414 | if (ATTN_LED(ctrl->ctrlcap)) | 414 | if (ATTN_LED(ctrl)) |
415 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | 415 | p_slot->hpc_ops->set_attention_status(p_slot, 0); |
416 | 416 | ||
417 | schedule_delayed_work(&p_slot->work, 5*HZ); | 417 | schedule_delayed_work(&p_slot->work, 5*HZ); |
@@ -427,13 +427,13 @@ static void handle_button_press_event(struct slot *p_slot) | |||
427 | dbg("%s: button cancel\n", __func__); | 427 | dbg("%s: button cancel\n", __func__); |
428 | cancel_delayed_work(&p_slot->work); | 428 | cancel_delayed_work(&p_slot->work); |
429 | if (p_slot->state == BLINKINGOFF_STATE) { | 429 | if (p_slot->state == BLINKINGOFF_STATE) { |
430 | if (PWR_LED(ctrl->ctrlcap)) | 430 | if (PWR_LED(ctrl)) |
431 | p_slot->hpc_ops->green_led_on(p_slot); | 431 | p_slot->hpc_ops->green_led_on(p_slot); |
432 | } else { | 432 | } else { |
433 | if (PWR_LED(ctrl->ctrlcap)) | 433 | if (PWR_LED(ctrl)) |
434 | p_slot->hpc_ops->green_led_off(p_slot); | 434 | p_slot->hpc_ops->green_led_off(p_slot); |
435 | } | 435 | } |
436 | if (ATTN_LED(ctrl->ctrlcap)) | 436 | if (ATTN_LED(ctrl)) |
437 | p_slot->hpc_ops->set_attention_status(p_slot, 0); | 437 | p_slot->hpc_ops->set_attention_status(p_slot, 0); |
438 | info("PCI slot #%s - action canceled due to button press\n", | 438 | info("PCI slot #%s - action canceled due to button press\n", |
439 | p_slot->name); | 439 | p_slot->name); |
@@ -492,16 +492,16 @@ static void interrupt_event_handler(struct work_struct *work) | |||
492 | handle_button_press_event(p_slot); | 492 | handle_button_press_event(p_slot); |
493 | break; | 493 | break; |
494 | case INT_POWER_FAULT: | 494 | case INT_POWER_FAULT: |
495 | if (!POWER_CTRL(ctrl->ctrlcap)) | 495 | if (!POWER_CTRL(ctrl)) |
496 | break; | 496 | break; |
497 | if (ATTN_LED(ctrl->ctrlcap)) | 497 | if (ATTN_LED(ctrl)) |
498 | p_slot->hpc_ops->set_attention_status(p_slot, 1); | 498 | p_slot->hpc_ops->set_attention_status(p_slot, 1); |
499 | if (PWR_LED(ctrl->ctrlcap)) | 499 | if (PWR_LED(ctrl)) |
500 | p_slot->hpc_ops->green_led_off(p_slot); | 500 | p_slot->hpc_ops->green_led_off(p_slot); |
501 | break; | 501 | break; |
502 | case INT_PRESENCE_ON: | 502 | case INT_PRESENCE_ON: |
503 | case INT_PRESENCE_OFF: | 503 | case INT_PRESENCE_OFF: |
504 | if (!HP_SUPR_RM(ctrl->ctrlcap)) | 504 | if (!HP_SUPR_RM(ctrl)) |
505 | break; | 505 | break; |
506 | dbg("Surprise Removal\n"); | 506 | dbg("Surprise Removal\n"); |
507 | update_slot_info(p_slot); | 507 | update_slot_info(p_slot); |
@@ -531,7 +531,7 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
531 | mutex_unlock(&p_slot->ctrl->crit_sect); | 531 | mutex_unlock(&p_slot->ctrl->crit_sect); |
532 | return -ENODEV; | 532 | return -ENODEV; |
533 | } | 533 | } |
534 | if (MRL_SENS(p_slot->ctrl->ctrlcap)) { | 534 | if (MRL_SENS(p_slot->ctrl)) { |
535 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 535 | rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
536 | if (rc || getstatus) { | 536 | if (rc || getstatus) { |
537 | info("%s: latch open on slot(%s)\n", __func__, | 537 | info("%s: latch open on slot(%s)\n", __func__, |
@@ -541,7 +541,7 @@ int pciehp_enable_slot(struct slot *p_slot) | |||
541 | } | 541 | } |
542 | } | 542 | } |
543 | 543 | ||
544 | if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { | 544 | if (POWER_CTRL(p_slot->ctrl)) { |
545 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 545 | rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
546 | if (rc || getstatus) { | 546 | if (rc || getstatus) { |
547 | info("%s: already enabled on slot(%s)\n", __func__, | 547 | info("%s: already enabled on slot(%s)\n", __func__, |
@@ -576,7 +576,7 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
576 | /* Check to see if (latch closed, card present, power on) */ | 576 | /* Check to see if (latch closed, card present, power on) */ |
577 | mutex_lock(&p_slot->ctrl->crit_sect); | 577 | mutex_lock(&p_slot->ctrl->crit_sect); |
578 | 578 | ||
579 | if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { | 579 | if (!HP_SUPR_RM(p_slot->ctrl)) { |
580 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); | 580 | ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); |
581 | if (ret || !getstatus) { | 581 | if (ret || !getstatus) { |
582 | info("%s: no adapter on slot(%s)\n", __func__, | 582 | info("%s: no adapter on slot(%s)\n", __func__, |
@@ -586,7 +586,7 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
586 | } | 586 | } |
587 | } | 587 | } |
588 | 588 | ||
589 | if (MRL_SENS(p_slot->ctrl->ctrlcap)) { | 589 | if (MRL_SENS(p_slot->ctrl)) { |
590 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); | 590 | ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); |
591 | if (ret || getstatus) { | 591 | if (ret || getstatus) { |
592 | info("%s: latch open on slot(%s)\n", __func__, | 592 | info("%s: latch open on slot(%s)\n", __func__, |
@@ -596,7 +596,7 @@ int pciehp_disable_slot(struct slot *p_slot) | |||
596 | } | 596 | } |
597 | } | 597 | } |
598 | 598 | ||
599 | if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { | 599 | if (POWER_CTRL(p_slot->ctrl)) { |
600 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); | 600 | ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); |
601 | if (ret || !getstatus) { | 601 | if (ret || !getstatus) { |
602 | info("%s: already disabled slot(%s)\n", __func__, | 602 | info("%s: already disabled slot(%s)\n", __func__, |