Skip to content

Commit 7aa1402

Browse files
keesdavem330
authored andcommitted
net: ethernet/sfc: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: Solarflare linux maintainers <linux-net-drivers@solarflare.com> Cc: Edward Cree <ecree@solarflare.com> Cc: Bert Kenward <bkenward@solarflare.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Jiri Pirko <jiri@mellanox.com> Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Bert Kenward <bkenward@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fc8bcaa commit 7aa1402

9 files changed

Lines changed: 22 additions & 24 deletions

File tree

‎drivers/net/ethernet/sfc/efx.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,7 @@ efx_alloc_channel(struct efx_nic *efx, int i, struct efx_channel *old_channel)
471471

472472
rx_queue = &channel->rx_queue;
473473
rx_queue->efx = efx;
474-
setup_timer(&rx_queue->slow_fill, efx_rx_slow_fill,
475-
(unsigned long)rx_queue);
474+
timer_setup(&rx_queue->slow_fill, efx_rx_slow_fill, 0);
476475

477476
return channel;
478477
}
@@ -511,8 +510,7 @@ efx_copy_channel(const struct efx_channel *old_channel)
511510
rx_queue = &channel->rx_queue;
512511
rx_queue->buffer = NULL;
513512
memset(&rx_queue->rxd, 0, sizeof(rx_queue->rxd));
514-
setup_timer(&rx_queue->slow_fill, efx_rx_slow_fill,
515-
(unsigned long)rx_queue);
513+
timer_setup(&rx_queue->slow_fill, efx_rx_slow_fill, 0);
516514

517515
return channel;
518516
}

‎drivers/net/ethernet/sfc/efx.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void efx_remove_rx_queue(struct efx_rx_queue *rx_queue);
4646
void efx_init_rx_queue(struct efx_rx_queue *rx_queue);
4747
void efx_fini_rx_queue(struct efx_rx_queue *rx_queue);
4848
void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic);
49-
void efx_rx_slow_fill(unsigned long context);
49+
void efx_rx_slow_fill(struct timer_list *t);
5050
void __efx_rx_packet(struct efx_channel *channel);
5151
void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
5252
unsigned int n_frags, unsigned int len, u16 flags);

‎drivers/net/ethernet/sfc/falcon/efx.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,7 @@ ef4_alloc_channel(struct ef4_nic *efx, int i, struct ef4_channel *old_channel)
449449

450450
rx_queue = &channel->rx_queue;
451451
rx_queue->efx = efx;
452-
setup_timer(&rx_queue->slow_fill, ef4_rx_slow_fill,
453-
(unsigned long)rx_queue);
452+
timer_setup(&rx_queue->slow_fill, ef4_rx_slow_fill, 0);
454453

455454
return channel;
456455
}
@@ -489,8 +488,7 @@ ef4_copy_channel(const struct ef4_channel *old_channel)
489488
rx_queue = &channel->rx_queue;
490489
rx_queue->buffer = NULL;
491490
memset(&rx_queue->rxd, 0, sizeof(rx_queue->rxd));
492-
setup_timer(&rx_queue->slow_fill, ef4_rx_slow_fill,
493-
(unsigned long)rx_queue);
491+
timer_setup(&rx_queue->slow_fill, ef4_rx_slow_fill, 0);
494492

495493
return channel;
496494
}

‎drivers/net/ethernet/sfc/falcon/efx.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void ef4_remove_rx_queue(struct ef4_rx_queue *rx_queue);
4545
void ef4_init_rx_queue(struct ef4_rx_queue *rx_queue);
4646
void ef4_fini_rx_queue(struct ef4_rx_queue *rx_queue);
4747
void ef4_fast_push_rx_descriptors(struct ef4_rx_queue *rx_queue, bool atomic);
48-
void ef4_rx_slow_fill(unsigned long context);
48+
void ef4_rx_slow_fill(struct timer_list *t);
4949
void __ef4_rx_packet(struct ef4_channel *channel);
5050
void ef4_rx_packet(struct ef4_rx_queue *rx_queue, unsigned int index,
5151
unsigned int n_frags, unsigned int len, u16 flags);

‎drivers/net/ethernet/sfc/falcon/falcon.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,10 +1454,11 @@ static void falcon_stats_complete(struct ef4_nic *efx)
14541454
}
14551455
}
14561456

1457-
static void falcon_stats_timer_func(unsigned long context)
1457+
static void falcon_stats_timer_func(struct timer_list *t)
14581458
{
1459-
struct ef4_nic *efx = (struct ef4_nic *)context;
1460-
struct falcon_nic_data *nic_data = efx->nic_data;
1459+
struct falcon_nic_data *nic_data = from_timer(nic_data, t,
1460+
stats_timer);
1461+
struct ef4_nic *efx = nic_data->efx;
14611462

14621463
spin_lock(&efx->stats_lock);
14631464

@@ -2295,6 +2296,7 @@ static int falcon_probe_nic(struct ef4_nic *efx)
22952296
if (!nic_data)
22962297
return -ENOMEM;
22972298
efx->nic_data = nic_data;
2299+
nic_data->efx = efx;
22982300

22992301
rc = -ENODEV;
23002302

@@ -2402,8 +2404,7 @@ static int falcon_probe_nic(struct ef4_nic *efx)
24022404
}
24032405

24042406
nic_data->stats_disable_count = 1;
2405-
setup_timer(&nic_data->stats_timer, &falcon_stats_timer_func,
2406-
(unsigned long)efx);
2407+
timer_setup(&nic_data->stats_timer, falcon_stats_timer_func, 0);
24072408

24082409
return 0;
24092410

‎drivers/net/ethernet/sfc/falcon/nic.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ enum {
267267
/**
268268
* struct falcon_nic_data - Falcon NIC state
269269
* @pci_dev2: Secondary function of Falcon A
270+
* @efx: ef4_nic pointer
270271
* @board: Board state and functions
271272
* @stats: Hardware statistics
272273
* @stats_disable_count: Nest count for disabling statistics fetches
@@ -280,6 +281,7 @@ enum {
280281
*/
281282
struct falcon_nic_data {
282283
struct pci_dev *pci_dev2;
284+
struct ef4_nic *efx;
283285
struct falcon_board board;
284286
u64 stats[FALCON_STAT_COUNT];
285287
unsigned int stats_disable_count;

‎drivers/net/ethernet/sfc/falcon/rx.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ void ef4_fast_push_rx_descriptors(struct ef4_rx_queue *rx_queue, bool atomic)
376376
ef4_nic_notify_rx_desc(rx_queue);
377377
}
378378

379-
void ef4_rx_slow_fill(unsigned long context)
379+
void ef4_rx_slow_fill(struct timer_list *t)
380380
{
381-
struct ef4_rx_queue *rx_queue = (struct ef4_rx_queue *)context;
381+
struct ef4_rx_queue *rx_queue = from_timer(rx_queue, t, slow_fill);
382382

383383
/* Post an event to cause NAPI to run and refill the queue */
384384
ef4_nic_generate_fill_event(rx_queue);

‎drivers/net/ethernet/sfc/mcdi.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct efx_mcdi_async_param {
4848
/* followed by request/response buffer */
4949
};
5050

51-
static void efx_mcdi_timeout_async(unsigned long context);
51+
static void efx_mcdi_timeout_async(struct timer_list *t);
5252
static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
5353
bool *was_attached_out);
5454
static bool efx_mcdi_poll_once(struct efx_nic *efx);
@@ -87,8 +87,7 @@ int efx_mcdi_init(struct efx_nic *efx)
8787
mcdi->mode = MCDI_MODE_POLL;
8888
spin_lock_init(&mcdi->async_lock);
8989
INIT_LIST_HEAD(&mcdi->async_list);
90-
setup_timer(&mcdi->async_timer, efx_mcdi_timeout_async,
91-
(unsigned long)mcdi);
90+
timer_setup(&mcdi->async_timer, efx_mcdi_timeout_async, 0);
9291

9392
(void) efx_mcdi_poll_reboot(efx);
9493
mcdi->new_epoch = true;
@@ -608,9 +607,9 @@ static void efx_mcdi_ev_cpl(struct efx_nic *efx, unsigned int seqno,
608607
}
609608
}
610609

611-
static void efx_mcdi_timeout_async(unsigned long context)
610+
static void efx_mcdi_timeout_async(struct timer_list *t)
612611
{
613-
struct efx_mcdi_iface *mcdi = (struct efx_mcdi_iface *)context;
612+
struct efx_mcdi_iface *mcdi = from_timer(mcdi, t, async_timer);
614613

615614
efx_mcdi_complete_async(mcdi, true);
616615
}

‎drivers/net/ethernet/sfc/rx.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic)
376376
efx_nic_notify_rx_desc(rx_queue);
377377
}
378378

379-
void efx_rx_slow_fill(unsigned long context)
379+
void efx_rx_slow_fill(struct timer_list *t)
380380
{
381-
struct efx_rx_queue *rx_queue = (struct efx_rx_queue *)context;
381+
struct efx_rx_queue *rx_queue = from_timer(rx_queue, t, slow_fill);
382382

383383
/* Post an event to cause NAPI to run and refill the queue */
384384
efx_nic_generate_fill_event(rx_queue);

0 commit comments

Comments
 (0)