Re: [PATCH v2 2/3] mei: vsc: Don't use sleeping condition in wait_event_timeout()

From: Andy Shevchenko
Date: Tue Mar 05 2024 - 12:11:50 EST


On Mon, Feb 19, 2024 at 09:58:06PM +0200, Sakari Ailus wrote:
> vsc_tp_wakeup_request() called wait_event_timeout() with
> gpiod_get_value_cansleep() which may sleep, and does so as the
> implementation is that of gpio-ljca.
>
> Move the GPIO state check outside the call.

..

> +#define VSC_TP_WAIT_FW_POLL_TIMEOUT (2 * HZ)
> +#define VSC_TP_WAIT_FW_POLL_DELAY_US (20 * USEC_PER_MSEC)

..

> ret = wait_event_timeout(tp->xfer_wait,
> - atomic_read(&tp->assert_cnt) &&
> - gpiod_get_value_cansleep(tp->wakeuphost),
> - VSC_TP_WAIT_FW_ASSERTED_TIMEOUT);
> + atomic_read(&tp->assert_cnt),
> + VSC_TP_WAIT_FW_POLL_TIMEOUT);

First of all, there is an API for such cases (wait_woken_up() IIRC).

> if (!ret)
> return -ETIMEDOUT;

..

> + return read_poll_timeout(gpiod_get_value_cansleep, ret, ret,
> + VSC_TP_WAIT_FW_POLL_DELAY_US,
> + VSC_TP_WAIT_FW_POLL_TIMEOUT, false,

Second, this is a bug as you are using jiffies as microseconds. How had it been tested?

> + tp->wakeuphost);

--
With Best Regards,
Andy Shevchenko