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

Commit d737bdc1 authored by Kenji Kaneshige's avatar Kenji Kaneshige Committed by Jesse Barnes
Browse files

pciehp: block signals while waiting for command completion



Since we need to wait for command completion for muximum 1sec, waiting
command should not be interrupted by a signal.

Signed-off-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 125c39f7
Loading
Loading
Loading
Loading
+4 −12
Original line number Original line Diff line number Diff line
@@ -268,9 +268,8 @@ static inline int pcie_poll_cmd(struct controller *ctrl)
	return timeout;
	return timeout;
}
}


static inline int pcie_wait_cmd(struct controller *ctrl, int poll)
static inline void pcie_wait_cmd(struct controller *ctrl, int poll)
{
{
	int retval = 0;
	unsigned int msecs = pciehp_poll_mode ? 2500 : 1000;
	unsigned int msecs = pciehp_poll_mode ? 2500 : 1000;
	unsigned long timeout = msecs_to_jiffies(msecs);
	unsigned long timeout = msecs_to_jiffies(msecs);
	int rc;
	int rc;
@@ -278,16 +277,9 @@ static inline int pcie_wait_cmd(struct controller *ctrl, int poll)
	if (poll)
	if (poll)
		rc = pcie_poll_cmd(ctrl);
		rc = pcie_poll_cmd(ctrl);
	else
	else
		rc = wait_event_interruptible_timeout(ctrl->queue,
		rc = wait_event_timeout(ctrl->queue, !ctrl->cmd_busy, timeout);
					      !ctrl->cmd_busy, timeout);
	if (!rc)
	if (!rc)
		dbg("Command not completed in 1000 msec\n");
		dbg("Command not completed in 1000 msec\n");
	else if (rc < 0) {
		retval = -EINTR;
		info("Command was interrupted by a signal\n");
	}

	return retval;
}
}


/**
/**
@@ -365,7 +357,7 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
		if (!(slot_ctrl & HP_INTR_ENABLE) ||
		if (!(slot_ctrl & HP_INTR_ENABLE) ||
		    !(slot_ctrl & CMD_CMPL_INTR_ENABLE))
		    !(slot_ctrl & CMD_CMPL_INTR_ENABLE))
			poll = 1;
			poll = 1;
                retval = pcie_wait_cmd(ctrl, poll);
                pcie_wait_cmd(ctrl, poll);
	}
	}
 out:
 out:
	mutex_unlock(&ctrl->ctrl_lock);
	mutex_unlock(&ctrl->ctrl_lock);
@@ -797,7 +789,7 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
	if (intr_loc & CMD_COMPLETED) {
	if (intr_loc & CMD_COMPLETED) {
		ctrl->cmd_busy = 0;
		ctrl->cmd_busy = 0;
		smp_mb();
		smp_mb();
		wake_up_interruptible(&ctrl->queue);
		wake_up(&ctrl->queue);
	}
	}


	if (!(intr_loc & ~CMD_COMPLETED))
	if (!(intr_loc & ~CMD_COMPLETED))