Re: [PATCH v2 2/2] mwifiex: Try waking the firmware until we get an interrupt

From: Brian Norris
Date: Mon Oct 04 2021 - 13:52:31 EST


Hi,

On Sun, Oct 3, 2021 at 2:18 AM Jonas Dreßler <verdre@xxxxxxx> wrote:
> So I think I have another solution that might be a lot more elegant, how
> about this:
>
> try_again:
> n_tries++;
>
> mwifiex_write_reg(adapter, reg->fw_status, FIRMWARE_READY_PCIE);
>
> if (wait_event_interruptible_timeout(adapter->card_wakeup_wait_q,
> READ_ONCE(adapter->int_status) != 0,
> WAKEUP_TRY_AGAIN_TIMEOUT) == 0 &&
> n_tries < MAX_N_WAKEUP_TRIES) {
> goto try_again;
> }

Isn't wait_event_interruptible_timeout()'s timeout in jiffies, which
is not necessarily that predictable, and also a lot more
coarse-grained than we want? (As in, if HZ=100, we're looking at
precision on the order of 10ms, whereas the expected wakeup latency is
~6ms.) That would be OK for well-behaved PCI cases, where we never
miss a write, but it could ~double your latency for your bad systems
that will need more than one run of the loop.

Also, feels like a do/while could be cleaner, but that's a lesser detail.

> and then call wake_up_interruptible() in the mwifiex_interrupt_status()
> interrupt handler.
>
> This solution should make sure we always keep wakeup latency to a minimum
> and can still retry the register write if things didn't work.

Brian