Commit Graph

691 Commits

Author SHA1 Message Date
Jouni Malinen 23f77ad13f ath9k: Postpone key cache entry deletion for TXQ frames reference it
commit ca2848022c12789685d3fab3227df02b863f9696 upstream.

Do not delete a key cache entry that is still being referenced by
pending frames in TXQs. This avoids reuse of the key cache entry while a
frame might still be transmitted using it.

To avoid having to do any additional operations during the main TX path
operations, track pending key cache entries in a new bitmap and check
whether any pending entries can be deleted before every new key
add/remove operation. Also clear any remaining entries when stopping the
interface.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20201214172118.18100-6-jouni@codeaurora.org
Cc: Pali Rohár <pali@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-26 08:36:12 -04:00
Jouni Malinen c6feaf806d ath: Modify ath_key_delete() to not need full key entry
commit 144cd24dbc36650a51f7fe3bf1424a1432f1f480 upstream.

tkip_keymap can be used internally to avoid the reference to key->cipher
and with this, only the key index value itself is needed. This allows
ath_key_delete() call to be postponed to be handled after the upper
layer STA and key entry have already been removed. This is needed to
make ath9k key cache management safer.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20201214172118.18100-5-jouni@codeaurora.org
Cc: Pali Rohár <pali@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-26 08:36:11 -04:00
Jouni Malinen add283e251 ath9k: Clear key cache explicitly on disabling hardware
commit 73488cb2fa3bb1ef9f6cf0d757f76958bd4deaca upstream.

Now that ath/key.c may not be explicitly clearing keys from the key
cache, clear all key cache entries when disabling hardware to make sure
no keys are left behind beyond this point.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20201214172118.18100-3-jouni@codeaurora.org
Cc: Pali Rohár <pali@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-26 08:36:11 -04:00
Pali Rohár 96bb095f85 ath9k: Fix kernel NULL pointer dereference during ath_reset_internal()
commit fb312ac5ccb007e843f982b38d4d6886ba4b32f2 upstream.

I got this crash more times during debugging of PCIe controller and crash
happens somehow at the time when PCIe kernel code started link retraining (as
part of ASPM code) when at the same time PCIe link went down and ath9k probably
executed hw reset procedure.

Currently I'm not able to reproduce this issue as it looks like to be
some race condition between link training, ASPM, link down and reset
path. And as always, race conditions which depends on more input
parameters are hard to reproduce as it depends on precise timings.

But it is clear that pointers are zero in this case and should be
properly filled as same code pattern is used in ath9k_stop() function.
Anyway I was able to reproduce this crash by manually triggering ath
reset worker prior putting card up. I created simple patch to export
reset functionality via debugfs and use it to "simulate" of triggering
reset.    s proved that NULL-pointer dereference issue is there.

Function ath9k_hw_reset() is dereferencing chan structure pointer, so it
needs to be non-NULL pointer.

Function ath9k_stop() already contains code which sets ah->curchan to valid
non-NULL pointer prior calling ath9k_hw_reset() function.

Add same code pattern also into ath_reset_internal() function to prevent
kernel NULL pointer dereference in ath9k_hw_reset() function.

This change fixes kernel NULL pointer dereference in ath9k_hw_reset() which
is caused by calling ath9k_hw_reset() from ath_reset_internal() with NULL
chan structure.

    [   45.334305] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
    [   45.344417] Mem abort info:
    [   45.347301]   ESR = 0x96000005
    [   45.350448]   EC = 0x25: DABT (current EL), IL = 32 bits
    [   45.356166]   SET = 0, FnV = 0
    [   45.359350]   EA = 0, S1PTW = 0
    [   45.362596] Data abort info:
    [   45.365756]   ISV = 0, ISS = 0x00000005
    [   45.369735]   CM = 0, WnR = 0
    [   45.372814] user pgtable: 4k pages, 39-bit VAs, pgdp=000000000685d000
    [   45.379663] [0000000000000008] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
    [   45.388856] Internal error: Oops: 96000005 [#1] SMP
    [   45.393897] Modules linked in: ath9k ath9k_common ath9k_hw
    [   45.399574] CPU: 1 PID: 309 Comm: kworker/u4:2 Not tainted 5.12.0-rc2-dirty #785
    [   45.414746] Workqueue: phy0 ath_reset_work [ath9k]
    [   45.419713] pstate: 40000005 (nZcv daif -PAN -UAO -TCO BTYPE=--)
    [   45.425910] pc : ath9k_hw_reset+0xc4/0x1c48 [ath9k_hw]
    [   45.431234] lr : ath9k_hw_reset+0xc0/0x1c48 [ath9k_hw]
    [   45.436548] sp : ffffffc0118dbca0
    [   45.439961] x29: ffffffc0118dbca0 x28: 0000000000000000
    [   45.445442] x27: ffffff800dee4080 x26: 0000000000000000
    [   45.450923] x25: ffffff800df9b9d8 x24: 0000000000000000
    [   45.456404] x23: ffffffc0115f6000 x22: ffffffc008d0d408
    [   45.461885] x21: ffffff800dee5080 x20: ffffff800df9b9d8
    [   45.467366] x19: 0000000000000000 x18: 0000000000000000
    [   45.472846] x17: 0000000000000000 x16: 0000000000000000
    [   45.478326] x15: 0000000000000010 x14: ffffffffffffffff
    [   45.483807] x13: ffffffc0918db94f x12: ffffffc011498720
    [   45.489289] x11: 0000000000000003 x10: ffffffc0114806e0
    [   45.494770] x9 : ffffffc01014b2ec x8 : 0000000000017fe8
    [   45.500251] x7 : c0000000ffffefff x6 : 0000000000000001
    [   45.505733] x5 : 0000000000000000 x4 : 0000000000000000
    [   45.511213] x3 : 0000000000000000 x2 : ffffff801fece870
    [   45.516693] x1 : ffffffc00eded000 x0 : 000000000000003f
    [   45.522174] Call trace:
    [   45.524695]  ath9k_hw_reset+0xc4/0x1c48 [ath9k_hw]
    [   45.529653]  ath_reset_internal+0x1a8/0x2b8 [ath9k]
    [   45.534696]  ath_reset_work+0x2c/0x40 [ath9k]
    [   45.539198]  process_one_work+0x210/0x480
    [   45.543339]  worker_thread+0x5c/0x510
    [   45.547115]  kthread+0x12c/0x130
    [   45.550445]  ret_from_fork+0x10/0x1c
    [   45.554138] Code: 910922c2 9117e021 95ff0398 b4000294 (b9400a61)
    [   45.560430] ---[ end trace 566410ba90b50e8b ]---
    [   45.565193] Kernel panic - not syncing: Oops: Fatal exception in interrupt
    [   45.572282] SMP: stopping secondary CPUs
    [   45.576331] Kernel Offset: disabled
    [   45.579924] CPU features: 0x00040002,0000200c
    [   45.584416] Memory Limit: none
    [   45.587564] Rebooting in 3 seconds..

Signed-off-by: Pali Rohár <pali@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210402122653.24014-1-pali@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-14 16:53:07 +02:00
Remi Pommarel 0a993df8d6 ath9k: Handle txpower changes even when TPC is disabled
commit 968ae2caad0782db5dbbabb560d3cdefd2945d38 upstream.

When TPC is disabled IEEE80211_CONF_CHANGE_POWER event can be handled to
reconfigure HW's maximum txpower.

This fixes 0dBm txpower setting when user attaches to an interface for
the first time with the following scenario:

ieee80211_do_open()
    ath9k_add_interface()
        ath9k_set_txpower() /* Set TX power with not yet initialized
                               sc->hw->conf.power_level */

    ieee80211_hw_config() /* Iniatilize sc->hw->conf.power_level and
                             raise IEEE80211_CONF_CHANGE_POWER */

    ath9k_config() /* IEEE80211_CONF_CHANGE_POWER is ignored */

This issue can be reproduced with the following:

  $ modprobe -r ath9k
  $ modprobe ath9k
  $ wpa_supplicant -i wlan0 -c /tmp/wpa.conf &
  $ iw dev /* Here TX power is either 0 or 3 depending on RF chain */
  $ killall wpa_supplicant
  $ iw dev /* TX power goes back to calibrated value and subsequent
              calls will be fine */

Fixes: 283dd11994 ("ath9k: add per-vif TX power capability")
Cc: stable@vger.kernel.org
Signed-off-by: Remi Pommarel <repk@triplefau.lt>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-17 10:50:12 +02:00
Emmanuel Grumbach 5db4c4b955 mac80211: pass the vif to cancel_remain_on_channel
This low level driver can find it useful to get the vif
when a remain on channel session is cancelled.

iwlwifi will need this soon.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Link: https://lore.kernel.org/r/20190723180001.5828-1-emmanuel.grumbach@intel.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2019-07-26 13:08:28 +02:00
Dan Carpenter 461cf03605 ath9k: Fix a locking bug in ath9k_add_interface()
We tried to revert commit d9c52fd17c ("ath9k: fix tx99 with monitor
mode interface") but accidentally missed part of the locking change.

The lock has to be held earlier so that we're holding it when we do
"sc->tx99_vif = vif;" and also there in the current code there is a
stray unlock before we have taken the lock.

Fixes: 6df0580be8 ("ath9k: add back support for using active monitor interfaces for tx99")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2018-11-06 18:43:30 +02:00
Arnd Bergmann 72569b7be4 ath9k: fix RX_STAT_INC() etc macros
A couple of macros that deal with statistics in ath9k rely on the
declaration of the 'sc' variable, which they dereference.

However, when the statistics are disabled, the new instance in
ath_cmn_process_fft() causes a warning for an unused variable:

drivers/net/wireless/ath/ath9k/common-spectral.c: In function 'ath_cmn_process_fft':
drivers/net/wireless/ath/ath9k/common-spectral.c:474:20: error: unused variable 'sc' [-Werror=unused-variable]

It's better if those macros only operate on their arguments instead of
known variable names, and adding a cast to (void) kills off that warning.

Fixes: 03224678c0 ("ath9k: add counters for good and errorneous FFT/spectral frames")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2018-10-13 20:27:35 +03:00
Felix Fietkau 6df0580be8 ath9k: add back support for using active monitor interfaces for tx99
Various documented examples on how to set up tx99 with ath9k rely
on setting up a regular monitor interface for setting the channel.
My previous patch "ath9k: fix tx99 with monitor mode interface" made
it possible to set it up this way again. However, it was removing support
for using an active monitor interface, which is required for controlling
the bitrate as well, since the bitrate is not passed down with a regular
monitor interface.

This patch partially reverts the previous one, but keeps support for using
a regular monitor interface to keep documented steps working in cases
where the bitrate does not matter

Fixes: d9c52fd17c ("ath9k: fix tx99 with monitor mode interface")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2018-10-02 07:54:26 +03:00
Felix Fietkau d9c52fd17c ath9k: fix tx99 with monitor mode interface
Tx99 is typically configured via a monitor mode interface, which does
not get added to the driver as a vif. Since the code currently expects
a configured virtual interface for tx99, enabling tx99 via debugfs fails.
Since the vif is not needed anyway, remove all checks for it.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
[kvalo@codeaurora.org: s/CPTCFG/CONFIG/]
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2018-08-28 16:45:40 +03:00
Arnd Bergmann fe041deba4 ath9k: use timespec64 for tsf_ts
ath9k is the last remaining user of the deprecated getrawmonotonic()
interface. There is nothing wrong with this usage, but migrating
to a timespec64 based interface lets us clean up the old API.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2018-06-29 14:44:49 +03:00
Kalle Valo 4cf44d5255 Merge ath-next from git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
ath.git patches for 4.19. Major changes:

ath10k

* support channel 173

* fix spectral scan for QCA9984 and QCA9888 chipsets

ath6kl

* add support for Dell Wireless 1537
2018-06-18 16:48:15 +03:00
Gustavo A. R. Silva 12b67b0d6b ath9k: mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2018-06-13 14:45:20 +03:00
Ilan Peer d4e36e5554 mac80211: Support adding duration for prepare_tx() callback
There are specific cases, such as SAE authentication exchange, that
might require long duration to complete. For such cases, add support
for indicating to the driver the required duration of the prepare_tx()
operation, so the driver would still be able to complete the frame
exchange.

Currently, indicate the duration only for SAE authentication exchange,
as SAE authentication can take up to 2000 msec (as defined in IEEE
P802.11-REVmd D1.0 p. 3504).

As the patch modified the prepare_tx() callback API, also modify
the relevant code in iwlwifi.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2018-05-23 11:06:10 +02:00
Kees Cook 7ac767645a ath: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2017-10-27 16:54:19 +03:00
Ville Syrjälä ba24d63dd3 ath9k: Avoid a potential deadlock
Lockdep warns us that sc_pm_lock and cc_lock can cause a deadlock when
cc_lock is acquired by itself with interrupts enabled. Disable irqs
whenever taking cc_lock to avoid this.

[   19.094524] kworker/u2:0/5 just changed the state of lock:
[   19.094578]  (&(&sc->sc_pm_lock)->rlock){-.-...}, at: [<f836c00e>] ath_isr+0x15e/0x200 [ath9k]
[   19.094674] but this lock took another, HARDIRQ-unsafe lock in the past:
[   19.094731]  (&(&common->cc_lock)->rlock){+.-...}
[   19.094741]

               and interrupts could create inverse lock ordering between them.

[   19.094866]
               other info that might help us debug this:
[   19.094926]  Possible interrupt unsafe locking scenario:

[   19.094985]        CPU0                    CPU1
[   19.095036]        ----                    ----
[   19.095086]   lock(&(&common->cc_lock)->rlock);
[   19.095197]                                local_irq_disable();
[   19.095305]                                lock(&(&sc->sc_pm_lock)->rlock);
[   19.095423]                                lock(&(&common->cc_lock)->rlock);
[   19.095539]   <Interrupt>
[   19.095636]     lock(&(&sc->sc_pm_lock)->rlock);
[   19.095745]
                *** DEADLOCK ***

[   19.095965] 3 locks held by kworker/u2:0/5:
[   19.096067]  #0:  ("%s"wiphy_name(local->hw.wiphy)){.+.+.+}, at: [<c1067f37>] process_one_work+0x127/0x580
[   19.096260]  #1:  ((&local->dynamic_ps_enable_work)){+.+...}, at: [<c1067f37>] process_one_work+0x127/0x580
[   19.096447]  #2:  (&sc->mutex){+.+...}, at: [<f836b8b0>] ath9k_config+0x30/0x1d0 [ath9k]
[   19.096639]
               the shortest dependencies between 2nd lock and 1st lock:
[   19.096813]  -> (&(&common->cc_lock)->rlock){+.-...} ops: 38 {
[   19.096816]     HARDIRQ-ON-W at:
[   19.096816]                       __lock_acquire+0x57e/0x1260
[   19.096816]                       lock_acquire+0xb1/0x1c0
[   19.096816]                       _raw_spin_lock_bh+0x3f/0x50
[   19.096816]                       ath_chanctx_set_channel+0xb6/0x2c0 [ath9k]
[   19.096816]                       ath9k_config+0xa8/0x1d0 [ath9k]
[   19.096816]                       ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]                       ieee80211_do_open+0x67a/0x920 [mac80211]
[   19.096816]                       ieee80211_open+0x41/0x50 [mac80211]
[   19.096816]                       __dev_open+0xab/0x140
[   19.096816]                       __dev_change_flags+0x89/0x150
[   19.096816]                       dev_change_flags+0x28/0x60
[   19.096816]                       do_setlink+0x290/0x890
[   19.096816]                       rtnl_newlink+0x7cf/0x8e0
[   19.096816]                       rtnetlink_rcv_msg+0xbf/0x1f0
[   19.096816]                       netlink_rcv_skb+0xb9/0xe0
[   19.096816]                       rtnetlink_rcv+0x1e/0x30
[   19.096816]                       netlink_unicast+0x13a/0x2c0
[   19.096816]                       netlink_sendmsg+0x290/0x380
[   19.096816]                       ___sys_sendmsg+0x1e2/0x280
[   19.096816]                       __sys_sendmsg+0x3f/0x80
[   19.096816]                       SyS_socketcall+0x58c/0x6b0
[   19.096816]                       do_fast_syscall_32+0x96/0x1d0
[   19.096816]                       entry_SYSENTER_32+0x4c/0x7b
[   19.096816]     IN-SOFTIRQ-W at:
[   19.096816]                       __lock_acquire+0x55a/0x1260
[   19.096816]                       lock_acquire+0xb1/0x1c0
[   19.096816]                       _raw_spin_lock+0x3c/0x50
[   19.096816]                       ath_ps_full_sleep+0x24/0x70 [ath9k]
[   19.096816]                       call_timer_fn+0xa4/0x300
[   19.096816]                       run_timer_softirq+0x1b1/0x560
[   19.096816]                       __do_softirq+0xb0/0x430
[   19.096816]                       do_softirq_own_stack+0x33/0x40
[   19.096816]                       irq_exit+0xad/0xc0
[   19.096816]                       smp_apic_timer_interrupt+0x31/0x40
[   19.096816]                       apic_timer_interrupt+0x37/0x3c
[   19.096816]                       wp_page_copy+0xb8/0x580
[   19.096816]                       do_wp_page+0x64/0x420
[   19.096816]                       handle_mm_fault+0x430/0x990
[   19.096816]                       __do_page_fault+0x18b/0x430
[   19.096816]                       do_page_fault+0xb/0x10
[   19.096816]                       common_exception+0x62/0x6a
[   19.096816]     INITIAL USE at:
[   19.096816]                      __lock_acquire+0x204/0x1260
[   19.096816]                      lock_acquire+0xb1/0x1c0
[   19.096816]                      _raw_spin_lock_bh+0x3f/0x50
[   19.096816]                      ath_chanctx_set_channel+0xb6/0x2c0 [ath9k]
[   19.096816]                      ath9k_config+0xa8/0x1d0 [ath9k]
[   19.096816]                      ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]                      ieee80211_do_open+0x67a/0x920 [mac80211]
[   19.096816]                      ieee80211_open+0x41/0x50 [mac80211]
[   19.096816]                      __dev_open+0xab/0x140
[   19.096816]                      __dev_change_flags+0x89/0x150
[   19.096816]                      dev_change_flags+0x28/0x60
[   19.096816]                      do_setlink+0x290/0x890
[   19.096816]                      rtnl_newlink+0x7cf/0x8e0
[   19.096816]                      rtnetlink_rcv_msg+0xbf/0x1f0
[   19.096816]                      netlink_rcv_skb+0xb9/0xe0
[   19.096816]                      rtnetlink_rcv+0x1e/0x30
[   19.096816]                      netlink_unicast+0x13a/0x2c0
[   19.096816]                      netlink_sendmsg+0x290/0x380
[   19.096816]                      ___sys_sendmsg+0x1e2/0x280
[   19.096816]                      __sys_sendmsg+0x3f/0x80
[   19.096816]                      SyS_socketcall+0x58c/0x6b0
[   19.096816]                      do_fast_syscall_32+0x96/0x1d0
[   19.096816]                      entry_SYSENTER_32+0x4c/0x7b
[   19.096816]   }
[   19.096816]   ... key      at: [<f837b694>] __key.61991+0x0/0xffffc96c [ath9k]
[   19.096816]   ... acquired at:
[   19.096816]    lock_acquire+0xb1/0x1c0
[   19.096816]    _raw_spin_lock+0x3c/0x50
[   19.096816]    ath9k_ps_wakeup+0x85/0xe0 [ath9k]
[   19.096816]    ath9k_bss_info_changed+0x2a/0x1b0 [ath9k]
[   19.096816]    ieee80211_bss_info_change_notify+0xf3/0x360 [mac80211]
[   19.096816]    ieee80211_recalc_txpower+0x33/0x40 [mac80211]
[   19.096816]    ieee80211_set_tx_power+0x45/0x1d0 [mac80211]
[   19.096816]    cfg80211_wext_siwtxpower+0xd3/0x350 [cfg80211]
[   19.096816]    ioctl_standard_call+0x4e/0x400
[   19.096816]    wext_handle_ioctl+0xf4/0x190
[   19.096816]    dev_ioctl+0xb7/0x630
[   19.096816]    sock_ioctl+0x13e/0x2d0
[   19.096816]    do_vfs_ioctl+0x84/0x750
[   19.096816]    SyS_ioctl+0x34/0x60
[   19.096816]    do_fast_syscall_32+0x96/0x1d0
[   19.096816]    entry_SYSENTER_32+0x4c/0x7b

[   19.096816] -> (&(&sc->sc_pm_lock)->rlock){-.-...} ops: 597 {
[   19.096816]    IN-HARDIRQ-W at:
[   19.096816]                     __lock_acquire+0x6ae/0x1260
[   19.096816]                     lock_acquire+0xb1/0x1c0
[   19.096816]                     _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]                     ath_isr+0x15e/0x200 [ath9k]
[   19.096816]                     __handle_irq_event_percpu+0x44/0x340
[   19.096816]                     handle_irq_event_percpu+0x1d/0x50
[   19.096816]                     handle_irq_event+0x32/0x60
[   19.096816]                     handle_level_irq+0x81/0x100
[   19.096816]                     handle_irq+0x9c/0xd0
[   19.096816]                     do_IRQ+0x5c/0x120
[   19.096816]                     common_interrupt+0x36/0x3c
[   19.096816]                     _raw_spin_unlock_irqrestore+0x57/0x70
[   19.096816]                     ath9k_config+0x16a/0x1d0 [ath9k]
[   19.096816]                     ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]                     ieee80211_dynamic_ps_enable_work+0x1c3/0x680 [mac80211]
[   19.096816]                     process_one_work+0x1d1/0x580
[   19.096816]                     worker_thread+0x31/0x380
[   19.096816]                     kthread+0xd9/0x110
[   19.096816]                     ret_from_fork+0x19/0x24
[   19.096816]    IN-SOFTIRQ-W at:
[   19.096816]                     __lock_acquire+0x55a/0x1260
[   19.096816]                     lock_acquire+0xb1/0x1c0
[   19.096816]                     _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]                     ath9k_ps_wakeup+0x24/0xe0 [ath9k]
[   19.096816]                     ath9k_tasklet+0x42/0x260 [ath9k]
[   19.096816]                     tasklet_action+0x196/0x1e0
[   19.096816]                     __do_softirq+0xb0/0x430
[   19.096816]                     do_softirq_own_stack+0x33/0x40
[   19.096816]                     irq_exit+0xad/0xc0
[   19.096816]                     do_IRQ+0x65/0x120
[   19.096816]                     common_interrupt+0x36/0x3c
[   19.096816]                     get_page_from_freelist+0x20a/0x970
[   19.096816]                     __alloc_pages_nodemask+0xca/0xed0
[   19.096816]                     __get_free_pages+0x14/0x30
[   19.096816]                     pgd_alloc+0x1d/0x160
[   19.096816]                     mm_init.isra.47+0x13a/0x1b0
[   19.096816]                     copy_process.part.54+0xb55/0x1700
[   19.096816]                     _do_fork+0xd4/0x6a0
[   19.096816]                     SyS_clone+0x27/0x30
[   19.096816]                     do_fast_syscall_32+0x96/0x1d0
[   19.096816]                     entry_SYSENTER_32+0x4c/0x7b
[   19.096816]    INITIAL USE at:
[   19.096816]                    __lock_acquire+0x204/0x1260
[   19.096816]                    lock_acquire+0xb1/0x1c0
[   19.096816]                    _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]                    ath9k_ps_wakeup+0x24/0xe0 [ath9k]
[   19.096816]                    ath9k_start+0x29/0x1f0 [ath9k]
[   19.096816]                    drv_start+0x71/0x270 [mac80211]
[   19.096816]                    ieee80211_do_open+0x31f/0x920 [mac80211]
[   19.096816]                    ieee80211_open+0x41/0x50 [mac80211]
[   19.096816]                    __dev_open+0xab/0x140
[   19.096816]                    __dev_change_flags+0x89/0x150
[   19.096816]                    dev_change_flags+0x28/0x60
[   19.096816]                    do_setlink+0x290/0x890
[   19.096816]                    rtnl_newlink+0x7cf/0x8e0
[   19.096816]                    rtnetlink_rcv_msg+0xbf/0x1f0
[   19.096816]                    netlink_rcv_skb+0xb9/0xe0
[   19.096816]                    rtnetlink_rcv+0x1e/0x30
[   19.096816]                    netlink_unicast+0x13a/0x2c0
[   19.096816]                    netlink_sendmsg+0x290/0x380
[   19.096816]                    ___sys_sendmsg+0x1e2/0x280
[   19.096816]                    __sys_sendmsg+0x3f/0x80
[   19.096816]                    SyS_socketcall+0x58c/0x6b0
[   19.096816]                    do_fast_syscall_32+0x96/0x1d0
[   19.096816]                    entry_SYSENTER_32+0x4c/0x7b
[   19.096816]  }
[   19.096816]  ... key      at: [<f837b67c>] __key.61994+0x0/0xffffc984 [ath9k]
[   19.096816]  ... acquired at:
[   19.096816]    check_usage_forwards+0x118/0x120
[   19.096816]    mark_lock+0x2e4/0x590
[   19.096816]    __lock_acquire+0x6ae/0x1260
[   19.096816]    lock_acquire+0xb1/0x1c0
[   19.096816]    _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]    ath_isr+0x15e/0x200 [ath9k]
[   19.096816]    __handle_irq_event_percpu+0x44/0x340
[   19.096816]    handle_irq_event_percpu+0x1d/0x50
[   19.096816]    handle_irq_event+0x32/0x60
[   19.096816]    handle_level_irq+0x81/0x100
[   19.096816]    handle_irq+0x9c/0xd0
[   19.096816]    do_IRQ+0x5c/0x120
[   19.096816]    common_interrupt+0x36/0x3c
[   19.096816]    _raw_spin_unlock_irqrestore+0x57/0x70
[   19.096816]    ath9k_config+0x16a/0x1d0 [ath9k]
[   19.096816]    ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]    ieee80211_dynamic_ps_enable_work+0x1c3/0x680 [mac80211]
[   19.096816]    process_one_work+0x1d1/0x580
[   19.096816]    worker_thread+0x31/0x380
[   19.096816]    kthread+0xd9/0x110
[   19.096816]    ret_from_fork+0x19/0x24

[   19.096816]
               stack backtrace:
[   19.096816] CPU: 0 PID: 5 Comm: kworker/u2:0 Not tainted 4.13.0-mgm-ovl+ #51
[   19.096816] Hardware name: FUJITSU SIEMENS LIFEBOOK S6120/FJNB16C, BIOS Version 1.26  05/10/2004
[   19.096816] Workqueue: phy0 ieee80211_dynamic_ps_enable_work [mac80211]
[   19.096816] Call Trace:
[   19.096816]  <IRQ>
[   19.096816]  dump_stack+0x16/0x19
[   19.096816]  print_irq_inversion_bug.part.37+0x16c/0x179
[   19.096816]  check_usage_forwards+0x118/0x120
[   19.096816]  ? ret_from_fork+0x19/0x24
[   19.096816]  ? print_shortest_lock_dependencies+0x1a0/0x1a0
[   19.096816]  mark_lock+0x2e4/0x590
[   19.096816]  ? print_shortest_lock_dependencies+0x1a0/0x1a0
[   19.096816]  __lock_acquire+0x6ae/0x1260
[   19.096816]  lock_acquire+0xb1/0x1c0
[   19.096816]  ? ath_isr+0x15e/0x200 [ath9k]
[   19.096816]  _raw_spin_lock_irqsave+0x45/0x60
[   19.096816]  ? ath_isr+0x15e/0x200 [ath9k]
[   19.096816]  ath_isr+0x15e/0x200 [ath9k]
[   19.096816]  __handle_irq_event_percpu+0x44/0x340
[   19.096816]  handle_irq_event_percpu+0x1d/0x50
[   19.096816]  handle_irq_event+0x32/0x60
[   19.096816]  ? handle_nested_irq+0x100/0x100
[   19.096816]  handle_level_irq+0x81/0x100
[   19.096816]  handle_irq+0x9c/0xd0
[   19.096816]  </IRQ>
[   19.096816]  do_IRQ+0x5c/0x120
[   19.096816]  common_interrupt+0x36/0x3c
[   19.096816] EIP: _raw_spin_unlock_irqrestore+0x57/0x70
[   19.096816] EFLAGS: 00000286 CPU: 0
[   19.096816] EAX: f60a3600 EBX: 00000286 ECX: 00000006 EDX: 00000001
[   19.096816] ESI: f46c9e68 EDI: f46c8620 EBP: f60b5e8c ESP: f60b5e84
[   19.096816]  DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
[   19.096816]  ath9k_config+0x16a/0x1d0 [ath9k]
[   19.096816]  ieee80211_hw_config+0xa8/0x5f0 [mac80211]
[   19.096816]  ? ieee80211_hw_config+0x1db/0x5f0 [mac80211]
[   19.096816]  ieee80211_dynamic_ps_enable_work+0x1c3/0x680 [mac80211]
[   19.096816]  ? process_one_work+0x127/0x580
[   19.096816]  ? process_one_work+0x127/0x580
[   19.096816]  process_one_work+0x1d1/0x580
[   19.096816]  ? process_one_work+0x127/0x580
[   19.096816]  worker_thread+0x31/0x380
[   19.096816]  kthread+0xd9/0x110
[   19.096816]  ? process_one_work+0x580/0x580
[   19.096816]  ? kthread_create_on_node+0x30/0x30
[   19.096816]  ret_from_fork+0x19/0x24

Cc: QCA ath9k Development <ath9k-devel@qca.qualcomm.com>
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2017-09-25 10:17:42 +03:00
Himanshu Jha 50c8cd44ed ath9k: remove cast to void pointer
casting to void pointer from any pointer type and vice-versa is done
implicitly and therefore casting is not needed in such a case.

Done using Coccinellle.
Semantic Patch used :

@r@
expression x;
void* e;
type T;
identifier f;
@@

(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T *)x)->f
|
- (T *)
  e
)


Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2017-09-25 10:13:58 +03:00
Miaoqing Pan f23cdfb3fe ath9k: Use mutex_lock to avoid potential race in start/stop rng
Move ath9k_rng_stop/ath9k_rng_start pair into critical section,
use mutex_lock to void potential race accessing.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2017-06-28 19:54:43 +03:00
Felix Fietkau 3a5e969bb2 ath9k: fix race condition in enabling/disabling IRQs
The code currently relies on refcounting to disable IRQs from within the
IRQ handler and re-enabling them again after the tasklet has run.

However, due to race conditions sometimes the IRQ handler might be
called twice, or the tasklet may not run at all (if interrupted in the
middle of a reset).

This can cause nasty imbalances in the irq-disable refcount which will
get the driver permanently stuck until the entire radio has been stopped
and started again (ath_reset will not recover from this).

Instead of using this fragile logic, change the code to ensure that
running the irq handler during tasklet processing is safe, and leave the
refcount untouched.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2017-02-07 11:00:25 +02:00
Felix Fietkau d63ffc45c5 ath9k: rename tx_complete_work to hw_check_work
Also include common MAC alive check. This should make the hang checks
more reliable for modes where beacons are not sent and is used as a
starting point for further hang check improvements

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2017-02-07 11:00:17 +02:00
Toke Høiland-Jørgensen 63fefa0504 ath9k: Introduce airtime fairness scheduling between stations
This reworks the ath9k driver to schedule transmissions to connected
stations in a way that enforces airtime fairness between them. It
accomplishes this by measuring the time spent transmitting to or
receiving from a station at TX and RX completion, and accounting this to
a per-station, per-QoS level airtime deficit. Then, an FQ-CoDel based
deficit scheduler is employed at packet dequeue time, to control which
station gets the next transmission opportunity.

Airtime fairness can significantly improve the efficiency of the network
when station rates vary. The following throughput values are from a
simple three-station test scenario, where two stations operate at the
highest HT20 rate, and one station at the lowest, and the scheduler is
employed at the access point:

                  Before   /   After
Fast station 1:    19.17   /   25.09 Mbps
Fast station 2:    19.83   /   25.21 Mbps
Slow station:       2.58   /    1.77 Mbps
Total:             41.58   /   52.07 Mbps

The benefit of airtime fairness goes up the more stations are present.
In a 30-station test with one station artificially limited to 1 Mbps,
we have seen aggregate throughput go from 2.14 to 17.76 Mbps.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-12-15 10:43:05 +02:00
Toke Høiland-Jørgensen 50f08edf98 ath9k: Switch to using mac80211 intermediate software queues.
This switches ath9k over to using the mac80211 intermediate software
queueing mechanism for data packets. It removes the queueing inside the
driver, except for the retry queue, and instead pulls from mac80211 when
a packet is needed. The retry queue is used to store a packet that was
pulled but can't be sent immediately.

The old code path in ath_tx_start that would queue packets has been
removed completely, as has the qlen limit tunables (since there's no
longer a queue in the driver to limit).

The mac80211 intermediate software queues offer significant latency
reductions, and this patch allows ath9k to realise them. The exact gains
from this varies with the test scenario, but in an access point scenario
we have seen latency reductions ranging from 1/3 to as much as an order
of magnitude. We also achieve slightly better aggregation.

Median latency (ping) figures with this patch applied at the access point,
with two high-rate stations and one low-rate station (HT20 5Ghz), running
a Flent rtt_fair_var_up test with one TCP flow and one ping flow going to
each station:

                                 Fast station        Slow station
Default pfifo_fast qdisc:            430.4 ms            638.7 ms
fq_codel qdisc on iface:              35.5 ms            211.8 ms
This patch set:                       22.4 ms             38.2 ms

Median aggregation sizes over the same test:

Default pfifo_fast qdisc:            9.5 pkts            1.9 pkts
fq_codel qdisc on iface:            11.2 pkts            1.9 pkts
This patch set:                     13.9 pkts            1.9 pkts

This patch is based on Tim's original patch set, but reworked quite
thoroughly.

Cc: Tim Shepard <shep@alum.mit.edu>
Cc: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-11-15 17:00:04 +02:00
Kalle Valo 3cd32dde17 Merge branch 'ath-current' into ath-next
Commit 3c97f5de1f ("ath10k: implement NAPI support") conflicts with
ath-current. To avoid any merge problems merge ath-current to ath-next already now.

Conflicts:
	drivers/net/wireless/ath/ath10k/htt_rx.c
2016-09-09 15:19:40 +03:00
Giedrius Statkevičius e34f2ff40e ath9k: bring back direction setting in ath9k_{start_stop}
A regression was introduced in commit id 79d4db1214 ("ath9k: cleanup
led_pin initial") that broken the WLAN status led on my laptop with
AR9287 after suspending and resuming.

Steps to reproduce:
* Suspend (laptop)
* Resume (laptop)
* Observe that the WLAN led no longer turns ON/OFF depending on the
  status and is always red

Even though for my case it only needs to be set to OUT in ath9k_start
but for consistency bring back the IN direction setting as well.

Fixes: 79d4db1214 ("ath9k: cleanup led_pin initial")
Cc: Miaoqing Pan <miaoqing@codeaurora.org>
Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: <stable@vger.kernel.org> # 4.7+
Link: https://bugzilla.kernel.org/show_bug.cgi?id=151711
Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
[kvalo@qca.qualcomm.com: improve commit log]
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-09-07 16:21:04 +03:00
Felix Fietkau 7711aaf08a ath9k: fix using sta->drv_priv before initializing it
A station pointer can be passed to the driver on tx, before it has been
marked as associated. Since ath9k_sta_state was initializing the entry
too late, it resulted in some spurious crashes.

Fixes: df3c6eb34d ("ath9k: Use sta_state() callback")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-08-22 19:07:56 +03:00
Felix Fietkau 05860bed49 ath9k: fix client mode beacon configuration
For pure station mode, iter_data.primary_beacon_vif was used and passed
to ath_beacon_config, but not set to the station vif.
This was causing the following warning:

[  100.310919] ------------[ cut here ]------------
[  100.315683] WARNING: CPU: 0 PID: 7 at compat-wireless-2016-06-20/drivers/net/wireless/ath/ath9k/beacon.c:642 ath9k_calculate_summary_state+0x250/0x60c [ath9k]()
[  100.402028] CPU: 0 PID: 7 Comm: kworker/u2:1 Tainted: G        W       4.4.15 #5
[  100.409676] Workqueue: phy0 ieee80211_ibss_leave [mac80211]
[  100.415351] Stack : 8736e98c 870b4b20 87a25b54 800a6800 8782a080 80400d63 8039b96c 00000007
[  100.415351]    803c5edc 87875914 80400000 800a47cc 87a25b54 800a6800 803a0fd8 80400000
[  100.415351]    00000003 87875914 80400000 80094ae0 87a25b54 8787594c 00000000 801ef308
[  100.415351]    803ffe70 801ef300 87193d58 87b3a400 87b3ad00 70687930 00000000 00000000
[  100.415351]    00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  100.415351]    ...
[  100.451703] Call Trace:
[  100.454235] [<800a6800>] vprintk_default+0x24/0x30
[  100.459110] [<800a47cc>] printk+0x2c/0x38
[  100.463190] [<800a6800>] vprintk_default+0x24/0x30
[  100.468072] [<80094ae0>] print_worker_info+0x148/0x174
[  100.473378] [<801ef308>] serial8250_console_putchar+0x0/0x44
[  100.479122] [<801ef300>] wait_for_xmitr+0xc4/0xcc
[  100.484014] [<87193d58>] ieee80211_ibss_leave+0xb90/0x1900 [mac80211]
[  100.490590] [<80081604>] warn_slowpath_common+0xa0/0xd0
[  100.495922] [<801a359c>] dump_stack+0x14/0x28
[  100.500350] [<80071a00>] show_stack+0x50/0x84
[  100.504784] [<80081604>] warn_slowpath_common+0xa0/0xd0
[  100.510106] [<87024c60>] ath9k_calculate_summary_state+0x250/0x60c [ath9k]
[  100.517105] [<800816b8>] warn_slowpath_null+0x18/0x24
[  100.522256] [<87024c60>] ath9k_calculate_summary_state+0x250/0x60c [ath9k]
[  100.529273] [<87025418>] ath9k_set_txpower+0x148/0x498 [ath9k]
[  100.535302] [<871d2c64>] cleanup_module+0xa74/0xd4c [mac80211]
[  100.541237] [<801ef308>] serial8250_console_putchar+0x0/0x44
[  100.547042] [<800a5d18>] wake_up_klogd+0x54/0x68
[  100.551730] [<800a6650>] vprintk_emit+0x404/0x43c
[  100.556623] [<871b9db8>] ieee80211_sta_rx_notify+0x258/0x32c [mac80211]
[  100.563475] [<871ba6a4>] ieee80211_sta_rx_queued_mgmt+0x63c/0x734 [mac80211]
[  100.570693] [<871aa49c>] ieee80211_tx_prepare_skb+0x210/0x230 [mac80211]
[  100.577609] [<800af5d4>] mod_timer+0x15c/0x190
[  100.582220] [<871ba8b8>] ieee80211_sta_work+0xfc/0xe1c [mac80211]
[  100.588539] [<871940b4>] ieee80211_ibss_leave+0xeec/0x1900 [mac80211]
[  100.595122] [<8009ec84>] dequeue_task_fair+0x44/0x130
[  100.600281] [<80092a34>] process_one_work+0x1f8/0x334
[  100.605454] [<80093830>] worker_thread+0x2b4/0x408
[  100.610317] [<8009357c>] worker_thread+0x0/0x408
[  100.615019] [<8009357c>] worker_thread+0x0/0x408
[  100.619705] [<80097b68>] kthread+0xdc/0xe8
[  100.623886] [<80097a8c>] kthread+0x0/0xe8
[  100.627961] [<80060878>] ret_from_kernel_thread+0x14/0x1c
[  100.633448]
[  100.634956] ---[ end trace aafbe57e9ae6862f ]---

Fixes: cfda2d8e23 ("ath9k: Fix beacon configuration for addition/removal of interfaces")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-08-22 19:05:01 +03:00
Bob Copeland 4c51e7db87 ath9k: fix misleading indent
Fixes smatch warning:

ath9k_vif_iter_set_beacon() warn if statement not indented

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Reviewed-by: Julian Calaby <julian.calaby@gmail.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-08-19 13:05:26 +03:00
Masahiro Yamada 97f2645f35 tree-wide: replace config_enabled() with IS_ENABLED()
The use of config_enabled() against config options is ambiguous.  In
practical terms, config_enabled() is equivalent to IS_BUILTIN(), but the
author might have used it for the meaning of IS_ENABLED().  Using
IS_ENABLED(), IS_BUILTIN(), IS_MODULE() etc.  makes the intention
clearer.

This commit replaces config_enabled() with IS_ENABLED() where possible.
This commit is only touching bool config options.

I noticed two cases where config_enabled() is used against a tristate
option:

 - config_enabled(CONFIG_HWMON)
  [ drivers/net/wireless/ath/ath10k/thermal.c ]

 - config_enabled(CONFIG_BACKLIGHT_CLASS_DEVICE)
  [ drivers/gpu/drm/gma500/opregion.c ]

I did not touch them because they should be converted to IS_BUILTIN()
in order to keep the logic, but I was not sure it was the authors'
intention.

Link: http://lkml.kernel.org/r/1465215656-20569-1-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Stas Sergeev <stsp@list.ru>
Cc: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: Joshua Kinard <kumba@gentoo.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: "Dmitry V. Levin" <ldv@altlinux.org>
Cc: yu-cheng yu <yu-cheng.yu@intel.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Will Drewry <wad@chromium.org>
Cc: Nikolay Martynov <mar.kolya@gmail.com>
Cc: Huacai Chen <chenhc@lemote.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Cc: Rafal Milecki <zajec5@gmail.com>
Cc: James Cowgill <James.Cowgill@imgtec.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Alex Smith <alex.smith@imgtec.com>
Cc: Adam Buchbinder <adam.buchbinder@gmail.com>
Cc: Qais Yousef <qais.yousef@imgtec.com>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Roland McGrath <roland@hack.frob.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Tony Wu <tung7970@gmail.com>
Cc: Huaitong Han <huaitong.han@intel.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andrea Gelmini <andrea.gelmini@gelma.net>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Rabin Vincent <rabin@rab.in>
Cc: "Maciej W. Rozycki" <macro@imgtec.com>
Cc: David Daney <david.daney@cavium.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-08-04 08:50:07 -04:00
Benjamin Berg cfda2d8e23 ath9k: Fix beacon configuration for addition/removal of interfaces
This patch fixes some issues with interface reconfiguration. It could
for example happen that an AP interface in beacon slot 0 was removed
leaving an IBSS station in one of the other slots. When this happens
the driver never sends out the beacon as it only tries to send a beacon
from slot 0.

Appart from that the tracking of required changes to the beacon config is
relatively complicated and prone to errors.

The approach taken here is to solve reconfiguration issues is to
reconfigure the beacons when any interface changes. This means that
the complexity of deciding whether an interface change may modify the
beacon configuration is gone. It also means that the beacon config will
be reliably updated when an interface is removed.

The issue that a single non-AP interface might not be in beacon
slot 0 and wouldn't be send out is solved by moving it into the
first slot. The TSF value in hardware is adjusted accordingly so
that the timestamp of the beacons stay consistent.

Signed-off-by: Benjamin Berg <benjamin.berg@open-mesh.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-07-08 17:03:41 +03:00
Benjamin Berg 11b0ac2e0c ath9k: Remove some #defined constants to decrease verbosity
The removed ATH9K_SLOT_TIME_X constants simply map the value in microseconds
to the same integer. These constants were not used consistently, so fix the
inconsistency issue by replacing all occurances with the integer equivalent.

Signed-off-by: Benjamin Berg <benjamin.berg@open-mesh.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-07-08 17:03:37 +03:00
Benjamin Berg 7fde51227a ath9k: Expose tsf_adjustment in mac80211 tsf getters and setters.
The ath9k driver modifies the TSF for VIFs for the purpose of sending
beacons in a staggered fashion. This patch exposes this VIF specific
adjustment of the TSF value to mac80211. Without the change the TSF
routines handle the hardware TSF value instead of the actual TSF value as
seen on the air.

Signed-off-by: Benjamin Berg <benjamin.berg@open-mesh.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-07-08 17:03:33 +03:00
Benjamin Berg 9580cb889f ath9k: Handle channel context in get_/set_/reset_tsf
The ath9k TSF handling routines need to be aware of the channel context that
is being modified. With this change the TSF related values that are stored
in each channel context will be correctly tracked and the harware will only
be updated if the modified context is currently the active one.

Without this change the TSF modifications done using these routines would
for example be lost during a hardware reset as done by ath_complete_reset.

Signed-off-by: Benjamin Berg <benjamin.berg@open-mesh.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-07-08 17:03:24 +03:00
Johannes Berg 57fbcce37b cfg80211: remove enum ieee80211_band
This enum is already perfectly aliased to enum nl80211_band, and
the only reason for it is that we get IEEE80211_NUM_BANDS out of
it. There's no really good reason to not declare the number of
bands in nl80211 though, so do that and remove the cfg80211 one.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2016-04-12 15:56:15 +02:00
Miaoqing Pan 79d4db1214 ath9k: cleanup led_pin initial
Make ath_init_leds() and ath_deinit_leds() pairs as the only
API to set leds, also removed direction configuration from
ath9k_start() and ath9k_stop(). So the initial is more clear
now.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-03-11 14:00:02 +02:00
Miaoqing Pan b2d70d4944 ath9k: make GPIO API to support both of WMAC and SOC
commit 61b559dea4 ("ath9k: add extra GPIO led support")
added ath9k to support access SOC's GPIOs, but implemented
in a separated API: ath9k_hw_request_gpio().

So this patch make the APIs more common, to support both
of WMAC and SOC GPIOs. The new APIs as below,

void ath9k_hw_gpio_request_in();
void ath9k_hw_gpio_request_out();
void ath9k_hw_gpio_free();

NOTE, the BSP of the SOC chips(AR9340, AR9531, AR9550, AR9561)
should set the corresponding MUX registers correctly.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-03-11 14:00:02 +02:00
Kalle Valo 89ef41bfaa Merge 'net-next/master'
Needed by the upcoming merge of iwlwifi-next-for-kalle-2016-03-02 tag.
2016-03-06 14:57:44 +02:00
Kalle Valo b9a9693fd9 ath9k: request NOA update when chanctx active
Request NOA update when chanctx active, also in case
of STA.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2016-01-26 16:47:38 +02:00
Sara Sharon 50ea05efaf mac80211: pass block ack session timeout to to driver
Currently mac80211 does not inform the driver of the session
block ack timeout when starting a rx aggregation session.
Drivers that manage the reorder buffer need to know this
parameter.
Seeing that there are now too many arguments for the
drv_ampdu_action() function, wrap them inside a structure.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2016-01-14 11:13:17 +01:00
Miaoqing Pan ed14dc0af7 ath9k: feeding entropy in kernel from ADC capture
This patch is derived from
commit 6301566e0b ("ath9k: export HW random number generator"),

We evaluated the entropy of the ADC data on QCA9531, QCA9561, QCA955x,
and AR9340, and it has sufficient quality random data (at least 10 bits
and up to 22 bits of min-entropy for a 32-bit value). We conservatively
assume the min-entropy is 10 bits out of 32 bits. Thus, ATH9K_RNG_BUF_SIZE
is set to 320 (u32) i.e., 1.25 kilobytes of data is inserted to fill up
the pool as soon as the entropy counter becomes 896/4096 (set by random.c).
Since ADC was not designed to be a dedicated HW RNG, we do not want to bind
it to /dev/hwrng framework directly. This patch feeds the entropy directly
from the WiFi driver to the input pool. The ADC register output is only
used as a seed for the Linux entropy pool. No conditioning is needed,
since all the conditioning is performed by the pool itself.

Signed-off-by: Miaoqing Pan <miaoqing@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-12-11 14:08:58 +02:00
David S. Miller 9916596742 Major changes:
iwlwifi
 
 * some debugfs improvements
 * fix signedness in beacon statistics
 * deinline some functions to reduce size when device tracing is enabled
 * filter beacons out in AP mode when no stations are associated
 * deprecate firmwares version -12
 * fix a runtime PM vs. legacy suspend race
 * one-liner fix for a ToF bug
 * clean-ups in the rx code
 * small debugging improvement
 * fix WoWLAN with new firmware versions
 * more clean-ups towards multiple RX queues;
 * some rate scaling fixes and improvements;
 * some time-of-flight fixes;
 * other generic improvements and clean-ups;
 
 brcmfmac
 
 * rework code dealing with multiple interfaces
 * allow logging firmware console using debug level
 * support for BCM4350, BCM4365, and BCM4366 PCIE devices
 * fixed for legacy P2P and P2P device handling
 * correct set and get tx-power
 
 ath9k
 
 * add support for Outside Context of a BSS (OCB) mode
 
 mwifiex
 
 * add USB multichannel feature
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQEcBAABAgAGBQJWF9ciAAoJEG4XJFUm622bVaAH/3Fi4CaKrDF6L8lxSRWUZzft
 Ie2X0FC+d5knpS7dOd7iI02MuEuKCg3f6dmtDrCDFBqFohvfO5NkG4XU81jdIiWM
 Xkyxlgcy/1TuILNjQfNh/2nhjpvvHDCyptl+jimeT2VR2ITD/Vj3IOAMA5l4khyx
 OeWmgW7dT9xLwYYy20ql5QLGkbxwJlHawUw/d+3yiS+AHO+6dVGJL2OtpyrlPP/F
 0KpSj0lZY9UNRL+i6FbONDCBYeG+q/lA5G5nGXBF6zEeZ6BcuWNRcBBGr2n/6uMy
 gQMAunqBIunfYkfpEKYEPF5zoyO/wCmvPLxx56iS8okGSVw4KzQ2DtQ0leFbjBw=
 =1po3
 -----END PGP SIGNATURE-----

Merge tag 'wireless-drivers-next-for-davem-2015-10-09' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next

Kalle Valo says:

====================
Major changes:

iwlwifi

* some debugfs improvements
* fix signedness in beacon statistics
* deinline some functions to reduce size when device tracing is enabled
* filter beacons out in AP mode when no stations are associated
* deprecate firmwares version -12
* fix a runtime PM vs. legacy suspend race
* one-liner fix for a ToF bug
* clean-ups in the rx code
* small debugging improvement
* fix WoWLAN with new firmware versions
* more clean-ups towards multiple RX queues;
* some rate scaling fixes and improvements;
* some time-of-flight fixes;
* other generic improvements and clean-ups;

brcmfmac

* rework code dealing with multiple interfaces
* allow logging firmware console using debug level
* support for BCM4350, BCM4365, and BCM4366 PCIE devices
* fixed for legacy P2P and P2P device handling
* correct set and get tx-power

ath9k

* add support for Outside Context of a BSS (OCB) mode

mwifiex

* add USB multichannel feature
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-12 19:39:18 -07:00
Jan Kaisrlik 862a336c83 ath9k: Add support for OCB mode
The patch adds support for "outside the context of a BSS"(OCB) mode
to ath9k driver and extends debugfs files by OCB ralated information.

This patch was tested on AR9380-AL1A cards.

Signed-off-by: Jan Kaisrlik <kaisrja1@fel.cvut.cz>
Cc: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2015-09-29 10:39:22 +03:00
Emmanuel Grumbach e3abc8ff0f mac80211: allow to transmit A-MSDU within A-MPDU
Advertise the capability to send A-MSDU within A-MPDU
in the AddBA request sent by mac80211. Let the driver
know about the peer's capabilities.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2015-09-22 15:21:23 +02:00
Janusz.Dziedzic@tieto.com 1738203ee7 ath9k: setup rxfilter when offchannel
Setup rxfiler correctly for offchannel ctx.

This fix problem we didn't configure rxfilter, next
didn't receive probe requests and next failed
p2p_find. This was seen when ath9k loaded with
use_chanctx=1

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2015-08-06 10:11:14 +03:00
Janusz.Dziedzic@tieto.com f3771c0828 ath9k: setup rxfilter for all chanctx
While mac80211 setup this per HW, set same
rxfilter configuration for all chanctx.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2015-08-06 10:11:10 +03:00
Janusz.Dziedzic@tieto.com d83520b7cd ath9k: handle RoC cancel correctly
In case we will get ROC cancel from mac80211 we
should not call ieee80211_remain_on_channel_expired().

In other case I hit such warning on MIPS and
p2p negotiation failed (tested with use_chanctx=1).

ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506632
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: Stopping current chanctx: 2412
ath: phy0: Flush timeout: 200
ath: phy0: ath_chanctx_set_next: Set channel 2412 MHz
ath: phy0: Set channel: 2412 MHz width: 0
ath: phy0: Reset to 2412 MHz, HT40: 0 fastcc: 0
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_TSF_TIMER, state: ATH_CHANCTX_STATE_IDLE
ath: phy0: ath_offchannel_channel_change: offchannel state: ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: ATH_CHANCTX_STATE_IDLE
ath: phy0: Cancel RoC
ath: phy0: RoC aborted
ath: phy0: RoC request on vif: 00:03:7f:4e:a0:cd, type: 1 duration: 500
ath: phy0: Starting RoC period
ath: phy0: Channel definition created: 2412 MHz
ath: phy0: Assigned next_chan to 2412 MHz
ath: phy0: Offchannel duration for chan 2412 MHz : 506705
ath: phy0: ath_chanctx_set_next: current: 2412 MHz, next: 2412 MHz
ath: phy0: ath_offchannel_channel_change: offchannel state: ATH_OFFCHANNEL_ROC_START
ath: phy0: cur_chan: 2412 MHz, event: ATH_CHANCTX_EVENT_SWITCH, state: ATH_CHANCTX_STATE_IDLE
------------[ cut here ]------------
WARNING: CPU: 0 PID: 3312 at drivers/net/wireless/ath/ath9k/main.c:2319
Modules linked in: ath9k ath9k_common ath9k_hw ath mac80211 cfg80211

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2015-08-06 10:11:06 +03:00
Felix Fietkau 300f77c08d ath9k: fix DMA stop sequence for AR9003+
AR93xx and newer needs to stop rx before tx to avoid getting the DMA
engine or MAC into a stuck state.
This should reduce/fix the occurence of "Failed to stop Tx DMA" logspam.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2015-06-08 11:39:58 +03:00
Johannes Berg df1404650c mac80211: remove support for IFF_PROMISC
This support is essentially useless as typically networks are encrypted,
frames will be filtered by hardware, and rate scaling will be done with
the intended recipient in mind. For real monitoring of the network, the
monitor mode support should be used instead.

Removing it removes a lot of corner cases.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2015-04-24 11:14:13 +02:00
David S. Miller 28c0f02ffe Major changes:
brcmfmac:
 
 * sdio improvements
 * add a debugfs file so users can provide us all the revinfo we could
   ask for
 
 iwlwifi:
 
 * add triggers for firmware dump collection
 * remove support for -9.ucode
 * new statitics API
 * rate control improvements
 
 ath9k:
 
 * add per-vif TX power capability
 * BT coexistance fixes
 
 ath10k:
 
 * qca6174: enable STA transmit beamforming (TxBF) support
 * disable multi-vif power save by default
 
 bcma:
 
 * enable support for PCIe Gen 2 host devices
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQEcBAABAgAGBQJU+dliAAoJEG4XJFUm622bsqQH/RO1Gxuw6hmiHPeeIcoDmlvt
 MZKvy6xcAiFqREfGwDxjVminlTZ7/MB9bABeaoQKzpQFpCJW/ftjIqwfbRqZWsvG
 3IC0s2nPTwWU8YSsZTbifnyXCVNQDJuE+5nQ3hMO2rE/dZDi1zt1fS2hiSXtlASS
 kgBJcfXgoVxvhZ1WI+uVpbU0RtwXmI7tVylREE1sbgCrg7AuJx4Q2QmZ1GioPRLy
 20HnFVFcIcbHk4eXVwAJOspdjctujoR858pg/oxlcVXWb7MOOCV/Fk8WMursZxFh
 qj/I/kbDcFYh3H5uC+6qL/kRByY80/yckLDiMbghA0QR5/PSx2nvp/UfkqIf008=
 =qgVl
 -----END PGP SIGNATURE-----

Merge tag 'wireless-drivers-next-for-davem-2015-03-06' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next

Major changes:

brcmfmac:

* sdio improvements
* add a debugfs file so users can provide us all the revinfo we could
  ask for

iwlwifi:

* add triggers for firmware dump collection
* remove support for -9.ucode
* new statitics API
* rate control improvements

ath9k:

* add per-vif TX power capability
* BT coexistance fixes

ath10k:

* qca6174: enable STA transmit beamforming (TxBF) support
* disable multi-vif power save by default

bcma:

* enable support for PCIe Gen 2 host devices

Signed-off-by: David S. Miller <davem@davemloft.net>
2015-03-06 15:46:08 -05:00
Joe Perches 93803b3385 wireless: Use eth_<foo>_addr instead of memset
Use the built-in function instead of memset.

Miscellanea:

Add #include <linux/etherdevice.h> where appropriate
Use ETH_ALEN instead of 6

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-03-03 17:01:36 -05:00
Lorenzo Bianconi 283dd11994 ath9k: add per-vif TX power capability
Configure the HW with highest TX power among all vif when HW TPC has been
enabled in order to add support to per-vif TX power capability. Use lowest
configured power among all interfaces when TPC is disabled

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2015-03-03 15:36:01 +02:00