Skip to content

Commit 9e25450

Browse files
emuslnkuba-moo
authored andcommitted
ionic: add private workqueue per-device
Instead of using the system's default workqueue, add a private workqueue for the device to use for its little jobs. This is to better support the new work items we will be adding in the next patches for PF and VF specific jobs, without inundating the system workqueue in a couple of customer cases where our devices get scaled out to 100-200 VFs. Signed-off-by: Brett Creeley <brett.creeley@amd.com> Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Link: https://lore.kernel.org/r/20240619003257.6138-4-shannon.nelson@amd.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d458d4b commit 9e25450

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

drivers/net/ethernet/pensando/ionic/ionic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct ionic {
4747
struct ionic_dev_bar bars[IONIC_BARS_MAX];
4848
unsigned int num_bars;
4949
struct ionic_identity ident;
50+
struct workqueue_struct *wq;
5051
struct ionic_lif *lif;
5152
unsigned int nnqs_per_lif;
5253
unsigned int neqs_per_lif;

drivers/net/ethernet/pensando/ionic/ionic_dev.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ static void ionic_watchdog_cb(struct timer_list *t)
4343

4444
work->type = IONIC_DW_TYPE_RX_MODE;
4545
netdev_dbg(lif->netdev, "deferred: rx_mode\n");
46-
ionic_lif_deferred_enqueue(&lif->deferred, work);
46+
ionic_lif_deferred_enqueue(lif, work);
4747
}
4848
}
4949

50-
static void ionic_watchdog_init(struct ionic *ionic)
50+
static int ionic_watchdog_init(struct ionic *ionic)
5151
{
5252
struct ionic_dev *idev = &ionic->idev;
5353

@@ -63,6 +63,15 @@ static void ionic_watchdog_init(struct ionic *ionic)
6363
idev->fw_status_ready = true;
6464
idev->fw_generation = IONIC_FW_STS_F_GENERATION &
6565
ioread8(&idev->dev_info_regs->fw_status);
66+
67+
ionic->wq = alloc_workqueue("%s-wq", WQ_UNBOUND, 0,
68+
dev_name(ionic->dev));
69+
if (!ionic->wq) {
70+
dev_err(ionic->dev, "alloc_workqueue failed");
71+
return -ENOMEM;
72+
}
73+
74+
return 0;
6675
}
6776

6877
void ionic_init_devinfo(struct ionic *ionic)
@@ -94,6 +103,7 @@ int ionic_dev_setup(struct ionic *ionic)
94103
struct device *dev = ionic->dev;
95104
int size;
96105
u32 sig;
106+
int err;
97107

98108
/* BAR0: dev_cmd and interrupts */
99109
if (num_bars < 1) {
@@ -129,7 +139,9 @@ int ionic_dev_setup(struct ionic *ionic)
129139
return -EFAULT;
130140
}
131141

132-
ionic_watchdog_init(ionic);
142+
err = ionic_watchdog_init(ionic);
143+
if (err)
144+
return err;
133145

134146
idev->db_pages = bar->vaddr;
135147
idev->phy_db_pages = bar->bus_addr;
@@ -161,6 +173,7 @@ void ionic_dev_teardown(struct ionic *ionic)
161173
idev->phy_cmb_pages = 0;
162174
idev->cmb_npages = 0;
163175

176+
destroy_workqueue(ionic->wq);
164177
mutex_destroy(&idev->cmb_inuse_lock);
165178
}
166179

@@ -273,7 +286,7 @@ int ionic_heartbeat_check(struct ionic *ionic)
273286
if (work) {
274287
work->type = IONIC_DW_TYPE_LIF_RESET;
275288
work->fw_status = fw_status_ready;
276-
ionic_lif_deferred_enqueue(&lif->deferred, work);
289+
ionic_lif_deferred_enqueue(lif, work);
277290
}
278291
}
279292
}

drivers/net/ethernet/pensando/ionic/ionic_lif.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ static void ionic_lif_deferred_work(struct work_struct *work)
126126
} while (true);
127127
}
128128

129-
void ionic_lif_deferred_enqueue(struct ionic_deferred *def,
129+
void ionic_lif_deferred_enqueue(struct ionic_lif *lif,
130130
struct ionic_deferred_work *work)
131131
{
132-
spin_lock_bh(&def->lock);
133-
list_add_tail(&work->list, &def->list);
134-
spin_unlock_bh(&def->lock);
135-
schedule_work(&def->work);
132+
spin_lock_bh(&lif->deferred.lock);
133+
list_add_tail(&work->list, &lif->deferred.list);
134+
spin_unlock_bh(&lif->deferred.lock);
135+
queue_work(lif->ionic->wq, &lif->deferred.work);
136136
}
137137

138138
static void ionic_link_status_check(struct ionic_lif *lif)
@@ -207,7 +207,7 @@ void ionic_link_status_check_request(struct ionic_lif *lif, bool can_sleep)
207207
}
208208

209209
work->type = IONIC_DW_TYPE_LINK_STATUS;
210-
ionic_lif_deferred_enqueue(&lif->deferred, work);
210+
ionic_lif_deferred_enqueue(lif, work);
211211
} else {
212212
ionic_link_status_check(lif);
213213
}
@@ -1389,7 +1389,7 @@ static void ionic_ndo_set_rx_mode(struct net_device *netdev)
13891389
}
13901390
work->type = IONIC_DW_TYPE_RX_MODE;
13911391
netdev_dbg(lif->netdev, "deferred: rx_mode\n");
1392-
ionic_lif_deferred_enqueue(&lif->deferred, work);
1392+
ionic_lif_deferred_enqueue(lif, work);
13931393
}
13941394

13951395
static __le64 ionic_netdev_features_to_nic(netdev_features_t features)

drivers/net/ethernet/pensando/ionic/ionic_lif.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static inline bool ionic_txq_hwstamp_enabled(struct ionic_queue *q)
331331
void ionic_link_status_check_request(struct ionic_lif *lif, bool can_sleep);
332332
void ionic_get_stats64(struct net_device *netdev,
333333
struct rtnl_link_stats64 *ns);
334-
void ionic_lif_deferred_enqueue(struct ionic_deferred *def,
334+
void ionic_lif_deferred_enqueue(struct ionic_lif *lif,
335335
struct ionic_deferred_work *work);
336336
int ionic_lif_alloc(struct ionic *ionic);
337337
int ionic_lif_init(struct ionic_lif *lif);

drivers/net/ethernet/pensando/ionic/ionic_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ bool ionic_notifyq_service(struct ionic_cq *cq)
287287
clear_bit(IONIC_LIF_F_FW_STOPPING, lif->state);
288288
} else {
289289
work->type = IONIC_DW_TYPE_LIF_RESET;
290-
ionic_lif_deferred_enqueue(&lif->deferred, work);
290+
ionic_lif_deferred_enqueue(lif, work);
291291
}
292292
}
293293
break;

0 commit comments

Comments
 (0)