git: e03abec93cf8 - stable/15 - mlx4: convert to timer_setup() Linux KPI

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sat, 19 Sep 2026 14:40:20 UTC
The branch stable/15 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=e03abec93cf811c359e82291a41e0dbb49e1ebf1

commit e03abec93cf811c359e82291a41e0dbb49e1ebf1
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-09-14 22:51:09 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-09-19 09:34:09 +0000

    mlx4: convert to timer_setup() Linux KPI
    
    The Linux driver switched away from using this timer in e22979d96a55d.
    Locally adjust the code to use timer_setup/from_timer in order to get
    us out of Linux version 4.15 (and earlier) KPIs.
    Also, right away, apply 41cb08555c416 from_timer -> timer_container_of.
    
    Reviewed by:    kib
    Differential Revision: https://reviews.freebsd.org/D59680
    
    (cherry picked from commit 871c09c9b47eb0ef0f17a5a1fc2299dba7693516)
---
 sys/dev/mlx4/mlx4_en/en.h         | 2 +-
 sys/dev/mlx4/mlx4_en/mlx4_en_cq.c | 4 +---
 sys/dev/mlx4/mlx4_en/mlx4_en_tx.c | 4 ++--
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/sys/dev/mlx4/mlx4_en/en.h b/sys/dev/mlx4/mlx4_en/en.h
index 838894f7b02f..dbe29f1d24ec 100644
--- a/sys/dev/mlx4/mlx4_en/en.h
+++ b/sys/dev/mlx4/mlx4_en/en.h
@@ -836,7 +836,7 @@ void mlx4_en_deactivate_rx_ring(struct mlx4_en_priv *priv,
 int mlx4_en_process_rx_cq(if_t dev,
 			  struct mlx4_en_cq *cq,
 			  int budget);
-void mlx4_en_poll_tx_cq(unsigned long data);
+void mlx4_en_poll_tx_cq(struct timer_list *t);
 void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
 		int is_tx, int rss, int qpn, int cqn, int user_prio,
 		struct mlx4_qp_context *context);
diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_cq.c b/sys/dev/mlx4/mlx4_en/mlx4_en_cq.c
index 1b198778bfdd..00a506d08663 100644
--- a/sys/dev/mlx4/mlx4_en/mlx4_en_cq.c
+++ b/sys/dev/mlx4/mlx4_en/mlx4_en_cq.c
@@ -164,9 +164,7 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
 	cq->mcq.event = mlx4_en_cq_event;
 
         if (cq->is_tx) {
-                init_timer(&cq->timer);
-                cq->timer.function = mlx4_en_poll_tx_cq;
-                cq->timer.data = (unsigned long) cq;
+		timer_setup(&cq->timer, mlx4_en_poll_tx_cq, 0);
         }
 
 
diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
index d45ccacd7499..afb31cbb7104 100644
--- a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
+++ b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
@@ -433,9 +433,9 @@ void mlx4_en_tx_irq(struct mlx4_cq *mcq)
 	spin_unlock(&ring->comp_lock);
 }
 
-void mlx4_en_poll_tx_cq(unsigned long data)
+void mlx4_en_poll_tx_cq(struct timer_list *t)
 {
-	struct mlx4_en_cq *cq = (struct mlx4_en_cq *) data;
+	struct mlx4_en_cq *cq = timer_container_of(cq, t, timer);
 	struct mlx4_en_priv *priv = mlx4_netdev_priv(cq->dev);
 	struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring];
 	u32 inflight;