The periodic callout function and the interrupt handler both modify the
periodic flags. There is a possible race condition when an application
is going through dev_stop()/dev_start() and an interrupt handler is
invoked. We also need to ensure that periodic polling is not invoked in
interrupt context.
This patch handles such case by using separate variable to check for
interrupt context. Also, atomically load and store the periodic flag
value.
Fixes:
0f6ebeee2402 ("net/bnx2x: fix call to link handling periodic function")
Cc: stable@dpdk.org
Signed-off-by: Rasesh Mody <rmody@marvell.com>
-bnx2x_interrupt_action(struct rte_eth_dev *dev)
+bnx2x_interrupt_action(struct rte_eth_dev *dev, int intr_cxt)
{
struct bnx2x_softc *sc = dev->data->dev_private;
uint32_t link_status;
bnx2x_intr_legacy(sc);
{
struct bnx2x_softc *sc = dev->data->dev_private;
uint32_t link_status;
bnx2x_intr_legacy(sc);
- if (sc->periodic_flags & PERIODIC_GO)
+ if ((atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_GO) &&
+ !intr_cxt)
bnx2x_periodic_callout(sc);
link_status = REG_RD(sc, sc->link_params.shmem_base +
offsetof(struct shmem_region,
bnx2x_periodic_callout(sc);
link_status = REG_RD(sc, sc->link_params.shmem_base +
offsetof(struct shmem_region,
PMD_DEBUG_PERIODIC_LOG(INFO, sc, "Interrupt handled");
PMD_DEBUG_PERIODIC_LOG(INFO, sc, "Interrupt handled");
- atomic_store_rel_long(&sc->periodic_flags, PERIODIC_STOP);
- bnx2x_interrupt_action(dev);
- atomic_store_rel_long(&sc->periodic_flags, PERIODIC_GO);
+ bnx2x_interrupt_action(dev, 1);
rte_intr_enable(&sc->pci_dev->intr_handle);
}
rte_intr_enable(&sc->pci_dev->intr_handle);
}
int ret = 0;
atomic_store_rel_long(&sc->periodic_flags, PERIODIC_GO);
int ret = 0;
atomic_store_rel_long(&sc->periodic_flags, PERIODIC_GO);
- bnx2x_interrupt_action(dev);
+ bnx2x_interrupt_action(dev, 0);
if (IS_PF(sc)) {
ret = rte_eal_alarm_set(BNX2X_SP_TIMER_PERIOD,
bnx2x_periodic_start, (void *)dev);
if (IS_PF(sc)) {
ret = rte_eal_alarm_set(BNX2X_SP_TIMER_PERIOD,
bnx2x_periodic_start, (void *)dev);
atomic_store_rel_long(&sc->periodic_flags, PERIODIC_STOP);
rte_eal_alarm_cancel(bnx2x_periodic_start, (void *)dev);
atomic_store_rel_long(&sc->periodic_flags, PERIODIC_STOP);
rte_eal_alarm_cancel(bnx2x_periodic_start, (void *)dev);
+
+ PMD_DRV_LOG(DEBUG, sc, "Periodic poll stopped");
PMD_INIT_FUNC_TRACE(sc);
/* start the periodic callout */
PMD_INIT_FUNC_TRACE(sc);
/* start the periodic callout */
- if (sc->periodic_flags & PERIODIC_STOP)
+ if (atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_STOP) {
bnx2x_periodic_start(dev);
bnx2x_periodic_start(dev);
+ PMD_DRV_LOG(DEBUG, sc, "Periodic poll re-started");
+ }
ret = bnx2x_init(sc);
if (ret) {
ret = bnx2x_init(sc);
if (ret) {