diff options
author | Libor Pechacek <lpechacek@suse.cz> | 2014-04-29 14:38:34 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-05-05 22:25:06 -0400 |
commit | 86aae6c7b577654b7293374973985a153e0c147e (patch) | |
tree | 2bc969c42c78d2fa817c0bdb0d0a85dcf692d075 /net | |
parent | 22e70786413ed05950207eda7be420c280b776d7 (diff) |
Bluetooth: Convert RFCOMM spinlocks into mutexes
Enabling CONFIG_DEBUG_ATOMIC_SLEEP has shown that some rfcomm functions
acquiring spinlocks call sleeping locks further in the chain. Converting
the offending spinlocks into mutexes makes sleeping safe.
Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/rfcomm/core.c | 2 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/tty.c | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 633cceeb943e..05c609b12a1d 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -307,7 +307,7 @@ struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio) | |||
307 | setup_timer(&d->timer, rfcomm_dlc_timeout, (unsigned long)d); | 307 | setup_timer(&d->timer, rfcomm_dlc_timeout, (unsigned long)d); |
308 | 308 | ||
309 | skb_queue_head_init(&d->tx_queue); | 309 | skb_queue_head_init(&d->tx_queue); |
310 | spin_lock_init(&d->lock); | 310 | mutex_init(&d->lock); |
311 | atomic_set(&d->refcnt, 1); | 311 | atomic_set(&d->refcnt, 1); |
312 | 312 | ||
313 | rfcomm_dlc_clear_state(d); | 313 | rfcomm_dlc_clear_state(d); |
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 403ec09f480a..8e385a0ae60e 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
@@ -70,7 +70,7 @@ struct rfcomm_dev { | |||
70 | }; | 70 | }; |
71 | 71 | ||
72 | static LIST_HEAD(rfcomm_dev_list); | 72 | static LIST_HEAD(rfcomm_dev_list); |
73 | static DEFINE_SPINLOCK(rfcomm_dev_lock); | 73 | static DEFINE_MUTEX(rfcomm_dev_lock); |
74 | 74 | ||
75 | static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb); | 75 | static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb); |
76 | static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err); | 76 | static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err); |
@@ -96,9 +96,9 @@ static void rfcomm_dev_destruct(struct tty_port *port) | |||
96 | if (dev->tty_dev) | 96 | if (dev->tty_dev) |
97 | tty_unregister_device(rfcomm_tty_driver, dev->id); | 97 | tty_unregister_device(rfcomm_tty_driver, dev->id); |
98 | 98 | ||
99 | spin_lock(&rfcomm_dev_lock); | 99 | mutex_lock(&rfcomm_dev_lock); |
100 | list_del(&dev->list); | 100 | list_del(&dev->list); |
101 | spin_unlock(&rfcomm_dev_lock); | 101 | mutex_unlock(&rfcomm_dev_lock); |
102 | 102 | ||
103 | kfree(dev); | 103 | kfree(dev); |
104 | 104 | ||
@@ -161,14 +161,14 @@ static struct rfcomm_dev *rfcomm_dev_get(int id) | |||
161 | { | 161 | { |
162 | struct rfcomm_dev *dev; | 162 | struct rfcomm_dev *dev; |
163 | 163 | ||
164 | spin_lock(&rfcomm_dev_lock); | 164 | mutex_lock(&rfcomm_dev_lock); |
165 | 165 | ||
166 | dev = __rfcomm_dev_lookup(id); | 166 | dev = __rfcomm_dev_lookup(id); |
167 | 167 | ||
168 | if (dev && !tty_port_get(&dev->port)) | 168 | if (dev && !tty_port_get(&dev->port)) |
169 | dev = NULL; | 169 | dev = NULL; |
170 | 170 | ||
171 | spin_unlock(&rfcomm_dev_lock); | 171 | mutex_unlock(&rfcomm_dev_lock); |
172 | 172 | ||
173 | return dev; | 173 | return dev; |
174 | } | 174 | } |
@@ -224,7 +224,7 @@ static struct rfcomm_dev *__rfcomm_dev_add(struct rfcomm_dev_req *req, | |||
224 | if (!dev) | 224 | if (!dev) |
225 | return ERR_PTR(-ENOMEM); | 225 | return ERR_PTR(-ENOMEM); |
226 | 226 | ||
227 | spin_lock(&rfcomm_dev_lock); | 227 | mutex_lock(&rfcomm_dev_lock); |
228 | 228 | ||
229 | if (req->dev_id < 0) { | 229 | if (req->dev_id < 0) { |
230 | dev->id = 0; | 230 | dev->id = 0; |
@@ -305,11 +305,11 @@ static struct rfcomm_dev *__rfcomm_dev_add(struct rfcomm_dev_req *req, | |||
305 | holds reference to this module. */ | 305 | holds reference to this module. */ |
306 | __module_get(THIS_MODULE); | 306 | __module_get(THIS_MODULE); |
307 | 307 | ||
308 | spin_unlock(&rfcomm_dev_lock); | 308 | mutex_unlock(&rfcomm_dev_lock); |
309 | return dev; | 309 | return dev; |
310 | 310 | ||
311 | out: | 311 | out: |
312 | spin_unlock(&rfcomm_dev_lock); | 312 | mutex_unlock(&rfcomm_dev_lock); |
313 | kfree(dev); | 313 | kfree(dev); |
314 | return ERR_PTR(err); | 314 | return ERR_PTR(err); |
315 | } | 315 | } |
@@ -524,7 +524,7 @@ static int rfcomm_get_dev_list(void __user *arg) | |||
524 | 524 | ||
525 | di = dl->dev_info; | 525 | di = dl->dev_info; |
526 | 526 | ||
527 | spin_lock(&rfcomm_dev_lock); | 527 | mutex_lock(&rfcomm_dev_lock); |
528 | 528 | ||
529 | list_for_each_entry(dev, &rfcomm_dev_list, list) { | 529 | list_for_each_entry(dev, &rfcomm_dev_list, list) { |
530 | if (!tty_port_get(&dev->port)) | 530 | if (!tty_port_get(&dev->port)) |
@@ -540,7 +540,7 @@ static int rfcomm_get_dev_list(void __user *arg) | |||
540 | break; | 540 | break; |
541 | } | 541 | } |
542 | 542 | ||
543 | spin_unlock(&rfcomm_dev_lock); | 543 | mutex_unlock(&rfcomm_dev_lock); |
544 | 544 | ||
545 | dl->dev_num = n; | 545 | dl->dev_num = n; |
546 | size = sizeof(*dl) + n * sizeof(*di); | 546 | size = sizeof(*dl) + n * sizeof(*di); |