Re: [RFC 06/22] Bluetooth: Move L2CAP timers to workqueue
From: Ulisses Furquim <hidden>
Date: 2011-12-19 12:59:17
Hi Andrei, On Mon, Dec 19, 2011 at 9:05 AM, Andrei Emeltchenko [off-list ref] wrote:
Hi Gustavo, On Sat, Dec 17, 2011 at 07:29:26PM -0200, Gustavo F. Padovan wrote:quoted
From: "Gustavo F. Padovan" <redacted> L2CAP timers also need to run in process context. As the works in l2cap are small we are using the system worqueue. Signed-off-by: Gustavo F. Padovan <redacted> --- include/net/bluetooth/l2cap.h | 17 +++++----- net/bluetooth/l2cap_core.c | 70 ++++++++++++++++++----------------------- 2 files changed, 40 insertions(+), 47 deletions(-)...quoted
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 0369a9b..89cda6d 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c@@ -213,20 +213,18 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn)return 0; } -static void l2cap_set_timer(struct l2cap_chan *chan, struct timer_list *timer, long timeout) +static void l2cap_set_timer(struct l2cap_chan *chan, struct delayed_work *work, long timeout) { BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout); - if (!mod_timer(timer, jiffies + msecs_to_jiffies(timeout))) - chan_hold(chan); + cancel_delayed_work_sync(work); + + schedule_delayed_work(work, timeout); } -static void l2cap_clear_timer(struct l2cap_chan *chan, struct timer_list *timer) +static void l2cap_clear_timer(struct delayed_work *work) { - BT_DBG("chan %p state %d", chan, chan->state); - - if (timer_pending(timer) && del_timer(timer)) - chan_put(chan); + cancel_delayed_work_sync(work); }Do you think we do not need to use chan_hold / chan_put?
It's good you spotted it too. It's a known issue Padovan is looking at. Thanks. Best regards, -- Ulisses Furquim ProFUSION embedded systems http://profusion.mobi Mobile: +55 19 9250 0942 Skype: ulissesffs