lkml.org 
[lkml]   [2017]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 25/25] usb/gadget/NCM: Replace tasklet with softirq hrtimer
From: Thomas Gleixner <tglx@linutronix.de>

The tx_tasklet tasklet is used in invoke the hrtimer (task_timer) in
softirq context. This can be also achieved without the tasklet but with
CLOCK_MONOTONIC_SOFT as hrtimer base.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: linux-usb@vger.kernel.org
---
drivers/usb/gadget/function/f_ncm.c | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)

--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -77,9 +77,7 @@ struct f_ncm {
struct sk_buff *skb_tx_ndp;
u16 ndp_dgram_count;
bool timer_force_tx;
- struct tasklet_struct tx_tasklet;
struct hrtimer task_timer;
-
bool timer_stopping;
};

@@ -1154,17 +1152,15 @@ static struct sk_buff *ncm_wrap_ntb(stru
}

/*
- * This transmits the NTB if there are frames waiting.
+ * The transmit should only be run if no skb data has been sent
+ * for a certain duration.
*/
-static void ncm_tx_tasklet(unsigned long data)
+static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data)
{
- struct f_ncm *ncm = (void *)data;
-
- if (ncm->timer_stopping)
- return;
+ struct f_ncm *ncm = container_of(data, struct f_ncm, task_timer);

/* Only send if data is available. */
- if (ncm->skb_tx_data) {
+ if (!ncm->timer_stopping && ncm->skb_tx_data) {
ncm->timer_force_tx = true;

/* XXX This allowance of a NULL skb argument to ndo_start_xmit
@@ -1177,16 +1173,6 @@ static void ncm_tx_tasklet(unsigned long

ncm->timer_force_tx = false;
}
-}
-
-/*
- * The transmit should only be run if no skb data has been sent
- * for a certain duration.
- */
-static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data)
-{
- struct f_ncm *ncm = container_of(data, struct f_ncm, task_timer);
- tasklet_schedule(&ncm->tx_tasklet);
return HRTIMER_NORESTART;
}

@@ -1519,8 +1505,7 @@ static int ncm_bind(struct usb_configura
ncm->port.open = ncm_open;
ncm->port.close = ncm_close;

- tasklet_init(&ncm->tx_tasklet, ncm_tx_tasklet, (unsigned long) ncm);
- hrtimer_init(&ncm->task_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+ hrtimer_init(&ncm->task_timer, CLOCK_MONOTONIC_SOFT, HRTIMER_MODE_REL);
ncm->task_timer.function = ncm_tx_timeout;

DBG(cdev, "CDC Network: %s speed IN/%s OUT/%s NOTIFY/%s\n",
@@ -1629,7 +1614,6 @@ static void ncm_unbind(struct usb_config
DBG(c->cdev, "ncm unbind\n");

hrtimer_cancel(&ncm->task_timer);
- tasklet_kill(&ncm->tx_tasklet);

ncm_string_defs[0].id = 0;
usb_free_all_descriptors(f);

\
 
 \ /
  Last update: 2017-08-31 14:25    [W:0.284 / U:4.276 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site