ath10k: re-enable interrupts properly in hw recovery

Recent changes done to start/restart sequences
broke hw recovery in some hw configurations. The
pci transport was stopped twice however due to a
workaround in the pci disabling code the
disable/enable for first msi interrupt was not
balanced. This ended up with irqs not being
properly re-enabled and the following print out
during recovery:

 ath10k: failed to receive control response completion, polling..
 ath10k: Service connect timeout: -110
 ath10k: Could not init core: -110

Legacy interrupt mode was unaffected while msi
ranged mode would be partially crippled (it would
miss fw indication interrupts but otherwise it
worked fine).

This fixes completely broken fw recovery for a
single msi interrupt mode and fixes subsequent fw
crash reports for msi range interrupt mode.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: fix num_legacy_stations tracking

If a station was reassociated, i.e. due to change
of supported rates update via sta_rc_update() the
num_legacy_stations would be (incorrectly) bumped
up leading to unbalanced usage of the var. This in
turn could lock rtscts protection up as enabled.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: kill tasklets after free_irq

Commit 5c771e7454d148af35e8b4297d00f880de79ea49
introduced a regression. On some systems spurious
interrupts could schedule a tasklet while tearing
down leading to, e.g.:

 BUG: unable to handle kernel paging request at fe589030
 IP: [<c1316fb0>] ioread32+0x30/0x40
 ...
 Call Trace:
  [<fe576c1b>] ath10k_pci_tasklet+0x1b/0x60 [ath10k_pci]
  [<c1053fbe>] tasklet_action+0x9e/0xb0
  [<c10534f1>] __do_softirq+0xf1/0x3f0
  [<c1053400>] ? ftrace_raw_event_irq_handler_entry+0xa0/0xa0
  [<c1004999>] do_softirq_own_stack+0x29/0x40
  <IRQ>
  [<c1053a76>] irq_exit+0x86/0xb0
 ...
  [<c132d522>] do_pci_disable_device+0x52/0x60
  [<c132d57f>] pci_disable_device+0x4f/0xb0
  [<c132a961>] ? __pci_set_master+0x51/0x80
  [<fe5740b3>] ath10k_pci_release+0x33/0x40 [ath10k_pci]
  [<fe575d4b>] ath10k_pci_remove+0x7b/0x90 [ath10k_pci]

Reported-by: Kalle Valo <kvalo@qca.qualcomm.com>
Tested-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: fix monitor start/stop sequences

Fix some cases where monitor start failure left
the driver in a confused state.

This also makes the monitor code simpler.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: stop monitor vdev for sta assoc

This prevents some fw revisions from crashing in
many cases when user is trying to run a
promiscuous station interface (e.g. sniffing,
4addr bridge).

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: make ath10k_wmi_cmd_send() public

We need this function to send wmi packets from testmode.c.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: add testmode

Add testmode interface for starting and using UTF firmware which is used to run
factory tests. This is implemented by adding new state ATH10K_STATE_UTF and user
space can enable this state with ATH10K_TM_CMD_UTF_START command. To go back to
normal mode user space can send ATH10K_TM_CMD_UTF_STOP.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: remove diag_*_access functions

Remove the ugly _access functions. Being explicit
is a good thing.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: add device/driver strings to tracepoints

This makes it easier to log and debug via tracing
with more than 1 ath10k device on a system.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: Support firmware crash-by-assert.

10.1 firmware does not have an official way to
cause assert on purpose, but it can be done with
carefully crafted WMI command.  This is a different
kind of crash from the 'hard' crash, which is
a bad memory dereference.

Different crashes decode in different manners, so
this will help the crash-report testing as well as
offer better ways to test firmware failure and
recovery.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
ath10k: don't access tx_info while overwriting it

Nothing important was being overwritten so it
didn't yield any bugs yet.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>