Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a737f76b authored by Bjorn Helgaas's avatar Bjorn Helgaas
Browse files

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
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -140,15 +140,15 @@ struct controller *pcie_init(struct pcie_device *dev);
int pcie_init_notification(struct controller *ctrl);
int pciehp_enable_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_off_slot(struct slot *slot);
int pciehp_get_power_status(struct slot *slot, u8 *status);
int pciehp_get_attention_status(struct slot *slot, u8 *status);
void pciehp_power_off_slot(struct slot *slot);
void pciehp_get_power_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);
int pciehp_get_latch_status(struct slot *slot, u8 *status);
int pciehp_get_adapter_status(struct slot *slot, u8 *status);
void pciehp_set_attention_status(struct slot *slot, u8 status);
void pciehp_get_latch_status(struct slot *slot, u8 *status);
void pciehp_get_adapter_status(struct slot *slot, u8 *status);
int pciehp_query_power_fault(struct slot *slot);
void pciehp_green_led_on(struct slot *slot);
void pciehp_green_led_off(struct slot *slot);
+10 −5
Original line number Diff line number Diff line
@@ -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",
		  __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)
	ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
		  __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)
@@ -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",
		  __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)
@@ -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",
		 __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)
@@ -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",
		 __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)
+30 −60
Original line number Diff line number Diff line
@@ -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*/
	if (POWER_CTRL(ctrl)) {
		if (pciehp_power_off_slot(pslot)) {
			ctrl_err(ctrl,
				 "Issue of Slot Power Off command failed\n");
			return;
		}
		pciehp_power_off_slot(pslot);

		/*
		 * After turning power off, we must wait for at least 1 second
		 * 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)
		msleep(1000);
	}

	if (PWR_LED(ctrl))
	pciehp_green_led_off(pslot);

	if (ATTN_LED(ctrl)) {
		if (pciehp_set_attention_status(pslot, 1)) {
			ctrl_err(ctrl,
				 "Issue of Set Attention Led command failed\n");
			return;
		}
	}
	pciehp_set_attention_status(pslot, 1);
}

/**
@@ -203,7 +192,6 @@ static int board_added(struct slot *p_slot)
			return retval;
	}

	if (PWR_LED(ctrl))
	pciehp_green_led_blink(p_slot);

	/* Check link training status */
@@ -227,9 +215,7 @@ static int board_added(struct slot *p_slot)
		goto err_exit;
	}

	if (PWR_LED(ctrl))
	pciehp_green_led_on(p_slot);

	return 0;

err_exit:
@@ -243,7 +229,7 @@ static int board_added(struct slot *p_slot)
 */
static int remove_board(struct slot *p_slot)
{
	int retval = 0;
	int retval;
	struct controller *ctrl = p_slot->ctrl;

	retval = pciehp_unconfigure_device(p_slot);
@@ -251,13 +237,8 @@ static int remove_board(struct slot *p_slot)
		return retval;

	if (POWER_CTRL(ctrl)) {
		/* power off slot */
		retval = pciehp_power_off_slot(p_slot);
		if (retval) {
			ctrl_err(ctrl,
				 "Issue of Slot Disable command failed\n");
			return retval;
		}
		pciehp_power_off_slot(p_slot);

		/*
		 * After turning power off, we must wait for at least 1 second
		 * before taking any action that relies on power having been
@@ -267,9 +248,7 @@ static int remove_board(struct slot *p_slot)
	}

	/* turn off Green LED */
	if (PWR_LED(ctrl))
	pciehp_green_led_off(p_slot);

	return 0;
}

@@ -305,7 +284,7 @@ static void pciehp_power_thread(struct work_struct *work)
		break;
	case POWERON_STATE:
		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);
		mutex_lock(&p_slot->lock);
		p_slot->state = STATIC_STATE;
@@ -372,11 +351,8 @@ static void handle_button_press_event(struct slot *p_slot)
				  "press.\n", slot_name(p_slot));
		}
		/* blink green LED and turn off amber */
		if (PWR_LED(ctrl))
		pciehp_green_led_blink(p_slot);
		if (ATTN_LED(ctrl))
		pciehp_set_attention_status(p_slot, 0);

		queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ);
		break;
	case BLINKINGOFF_STATE:
@@ -389,13 +365,10 @@ static void handle_button_press_event(struct slot *p_slot)
		ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot));
		cancel_delayed_work(&p_slot->work);
		if (p_slot->state == BLINKINGOFF_STATE) {
			if (PWR_LED(ctrl))
			pciehp_green_led_on(p_slot);
		} else {
			if (PWR_LED(ctrl))
			pciehp_green_led_off(p_slot);
		}
		if (ATTN_LED(ctrl))
		pciehp_set_attention_status(p_slot, 0);
		ctrl_info(ctrl, "PCI slot #%s - action canceled "
			  "due to button press\n", slot_name(p_slot));
@@ -456,9 +429,7 @@ static void interrupt_event_handler(struct work_struct *work)
	case INT_POWER_FAULT:
		if (!POWER_CTRL(ctrl))
			break;
		if (ATTN_LED(ctrl))
		pciehp_set_attention_status(p_slot, 1);
		if (PWR_LED(ctrl))
		pciehp_green_led_off(p_slot);
		break;
	case INT_PRESENCE_ON:
@@ -482,14 +453,14 @@ int pciehp_enable_slot(struct slot *p_slot)
	int rc;
	struct controller *ctrl = p_slot->ctrl;

	rc = pciehp_get_adapter_status(p_slot, &getstatus);
	if (rc || !getstatus) {
	pciehp_get_adapter_status(p_slot, &getstatus);
	if (!getstatus) {
		ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot));
		return -ENODEV;
	}
	if (MRL_SENS(p_slot->ctrl)) {
		rc = pciehp_get_latch_status(p_slot, &getstatus);
		if (rc || getstatus) {
		pciehp_get_latch_status(p_slot, &getstatus);
		if (getstatus) {
			ctrl_info(ctrl, "Latch open on slot(%s)\n",
				  slot_name(p_slot));
			return -ENODEV;
@@ -497,8 +468,8 @@ int pciehp_enable_slot(struct slot *p_slot)
	}

	if (POWER_CTRL(p_slot->ctrl)) {
		rc = pciehp_get_power_status(p_slot, &getstatus);
		if (rc || getstatus) {
		pciehp_get_power_status(p_slot, &getstatus);
		if (getstatus) {
			ctrl_info(ctrl, "Already enabled on slot(%s)\n",
				  slot_name(p_slot));
			return -EINVAL;
@@ -518,15 +489,14 @@ int pciehp_enable_slot(struct slot *p_slot)
int pciehp_disable_slot(struct slot *p_slot)
{
	u8 getstatus = 0;
	int ret = 0;
	struct controller *ctrl = p_slot->ctrl;

	if (!p_slot->ctrl)
		return 1;

	if (!HP_SUPR_RM(p_slot->ctrl)) {
		ret = pciehp_get_adapter_status(p_slot, &getstatus);
		if (ret || !getstatus) {
		pciehp_get_adapter_status(p_slot, &getstatus);
		if (!getstatus) {
			ctrl_info(ctrl, "No adapter on slot(%s)\n",
				  slot_name(p_slot));
			return -ENODEV;
@@ -534,8 +504,8 @@ int pciehp_disable_slot(struct slot *p_slot)
	}

	if (MRL_SENS(p_slot->ctrl)) {
		ret = pciehp_get_latch_status(p_slot, &getstatus);
		if (ret || getstatus) {
		pciehp_get_latch_status(p_slot, &getstatus);
		if (getstatus) {
			ctrl_info(ctrl, "Latch open on slot(%s)\n",
				  slot_name(p_slot));
			return -ENODEV;
@@ -543,8 +513,8 @@ int pciehp_disable_slot(struct slot *p_slot)
	}

	if (POWER_CTRL(p_slot->ctrl)) {
		ret = pciehp_get_power_status(p_slot, &getstatus);
		if (ret || !getstatus) {
		pciehp_get_power_status(p_slot, &getstatus);
		if (!getstatus) {
			ctrl_info(ctrl, "Already disabled on slot(%s)\n",
				  slot_name(p_slot));
			return -EINVAL;
+128 −252

File changed.

Preview size limit exceeded, changes collapsed.

+2 −4
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ int pciehp_configure_device(struct slot *p_slot)

int pciehp_unconfigure_device(struct slot *p_slot)
{
	int ret, rc = 0;
	int rc = 0;
	u8 bctl = 0;
	u8 presence = 0;
	struct pci_dev *dev, *temp;
@@ -88,9 +88,7 @@ int pciehp_unconfigure_device(struct slot *p_slot)

	ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
		 __func__, pci_domain_nr(parent), parent->number);
	ret = pciehp_get_adapter_status(p_slot, &presence);
	if (ret)
		presence = 0;
	pciehp_get_adapter_status(p_slot, &presence);

	/*
	 * Stopping an SR-IOV PF device removes all the associated VFs,
Loading