All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Stanislaw Gruszka <sgruszka@redhat.com>,
	Helmut Schaa <helmut.schaa@googlemail.com>,
	Gertjan van Wingerde <gwingerde@gmail.com>,
	"John W. Linville" <linville@tuxdriver.com>
Subject: [ 27/69] rt2x00: use atomic variable for seqno
Date: Sun, 17 Jun 2012 19:00:08 +0100	[thread overview]
Message-ID: <20120617175945.172863157@decadent.org.uk> (raw)
In-Reply-To: <20120617175941.281333656@decadent.org.uk>

3.2-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Stanislaw Gruszka <sgruszka@redhat.com>

commit e5851dac2c95af7159716832300b9f50c62c648e upstream.

Remove spinlock as atomic_t can be used instead. Note we use only 16
lower bits, upper bits are changed but we impilcilty cast to u16.

This fix possible deadlock on IBSS mode reproted by lockdep:

=================================
[ INFO: inconsistent lock state ]
3.4.0-wl+ #4 Not tainted
---------------------------------
inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
kworker/u:2/30374 [HC0[0]:SC0[0]:HE1:SE1] takes:
 (&(&intf->seqlock)->rlock){+.?...}, at: [<f9979a20>] rt2x00queue_create_tx_descriptor+0x380/0x490 [rt2x00lib]
{IN-SOFTIRQ-W} state was registered at:
  [<c04978ab>] __lock_acquire+0x47b/0x1050
  [<c0498504>] lock_acquire+0x84/0xf0
  [<c0835733>] _raw_spin_lock+0x33/0x40
  [<f9979a20>] rt2x00queue_create_tx_descriptor+0x380/0x490 [rt2x00lib]
  [<f9979f2a>] rt2x00queue_write_tx_frame+0x1a/0x300 [rt2x00lib]
  [<f997834f>] rt2x00mac_tx+0x7f/0x380 [rt2x00lib]
  [<f98fe363>] __ieee80211_tx+0x1b3/0x300 [mac80211]
  [<f98ffdf5>] ieee80211_tx+0x105/0x130 [mac80211]
  [<f99000dd>] ieee80211_xmit+0xad/0x100 [mac80211]
  [<f9900519>] ieee80211_subif_start_xmit+0x2d9/0x930 [mac80211]
  [<c0782e87>] dev_hard_start_xmit+0x307/0x660
  [<c079bb71>] sch_direct_xmit+0xa1/0x1e0
  [<c0784bb3>] dev_queue_xmit+0x183/0x730
  [<c078c27a>] neigh_resolve_output+0xfa/0x1e0
  [<c07b436a>] ip_finish_output+0x24a/0x460
  [<c07b4897>] ip_output+0xb7/0x100
  [<c07b2d60>] ip_local_out+0x20/0x60
  [<c07e01ff>] igmpv3_sendpack+0x4f/0x60
  [<c07e108f>] igmp_ifc_timer_expire+0x29f/0x330
  [<c04520fc>] run_timer_softirq+0x15c/0x2f0
  [<c0449e3e>] __do_softirq+0xae/0x1e0
irq event stamp: 18380437
hardirqs last  enabled at (18380437): [<c0526027>] __slab_alloc.clone.3+0x67/0x5f0
hardirqs last disabled at (18380436): [<c0525ff3>] __slab_alloc.clone.3+0x33/0x5f0
softirqs last  enabled at (18377616): [<c0449eb3>] __do_softirq+0x123/0x1e0
softirqs last disabled at (18377611): [<c041278d>] do_softirq+0x9d/0xe0

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&(&intf->seqlock)->rlock);
  <Interrupt>
    lock(&(&intf->seqlock)->rlock);

 *** DEADLOCK ***

4 locks held by kworker/u:2/30374:
 #0:  (wiphy_name(local->hw.wiphy)){++++.+}, at: [<c045cf99>] process_one_work+0x109/0x3f0
 #1:  ((&sdata->work)){+.+.+.}, at: [<c045cf99>] process_one_work+0x109/0x3f0
 #2:  (&ifibss->mtx){+.+.+.}, at: [<f98f005b>] ieee80211_ibss_work+0x1b/0x470 [mac80211]
 #3:  (&intf->beacon_skb_mutex){+.+...}, at: [<f997a644>] rt2x00queue_update_beacon+0x24/0x50 [rt2x00lib]

stack backtrace:
Pid: 30374, comm: kworker/u:2 Not tainted 3.4.0-wl+ #4
Call Trace:
 [<c04962a6>] print_usage_bug+0x1f6/0x220
 [<c0496a12>] mark_lock+0x2c2/0x300
 [<c0495ff0>] ? check_usage_forwards+0xc0/0xc0
 [<c04978ec>] __lock_acquire+0x4bc/0x1050
 [<c0527890>] ? __kmalloc_track_caller+0x1c0/0x1d0
 [<c0777fb6>] ? copy_skb_header+0x26/0x90
 [<c0498504>] lock_acquire+0x84/0xf0
 [<f9979a20>] ? rt2x00queue_create_tx_descriptor+0x380/0x490 [rt2x00lib]
 [<c0835733>] _raw_spin_lock+0x33/0x40
 [<f9979a20>] ? rt2x00queue_create_tx_descriptor+0x380/0x490 [rt2x00lib]
 [<f9979a20>] rt2x00queue_create_tx_descriptor+0x380/0x490 [rt2x00lib]
 [<f997a5cf>] rt2x00queue_update_beacon_locked+0x5f/0xb0 [rt2x00lib]
 [<f997a64d>] rt2x00queue_update_beacon+0x2d/0x50 [rt2x00lib]
 [<f9977e3a>] rt2x00mac_bss_info_changed+0x1ca/0x200 [rt2x00lib]
 [<f9977c70>] ? rt2x00mac_remove_interface+0x70/0x70 [rt2x00lib]
 [<f98e4dd0>] ieee80211_bss_info_change_notify+0xe0/0x1d0 [mac80211]
 [<f98ef7b8>] __ieee80211_sta_join_ibss+0x3b8/0x610 [mac80211]
 [<c0496ab4>] ? mark_held_locks+0x64/0xc0
 [<c0440012>] ? virt_efi_query_capsule_caps+0x12/0x50
 [<f98efb09>] ieee80211_sta_join_ibss+0xf9/0x140 [mac80211]
 [<f98f0456>] ieee80211_ibss_work+0x416/0x470 [mac80211]
 [<c0496d8b>] ? trace_hardirqs_on+0xb/0x10
 [<c077683b>] ? skb_dequeue+0x4b/0x70
 [<f98f207f>] ieee80211_iface_work+0x13f/0x230 [mac80211]
 [<c045cf99>] ? process_one_work+0x109/0x3f0
 [<c045d015>] process_one_work+0x185/0x3f0
 [<c045cf99>] ? process_one_work+0x109/0x3f0
 [<f98f1f40>] ? ieee80211_teardown_sdata+0xa0/0xa0 [mac80211]
 [<c045ed86>] worker_thread+0x116/0x270
 [<c045ec70>] ? manage_workers+0x1e0/0x1e0
 [<c0462f64>] kthread+0x84/0x90
 [<c0462ee0>] ? __init_kthread_worker+0x60/0x60
 [<c083d382>] kernel_thread_helper+0x6/0x10

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/net/wireless/rt2x00/rt2x00.h      |    3 +--
 drivers/net/wireless/rt2x00/rt2x00mac.c   |    1 -
 drivers/net/wireless/rt2x00/rt2x00queue.c |   13 ++++++-------
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index ca36ccc..8f75402 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -396,8 +396,7 @@ struct rt2x00_intf {
 	 * for hardware which doesn't support hardware
 	 * sequence counting.
 	 */
-	spinlock_t seqlock;
-	u16 seqno;
+	atomic_t seqno;
 };
 
 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index b49773e..dd24b26 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -277,7 +277,6 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
 	else
 		rt2x00dev->intf_sta_count++;
 
-	spin_lock_init(&intf->seqlock);
 	mutex_init(&intf->beacon_skb_mutex);
 	intf->beacon = entry;
 
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 4c662ec..2fd8301 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -207,6 +207,7 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
 	struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
 	struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif);
+	u16 seqno;
 
 	if (!(tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ))
 		return;
@@ -238,15 +239,13 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
 	 * sequence counting per-frame, since those will override the
 	 * sequence counter given by mac80211.
 	 */
-	spin_lock(&intf->seqlock);
-
 	if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
-		intf->seqno += 0x10;
-	hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
-	hdr->seq_ctrl |= cpu_to_le16(intf->seqno);
-
-	spin_unlock(&intf->seqlock);
+		seqno = atomic_add_return(0x10, &intf->seqno);
+	else
+		seqno = atomic_read(&intf->seqno);
 
+	hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
+	hdr->seq_ctrl |= cpu_to_le16(seqno);
 }
 
 static void rt2x00queue_create_tx_descriptor_plcp(struct rt2x00_dev *rt2x00dev,



  parent reply	other threads:[~2012-06-17 18:26 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-17 17:59 [ 00/69] 3.2.21-stable review Ben Hutchings
2012-06-17 17:59 ` [ 01/69] drm/i915: Mark the ringbuffers as being in the GTT domain Ben Hutchings
2012-06-17 17:59 ` [ 02/69] drm/i915: hold forcewake around ring hw init Ben Hutchings
2012-06-17 17:59 ` [ 03/69] drm/i915: Unpin the flip target if we fail to queue the flip Ben Hutchings
2012-06-17 17:59 ` [ 04/69] drm/i915: fix up ivb plane 3 pageflips Ben Hutchings
2012-06-18 21:55   ` Herton Ronaldo Krzesinski
2012-06-18 22:10     ` Eugeni Dodonov
2012-06-19  3:59       ` Ben Hutchings
2012-06-19  8:23         ` Daniel Vetter
2012-06-19 11:59           ` Ben Hutchings
2012-06-19 11:45         ` Eugeni Dodonov
2012-06-17 17:59 ` [ 05/69] char/agp: add another Ironlake host bridge Ben Hutchings
2012-06-17 17:59 ` [ 06/69] x86/uv: Fix UV2 BAU legacy mode Ben Hutchings
2012-06-17 17:59 ` [ 07/69] powerpc: Fix kernel panic during kernel module load Ben Hutchings
2012-06-17 17:59 ` [ 08/69] drm/nouveau: determine a value for display_info.bpc if edid doesnt Ben Hutchings
2012-06-17 17:59 ` [ 09/69] drm/nouveau: default to 8bpc for non-LVDS panels if EDID isnt useful Ben Hutchings
2012-06-17 17:59 ` [ 10/69] drm/nouveau/disp: fix dithering not being enabled on some eDP macbooks Ben Hutchings
2012-06-17 17:59 ` [ 11/69] fuse: fix stat call on 32 bit platforms Ben Hutchings
2012-06-17 17:59 ` [ 12/69] x86, MCE, AMD: Make APIC LVT thresholding interrupt optional Ben Hutchings
2012-06-17 17:59 ` [ 13/69] x86/amd: Re-enable CPU topology extensions in case BIOS has disabled it Ben Hutchings
2012-06-17 17:59 ` [ 14/69] hwmon: (fam15h_power) Increase output resolution Ben Hutchings
2012-06-17 17:59 ` [ 15/69] sched: Fix the relax_domain_level boot parameter Ben Hutchings
2012-06-17 17:59 ` [ 16/69] iwlwifi: dont mess up the SCD when removing a key Ben Hutchings
2012-06-17 17:59 ` [ 17/69] hwrng: atmel-rng - fix race condition leading to repeated bits Ben Hutchings
2012-06-17 17:59   ` Ben Hutchings
2012-06-17 17:59 ` [ 18/69] crypto: aesni-intel - fix unaligned cbc decrypt for x86-32 Ben Hutchings
2012-06-17 17:59   ` Ben Hutchings
2012-06-17 18:00 ` [ 19/69] xen/setup: filter APERFMPERF cpuid feature out Ben Hutchings
2012-06-17 18:00 ` [ 20/69] NFSv4.1: Fix a request leak on the back channel Ben Hutchings
2012-06-17 18:00 ` [ 21/69] can: c_can: fix "BUG! echo_skb is occupied!" during transmit Ben Hutchings
2012-06-17 18:00 ` [ 22/69] can: c_can: fix an interrupt thrash issue with c_can driver Ben Hutchings
2012-06-17 18:00 ` [ 23/69] can: c_can: fix race condition in c_can_open() Ben Hutchings
2012-06-17 18:00 ` [ 24/69] ARM i.MX53: Fix PLL4 base address Ben Hutchings
2012-06-17 18:00 ` [ 25/69] usb: musb_gadget: fix crash caused by dangling pointer Ben Hutchings
2012-06-17 18:00 ` [ 26/69] mac80211: clean up remain-on-channel on interface stop Ben Hutchings
2012-06-17 18:00 ` Ben Hutchings [this message]
2012-06-17 18:00 ` [ 28/69] iwlwifi: disable WoWLAN if !CONFIG_PM_SLEEP Ben Hutchings
2012-06-17 18:00 ` [ 29/69] ASoC: wm8994: Ensure all AIFnCLK events are run from the _late variants Ben Hutchings
2012-06-17 18:00 ` [ 30/69] ASoC: wm8994: Apply volume updates with clocks enabled Ben Hutchings
2012-06-17 18:00 ` [ 31/69] iwlwifi: unregister LEDs if mac80211 registration fails Ben Hutchings
2012-06-17 18:00 ` [ 32/69] cfg80211: fix interface combinations check Ben Hutchings
2012-06-17 18:00 ` [ 33/69] [SCSI] mpt2sas: Fix unsafe using smp_processor_id() in preemptible Ben Hutchings
2012-06-17 18:00 ` [ 34/69] net: sierra_net: device IDs for Aircard 320U++ Ben Hutchings
2012-06-17 18:00 ` [ 35/69] ARM: imx6: exit coherency when shutting down a cpu Ben Hutchings
2012-06-17 18:00 ` [ 36/69] ARM i.MX imx21ads: Fix overlapping static i/o mappings Ben Hutchings
2012-06-17 18:00 ` [ 37/69] NFSv4: Fix unnecessary delegation returns in nfs4_do_open Ben Hutchings
2012-06-17 18:00 ` [ 38/69] iwlwifi: use correct supported firmware for 6035 and 6000g2 Ben Hutchings
2012-06-17 18:00 ` [ 39/69] iwlwifi: disable the buggy chain extension feature in HW Ben Hutchings
2012-06-18 19:18   ` Herton Ronaldo Krzesinski
2012-06-18 19:23     ` Grumbach, Emmanuel
2012-06-19  3:57       ` Ben Hutchings
2012-06-17 18:00 ` [ 40/69] ALSA: hda - Add codec->no_jack_detect flag Ben Hutchings
2012-06-17 18:00 ` [ 41/69] ALSA: hda - add support for Uniwill ECS M31EI notebook Ben Hutchings
2012-06-17 18:00 ` [ 42/69] ALSA: hda - Suppress auto-mute feature on some machines with ALC861 Ben Hutchings
2012-06-17 18:00 ` [ 43/69] ALSA: hda - Add another jack-detection suppression for ASUS ALC892 Ben Hutchings
2012-06-17 18:00 ` [ 44/69] ALSA: HDA: Pin fixup for Zotac Z68 motherboard Ben Hutchings
2012-06-17 18:00 ` [ 45/69] usb: cdc-wdm: Add device-id for Huawei 3G/LTE modems Ben Hutchings
2012-06-17 20:51   ` Bjørn Mork
2012-06-17 22:51     ` Ben Hutchings
2012-06-17 18:00 ` [ 46/69] USB: cdc-wdm: Add Vodafone/Huawei K5005 support Ben Hutchings
2012-06-17 20:50   ` Bjørn Mork
2012-06-17 18:00 ` [ 47/69] USB: option: " Ben Hutchings
2012-06-17 18:00 ` [ 48/69] USB: qcserial: Add Sierra Wireless device IDs Ben Hutchings
2012-06-17 18:00 ` [ 49/69] USB: ftdi-sio: Add support for RT Systems USB-RTS01 serial adapter Ben Hutchings
2012-06-17 18:00 ` [ 50/69] USB: serial: cp210x: add Optris MS Pro usb id Ben Hutchings
2012-06-17 18:00 ` [ 51/69] USB: serial: sierra: Add support for Sierra Wireless AirCard 320U modem Ben Hutchings
2012-06-17 18:00 ` [ 52/69] USB: option: Updated Huawei K4605 has better id Ben Hutchings
2012-06-17 18:00 ` [ 53/69] USB: mct_u232: Fix incorrect TIOCMSET return Ben Hutchings
2012-06-17 18:00 ` [ 54/69] USB: option: fix port-data abuse Ben Hutchings
2012-06-17 18:00 ` [ 55/69] USB: option: fix memory leak Ben Hutchings
2012-06-17 18:00 ` [ 56/69] USB: option: add more YUGA device ids Ben Hutchings
2012-06-17 18:00 ` [ 57/69] target: Return error to initiator if SET TARGET PORT GROUPS emulation fails Ben Hutchings
2012-06-17 18:00 ` [ 58/69] USB: add NO_D3_DURING_SLEEP flag and revert 151b61284776be2 Ben Hutchings
2012-06-17 18:00 ` [ 59/69] USB: serial: Enforce USB driver and USB serial driver match Ben Hutchings
2012-06-17 18:00 ` [ 60/69] usb-storage: Add 090c:1000 to unusal-devs Ben Hutchings
2012-06-18  8:39   ` Hans de Goede
2012-06-18  9:14     ` Simon Raffeiner
2012-06-18 13:38       ` Ben Hutchings
2012-06-17 18:00 ` [ 61/69] xhci: Fix invalid loop check in xhci_free_tt_info() Ben Hutchings
2012-06-17 18:00 ` [ 62/69] xhci: Dont free endpoints in xhci_mem_cleanup() Ben Hutchings
2012-06-17 18:00 ` [ 63/69] xHCI: Increase the timeout for controller save/restore state operation Ben Hutchings
2012-06-17 18:00 ` [ 64/69] usb: PS3 EHCI QH read work-around Ben Hutchings
2012-06-17 18:00 ` [ 65/69] USB: fix PS3 EHCI systems Ben Hutchings
2012-06-17 18:00 ` [ 66/69] usb: cdc-acm: fix devices not unthrottled on open Ben Hutchings
2012-06-17 18:00 ` [ 67/69] USB: fix gathering of interface associations Ben Hutchings
2012-06-17 18:00 ` [ 68/69] swap: fix shmem swapping when more than 8 areas Ben Hutchings
2012-06-17 18:00 ` [ 69/69] drm/radeon: add some additional 6xx/7xx/EG register init Ben Hutchings
2012-06-17 18:48 ` [ 00/69] 3.2.21-stable review Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120617175945.172863157@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=gwingerde@gmail.com \
    --cc=helmut.schaa@googlemail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=sgruszka@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.