351-0032-brcmfmac-Change-vif_event_lock-to-spinlock.patch 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. From b64abcb7dae6060c67ab0e548da3ef923c49641d Mon Sep 17 00:00:00 2001
  2. From: "mhiramat@kernel.org" <mhiramat@kernel.org>
  3. Date: Mon, 15 Aug 2016 18:41:12 +0900
  4. Subject: [PATCH] brcmfmac: Change vif_event_lock to spinlock
  5. Change vif_event_lock to spinlock from mutex, since this lock is
  6. used in wait_event_timeout() via vif_event_equals(). This caused
  7. a warning report as below.
  8. As far as I can see, this lock protects regions where updating
  9. structure members, not function calls. Also, since those
  10. regions are not called from interrupt handlers (of course, it
  11. was a mutex), spin_lock is used instead of spin_lock_irqsave.
  12. [ 186.678550] ------------[ cut here ]------------
  13. [ 186.678556] WARNING: CPU: 2 PID: 7140 at /home/mhiramat/ksrc/linux/kernel/sched/core.c:7545 __might_sleep+0x7c/0x80
  14. [ 186.678560] do not call blocking ops when !TASK_RUNNING; state=2 set at [<ffffffff980d9090>] prepare_to_wait_event+0x60/0x100
  15. [ 186.678560] Modules linked in: brcmfmac xt_CHECKSUM rfcomm ipt_MASQUERADE nf_nat_masquerade_ipv4 xt_addrtype br_netfilter xt_tcpudp ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 xt_conntrack ip_set nfnetlink ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_raw ip6table_security ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_filter ip6_tables iptable_raw iptable_security iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_filter ip_tables x_tables bnep nls_iso8859_1 i2c_designware_platform i2c_designware_core snd_hda_codec_hdmi snd_hda_codec_realtek dcdbas snd_hda_codec_generic snd_hda_intel snd_hda_codec intel_rapl snd_hda_core x86_pkg_temp_thermal intel_powerclamp coretemp
  16. [ 186.678594] snd_pcm crct10dif_pclmul crc32_pclmul aesni_intel aes_x86_64 joydev glue_helper snd_hwdep lrw gf128mul uvcvideo ablk_helper snd_seq_midi cryptd snd_seq_midi_event snd_rawmidi videobuf2_vmalloc videobuf2_memops snd_seq input_leds videobuf2_v4l2 cfg80211 videobuf2_core snd_timer videodev serio_raw btusb snd_seq_device media btrtl rtsx_pci_ms snd mei_me memstick hid_multitouch mei soundcore brcmutil idma64 virt_dma intel_lpss_pci processor_thermal_device intel_soc_dts_iosf hci_uart btbcm btqca btintel bluetooth int3403_thermal dell_smo8800 intel_lpss_acpi intel_lpss int3402_thermal int340x_thermal_zone intel_hid mac_hid int3400_thermal shpchp sparse_keymap acpi_pad acpi_thermal_rel acpi_als kfifo_buf industrialio kvm_intel kvm irqbypass parport_pc ppdev lp parport autofs4 btrfs xor raid6_pq
  17. [ 186.678631] usbhid nouveau ttm i915 rtsx_pci_sdmmc mxm_wmi i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops psmouse drm ahci rtsx_pci nvme nvme_core libahci i2c_hid hid pinctrl_sunrisepoint video wmi pinctrl_intel fjes [last unloaded: brcmfmac]
  18. [ 186.678646] CPU: 2 PID: 7140 Comm: wpa_supplicant Not tainted 4.8.0-rc1+ #8
  19. [ 186.678647] Hardware name: Dell Inc. XPS 15 9550/0N7TVV, BIOS 01.02.00 04/07/2016
  20. [ 186.678648] 0000000000000000 ffff9d8c64b5b900 ffffffff98442f23 ffff9d8c64b5b950
  21. [ 186.678651] 0000000000000000 ffff9d8c64b5b940 ffffffff9808b22b 00001d790000000d
  22. [ 186.678653] ffffffff98c75e78 000000000000026c 0000000000000000 ffff9d8c2706d058
  23. [ 186.678655] Call Trace:
  24. [ 186.678659] [<ffffffff98442f23>] dump_stack+0x85/0xc2
  25. [ 186.678666] [<ffffffff9808b22b>] __warn+0xcb/0xf0
  26. [ 186.678668] [<ffffffff9808b29f>] warn_slowpath_fmt+0x4f/0x60
  27. [ 186.678671] [<ffffffff980d9090>] ? prepare_to_wait_event+0x60/0x100
  28. [ 186.678672] [<ffffffff980d9090>] ? prepare_to_wait_event+0x60/0x100
  29. [ 186.678674] [<ffffffff980b922c>] __might_sleep+0x7c/0x80
  30. [ 186.678680] [<ffffffff988b0853>] mutex_lock_nested+0x33/0x3b0
  31. [ 186.678682] [<ffffffff980e5d8d>] ? trace_hardirqs_on+0xd/0x10
  32. [ 186.678689] [<ffffffffc0c57d2d>] brcmf_cfg80211_wait_vif_event+0xcd/0x130 [brcmfmac]
  33. [ 186.678691] [<ffffffff980d9190>] ? wake_atomic_t_function+0x60/0x60
  34. [ 186.678697] [<ffffffffc0c628e9>] brcmf_p2p_del_vif+0xf9/0x220 [brcmfmac]
  35. [ 186.678702] [<ffffffffc0c57fab>] brcmf_cfg80211_del_iface+0x21b/0x270 [brcmfmac]
  36. [ 186.678716] [<ffffffffc0b0539e>] nl80211_del_interface+0xfe/0x3a0 [cfg80211]
  37. [ 186.678718] [<ffffffff987ca335>] genl_family_rcv_msg+0x1b5/0x370
  38. [ 186.678720] [<ffffffff980e5d8d>] ? trace_hardirqs_on+0xd/0x10
  39. [ 186.678721] [<ffffffff987ca56d>] genl_rcv_msg+0x7d/0xb0
  40. [ 186.678722] [<ffffffff987ca4f0>] ? genl_family_rcv_msg+0x370/0x370
  41. [ 186.678724] [<ffffffff987c9a47>] netlink_rcv_skb+0x97/0xb0
  42. [ 186.678726] [<ffffffff987ca168>] genl_rcv+0x28/0x40
  43. [ 186.678727] [<ffffffff987c93c3>] netlink_unicast+0x1d3/0x2f0
  44. [ 186.678729] [<ffffffff987c933b>] ? netlink_unicast+0x14b/0x2f0
  45. [ 186.678731] [<ffffffff987c97cb>] netlink_sendmsg+0x2eb/0x3a0
  46. [ 186.678733] [<ffffffff9876dad8>] sock_sendmsg+0x38/0x50
  47. [ 186.678734] [<ffffffff9876e4df>] ___sys_sendmsg+0x27f/0x290
  48. [ 186.678737] [<ffffffff9828b935>] ? mntput_no_expire+0x5/0x3f0
  49. [ 186.678739] [<ffffffff9828b9be>] ? mntput_no_expire+0x8e/0x3f0
  50. [ 186.678741] [<ffffffff9828b935>] ? mntput_no_expire+0x5/0x3f0
  51. [ 186.678743] [<ffffffff9828bd44>] ? mntput+0x24/0x40
  52. [ 186.678744] [<ffffffff98267830>] ? __fput+0x190/0x200
  53. [ 186.678746] [<ffffffff9876f125>] __sys_sendmsg+0x45/0x80
  54. [ 186.678748] [<ffffffff9876f172>] SyS_sendmsg+0x12/0x20
  55. [ 186.678749] [<ffffffff988b5680>] entry_SYSCALL_64_fastpath+0x23/0xc1
  56. [ 186.678751] [<ffffffff980e2b8f>] ? trace_hardirqs_off_caller+0x1f/0xc0
  57. [ 186.678752] ---[ end trace e224d66c5d8408b5 ]---
  58. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
  59. Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  60. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  61. ---
  62. .../broadcom/brcm80211/brcmfmac/cfg80211.c | 26 +++++++++++-----------
  63. .../broadcom/brcm80211/brcmfmac/cfg80211.h | 2 +-
  64. 2 files changed, 14 insertions(+), 14 deletions(-)
  65. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  66. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  67. @@ -5555,7 +5555,7 @@ static s32 brcmf_notify_vif_event(struct
  68. ifevent->action, ifevent->flags, ifevent->ifidx,
  69. ifevent->bsscfgidx);
  70. - mutex_lock(&event->vif_event_lock);
  71. + spin_lock(&event->vif_event_lock);
  72. event->action = ifevent->action;
  73. vif = event->vif;
  74. @@ -5563,7 +5563,7 @@ static s32 brcmf_notify_vif_event(struct
  75. case BRCMF_E_IF_ADD:
  76. /* waiting process may have timed out */
  77. if (!cfg->vif_event.vif) {
  78. - mutex_unlock(&event->vif_event_lock);
  79. + spin_unlock(&event->vif_event_lock);
  80. return -EBADF;
  81. }
  82. @@ -5574,24 +5574,24 @@ static s32 brcmf_notify_vif_event(struct
  83. ifp->ndev->ieee80211_ptr = &vif->wdev;
  84. SET_NETDEV_DEV(ifp->ndev, wiphy_dev(cfg->wiphy));
  85. }
  86. - mutex_unlock(&event->vif_event_lock);
  87. + spin_unlock(&event->vif_event_lock);
  88. wake_up(&event->vif_wq);
  89. return 0;
  90. case BRCMF_E_IF_DEL:
  91. - mutex_unlock(&event->vif_event_lock);
  92. + spin_unlock(&event->vif_event_lock);
  93. /* event may not be upon user request */
  94. if (brcmf_cfg80211_vif_event_armed(cfg))
  95. wake_up(&event->vif_wq);
  96. return 0;
  97. case BRCMF_E_IF_CHANGE:
  98. - mutex_unlock(&event->vif_event_lock);
  99. + spin_unlock(&event->vif_event_lock);
  100. wake_up(&event->vif_wq);
  101. return 0;
  102. default:
  103. - mutex_unlock(&event->vif_event_lock);
  104. + spin_unlock(&event->vif_event_lock);
  105. break;
  106. }
  107. return -EINVAL;
  108. @@ -5712,7 +5712,7 @@ static void wl_deinit_priv(struct brcmf_
  109. static void init_vif_event(struct brcmf_cfg80211_vif_event *event)
  110. {
  111. init_waitqueue_head(&event->vif_wq);
  112. - mutex_init(&event->vif_event_lock);
  113. + spin_lock_init(&event->vif_event_lock);
  114. }
  115. static s32 brcmf_dongle_roam(struct brcmf_if *ifp)
  116. @@ -6607,9 +6607,9 @@ static inline bool vif_event_equals(stru
  117. {
  118. u8 evt_action;
  119. - mutex_lock(&event->vif_event_lock);
  120. + spin_lock(&event->vif_event_lock);
  121. evt_action = event->action;
  122. - mutex_unlock(&event->vif_event_lock);
  123. + spin_unlock(&event->vif_event_lock);
  124. return evt_action == action;
  125. }
  126. @@ -6618,10 +6618,10 @@ void brcmf_cfg80211_arm_vif_event(struct
  127. {
  128. struct brcmf_cfg80211_vif_event *event = &cfg->vif_event;
  129. - mutex_lock(&event->vif_event_lock);
  130. + spin_lock(&event->vif_event_lock);
  131. event->vif = vif;
  132. event->action = 0;
  133. - mutex_unlock(&event->vif_event_lock);
  134. + spin_unlock(&event->vif_event_lock);
  135. }
  136. bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg)
  137. @@ -6629,9 +6629,9 @@ bool brcmf_cfg80211_vif_event_armed(stru
  138. struct brcmf_cfg80211_vif_event *event = &cfg->vif_event;
  139. bool armed;
  140. - mutex_lock(&event->vif_event_lock);
  141. + spin_lock(&event->vif_event_lock);
  142. armed = event->vif != NULL;
  143. - mutex_unlock(&event->vif_event_lock);
  144. + spin_unlock(&event->vif_event_lock);
  145. return armed;
  146. }
  147. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
  148. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
  149. @@ -227,7 +227,7 @@ struct escan_info {
  150. */
  151. struct brcmf_cfg80211_vif_event {
  152. wait_queue_head_t vif_wq;
  153. - struct mutex vif_event_lock;
  154. + spinlock_t vif_event_lock;
  155. u8 action;
  156. struct brcmf_cfg80211_vif *vif;
  157. };