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

From
Brian Norris <briannorris@chromium.org>
Date
2021-10-04 17:52:31
Also in
linux-pci, linux-wireless, lkml, stable
Reply to
Jonas Dreßler, 2021-10-03
Hi,

On Sun, Oct 3, 2021 at 2:18 AM Jonas Dreßler [off-list ref] 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
Thread (19 messages) 19 messages, 5 authors, last reply 2021-10-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help