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

From: Arnd Bergmann
Date: Tue Mar 05 2024 - 12:18:21 EST


On Tue, Mar 5, 2024, at 18:11, Andy Shevchenko wrote:
> 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).

I think wait_for_completion_timeout() would be the obvious
replacement if the wait_event is no longer waiting for the
gpio but only for the irq handler to complete.

Arnd