linux-stable/drivers/crypto/caam
Sebastian Andrzej Siewior f84754dbc5 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>
2020-11-03 17:41:03 -08:00
..
caamalg.c crypto: caam/jr - add support for XTS with 16B IV 2020-10-02 18:02:12 +10:00
caamalg_desc.c crypto: caam/jr - add support for XTS with 16B IV 2020-10-02 18:02:12 +10:00
caamalg_desc.h crypto: caam - update rfc4106 sh desc to support zero length input 2019-08-09 15:11:48 +10:00
caamalg_qi.c crypto: caam/qi - add support for XTS with 16B IV 2020-10-02 18:02:12 +10:00
caamalg_qi2.c crypto: caam/qi2 - add support for XTS with 16B IV 2020-10-02 18:02:12 +10:00
caamalg_qi2.h crypto: caam/qi2 - add fallback for XTS with more than 8B IV 2020-10-02 18:02:11 +10:00
caamhash.c crypto: drivers - set the flag CRYPTO_ALG_ALLOCATES_MEMORY 2020-07-16 21:49:10 +10:00
caamhash_desc.c crypto: caam - keep both virtual and dma key addresses 2019-08-09 15:11:49 +10:00
caamhash_desc.h crypto: caam - keep both virtual and dma key addresses 2019-08-09 15:11:49 +10:00
caampkc.c mm, treewide: rename kzfree() to kfree_sensitive() 2020-08-07 11:33:22 -07:00
caampkc.h crypto: caam - add crypto_engine support for RSA algorithms 2020-02-22 09:25:48 +08:00
caamrng.c crypto: caam - limit single JD RNG output to maximum of 16 bytes 2020-03-30 11:50:50 +11:00
compat.h crypto: caam - Remove broken arc4 support 2020-07-16 21:49:00 +10:00
ctrl.c crypto: caam - Fix kerneldoc 2020-09-18 17:20:12 +10:00
ctrl.h crypto: caam - staticize caam_get_era() 2018-04-21 00:58:36 +08:00
debugfs.c crypto: caam - Move debugfs fops into standalone file 2020-08-21 14:47:49 +10:00
debugfs.h crypto: caam - Move debugfs fops into standalone file 2020-08-21 14:47:49 +10:00
desc.h crypto: caam - fix typos 2020-06-15 17:38:54 +10:00
desc_constr.h crypto: caam - select DMA address size at runtime 2019-08-30 18:05:30 +10:00
dpseci-debugfs.c crypto: caam - Convert to DEFINE_SHOW_ATTRIBUTE 2020-09-25 17:48:16 +10:00
dpseci-debugfs.h crypto: caam/qi2 - Add printing dpseci fq stats using debugfs 2019-08-02 14:44:01 +10:00
dpseci.c crypto: caam/qi2 - add support for dpseci_reset() 2020-06-18 17:19:45 +10:00
dpseci.h crypto: caam/qi2 - add support for dpseci_reset() 2020-06-18 17:19:45 +10:00
dpseci_cmd.h crypto: caam/qi2 - add support for dpseci_reset() 2020-06-18 17:19:45 +10:00
error.c crypto: caam - add more RNG hw error codes 2020-07-31 18:25:28 +10:00
error.h crypto: caam - fix return code in completion callbacks 2019-08-09 15:11:45 +10:00
intern.h crypto: caam - Move debugfs fops into standalone file 2020-08-21 14:47:49 +10:00
jr.c crypto: caam - Fix kerneldoc 2020-09-18 17:20:12 +10:00
jr.h
Kconfig crypto: caam/qi2 - add fallback for XTS with more than 8B IV 2020-10-02 18:02:11 +10:00
key_gen.c crypto: caam - change return code in caam_jr_enqueue function 2020-02-22 09:25:47 +08:00
key_gen.h
Makefile crypto: caam - Move debugfs fops into standalone file 2020-08-21 14:47:49 +10:00
pdb.h crypto: caam - fix typos 2020-06-15 17:38:54 +10:00
pkc_desc.c crypto: caam - select DMA address size at runtime 2019-08-30 18:05:30 +10:00
qi.c soc/fsl/qbman: Add an argument to signal if NAPI processing is required. 2020-11-03 17:41:03 -08:00
qi.h crypto: caam/qi - optimize frame queue cleanup 2020-02-13 17:05:25 +08:00
regs.h crypto: caam - remove deadcode on 32-bit platforms 2020-07-31 18:25:27 +10:00
sg_sw_qm.h crypto: caam - use len instead of nents for bulding HW S/G table 2019-06-20 14:18:33 +08:00
sg_sw_qm2.h crypto: caam - use len instead of nents for bulding HW S/G table 2019-06-20 14:18:33 +08:00
sg_sw_sec4.h crypto: caam - use len instead of nents for bulding HW S/G table 2019-06-20 14:18:33 +08:00