staging/ks7010: replace SME taslet with work
authorDavidlohr Bueso <dave@stgolabs.net>
Mon, 11 Apr 2022 15:16:18 +0000 (08:16 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Apr 2022 13:53:50 +0000 (15:53 +0200)
Tasklets have long been deprecated as being too heavy on the system
by running in irq context - and this is not a performance critical
path. If a higher priority process wants to run, it must wait for
the tasklet to finish before doing so.

The execution of the SME event will now occur in task context. There
are, however, changes in concurrency. Workqueues, unlike tasklets,
are not serialized among themselves and can run concurrently
updating sme_i.qhead. However, the current code is already exposed
in same ways, regardless of the deferral mechanism, in that
hostif_sme_enqueue() does unserialized enqueues updating sme_i.qtail.

Also get rid of the bogus (power save) tasklet enabling, as it
is never disabled to begin with.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
Link: https://lore.kernel.org/r/20220411151620.129178-5-dave@stgolabs.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks_hostif.c
drivers/staging/ks7010/ks_wlan.h

index 1c63d595313df8202e4ac30abb2982ce54df5deb..f1aa3be4261d2200764e4599316f73dbdc2ab055 100644 (file)
@@ -84,10 +84,6 @@ static void ks_wlan_hw_wakeup_task(struct work_struct *work)
                        return;
                }
        }
-
-       /* power save */
-       if (atomic_read(&priv->sme_task.count) > 0)
-               tasklet_enable(&priv->sme_task);
 }
 
 static void ks_wlan_do_power_save(struct ks_wlan_private *priv)
@@ -2200,10 +2196,13 @@ static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
        }
 }
 
-static
-void hostif_sme_task(struct tasklet_struct *t)
+static void hostif_sme_work(struct work_struct *work)
 {
-       struct ks_wlan_private *priv = from_tasklet(priv, t, sme_task);
+       struct ks_wlan_private *priv;
+
+       priv = container_of(work, struct ks_wlan_private, sme_work);
+       if (!priv)
+               return;
 
        if (priv->dev_state < DEVICE_STATE_BOOT)
                return;
@@ -2214,7 +2213,7 @@ void hostif_sme_task(struct tasklet_struct *t)
        hostif_sme_execute(priv, priv->sme_i.event_buff[priv->sme_i.qhead]);
        inc_smeqhead(priv);
        if (cnt_smeqbody(priv) > 0)
-               tasklet_schedule(&priv->sme_task);
+               schedule_work(&priv->sme_work);
 }
 
 /* send to Station Management Entity module */
@@ -2229,7 +2228,7 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 event)
                netdev_err(priv->net_dev, "sme queue buffer overflow\n");
        }
 
-       tasklet_schedule(&priv->sme_task);
+       schedule_work(&priv->sme_work);
 }
 
 static inline void hostif_aplist_init(struct ks_wlan_private *priv)
@@ -2254,7 +2253,7 @@ static inline void hostif_sme_init(struct ks_wlan_private *priv)
        priv->sme_i.qtail = 0;
        spin_lock_init(&priv->sme_i.sme_spin);
        priv->sme_i.sme_flag = 0;
-       tasklet_setup(&priv->sme_task, hostif_sme_task);
+       INIT_WORK(&priv->sme_work, hostif_sme_work);
 }
 
 static inline void hostif_wpa_init(struct ks_wlan_private *priv)
@@ -2312,5 +2311,5 @@ int hostif_init(struct ks_wlan_private *priv)
 
 void hostif_exit(struct ks_wlan_private *priv)
 {
-       tasklet_kill(&priv->sme_task);
+       cancel_work_sync(&priv->sme_work);
 }
index 7aaf8d780939e690013b36db6e578e8ccf86e36a..3e9a91b5131ce8e7029ec10dba93345f47cac231 100644 (file)
@@ -449,7 +449,7 @@ struct ks_wlan_private {
        struct sme_info sme_i;
        u8 *rxp;
        unsigned int rx_size;
-       struct tasklet_struct sme_task;
+       struct work_struct sme_work;
        struct work_struct wakeup_work;
        int scan_ind_count;