2 * PCI Express Hot Plug Controller Driver
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
30 #include <linux/config.h>
31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/types.h>
34 #include <linux/slab.h>
35 #include <linux/workqueue.h>
36 #include <linux/interrupt.h>
37 #include <linux/delay.h>
38 #include <linux/wait.h>
39 #include <linux/smp_lock.h>
40 #include <linux/pci.h>
44 static void interrupt_event_handler(struct controller *ctrl);
46 static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */
47 static struct semaphore event_exit; /* guard ensure thread has exited before calling it quits */
48 static int event_finished;
49 static unsigned long pushbutton_pending; /* = 0 */
50 static unsigned long surprise_rm_pending; /* = 0 */
52 u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
54 struct controller *ctrl = (struct controller *) inst_id;
58 struct event_info *taskInfo;
60 /* Attention Button Change */
61 dbg("pciehp: Attention button interrupt received.\n");
63 /* This is the structure that tells the worker thread what to do */
64 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
65 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
67 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
68 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
70 ctrl->next_event = (ctrl->next_event + 1) % 10;
71 taskInfo->hp_slot = hp_slot;
76 * Button pressed - See if need to TAKE ACTION!!!
78 info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot);
79 taskInfo->event_type = INT_BUTTON_PRESS;
81 if ((p_slot->state == BLINKINGON_STATE)
82 || (p_slot->state == BLINKINGOFF_STATE)) {
83 /* Cancel if we are still blinking; this means that we press the
84 * attention again before the 5 sec. limit expires to cancel hot-add
87 taskInfo->event_type = INT_BUTTON_CANCEL;
88 info("Button cancel on Slot(%d)\n", ctrl->first_slot + hp_slot);
89 } else if ((p_slot->state == POWERON_STATE)
90 || (p_slot->state == POWEROFF_STATE)) {
91 /* Ignore if the slot is on power-on or power-off state; this
92 * means that the previous attention button action to hot-add or
93 * hot-remove is undergoing
95 taskInfo->event_type = INT_BUTTON_IGNORE;
96 info("Button ignore on Slot(%d)\n", ctrl->first_slot + hp_slot);
100 up(&event_semaphore); /* signal event thread that new event is posted */
106 u8 pciehp_handle_switch_change(u8 hp_slot, void *inst_id)
108 struct controller *ctrl = (struct controller *) inst_id;
112 struct event_info *taskInfo;
115 dbg("pciehp: Switch interrupt received.\n");
117 /* This is the structure that tells the worker thread
120 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
121 ctrl->next_event = (ctrl->next_event + 1) % 10;
122 taskInfo->hp_slot = hp_slot;
125 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
126 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
127 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
133 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot);
134 p_slot->switch_save = 0;
135 taskInfo->event_type = INT_SWITCH_OPEN;
140 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot);
141 p_slot->switch_save = 0x10;
142 taskInfo->event_type = INT_SWITCH_CLOSE;
146 up(&event_semaphore); /* signal event thread that new event is posted */
151 u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id)
153 struct controller *ctrl = (struct controller *) inst_id;
156 struct event_info *taskInfo;
158 /* Presence Change */
159 dbg("pciehp: Presence/Notify input change.\n");
161 /* This is the structure that tells the worker thread
164 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
165 ctrl->next_event = (ctrl->next_event + 1) % 10;
166 taskInfo->hp_slot = hp_slot;
169 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
171 /* Switch is open, assume a presence change
172 * Save the presence state
174 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
175 if (p_slot->presence_save) {
179 info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot);
180 taskInfo->event_type = INT_PRESENCE_ON;
185 info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot);
186 taskInfo->event_type = INT_PRESENCE_OFF;
190 up(&event_semaphore); /* signal event thread that new event is posted */
195 u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
197 struct controller *ctrl = (struct controller *) inst_id;
200 struct event_info *taskInfo;
203 dbg("pciehp: Power fault interrupt received.\n");
205 /* this is the structure that tells the worker thread
208 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
209 ctrl->next_event = (ctrl->next_event + 1) % 10;
210 taskInfo->hp_slot = hp_slot;
213 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
215 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
217 * power fault Cleared
219 info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot);
220 p_slot->status = 0x00;
221 taskInfo->event_type = INT_POWER_FAULT_CLEAR;
226 info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot);
227 taskInfo->event_type = INT_POWER_FAULT;
228 /* set power fault status for this board */
229 p_slot->status = 0xFF;
230 info("power fault bit %x set\n", hp_slot);
233 up(&event_semaphore); /* signal event thread that new event is posted */
238 /* The following routines constitute the bulk of the
239 hotplug controller logic
242 static void set_slot_off(struct controller *ctrl, struct slot * pslot)
244 /* Wait for exclusive access to hardware */
245 down(&ctrl->crit_sect);
247 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
248 if (POWER_CTRL(ctrl->ctrlcap)) {
249 if (pslot->hpc_ops->power_off_slot(pslot)) {
250 err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__);
251 up(&ctrl->crit_sect);
254 wait_for_ctrl_irq (ctrl);
257 if (PWR_LED(ctrl->ctrlcap)) {
258 pslot->hpc_ops->green_led_off(pslot);
259 wait_for_ctrl_irq (ctrl);
262 if (ATTN_LED(ctrl->ctrlcap)) {
263 if (pslot->hpc_ops->set_attention_status(pslot, 1)) {
264 err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__);
265 up(&ctrl->crit_sect);
268 wait_for_ctrl_irq (ctrl);
271 /* Done with exclusive hardware access */
272 up(&ctrl->crit_sect);
276 * board_added - Called after a board has been added to the system.
278 * Turns power on for the board
282 static u32 board_added(struct slot *p_slot)
285 u32 temp_register = 0xFFFFFFFF;
287 struct controller *ctrl = p_slot->ctrl;
289 hp_slot = p_slot->device - ctrl->slot_device_offset;
291 dbg("%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n", __FUNCTION__, p_slot->device, ctrl->slot_device_offset, hp_slot);
293 /* Wait for exclusive access to hardware */
294 down(&ctrl->crit_sect);
296 if (POWER_CTRL(ctrl->ctrlcap)) {
298 rc = p_slot->hpc_ops->power_on_slot(p_slot);
300 up(&ctrl->crit_sect);
304 /* Wait for the command to complete */
305 wait_for_ctrl_irq (ctrl);
308 if (PWR_LED(ctrl->ctrlcap)) {
309 p_slot->hpc_ops->green_led_blink(p_slot);
311 /* Wait for the command to complete */
312 wait_for_ctrl_irq (ctrl);
315 /* Done with exclusive hardware access */
316 up(&ctrl->crit_sect);
318 /* Wait for ~1 second */
319 dbg("%s: before long_delay\n", __FUNCTION__);
320 wait_for_ctrl_irq (ctrl);
321 dbg("%s: afterlong_delay\n", __FUNCTION__);
323 /* Check link training status */
324 rc = p_slot->hpc_ops->check_lnk_status(ctrl);
326 err("%s: Failed to check link status\n", __FUNCTION__);
327 set_slot_off(ctrl, p_slot);
331 dbg("%s: slot status = %x\n", __FUNCTION__, p_slot->status);
333 /* Check for a power fault */
334 if (p_slot->status == 0xFF) {
335 /* power fault occurred, but it was benign */
336 temp_register = 0xFFFFFFFF;
337 dbg("%s: temp register set to %x by power fault\n", __FUNCTION__, temp_register);
343 rc = pciehp_configure_device(p_slot);
345 err("Cannot add device 0x%x:%x\n", p_slot->bus,
351 p_slot->switch_save = 0x10;
352 p_slot->is_a_board = 0x01;
355 * Some PCI Express root ports require fixup after hot-plug operation.
358 pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
359 if (PWR_LED(ctrl->ctrlcap)) {
360 /* Wait for exclusive access to hardware */
361 down(&ctrl->crit_sect);
363 p_slot->hpc_ops->green_led_on(p_slot);
365 /* Wait for the command to complete */
366 wait_for_ctrl_irq (ctrl);
368 /* Done with exclusive hardware access */
369 up(&ctrl->crit_sect);
374 set_slot_off(ctrl, p_slot);
380 * remove_board - Turns off slot and LED's
383 static u32 remove_board(struct slot *p_slot)
388 struct controller *ctrl = p_slot->ctrl;
390 if (pciehp_unconfigure_device(p_slot))
393 device = p_slot->device;
395 hp_slot = p_slot->device - ctrl->slot_device_offset;
396 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
398 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
400 /* Change status to shutdown */
401 if (p_slot->is_a_board)
402 p_slot->status = 0x01;
403 p_slot->configured = 0;
405 /* Wait for exclusive access to hardware */
406 down(&ctrl->crit_sect);
408 if (POWER_CTRL(ctrl->ctrlcap)) {
410 rc = p_slot->hpc_ops->power_off_slot(p_slot);
412 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
413 up(&ctrl->crit_sect);
416 /* Wait for the command to complete */
417 wait_for_ctrl_irq (ctrl);
420 if (PWR_LED(ctrl->ctrlcap)) {
421 /* turn off Green LED */
422 p_slot->hpc_ops->green_led_off(p_slot);
424 /* Wait for the command to complete */
425 wait_for_ctrl_irq (ctrl);
428 /* Done with exclusive hardware access */
429 up(&ctrl->crit_sect);
431 p_slot->switch_save = 0x10;
432 p_slot->is_a_board = 0;
438 static void pushbutton_helper_thread(unsigned long data)
440 pushbutton_pending = data;
442 up(&event_semaphore);
446 * pciehp_pushbutton_thread
448 * Scheduled procedure to handle blocking stuff for the pushbuttons
449 * Handles all pending events and exits.
452 static void pciehp_pushbutton_thread(unsigned long slot)
454 struct slot *p_slot = (struct slot *) slot;
457 pushbutton_pending = 0;
460 dbg("%s: Error! slot NULL\n", __FUNCTION__);
464 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
466 p_slot->state = POWEROFF_STATE;
467 dbg("In power_down_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
469 pciehp_disable_slot(p_slot);
470 p_slot->state = STATIC_STATE;
472 p_slot->state = POWERON_STATE;
473 dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
475 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
476 /* Wait for exclusive access to hardware */
477 down(&p_slot->ctrl->crit_sect);
479 p_slot->hpc_ops->green_led_off(p_slot);
481 /* Wait for the command to complete */
482 wait_for_ctrl_irq (p_slot->ctrl);
484 /* Done with exclusive hardware access */
485 up(&p_slot->ctrl->crit_sect);
487 p_slot->state = STATIC_STATE;
494 * pciehp_surprise_rm_thread
496 * Scheduled procedure to handle blocking stuff for the surprise removal
497 * Handles all pending events and exits.
500 static void pciehp_surprise_rm_thread(unsigned long slot)
502 struct slot *p_slot = (struct slot *) slot;
505 surprise_rm_pending = 0;
508 dbg("%s: Error! slot NULL\n", __FUNCTION__);
512 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
514 p_slot->state = POWEROFF_STATE;
515 dbg("In removing board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
517 pciehp_disable_slot(p_slot);
518 p_slot->state = STATIC_STATE;
520 p_slot->state = POWERON_STATE;
521 dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
523 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
524 /* Wait for exclusive access to hardware */
525 down(&p_slot->ctrl->crit_sect);
527 p_slot->hpc_ops->green_led_off(p_slot);
529 /* Wait for the command to complete */
530 wait_for_ctrl_irq (p_slot->ctrl);
532 /* Done with exclusive hardware access */
533 up(&p_slot->ctrl->crit_sect);
535 p_slot->state = STATIC_STATE;
543 /* this is the main worker thread */
544 static int event_thread(void* data)
546 struct controller *ctrl;
548 daemonize("pciehpd_event");
553 dbg("!!!!event_thread sleeping\n");
554 down_interruptible (&event_semaphore);
555 dbg("event_thread woken finished = %d\n", event_finished);
556 if (event_finished || signal_pending(current))
559 if (pushbutton_pending)
560 pciehp_pushbutton_thread(pushbutton_pending);
561 else if (surprise_rm_pending)
562 pciehp_surprise_rm_thread(surprise_rm_pending);
564 for (ctrl = pciehp_ctrl_list; ctrl; ctrl=ctrl->next)
565 interrupt_event_handler(ctrl);
567 dbg("event_thread signals exit\n");
572 int pciehp_event_start_thread(void)
576 /* initialize our semaphores */
577 init_MUTEX_LOCKED(&event_exit);
580 init_MUTEX_LOCKED(&event_semaphore);
581 pid = kernel_thread(event_thread, NULL, 0);
584 err ("Can't start up our event thread\n");
587 dbg("Our event thread pid = %d\n", pid);
592 void pciehp_event_stop_thread(void)
595 dbg("event_thread finish command given\n");
596 up(&event_semaphore);
597 dbg("wait for event_thread to exit\n");
602 static int update_slot_info(struct slot *slot)
604 struct hotplug_slot_info *info;
605 /* char buffer[SLOT_NAME_SIZE]; */
608 info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
612 /* make_slot_name (&buffer[0], SLOT_NAME_SIZE, slot); */
614 slot->hpc_ops->get_power_status(slot, &(info->power_status));
615 slot->hpc_ops->get_attention_status(slot, &(info->attention_status));
616 slot->hpc_ops->get_latch_status(slot, &(info->latch_status));
617 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status));
619 /* result = pci_hp_change_slot_info(buffer, info); */
620 result = pci_hp_change_slot_info(slot->hotplug_slot, info);
625 static void interrupt_event_handler(struct controller *ctrl)
636 for (loop = 0; loop < 10; loop++) {
637 if (ctrl->event_queue[loop].event_type != 0) {
638 hp_slot = ctrl->event_queue[loop].hp_slot;
640 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
642 dbg("hp_slot %d, p_slot %p\n", hp_slot, p_slot);
644 if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) {
645 dbg("button cancel\n");
646 del_timer(&p_slot->task_event);
648 switch (p_slot->state) {
649 case BLINKINGOFF_STATE:
650 /* Wait for exclusive access to hardware */
651 down(&ctrl->crit_sect);
653 if (PWR_LED(ctrl->ctrlcap)) {
654 p_slot->hpc_ops->green_led_on(p_slot);
655 /* Wait for the command to complete */
656 wait_for_ctrl_irq (ctrl);
658 if (ATTN_LED(ctrl->ctrlcap)) {
659 p_slot->hpc_ops->set_attention_status(p_slot, 0);
661 /* Wait for the command to complete */
662 wait_for_ctrl_irq (ctrl);
664 /* Done with exclusive hardware access */
665 up(&ctrl->crit_sect);
667 case BLINKINGON_STATE:
668 /* Wait for exclusive access to hardware */
669 down(&ctrl->crit_sect);
671 if (PWR_LED(ctrl->ctrlcap)) {
672 p_slot->hpc_ops->green_led_off(p_slot);
673 /* Wait for the command to complete */
674 wait_for_ctrl_irq (ctrl);
676 if (ATTN_LED(ctrl->ctrlcap)){
677 p_slot->hpc_ops->set_attention_status(p_slot, 0);
678 /* Wait for the command to complete */
679 wait_for_ctrl_irq (ctrl);
681 /* Done with exclusive hardware access */
682 up(&ctrl->crit_sect);
686 warn("Not a valid state\n");
689 info(msg_button_cancel, p_slot->number);
690 p_slot->state = STATIC_STATE;
692 /* ***********Button Pressed (No action on 1st press...) */
693 else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) {
695 if (ATTN_BUTTN(ctrl->ctrlcap)) {
696 dbg("Button pressed\n");
697 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
701 p_slot->state = BLINKINGOFF_STATE;
702 info(msg_button_off, p_slot->number);
705 dbg("slot is off\n");
706 p_slot->state = BLINKINGON_STATE;
707 info(msg_button_on, p_slot->number);
710 /* Wait for exclusive access to hardware */
711 down(&ctrl->crit_sect);
713 /* blink green LED and turn off amber */
714 if (PWR_LED(ctrl->ctrlcap)) {
715 p_slot->hpc_ops->green_led_blink(p_slot);
716 /* Wait for the command to complete */
717 wait_for_ctrl_irq (ctrl);
720 if (ATTN_LED(ctrl->ctrlcap)) {
721 p_slot->hpc_ops->set_attention_status(p_slot, 0);
723 /* Wait for the command to complete */
724 wait_for_ctrl_irq (ctrl);
727 /* Done with exclusive hardware access */
728 up(&ctrl->crit_sect);
730 init_timer(&p_slot->task_event);
731 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
732 p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
733 p_slot->task_event.data = (unsigned long) p_slot;
735 dbg("add_timer p_slot = %p\n", (void *) p_slot);
736 add_timer(&p_slot->task_event);
739 /***********POWER FAULT********************/
740 else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
741 if (POWER_CTRL(ctrl->ctrlcap)) {
742 dbg("power fault\n");
743 /* Wait for exclusive access to hardware */
744 down(&ctrl->crit_sect);
746 if (ATTN_LED(ctrl->ctrlcap)) {
747 p_slot->hpc_ops->set_attention_status(p_slot, 1);
748 wait_for_ctrl_irq (ctrl);
751 if (PWR_LED(ctrl->ctrlcap)) {
752 p_slot->hpc_ops->green_led_off(p_slot);
753 wait_for_ctrl_irq (ctrl);
756 /* Done with exclusive hardware access */
757 up(&ctrl->crit_sect);
760 /***********SURPRISE REMOVAL********************/
761 else if ((ctrl->event_queue[loop].event_type == INT_PRESENCE_ON) ||
762 (ctrl->event_queue[loop].event_type == INT_PRESENCE_OFF)) {
763 if (HP_SUPR_RM(ctrl->ctrlcap)) {
764 dbg("Surprise Removal\n");
766 surprise_rm_pending = (unsigned long) p_slot;
767 up(&event_semaphore);
768 update_slot_info(p_slot);
772 /* refresh notification */
774 update_slot_info(p_slot);
777 ctrl->event_queue[loop].event_type = 0;
781 } /* End of FOR loop */
786 int pciehp_enable_slot(struct slot *p_slot)
791 /* Check to see if (latch closed, card present, power off) */
792 down(&p_slot->ctrl->crit_sect);
794 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
795 if (rc || !getstatus) {
796 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
797 up(&p_slot->ctrl->crit_sect);
800 if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
801 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
802 if (rc || getstatus) {
803 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
804 up(&p_slot->ctrl->crit_sect);
809 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {
810 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
811 if (rc || getstatus) {
812 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
813 up(&p_slot->ctrl->crit_sect);
817 up(&p_slot->ctrl->crit_sect);
819 p_slot->configured = 0;
820 p_slot->is_a_board = 1;
822 /* We have to save the presence info for these slots */
823 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
824 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
825 p_slot->switch_save = !getstatus? 0x10:0;
827 rc = board_added(p_slot);
829 /* We have to save the presence info for these slots */
830 p_slot->hpc_ops->get_adapter_status(p_slot,
831 &(p_slot->presence_save));
832 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
833 p_slot->switch_save = !getstatus? 0x10:0;
837 update_slot_info(p_slot);
843 int pciehp_disable_slot(struct slot *p_slot)
851 /* Check to see if (latch closed, card present, power on) */
852 down(&p_slot->ctrl->crit_sect);
854 if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) {
855 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
856 if (ret || !getstatus) {
857 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
858 up(&p_slot->ctrl->crit_sect);
863 if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
864 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
865 if (ret || getstatus) {
866 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
867 up(&p_slot->ctrl->crit_sect);
872 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {
873 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
874 if (ret || !getstatus) {
875 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
876 up(&p_slot->ctrl->crit_sect);
881 up(&p_slot->ctrl->crit_sect);
883 ret = remove_board(p_slot);
884 update_slot_info(p_slot);