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

Commit b7dec8b7 authored by Jack Pham's avatar Jack Pham
Browse files

usb: pd: qpnp-pdphy: Switch to hrtimer-based wait



Currently wait_event_interruptible_timeout() is used when
sending a message or hard reset signal to wait for a completion
interrupt. However, the jiffies-based timer is not accurate for
the short timeout durations used (15ms TX, 5ms hard reset) and
can result in timing out too early. Switch to hrtimer-based
wait_event_interruptible_hrtimeout() for better accuracy.

Change-Id: I1c9866114b548ce849ec6002c0eb1362ac9a7786
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 385dbf30
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -443,12 +443,12 @@ int pd_phy_signal(enum pd_sig_type sig)
	if (ret)
		return ret;

	ret = wait_event_interruptible_timeout(pdphy->tx_waitq,
	ret = wait_event_interruptible_hrtimeout(pdphy->tx_waitq,
		pdphy->tx_status != -EINPROGRESS,
		msecs_to_jiffies(HARD_RESET_COMPLETE_TIME));
	if (ret <= 0) {
		ms_to_ktime(HARD_RESET_COMPLETE_TIME));
	if (ret) {
		dev_err(pdphy->dev, "%s: failed ret %d", __func__, ret);
		return ret ? ret : -ETIMEDOUT;
		return ret;
	}

	ret = pdphy_reg_write(pdphy, USB_PDPHY_TX_CONTROL, 0);
@@ -532,12 +532,12 @@ int pd_phy_write(u16 hdr, const u8 *data, size_t data_len, enum pd_sop_type sop)
	if (ret)
		return ret;

	ret = wait_event_interruptible_timeout(pdphy->tx_waitq,
	ret = wait_event_interruptible_hrtimeout(pdphy->tx_waitq,
		pdphy->tx_status != -EINPROGRESS,
		msecs_to_jiffies(RECEIVER_RESPONSE_TIME));
	if (ret <= 0) {
		ms_to_ktime(RECEIVER_RESPONSE_TIME));
	if (ret) {
		dev_err(pdphy->dev, "%s: failed ret %d", __func__, ret);
		return ret ? ret : -ETIMEDOUT;
		return ret;
	}

	if (hdr && !pdphy->tx_status)