Skip to content

Commit 4ded136

Browse files
emuslnkuba-moo
authored andcommitted
ionic: add work item for missed-doorbell check
Add the first queued work for checking on the missed doorbell. This is a delayed work item that reschedules itself every cycle starting at probe. Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Link: https://lore.kernel.org/r/20240619003257.6138-5-shannon.nelson@amd.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 9e25450 commit 4ded136

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct ionic {
5656
unsigned int nintrs;
5757
DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX);
5858
cpumask_var_t *affinity_masks;
59+
struct delayed_work doorbell_check_dwork;
5960
struct work_struct nb_work;
6061
struct notifier_block nb;
6162
struct rw_semaphore vf_op_lock; /* lock for VF operations */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
377377

378378
mod_timer(&ionic->watchdog_timer,
379379
round_jiffies(jiffies + ionic->watchdog_period));
380+
ionic_queue_doorbell_check(ionic, IONIC_NAPI_DEADLINE);
380381

381382
return 0;
382383

@@ -411,6 +412,7 @@ static void ionic_remove(struct pci_dev *pdev)
411412
if (test_and_clear_bit(IONIC_LIF_F_FW_RESET, ionic->lif->state))
412413
set_bit(IONIC_LIF_F_FW_STOPPING, ionic->lif->state);
413414

415+
cancel_delayed_work_sync(&ionic->doorbell_check_dwork);
414416
ionic_lif_unregister(ionic->lif);
415417
ionic_devlink_unregister(ionic);
416418
ionic_lif_deinit(ionic->lif);

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,61 @@ static void ionic_watchdog_cb(struct timer_list *t)
4747
}
4848
}
4949

50+
static void ionic_napi_schedule_do_softirq(struct napi_struct *napi)
51+
{
52+
local_bh_disable();
53+
napi_schedule(napi);
54+
local_bh_enable();
55+
}
56+
57+
static int ionic_get_preferred_cpu(struct ionic *ionic,
58+
struct ionic_intr_info *intr)
59+
{
60+
int cpu;
61+
62+
cpu = cpumask_first_and(*intr->affinity_mask, cpu_online_mask);
63+
if (cpu >= nr_cpu_ids)
64+
cpu = cpumask_local_spread(0, dev_to_node(ionic->dev));
65+
66+
return cpu;
67+
}
68+
69+
static void ionic_doorbell_check_dwork(struct work_struct *work)
70+
{
71+
struct ionic *ionic = container_of(work, struct ionic,
72+
doorbell_check_dwork.work);
73+
struct ionic_lif *lif = ionic->lif;
74+
75+
mutex_lock(&lif->queue_lock);
76+
77+
if (test_bit(IONIC_LIF_F_FW_STOPPING, lif->state) ||
78+
test_bit(IONIC_LIF_F_FW_RESET, lif->state)) {
79+
mutex_unlock(&lif->queue_lock);
80+
return;
81+
}
82+
83+
ionic_napi_schedule_do_softirq(&lif->adminqcq->napi);
84+
85+
if (test_bit(IONIC_LIF_F_UP, lif->state)) {
86+
int i;
87+
88+
for (i = 0; i < lif->nxqs; i++) {
89+
ionic_napi_schedule_do_softirq(&lif->txqcqs[i]->napi);
90+
ionic_napi_schedule_do_softirq(&lif->rxqcqs[i]->napi);
91+
}
92+
93+
if (lif->hwstamp_txq &&
94+
lif->hwstamp_txq->flags & IONIC_QCQ_F_INTR)
95+
ionic_napi_schedule_do_softirq(&lif->hwstamp_txq->napi);
96+
if (lif->hwstamp_rxq &&
97+
lif->hwstamp_rxq->flags & IONIC_QCQ_F_INTR)
98+
ionic_napi_schedule_do_softirq(&lif->hwstamp_rxq->napi);
99+
}
100+
mutex_unlock(&lif->queue_lock);
101+
102+
ionic_queue_doorbell_check(ionic, IONIC_NAPI_DEADLINE);
103+
}
104+
50105
static int ionic_watchdog_init(struct ionic *ionic)
51106
{
52107
struct ionic_dev *idev = &ionic->idev;
@@ -70,10 +125,21 @@ static int ionic_watchdog_init(struct ionic *ionic)
70125
dev_err(ionic->dev, "alloc_workqueue failed");
71126
return -ENOMEM;
72127
}
128+
INIT_DELAYED_WORK(&ionic->doorbell_check_dwork,
129+
ionic_doorbell_check_dwork);
73130

74131
return 0;
75132
}
76133

134+
void ionic_queue_doorbell_check(struct ionic *ionic, int delay)
135+
{
136+
int cpu;
137+
138+
cpu = ionic_get_preferred_cpu(ionic, &ionic->lif->adminqcq->intr);
139+
queue_delayed_work_on(cpu, ionic->wq, &ionic->doorbell_check_dwork,
140+
delay);
141+
}
142+
77143
void ionic_init_devinfo(struct ionic *ionic)
78144
{
79145
struct ionic_dev *idev = &ionic->idev;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define IONIC_DEV_INFO_REG_COUNT 32
2929
#define IONIC_DEV_CMD_REG_COUNT 32
3030

31-
#define IONIC_NAPI_DEADLINE (HZ / 200) /* 5ms */
31+
#define IONIC_NAPI_DEADLINE (HZ) /* 1 sec */
3232
#define IONIC_ADMIN_DOORBELL_DEADLINE (HZ / 2) /* 500ms */
3333
#define IONIC_TX_DOORBELL_DEADLINE (HZ / 100) /* 10ms */
3434
#define IONIC_RX_MIN_DOORBELL_DEADLINE (HZ / 100) /* 10ms */
@@ -386,6 +386,7 @@ bool ionic_q_is_posted(struct ionic_queue *q, unsigned int pos);
386386

387387
int ionic_heartbeat_check(struct ionic *ionic);
388388
bool ionic_is_fw_running(struct ionic_dev *idev);
389+
void ionic_queue_doorbell_check(struct ionic *ionic, int delay);
389390

390391
bool ionic_adminq_poke_doorbell(struct ionic_queue *q);
391392
bool ionic_txq_poke_doorbell(struct ionic_queue *q);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,7 @@ static int ionic_adminq_napi(struct napi_struct *napi, int budget)
11911191
if (lif->adminqcq && lif->adminqcq->flags & IONIC_QCQ_F_INITED)
11921192
a_work = ionic_cq_service(&lif->adminqcq->cq, budget,
11931193
ionic_adminq_service, NULL, NULL);
1194+
11941195
spin_unlock_irqrestore(&lif->adminq_lock, irqflags);
11951196

11961197
if (lif->hwstamp_rxq)
@@ -3406,6 +3407,7 @@ int ionic_restart_lif(struct ionic_lif *lif)
34063407
clear_bit(IONIC_LIF_F_FW_RESET, lif->state);
34073408
ionic_link_status_check_request(lif, CAN_SLEEP);
34083409
netif_device_attach(lif->netdev);
3410+
ionic_queue_doorbell_check(ionic, IONIC_NAPI_DEADLINE);
34093411

34103412
return 0;
34113413

0 commit comments

Comments
 (0)