* [PATCH-next v1] r8152: Convert tasklet API to new bottom half workqueue mechanism
@ 2024-07-01 10:03 Anand Moon
2024-07-03 1:42 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Anand Moon @ 2024-07-01 10:03 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Anand Moon, linux-usb, netdev, linux-kernel
Migrate tasklet APIs to the new bottom half workqueue mechanism. It
replaces all occurrences of tasklet usage with the appropriate workqueue
APIs throughout the alteon driver. This transition ensures compatibility
with the latest design and enhances performance
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
Tested on odroidxu4
---
drivers/net/usb/r8152.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 15e12f46d0ea..57a932a6f759 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -26,6 +26,7 @@
#include <linux/atomic.h>
#include <linux/acpi.h>
#include <linux/firmware.h>
+#include <linux/workqueue.h>
#include <crypto/hash.h>
#include <linux/usb/r8152.h>
#include <net/gso.h>
@@ -883,7 +884,7 @@ struct r8152 {
#ifdef CONFIG_PM_SLEEP
struct notifier_block pm_notifier;
#endif
- struct tasklet_struct tx_tl;
+ struct work_struct tx_work;
struct rtl_ops {
void (*init)(struct r8152 *tp);
@@ -1950,7 +1951,7 @@ static void write_bulk_callback(struct urb *urb)
return;
if (!skb_queue_empty(&tp->tx_queue))
- tasklet_schedule(&tp->tx_tl);
+ queue_work(system_bh_wq, &tp->tx_work);
}
static void intr_callback(struct urb *urb)
@@ -2748,9 +2749,9 @@ static void tx_bottom(struct r8152 *tp)
} while (res == 0);
}
-static void bottom_half(struct tasklet_struct *t)
+static void bottom_half(struct work_struct *t)
{
- struct r8152 *tp = from_tasklet(tp, t, tx_tl);
+ struct r8152 *tp = from_work(tp, t, tx_work);
if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
return;
@@ -2944,7 +2945,7 @@ static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb,
schedule_delayed_work(&tp->schedule, 0);
} else {
usb_mark_last_busy(tp->udev);
- tasklet_schedule(&tp->tx_tl);
+ queue_work(system_bh_wq, &tp->tx_work);
}
} else if (skb_queue_len(&tp->tx_queue) > tp->tx_qlen) {
netif_stop_queue(netdev);
@@ -6826,11 +6827,11 @@ static void set_carrier(struct r8152 *tp)
} else {
if (netif_carrier_ok(netdev)) {
netif_carrier_off(netdev);
- tasklet_disable(&tp->tx_tl);
+ disable_work_sync(&tp->tx_work);
napi_disable(napi);
tp->rtl_ops.disable(tp);
napi_enable(napi);
- tasklet_enable(&tp->tx_tl);
+ enable_and_queue_work(system_bh_wq, &tp->tx_work);
netif_info(tp, link, netdev, "carrier off\n");
}
}
@@ -6866,7 +6867,7 @@ static void rtl_work_func_t(struct work_struct *work)
/* don't schedule tasket before linking */
if (test_and_clear_bit(SCHEDULE_TASKLET, &tp->flags) &&
netif_carrier_ok(tp->netdev))
- tasklet_schedule(&tp->tx_tl);
+ queue_work(system_bh_wq, &tp->tx_work);
if (test_and_clear_bit(RX_EPROTO, &tp->flags) &&
!list_empty(&tp->rx_done))
@@ -6973,7 +6974,7 @@ static int rtl8152_open(struct net_device *netdev)
goto out_unlock;
}
napi_enable(&tp->napi);
- tasklet_enable(&tp->tx_tl);
+ enable_and_queue_work(system_bh_wq, &tp->tx_work);
mutex_unlock(&tp->control);
@@ -7001,7 +7002,7 @@ static int rtl8152_close(struct net_device *netdev)
#ifdef CONFIG_PM_SLEEP
unregister_pm_notifier(&tp->pm_notifier);
#endif
- tasklet_disable(&tp->tx_tl);
+ disable_work_sync(&tp->tx_work);
clear_bit(WORK_ENABLE, &tp->flags);
usb_kill_urb(tp->intr_urb);
cancel_delayed_work_sync(&tp->schedule);
@@ -8423,7 +8424,7 @@ static int rtl8152_pre_reset(struct usb_interface *intf)
return 0;
netif_stop_queue(netdev);
- tasklet_disable(&tp->tx_tl);
+ disable_work_sync(&tp->tx_work);
clear_bit(WORK_ENABLE, &tp->flags);
usb_kill_urb(tp->intr_urb);
cancel_delayed_work_sync(&tp->schedule);
@@ -8468,7 +8469,7 @@ static int rtl8152_post_reset(struct usb_interface *intf)
}
napi_enable(&tp->napi);
- tasklet_enable(&tp->tx_tl);
+ enable_and_queue_work(system_bh_wq, &tp->tx_work);
netif_wake_queue(netdev);
usb_submit_urb(tp->intr_urb, GFP_KERNEL);
@@ -8640,12 +8641,12 @@ static int rtl8152_system_suspend(struct r8152 *tp)
clear_bit(WORK_ENABLE, &tp->flags);
usb_kill_urb(tp->intr_urb);
- tasklet_disable(&tp->tx_tl);
+ disable_work_sync(&tp->tx_work);
napi_disable(napi);
cancel_delayed_work_sync(&tp->schedule);
tp->rtl_ops.down(tp);
napi_enable(napi);
- tasklet_enable(&tp->tx_tl);
+ enable_and_queue_work(system_bh_wq, &tp->tx_work);
}
/* If we're inaccessible here then some of the work that we did to
@@ -9407,11 +9408,11 @@ static int rtl8152_change_mtu(struct net_device *dev, int new_mtu)
if (netif_carrier_ok(dev)) {
netif_stop_queue(dev);
napi_disable(&tp->napi);
- tasklet_disable(&tp->tx_tl);
+ disable_work_sync(&tp->tx_work);
tp->rtl_ops.disable(tp);
tp->rtl_ops.enable(tp);
rtl_start_rx(tp);
- tasklet_enable(&tp->tx_tl);
+ enable_and_queue_work(system_bh_wq, &tp->tx_work);
napi_enable(&tp->napi);
rtl8152_set_rx_mode(dev);
netif_wake_queue(dev);
@@ -9839,8 +9840,8 @@ static int rtl8152_probe_once(struct usb_interface *intf,
mutex_init(&tp->control);
INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t);
INIT_DELAYED_WORK(&tp->hw_phy_work, rtl_hw_phy_work_func_t);
- tasklet_setup(&tp->tx_tl, bottom_half);
- tasklet_disable(&tp->tx_tl);
+ INIT_WORK(&tp->tx_work, bottom_half);
+ disable_work_sync(&tp->tx_work);
netdev->netdev_ops = &rtl8152_netdev_ops;
netdev->watchdog_timeo = RTL8152_TX_TIMEOUT;
@@ -9974,7 +9975,7 @@ static int rtl8152_probe_once(struct usb_interface *intf,
unregister_netdev(netdev);
out1:
- tasklet_kill(&tp->tx_tl);
+ cancel_work_sync(&tp->tx_work);
cancel_delayed_work_sync(&tp->hw_phy_work);
if (tp->rtl_ops.unload)
tp->rtl_ops.unload(tp);
@@ -10030,7 +10031,7 @@ static void rtl8152_disconnect(struct usb_interface *intf)
rtl_set_unplug(tp);
unregister_netdev(tp->netdev);
- tasklet_kill(&tp->tx_tl);
+ cancel_work_sync(&tp->tx_work);
cancel_delayed_work_sync(&tp->hw_phy_work);
if (tp->rtl_ops.unload)
tp->rtl_ops.unload(tp);
--
2.44.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH-next v1] r8152: Convert tasklet API to new bottom half workqueue mechanism
2024-07-01 10:03 [PATCH-next v1] r8152: Convert tasklet API to new bottom half workqueue mechanism Anand Moon
@ 2024-07-03 1:42 ` Jakub Kicinski
2024-07-03 3:47 ` Anand Moon
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2024-07-03 1:42 UTC (permalink / raw)
To: Anand Moon
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, linux-usb, netdev,
linux-kernel
On Mon, 1 Jul 2024 15:33:27 +0530 Anand Moon wrote:
> Migrate tasklet APIs to the new bottom half workqueue mechanism. It
> replaces all occurrences of tasklet usage with the appropriate workqueue
> APIs throughout the alteon driver. This transition ensures compatibility
> with the latest design and enhances performance
alteon ?
> - tasklet_enable(&tp->tx_tl);
> + enable_and_queue_work(system_bh_wq, &tp->tx_work);
This is not obviously correct. Please explain why in the commit message
if you're sure this is right.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH-next v1] r8152: Convert tasklet API to new bottom half workqueue mechanism
2024-07-03 1:42 ` Jakub Kicinski
@ 2024-07-03 3:47 ` Anand Moon
0 siblings, 0 replies; 3+ messages in thread
From: Anand Moon @ 2024-07-03 3:47 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, linux-usb, netdev,
linux-kernel, Allen Pais
Hi Jakub,
Thanks for this review's comments.
+ Allen Pais
On Wed, 3 Jul 2024 at 07:12, Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Mon, 1 Jul 2024 15:33:27 +0530 Anand Moon wrote:
> > Migrate tasklet APIs to the new bottom half workqueue mechanism. It
> > replaces all occurrences of tasklet usage with the appropriate workqueue
> > APIs throughout the alteon driver. This transition ensures compatibility
> > with the latest design and enhances performance
>
> alteon ?
Ok copy past the committee message, I will fix this in the next patch.
This patch is just follow-up on work done by Allen Pais
[1] https://lore.kernel.org/all/20240621183947.4105278-14-allen.lkml@gmail.com/
>
> > - tasklet_enable(&tp->tx_tl);
> > + enable_and_queue_work(system_bh_wq, &tp->tx_work);
>
> This is not obviously correct. Please explain why in the commit message
> if you're sure this is right.
Ok, I will gather all the feedback and work on these changes.
And update this patch.
> --
> pw-bot: cr
Thanks
-Anand
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-03 3:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-01 10:03 [PATCH-next v1] r8152: Convert tasklet API to new bottom half workqueue mechanism Anand Moon
2024-07-03 1:42 ` Jakub Kicinski
2024-07-03 3:47 ` Anand Moon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).