• Sebastian Andrzej Siewior's avatar
    soc/fsl/qbman: Add an argument to signal if NAPI processing is required. · f84754db
    Sebastian Andrzej Siewior authored
    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: default avatarSebastian 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: default avatarHoria Geantă <horia.geanta@nxp.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    Reviewed-by: default avatarMadalin Bucur <madalin.bucur@oss.nxp.com>
    Tested-by: default avatarCamelia Groza <camelia.groza@nxp.com>
    f84754db
qman.h 42.5 KB