wl12xx: always clear recovery flag during recovery_work

If recovery is called when the FW is off, we should clear
the recovery flag. Otherwise we risk booting the driver in
permanent pending-recovery state or getting into a state where
the driver is left in an OFF state.
This can happen if a 2nd recovery is triggered and runs before
ieee80211_reconfig adds back the interface.
Fix this by always clearing the recovery flag.
In addition, enable interrupts to balance the disable in
wl1271_queue_recovery_work.

(This is based on Arik's patch for wlcore with fixes)

Signed-off-by: Eyal Shapira <eyal@wizery.com>
wlcore: Prevent processing of work items during op_stop

The interrupt line is disabled in op_stop using disable_irq. Since
pending interrupts are synchronized, the mutex has to be released before
disabling the interrupt to avoid a deadlock with the interrupt handler.

In addition, the internal state of the driver is only set to 'off'
after the interrupt is disabled. Otherwise, if an interrupt fires after
the state is set but before the interrupt line is disabled, the
interrupt handler will not be able to acknowledge the interrupt
resulting in an interrupt storm.

The driver's operations might be called during recovery. If these
acquire the mutex after it was released by op_stop, but before the
driver's state is changed, they may queue new work items instead of just
failing. This is especially problematic in the case of scans, in which a
new scan may be scheduled after all scan requests were cancelled.

Signed-off-by: Ido Yariv <ido@wizery.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Eyal Shapira <eyal@wizery.com>
mac80211: don't require associated->beacon_ies for ps

beacon_ies is needed only in order to extract the dtim
period. However, even if it's missing we can still enter
ps with dtim=1 (which also happens if the TIM ie is invalid).

Most drivers don't use conf.max_sleep_period/ps_dtim_period
anyway, and this check prevents them from entering ps if
they don't have beacon (but only probe response), even though
the beacon is not needed at all.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Eyal Shapira <eyal@wizery.com>
wlcore: don't set SDIO_FAILED flag when driver state is off

If some IO read/write fails while the FW is not loaded, a recovery
will not take place. This means the SDIO_FAILED flag will stay in place
forever and prevent further read/writes.

This can happen if a check for STATE_OFF was forgotten in some routine.

Take this opportunity to rename the flag to IO_FAILED, since we support
other buses as well.

Reported-by: Ido Yariv <ido@wizery.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Eyal Shapira <eyal@wizery.com>
mac80211: fix list_aliases handling (INTERNAL)

commit 37a5502 ("cfg80211: more correct support of multi-essid bss-es")
used the wrong syntax for adding an entry to existing list, causing
memory corruption later on, if the original list was not empty.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Eyal Shapira <eyal@wizery.com>
wlcore: android: don't suspend on pending recovery (INTERNAL)

Some customers complain that if we cancel a pending recovery during
suspend, the android scheduler will keep banging on the suspend handler,
without letting recovery take its course. Grab a wakelock to give the
recovery process some breathing room.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: Eyal Shapira <eyal@wizery.com>
wl12xx: sync recovery work with reconfig

A second recovery can occur during mac80211 reconfig
which began due a previous recovery. recover_work can
be scheduled and will do op_stop which switches us to off.
This is bad as a remaining part of the reconfig will fail.
Instead, sync recovery work with reconfig by using RTNL
which mac80211 locks while doing reconfig. mac80211 wq
can't be used under RTNL so switch to the global wq.
Also avoid disabling interrupts when queuing the recovery
as this would fail any further command which is part of
the reconfig. Instead, do it in recovery work after reading
FW log which also requires enabled interrupts.

Signed-off-by: Eyal Shapira <eyal@wizery.com>