[PATCH 05/10] net: emac: mal: replace busy-wait in mal_poll_disable with wait_event
From: Rosen Penev <hidden>
Date: 2026-06-30 04:16:43
Also in:
lkml
Subsystem:
networking drivers, the rest · Maintainers:
Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
Replace the msleep(1) busy-wait loop in mal_poll_disable() with a proper wait_event/wake_up mechanism. Add wait_queue_head_t to struct mal_commac, initialize it in mal_poll_add(), and wake waiters in mal_poll_enable(). Assisted-by: opencode:big-pickle Signed-off-by: Rosen Penev <redacted> --- drivers/net/ethernet/ibm/emac/mal.c | 7 +++++-- drivers/net/ethernet/ibm/emac/mal.h | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm/emac/mal.c
index 82d502d576ee..d12a376f69fd 100644
--- a/drivers/net/ethernet/ibm/emac/mal.c
+++ b/drivers/net/ethernet/ibm/emac/mal.c@@ -176,6 +176,8 @@ void mal_poll_add(struct mal_instance *mal, struct mal_commac *commac) MAL_DBG(mal, "poll_add(%p)" NL, commac); + init_waitqueue_head(&commac->poll_wait); + /* starts disabled */ set_bit(MAL_COMMAC_POLL_DISABLED, &commac->flags);
@@ -371,8 +373,8 @@ static irqreturn_t mal_int(int irq, void *dev_instance) void mal_poll_disable(struct mal_instance *mal, struct mal_commac *commac) { /* Spinlock-type semantics: only one caller disable poll at a time */ - while (test_and_set_bit(MAL_COMMAC_POLL_DISABLED, &commac->flags)) - msleep(1); + wait_event(commac->poll_wait, + !test_and_set_bit(MAL_COMMAC_POLL_DISABLED, &commac->flags)); /* Synchronize with the MAL NAPI poller */ napi_synchronize(&mal->napi);
@@ -382,6 +384,7 @@ void mal_poll_enable(struct mal_instance *mal, struct mal_commac *commac) { smp_wmb(); clear_bit(MAL_COMMAC_POLL_DISABLED, &commac->flags); + wake_up(&commac->poll_wait); /* Feels better to trigger a poll here to catch up with events that * may have happened on this channel while disabled. It will most
diff --git a/drivers/net/ethernet/ibm/emac/mal.h b/drivers/net/ethernet/ibm/emac/mal.h
index e0ddc41186a2..bd52bb41adee 100644
--- a/drivers/net/ethernet/ibm/emac/mal.h
+++ b/drivers/net/ethernet/ibm/emac/mal.h@@ -19,6 +19,8 @@ #ifndef __IBM_NEWEMAC_MAL_H #define __IBM_NEWEMAC_MAL_H +#include <linux/wait.h> + /* * There are some variations on the MAL, we express them in this driver as * MAL Version 1 and 2 though that doesn't match any IBM terminology.
@@ -172,6 +174,7 @@ struct mal_commac { void *dev; struct list_head poll_list; long flags; + wait_queue_head_t poll_wait; #define MAL_COMMAC_RX_STOPPED 0 #define MAL_COMMAC_POLL_DISABLED 1 u32 tx_chan_mask;
--
2.54.0