Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc/fsl/qbman: Add an argument to signal if NAPI processing is required.

dpaa_eth_napi_schedule() and caam_qi_napi_schedule() schedule NAPI if
invoked from:

- Hard interrupt context
- Any context which is not serving soft interrupts

Any context which is not serving soft interrupts includes hard interrupts
so the in_irq() check is redundant. caam_qi_napi_schedule() has a comment
about this:

/*
* In case of threaded ISR, for RT kernels in_irq() does not return
* appropriate value, so use in_serving_softirq to distinguish between
* softirq and irq contexts.
*/
if (in_irq() || !in_serving_softirq())

This has nothing to do with RT. Even on a non RT kernel force threaded
interrupts run obviously in thread context and therefore in_irq() returns
false when invoked from the handler.

The extension of the in_irq() check with !in_serving_softirq() was there
when the drivers were added, but in the out of tree FSL BSP the original
condition was in_irq() which got extended due to failures on RT.

The usage of in_xxx() in drivers is phased out and Linus clearly requested
that code which changes behaviour depending on context should either be
separated or the context be conveyed in an argument passed by the caller,
which usually knows the context. Right he is, the above construct is
clearly showing why.

The following callchains have been analyzed to end up in
dpaa_eth_napi_schedule():

qman_p_poll_dqrr()
__poll_portal_fast()
fq->cb.dqrr()
dpaa_eth_napi_schedule()

portal_isr()
__poll_portal_fast()
fq->cb.dqrr()
dpaa_eth_napi_schedule()

Both need to schedule NAPI.
The crypto part has another code path leading up to this:
kill_fq()
empty_retired_fq()
qman_p_poll_dqrr()
__poll_portal_fast()
fq->cb.dqrr()
dpaa_eth_napi_schedule()

kill_fq() is called from task context and ends up scheduling NAPI, but
that's pointless and an unintended side effect of the !in_serving_softirq()
check.

The code path:
caam_qi_poll() -> qman_p_poll_dqrr()

is invoked from NAPI and I *assume* from crypto's NAPI device and not
from qbman's NAPI device. I *guess* it is okay to skip scheduling NAPI
(because this is what happens now) but could be changed if it is wrong
due to `budget' handling.

Add an argument to __poll_portal_fast() which is true if NAPI needs to be
scheduled. This requires propagating the value to the caller including
`qman_cb_dqrr' typedef which is used by the dpaa and the crypto driver.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Aymen Sghaier <aymen.sghaier@nxp.com>
Cc: Herbert XS <herbert@gondor.apana.org.au>
Cc: Li Yang <leoyang.li@nxp.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Madalin Bucur <madalin.bucur@oss.nxp.com>
Tested-by: Camelia Groza <camelia.groza@nxp.com>

authored by

Sebastian Andrzej Siewior and committed by
Jakub Kicinski
f84754db e9e13b6a

+26 -16
+2 -1
drivers/crypto/caam/qi.c
··· 564 564 565 565 static enum qman_cb_dqrr_result caam_rsp_fq_dqrr_cb(struct qman_portal *p, 566 566 struct qman_fq *rsp_fq, 567 - const struct qm_dqrr_entry *dqrr) 567 + const struct qm_dqrr_entry *dqrr, 568 + bool sched_napi) 568 569 { 569 570 struct caam_napi *caam_napi = raw_cpu_ptr(&pcpu_qipriv.caam_napi); 570 571 struct caam_drv_req *drv_req;
+8 -4
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
··· 2316 2316 2317 2317 static enum qman_cb_dqrr_result rx_error_dqrr(struct qman_portal *portal, 2318 2318 struct qman_fq *fq, 2319 - const struct qm_dqrr_entry *dq) 2319 + const struct qm_dqrr_entry *dq, 2320 + bool sched_napi) 2320 2321 { 2321 2322 struct dpaa_fq *dpaa_fq = container_of(fq, struct dpaa_fq, fq_base); 2322 2323 struct dpaa_percpu_priv *percpu_priv; ··· 2344 2343 2345 2344 static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal, 2346 2345 struct qman_fq *fq, 2347 - const struct qm_dqrr_entry *dq) 2346 + const struct qm_dqrr_entry *dq, 2347 + bool sched_napi) 2348 2348 { 2349 2349 struct skb_shared_hwtstamps *shhwtstamps; 2350 2350 struct rtnl_link_stats64 *percpu_stats; ··· 2462 2460 2463 2461 static enum qman_cb_dqrr_result conf_error_dqrr(struct qman_portal *portal, 2464 2462 struct qman_fq *fq, 2465 - const struct qm_dqrr_entry *dq) 2463 + const struct qm_dqrr_entry *dq, 2464 + bool sched_napi) 2466 2465 { 2467 2466 struct dpaa_percpu_priv *percpu_priv; 2468 2467 struct net_device *net_dev; ··· 2484 2481 2485 2482 static enum qman_cb_dqrr_result conf_dflt_dqrr(struct qman_portal *portal, 2486 2483 struct qman_fq *fq, 2487 - const struct qm_dqrr_entry *dq) 2484 + const struct qm_dqrr_entry *dq, 2485 + bool sched_napi) 2488 2486 { 2489 2487 struct dpaa_percpu_priv *percpu_priv; 2490 2488 struct net_device *net_dev;
+6 -6
drivers/soc/fsl/qbman/qman.c
··· 1159 1159 1160 1160 static u32 __poll_portal_slow(struct qman_portal *p, u32 is); 1161 1161 static inline unsigned int __poll_portal_fast(struct qman_portal *p, 1162 - unsigned int poll_limit); 1162 + unsigned int poll_limit, bool sched_napi); 1163 1163 static void qm_congestion_task(struct work_struct *work); 1164 1164 static void qm_mr_process_task(struct work_struct *work); 1165 1165 ··· 1174 1174 1175 1175 /* DQRR-handling if it's interrupt-driven */ 1176 1176 if (is & QM_PIRQ_DQRI) { 1177 - __poll_portal_fast(p, QMAN_POLL_LIMIT); 1177 + __poll_portal_fast(p, QMAN_POLL_LIMIT, true); 1178 1178 clear = QM_DQAVAIL_MASK | QM_PIRQ_DQRI; 1179 1179 } 1180 1180 /* Handling of anything else that's interrupt-driven */ ··· 1602 1602 * user callbacks to call into any QMan API. 1603 1603 */ 1604 1604 static inline unsigned int __poll_portal_fast(struct qman_portal *p, 1605 - unsigned int poll_limit) 1605 + unsigned int poll_limit, bool sched_napi) 1606 1606 { 1607 1607 const struct qm_dqrr_entry *dq; 1608 1608 struct qman_fq *fq; ··· 1636 1636 * and we don't want multiple if()s in the critical 1637 1637 * path (SDQCR). 1638 1638 */ 1639 - res = fq->cb.dqrr(p, fq, dq); 1639 + res = fq->cb.dqrr(p, fq, dq, sched_napi); 1640 1640 if (res == qman_cb_dqrr_stop) 1641 1641 break; 1642 1642 /* Check for VDQCR completion */ ··· 1646 1646 /* SDQCR: context_b points to the FQ */ 1647 1647 fq = tag_to_fq(be32_to_cpu(dq->context_b)); 1648 1648 /* Now let the callback do its stuff */ 1649 - res = fq->cb.dqrr(p, fq, dq); 1649 + res = fq->cb.dqrr(p, fq, dq, sched_napi); 1650 1650 /* 1651 1651 * The callback can request that we exit without 1652 1652 * consuming this entry nor advancing; ··· 1753 1753 1754 1754 int qman_p_poll_dqrr(struct qman_portal *p, unsigned int limit) 1755 1755 { 1756 - return __poll_portal_fast(p, limit); 1756 + return __poll_portal_fast(p, limit, false); 1757 1757 } 1758 1758 EXPORT_SYMBOL(qman_p_poll_dqrr); 1759 1759
+4 -2
drivers/soc/fsl/qbman/qman_test_api.c
··· 45 45 46 46 static enum qman_cb_dqrr_result cb_dqrr(struct qman_portal *, 47 47 struct qman_fq *, 48 - const struct qm_dqrr_entry *); 48 + const struct qm_dqrr_entry *, 49 + bool sched_napi); 49 50 static void cb_ern(struct qman_portal *, struct qman_fq *, 50 51 const union qm_mr_entry *); 51 52 static void cb_fqs(struct qman_portal *, struct qman_fq *, ··· 209 208 210 209 static enum qman_cb_dqrr_result cb_dqrr(struct qman_portal *p, 211 210 struct qman_fq *fq, 212 - const struct qm_dqrr_entry *dq) 211 + const struct qm_dqrr_entry *dq, 212 + bool sched_napi) 213 213 { 214 214 if (WARN_ON(fd_neq(&fd_dq, &dq->fd))) { 215 215 pr_err("BADNESS: dequeued frame doesn't match;\n");
+4 -2
drivers/soc/fsl/qbman/qman_test_stash.c
··· 275 275 276 276 static enum qman_cb_dqrr_result normal_dqrr(struct qman_portal *portal, 277 277 struct qman_fq *fq, 278 - const struct qm_dqrr_entry *dqrr) 278 + const struct qm_dqrr_entry *dqrr, 279 + bool sched_napi) 279 280 { 280 281 struct hp_handler *handler = (struct hp_handler *)fq; 281 282 ··· 294 293 295 294 static enum qman_cb_dqrr_result special_dqrr(struct qman_portal *portal, 296 295 struct qman_fq *fq, 297 - const struct qm_dqrr_entry *dqrr) 296 + const struct qm_dqrr_entry *dqrr, 297 + bool sched_napi) 298 298 { 299 299 struct hp_handler *handler = (struct hp_handler *)fq; 300 300
+2 -1
include/soc/fsl/qman.h
··· 689 689 }; 690 690 typedef enum qman_cb_dqrr_result (*qman_cb_dqrr)(struct qman_portal *qm, 691 691 struct qman_fq *fq, 692 - const struct qm_dqrr_entry *dqrr); 692 + const struct qm_dqrr_entry *dqrr, 693 + bool sched_napi); 693 694 694 695 /* 695 696 * This callback type is used when handling ERNs, FQRNs and FQRLs via MR. They