Commit a737f76b authored by Bjorn Helgaas's avatar Bjorn Helgaas

Merge branch 'pci/pciehp' into next

* pci/pciehp:
  PCI: pciehp: Move Attention & Power Indicator support tests to accessors
  PCI: pciehp: Use symbolic constants for Slot Control fields
  PCI: pciehp: Use symbolic constants, not hard-coded bitmask
  PCI: pciehp: Simplify "Power Fault Detected" checking/clearing
  PCI: pciehp: Announce slot capabilities (slot #, button, LEDs, etc)
  PCI: pciehp: Make various functions void since they can't fail
  PCI: pciehp: Remove error checks when accessing PCIe Capability
  PCI: pciehp: Drop pciehp_readw()/pciehp_writew() wrappers
parents 765147f8 af9ab791
...@@ -140,15 +140,15 @@ struct controller *pcie_init(struct pcie_device *dev); ...@@ -140,15 +140,15 @@ struct controller *pcie_init(struct pcie_device *dev);
int pcie_init_notification(struct controller *ctrl); int pcie_init_notification(struct controller *ctrl);
int pciehp_enable_slot(struct slot *p_slot); int pciehp_enable_slot(struct slot *p_slot);
int pciehp_disable_slot(struct slot *p_slot); int pciehp_disable_slot(struct slot *p_slot);
int pcie_enable_notification(struct controller *ctrl); void pcie_enable_notification(struct controller *ctrl);
int pciehp_power_on_slot(struct slot *slot); int pciehp_power_on_slot(struct slot *slot);
int pciehp_power_off_slot(struct slot *slot); void pciehp_power_off_slot(struct slot *slot);
int pciehp_get_power_status(struct slot *slot, u8 *status); void pciehp_get_power_status(struct slot *slot, u8 *status);
int pciehp_get_attention_status(struct slot *slot, u8 *status); void pciehp_get_attention_status(struct slot *slot, u8 *status);
int pciehp_set_attention_status(struct slot *slot, u8 status); void pciehp_set_attention_status(struct slot *slot, u8 status);
int pciehp_get_latch_status(struct slot *slot, u8 *status); void pciehp_get_latch_status(struct slot *slot, u8 *status);
int pciehp_get_adapter_status(struct slot *slot, u8 *status); void pciehp_get_adapter_status(struct slot *slot, u8 *status);
int pciehp_query_power_fault(struct slot *slot); int pciehp_query_power_fault(struct slot *slot);
void pciehp_green_led_on(struct slot *slot); void pciehp_green_led_on(struct slot *slot);
void pciehp_green_led_off(struct slot *slot); void pciehp_green_led_off(struct slot *slot);
......
...@@ -160,7 +160,8 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) ...@@ -160,7 +160,8 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
return pciehp_set_attention_status(slot, status); pciehp_set_attention_status(slot, status);
return 0;
} }
...@@ -192,7 +193,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -192,7 +193,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
return pciehp_get_power_status(slot, value); pciehp_get_power_status(slot, value);
return 0;
} }
static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
...@@ -202,7 +204,8 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -202,7 +204,8 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
return pciehp_get_attention_status(slot, value); pciehp_get_attention_status(slot, value);
return 0;
} }
static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
...@@ -212,7 +215,8 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -212,7 +215,8 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
return pciehp_get_latch_status(slot, value); pciehp_get_latch_status(slot, value);
return 0;
} }
static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
...@@ -222,7 +226,8 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -222,7 +226,8 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
__func__, slot_name(slot)); __func__, slot_name(slot));
return pciehp_get_adapter_status(slot, value); pciehp_get_adapter_status(slot, value);
return 0;
} }
static int reset_slot(struct hotplug_slot *hotplug_slot, int probe) static int reset_slot(struct hotplug_slot *hotplug_slot, int probe)
......
...@@ -158,11 +158,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) ...@@ -158,11 +158,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
{ {
/* turn off slot, turn on Amber LED, turn off Green LED if supported*/ /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
if (POWER_CTRL(ctrl)) { if (POWER_CTRL(ctrl)) {
if (pciehp_power_off_slot(pslot)) { pciehp_power_off_slot(pslot);
ctrl_err(ctrl,
"Issue of Slot Power Off command failed\n");
return;
}
/* /*
* After turning power off, we must wait for at least 1 second * After turning power off, we must wait for at least 1 second
* before taking any action that relies on power having been * before taking any action that relies on power having been
...@@ -171,16 +168,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) ...@@ -171,16 +168,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
msleep(1000); msleep(1000);
} }
if (PWR_LED(ctrl)) pciehp_green_led_off(pslot);
pciehp_green_led_off(pslot); pciehp_set_attention_status(pslot, 1);
if (ATTN_LED(ctrl)) {
if (pciehp_set_attention_status(pslot, 1)) {
ctrl_err(ctrl,
"Issue of Set Attention Led command failed\n");
return;
}
}
} }
/** /**
...@@ -203,8 +192,7 @@ static int board_added(struct slot *p_slot) ...@@ -203,8 +192,7 @@ static int board_added(struct slot *p_slot)
return retval; return retval;
} }
if (PWR_LED(ctrl)) pciehp_green_led_blink(p_slot);
pciehp_green_led_blink(p_slot);
/* Check link training status */ /* Check link training status */
retval = pciehp_check_link_status(ctrl); retval = pciehp_check_link_status(ctrl);
...@@ -227,9 +215,7 @@ static int board_added(struct slot *p_slot) ...@@ -227,9 +215,7 @@ static int board_added(struct slot *p_slot)
goto err_exit; goto err_exit;
} }
if (PWR_LED(ctrl)) pciehp_green_led_on(p_slot);
pciehp_green_led_on(p_slot);
return 0; return 0;
err_exit: err_exit:
...@@ -243,7 +229,7 @@ static int board_added(struct slot *p_slot) ...@@ -243,7 +229,7 @@ static int board_added(struct slot *p_slot)
*/ */
static int remove_board(struct slot *p_slot) static int remove_board(struct slot *p_slot)
{ {
int retval = 0; int retval;
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
retval = pciehp_unconfigure_device(p_slot); retval = pciehp_unconfigure_device(p_slot);
...@@ -251,13 +237,8 @@ static int remove_board(struct slot *p_slot) ...@@ -251,13 +237,8 @@ static int remove_board(struct slot *p_slot)
return retval; return retval;
if (POWER_CTRL(ctrl)) { if (POWER_CTRL(ctrl)) {
/* power off slot */ pciehp_power_off_slot(p_slot);
retval = pciehp_power_off_slot(p_slot);
if (retval) {
ctrl_err(ctrl,
"Issue of Slot Disable command failed\n");
return retval;
}
/* /*
* After turning power off, we must wait for at least 1 second * After turning power off, we must wait for at least 1 second
* before taking any action that relies on power having been * before taking any action that relies on power having been
...@@ -267,9 +248,7 @@ static int remove_board(struct slot *p_slot) ...@@ -267,9 +248,7 @@ static int remove_board(struct slot *p_slot)
} }
/* turn off Green LED */ /* turn off Green LED */
if (PWR_LED(ctrl)) pciehp_green_led_off(p_slot);
pciehp_green_led_off(p_slot);
return 0; return 0;
} }
...@@ -305,7 +284,7 @@ static void pciehp_power_thread(struct work_struct *work) ...@@ -305,7 +284,7 @@ static void pciehp_power_thread(struct work_struct *work)
break; break;
case POWERON_STATE: case POWERON_STATE:
mutex_unlock(&p_slot->lock); mutex_unlock(&p_slot->lock);
if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl)) if (pciehp_enable_slot(p_slot))
pciehp_green_led_off(p_slot); pciehp_green_led_off(p_slot);
mutex_lock(&p_slot->lock); mutex_lock(&p_slot->lock);
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
...@@ -372,11 +351,8 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -372,11 +351,8 @@ static void handle_button_press_event(struct slot *p_slot)
"press.\n", slot_name(p_slot)); "press.\n", slot_name(p_slot));
} }
/* blink green LED and turn off amber */ /* blink green LED and turn off amber */
if (PWR_LED(ctrl)) pciehp_green_led_blink(p_slot);
pciehp_green_led_blink(p_slot); pciehp_set_attention_status(p_slot, 0);
if (ATTN_LED(ctrl))
pciehp_set_attention_status(p_slot, 0);
queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ); queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ);
break; break;
case BLINKINGOFF_STATE: case BLINKINGOFF_STATE:
...@@ -389,14 +365,11 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -389,14 +365,11 @@ static void handle_button_press_event(struct slot *p_slot)
ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot)); ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot));
cancel_delayed_work(&p_slot->work); cancel_delayed_work(&p_slot->work);
if (p_slot->state == BLINKINGOFF_STATE) { if (p_slot->state == BLINKINGOFF_STATE) {
if (PWR_LED(ctrl)) pciehp_green_led_on(p_slot);
pciehp_green_led_on(p_slot);
} else { } else {
if (PWR_LED(ctrl)) pciehp_green_led_off(p_slot);
pciehp_green_led_off(p_slot);
} }
if (ATTN_LED(ctrl)) pciehp_set_attention_status(p_slot, 0);
pciehp_set_attention_status(p_slot, 0);
ctrl_info(ctrl, "PCI slot #%s - action canceled " ctrl_info(ctrl, "PCI slot #%s - action canceled "
"due to button press\n", slot_name(p_slot)); "due to button press\n", slot_name(p_slot));
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
...@@ -456,10 +429,8 @@ static void interrupt_event_handler(struct work_struct *work) ...@@ -456,10 +429,8 @@ static void interrupt_event_handler(struct work_struct *work)
case INT_POWER_FAULT: case INT_POWER_FAULT:
if (!POWER_CTRL(ctrl)) if (!POWER_CTRL(ctrl))
break; break;
if (ATTN_LED(ctrl)) pciehp_set_attention_status(p_slot, 1);
pciehp_set_attention_status(p_slot, 1); pciehp_green_led_off(p_slot);
if (PWR_LED(ctrl))
pciehp_green_led_off(p_slot);
break; break;
case INT_PRESENCE_ON: case INT_PRESENCE_ON:
case INT_PRESENCE_OFF: case INT_PRESENCE_OFF:
...@@ -482,14 +453,14 @@ int pciehp_enable_slot(struct slot *p_slot) ...@@ -482,14 +453,14 @@ int pciehp_enable_slot(struct slot *p_slot)
int rc; int rc;
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
rc = pciehp_get_adapter_status(p_slot, &getstatus); pciehp_get_adapter_status(p_slot, &getstatus);
if (rc || !getstatus) { if (!getstatus) {
ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot)); ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot));
return -ENODEV; return -ENODEV;
} }
if (MRL_SENS(p_slot->ctrl)) { if (MRL_SENS(p_slot->ctrl)) {
rc = pciehp_get_latch_status(p_slot, &getstatus); pciehp_get_latch_status(p_slot, &getstatus);
if (rc || getstatus) { if (getstatus) {
ctrl_info(ctrl, "Latch open on slot(%s)\n", ctrl_info(ctrl, "Latch open on slot(%s)\n",
slot_name(p_slot)); slot_name(p_slot));
return -ENODEV; return -ENODEV;
...@@ -497,8 +468,8 @@ int pciehp_enable_slot(struct slot *p_slot) ...@@ -497,8 +468,8 @@ int pciehp_enable_slot(struct slot *p_slot)
} }
if (POWER_CTRL(p_slot->ctrl)) { if (POWER_CTRL(p_slot->ctrl)) {
rc = pciehp_get_power_status(p_slot, &getstatus); pciehp_get_power_status(p_slot, &getstatus);
if (rc || getstatus) { if (getstatus) {
ctrl_info(ctrl, "Already enabled on slot(%s)\n", ctrl_info(ctrl, "Already enabled on slot(%s)\n",
slot_name(p_slot)); slot_name(p_slot));
return -EINVAL; return -EINVAL;
...@@ -518,15 +489,14 @@ int pciehp_enable_slot(struct slot *p_slot) ...@@ -518,15 +489,14 @@ int pciehp_enable_slot(struct slot *p_slot)
int pciehp_disable_slot(struct slot *p_slot) int pciehp_disable_slot(struct slot *p_slot)
{ {
u8 getstatus = 0; u8 getstatus = 0;
int ret = 0;
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
if (!p_slot->ctrl) if (!p_slot->ctrl)
return 1; return 1;
if (!HP_SUPR_RM(p_slot->ctrl)) { if (!HP_SUPR_RM(p_slot->ctrl)) {
ret = pciehp_get_adapter_status(p_slot, &getstatus); pciehp_get_adapter_status(p_slot, &getstatus);
if (ret || !getstatus) { if (!getstatus) {
ctrl_info(ctrl, "No adapter on slot(%s)\n", ctrl_info(ctrl, "No adapter on slot(%s)\n",
slot_name(p_slot)); slot_name(p_slot));
return -ENODEV; return -ENODEV;
...@@ -534,8 +504,8 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -534,8 +504,8 @@ int pciehp_disable_slot(struct slot *p_slot)
} }
if (MRL_SENS(p_slot->ctrl)) { if (MRL_SENS(p_slot->ctrl)) {
ret = pciehp_get_latch_status(p_slot, &getstatus); pciehp_get_latch_status(p_slot, &getstatus);
if (ret || getstatus) { if (getstatus) {
ctrl_info(ctrl, "Latch open on slot(%s)\n", ctrl_info(ctrl, "Latch open on slot(%s)\n",
slot_name(p_slot)); slot_name(p_slot));
return -ENODEV; return -ENODEV;
...@@ -543,8 +513,8 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -543,8 +513,8 @@ int pciehp_disable_slot(struct slot *p_slot)
} }
if (POWER_CTRL(p_slot->ctrl)) { if (POWER_CTRL(p_slot->ctrl)) {
ret = pciehp_get_power_status(p_slot, &getstatus); pciehp_get_power_status(p_slot, &getstatus);
if (ret || !getstatus) { if (!getstatus) {
ctrl_info(ctrl, "Already disabled on slot(%s)\n", ctrl_info(ctrl, "Already disabled on slot(%s)\n",
slot_name(p_slot)); slot_name(p_slot));
return -EINVAL; return -EINVAL;
......
This diff is collapsed.
...@@ -78,7 +78,7 @@ int pciehp_configure_device(struct slot *p_slot) ...@@ -78,7 +78,7 @@ int pciehp_configure_device(struct slot *p_slot)
int pciehp_unconfigure_device(struct slot *p_slot) int pciehp_unconfigure_device(struct slot *p_slot)
{ {
int ret, rc = 0; int rc = 0;
u8 bctl = 0; u8 bctl = 0;
u8 presence = 0; u8 presence = 0;
struct pci_dev *dev, *temp; struct pci_dev *dev, *temp;
...@@ -88,9 +88,7 @@ int pciehp_unconfigure_device(struct slot *p_slot) ...@@ -88,9 +88,7 @@ int pciehp_unconfigure_device(struct slot *p_slot)
ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n", ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
__func__, pci_domain_nr(parent), parent->number); __func__, pci_domain_nr(parent), parent->number);
ret = pciehp_get_adapter_status(p_slot, &presence); pciehp_get_adapter_status(p_slot, &presence);
if (ret)
presence = 0;
/* /*
* Stopping an SR-IOV PF device removes all the associated VFs, * Stopping an SR-IOV PF device removes all the associated VFs,
......
...@@ -518,8 +518,16 @@ ...@@ -518,8 +518,16 @@
#define PCI_EXP_SLTCTL_CCIE 0x0010 /* Command Completed Interrupt Enable */ #define PCI_EXP_SLTCTL_CCIE 0x0010 /* Command Completed Interrupt Enable */
#define PCI_EXP_SLTCTL_HPIE 0x0020 /* Hot-Plug Interrupt Enable */ #define PCI_EXP_SLTCTL_HPIE 0x0020 /* Hot-Plug Interrupt Enable */
#define PCI_EXP_SLTCTL_AIC 0x00c0 /* Attention Indicator Control */ #define PCI_EXP_SLTCTL_AIC 0x00c0 /* Attention Indicator Control */
#define PCI_EXP_SLTCTL_ATTN_IND_ON 0x0040 /* Attention Indicator on */
#define PCI_EXP_SLTCTL_ATTN_IND_BLINK 0x0080 /* Attention Indicator blinking */
#define PCI_EXP_SLTCTL_ATTN_IND_OFF 0x00c0 /* Attention Indicator off */
#define PCI_EXP_SLTCTL_PIC 0x0300 /* Power Indicator Control */ #define PCI_EXP_SLTCTL_PIC 0x0300 /* Power Indicator Control */
#define PCI_EXP_SLTCTL_PWR_IND_ON 0x0100 /* Power Indicator on */
#define PCI_EXP_SLTCTL_PWR_IND_BLINK 0x0200 /* Power Indicator blinking */
#define PCI_EXP_SLTCTL_PWR_IND_OFF 0x0300 /* Power Indicator off */
#define PCI_EXP_SLTCTL_PCC 0x0400 /* Power Controller Control */ #define PCI_EXP_SLTCTL_PCC 0x0400 /* Power Controller Control */
#define PCI_EXP_SLTCTL_PWR_ON 0x0000 /* Power On */
#define PCI_EXP_SLTCTL_PWR_OFF 0x0400 /* Power Off */
#define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */ #define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */
#define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */ #define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */
#define PCI_EXP_SLTSTA 26 /* Slot Status */ #define PCI_EXP_SLTSTA 26 /* Slot Status */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment