Skip to content

Commit a05e7a6

Browse files
committed
Merge branch 'ionic-code-maintenance'
Shannon Nelson says: ==================== ionic: code maintenance These are a few fixes for a hardware bug, a couple of sw bugs, and a little code cleanup. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 69ff53e + b69585b commit a05e7a6

File tree

6 files changed

+195
-12
lines changed

6 files changed

+195
-12
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,16 @@ void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, ionic_desc_cb cb,
708708
q->lif->index, q->name, q->hw_type, q->hw_index,
709709
q->head_idx, ring_doorbell);
710710

711-
if (ring_doorbell)
711+
if (ring_doorbell) {
712712
ionic_dbell_ring(lif->kern_dbpage, q->hw_type,
713713
q->dbval | q->head_idx);
714+
715+
q->dbell_jiffies = jiffies;
716+
717+
if (q_to_qcq(q)->napi_qcq)
718+
mod_timer(&q_to_qcq(q)->napi_qcq->napi_deadline,
719+
jiffies + IONIC_NAPI_DEADLINE);
720+
}
714721
}
715722

716723
static bool ionic_q_is_posted(struct ionic_queue *q, unsigned int pos)

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
#define IONIC_DEV_INFO_REG_COUNT 32
2626
#define IONIC_DEV_CMD_REG_COUNT 32
2727

28+
#define IONIC_NAPI_DEADLINE (HZ / 200) /* 5ms */
29+
#define IONIC_ADMIN_DOORBELL_DEADLINE (HZ / 2) /* 500ms */
30+
#define IONIC_TX_DOORBELL_DEADLINE (HZ / 100) /* 10ms */
31+
#define IONIC_RX_MIN_DOORBELL_DEADLINE (HZ / 100) /* 10ms */
32+
#define IONIC_RX_MAX_DOORBELL_DEADLINE (HZ * 5) /* 5s */
33+
2834
struct ionic_dev_bar {
2935
void __iomem *vaddr;
3036
phys_addr_t bus_addr;
@@ -216,6 +222,8 @@ struct ionic_queue {
216222
struct ionic_lif *lif;
217223
struct ionic_desc_info *info;
218224
u64 dbval;
225+
unsigned long dbell_deadline;
226+
unsigned long dbell_jiffies;
219227
u16 head_idx;
220228
u16 tail_idx;
221229
unsigned int index;
@@ -361,4 +369,8 @@ void ionic_q_service(struct ionic_queue *q, struct ionic_cq_info *cq_info,
361369
int ionic_heartbeat_check(struct ionic *ionic);
362370
bool ionic_is_fw_running(struct ionic_dev *idev);
363371

372+
bool ionic_adminq_poke_doorbell(struct ionic_queue *q);
373+
bool ionic_txq_poke_doorbell(struct ionic_queue *q);
374+
bool ionic_rxq_poke_doorbell(struct ionic_queue *q);
375+
364376
#endif /* _IONIC_DEV_H_ */

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

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "ionic.h"
1818
#include "ionic_bus.h"
19+
#include "ionic_dev.h"
1920
#include "ionic_lif.h"
2021
#include "ionic_txrx.h"
2122
#include "ionic_ethtool.h"
@@ -200,6 +201,13 @@ void ionic_link_status_check_request(struct ionic_lif *lif, bool can_sleep)
200201
}
201202
}
202203

204+
static void ionic_napi_deadline(struct timer_list *timer)
205+
{
206+
struct ionic_qcq *qcq = container_of(timer, struct ionic_qcq, napi_deadline);
207+
208+
napi_schedule(&qcq->napi);
209+
}
210+
203211
static irqreturn_t ionic_isr(int irq, void *data)
204212
{
205213
struct napi_struct *napi = data;
@@ -269,23 +277,32 @@ static int ionic_qcq_enable(struct ionic_qcq *qcq)
269277
.oper = IONIC_Q_ENABLE,
270278
},
271279
};
280+
int ret;
272281

273282
idev = &lif->ionic->idev;
274283
dev = lif->ionic->dev;
275284

276285
dev_dbg(dev, "q_enable.index %d q_enable.qtype %d\n",
277286
ctx.cmd.q_control.index, ctx.cmd.q_control.type);
278287

288+
if (qcq->flags & IONIC_QCQ_F_INTR)
289+
ionic_intr_clean(idev->intr_ctrl, qcq->intr.index);
290+
291+
ret = ionic_adminq_post_wait(lif, &ctx);
292+
if (ret)
293+
return ret;
294+
295+
if (qcq->napi.poll)
296+
napi_enable(&qcq->napi);
297+
279298
if (qcq->flags & IONIC_QCQ_F_INTR) {
280299
irq_set_affinity_hint(qcq->intr.vector,
281300
&qcq->intr.affinity_mask);
282-
napi_enable(&qcq->napi);
283-
ionic_intr_clean(idev->intr_ctrl, qcq->intr.index);
284301
ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
285302
IONIC_INTR_MASK_CLEAR);
286303
}
287304

288-
return ionic_adminq_post_wait(lif, &ctx);
305+
return 0;
289306
}
290307

291308
static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int fw_err)
@@ -316,6 +333,7 @@ static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int f
316333
synchronize_irq(qcq->intr.vector);
317334
irq_set_affinity_hint(qcq->intr.vector, NULL);
318335
napi_disable(&qcq->napi);
336+
del_timer_sync(&qcq->napi_deadline);
319337
}
320338

321339
/* If there was a previous fw communcation error, don't bother with
@@ -451,6 +469,7 @@ static void ionic_link_qcq_interrupts(struct ionic_qcq *src_qcq,
451469

452470
n_qcq->intr.vector = src_qcq->intr.vector;
453471
n_qcq->intr.index = src_qcq->intr.index;
472+
n_qcq->napi_qcq = src_qcq->napi_qcq;
454473
}
455474

456475
static int ionic_alloc_qcq_interrupt(struct ionic_lif *lif, struct ionic_qcq *qcq)
@@ -564,13 +583,15 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
564583
}
565584

566585
if (flags & IONIC_QCQ_F_NOTIFYQ) {
567-
int q_size, cq_size;
586+
int q_size;
568587

569-
/* q & cq need to be contiguous in case of notifyq */
588+
/* q & cq need to be contiguous in NotifyQ, so alloc it all in q
589+
* and don't alloc qc. We leave new->qc_size and new->qc_base
590+
* as 0 to be sure we don't try to free it later.
591+
*/
570592
q_size = ALIGN(num_descs * desc_size, PAGE_SIZE);
571-
cq_size = ALIGN(num_descs * cq_desc_size, PAGE_SIZE);
572-
573-
new->q_size = PAGE_SIZE + q_size + cq_size;
593+
new->q_size = PAGE_SIZE + q_size +
594+
ALIGN(num_descs * cq_desc_size, PAGE_SIZE);
574595
new->q_base = dma_alloc_coherent(dev, new->q_size,
575596
&new->q_base_pa, GFP_KERNEL);
576597
if (!new->q_base) {
@@ -773,8 +794,14 @@ static int ionic_lif_txq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)
773794
dev_dbg(dev, "txq->hw_type %d\n", q->hw_type);
774795
dev_dbg(dev, "txq->hw_index %d\n", q->hw_index);
775796

776-
if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state))
797+
q->dbell_deadline = IONIC_TX_DOORBELL_DEADLINE;
798+
q->dbell_jiffies = jiffies;
799+
800+
if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) {
777801
netif_napi_add(lif->netdev, &qcq->napi, ionic_tx_napi);
802+
qcq->napi_qcq = qcq;
803+
timer_setup(&qcq->napi_deadline, ionic_napi_deadline, 0);
804+
}
778805

779806
qcq->flags |= IONIC_QCQ_F_INITED;
780807

@@ -828,11 +855,17 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)
828855
dev_dbg(dev, "rxq->hw_type %d\n", q->hw_type);
829856
dev_dbg(dev, "rxq->hw_index %d\n", q->hw_index);
830857

858+
q->dbell_deadline = IONIC_RX_MIN_DOORBELL_DEADLINE;
859+
q->dbell_jiffies = jiffies;
860+
831861
if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state))
832862
netif_napi_add(lif->netdev, &qcq->napi, ionic_rx_napi);
833863
else
834864
netif_napi_add(lif->netdev, &qcq->napi, ionic_txrx_napi);
835865

866+
qcq->napi_qcq = qcq;
867+
timer_setup(&qcq->napi_deadline, ionic_napi_deadline, 0);
868+
836869
qcq->flags |= IONIC_QCQ_F_INITED;
837870

838871
return 0;
@@ -1150,6 +1183,7 @@ static int ionic_adminq_napi(struct napi_struct *napi, int budget)
11501183
struct ionic_dev *idev = &lif->ionic->idev;
11511184
unsigned long irqflags;
11521185
unsigned int flags = 0;
1186+
bool resched = false;
11531187
int rx_work = 0;
11541188
int tx_work = 0;
11551189
int n_work = 0;
@@ -1187,6 +1221,16 @@ static int ionic_adminq_napi(struct napi_struct *napi, int budget)
11871221
ionic_intr_credits(idev->intr_ctrl, intr->index, credits, flags);
11881222
}
11891223

1224+
if (!a_work && ionic_adminq_poke_doorbell(&lif->adminqcq->q))
1225+
resched = true;
1226+
if (lif->hwstamp_rxq && !rx_work && ionic_rxq_poke_doorbell(&lif->hwstamp_rxq->q))
1227+
resched = true;
1228+
if (lif->hwstamp_txq && !tx_work && ionic_txq_poke_doorbell(&lif->hwstamp_txq->q))
1229+
resched = true;
1230+
if (resched)
1231+
mod_timer(&lif->adminqcq->napi_deadline,
1232+
jiffies + IONIC_NAPI_DEADLINE);
1233+
11901234
return work_done;
11911235
}
11921236

@@ -3245,8 +3289,14 @@ static int ionic_lif_adminq_init(struct ionic_lif *lif)
32453289
dev_dbg(dev, "adminq->hw_type %d\n", q->hw_type);
32463290
dev_dbg(dev, "adminq->hw_index %d\n", q->hw_index);
32473291

3292+
q->dbell_deadline = IONIC_ADMIN_DOORBELL_DEADLINE;
3293+
q->dbell_jiffies = jiffies;
3294+
32483295
netif_napi_add(lif->netdev, &qcq->napi, ionic_adminq_napi);
32493296

3297+
qcq->napi_qcq = qcq;
3298+
timer_setup(&qcq->napi_deadline, ionic_napi_deadline, 0);
3299+
32503300
napi_enable(&qcq->napi);
32513301

32523302
if (qcq->flags & IONIC_QCQ_F_INTR)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ struct ionic_qcq {
7474
struct ionic_queue q;
7575
struct ionic_cq cq;
7676
struct ionic_intr_info intr;
77+
struct timer_list napi_deadline;
7778
struct napi_struct napi;
7879
unsigned int flags;
80+
struct ionic_qcq *napi_qcq;
7981
struct dentry *dentry;
8082
};
8183

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,35 @@ static void ionic_adminq_cb(struct ionic_queue *q,
289289
complete_all(&ctx->work);
290290
}
291291

292+
bool ionic_adminq_poke_doorbell(struct ionic_queue *q)
293+
{
294+
struct ionic_lif *lif = q->lif;
295+
unsigned long now, then, dif;
296+
unsigned long irqflags;
297+
298+
spin_lock_irqsave(&lif->adminq_lock, irqflags);
299+
300+
if (q->tail_idx == q->head_idx) {
301+
spin_unlock_irqrestore(&lif->adminq_lock, irqflags);
302+
return false;
303+
}
304+
305+
now = READ_ONCE(jiffies);
306+
then = q->dbell_jiffies;
307+
dif = now - then;
308+
309+
if (dif > q->dbell_deadline) {
310+
ionic_dbell_ring(q->lif->kern_dbpage, q->hw_type,
311+
q->dbval | q->head_idx);
312+
313+
q->dbell_jiffies = now;
314+
}
315+
316+
spin_unlock_irqrestore(&lif->adminq_lock, irqflags);
317+
318+
return true;
319+
}
320+
292321
int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
293322
{
294323
struct ionic_desc_info *desc_info;

0 commit comments

Comments
 (0)