net: ethernet: ti: am65-cpsw: Add RX DMA Channel Teardown Quirk
authorSiddharth Vadapalli <s-vadapalli@ti.com>
Thu, 9 Feb 2023 08:44:32 +0000 (14:14 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Feb 2023 11:57:08 +0000 (12:57 +0100)
commit 0ed577e7e8e508c24e22ba07713ecc4903e147c3 upstream.

In TI's AM62x/AM64x SoCs, successful teardown of RX DMA Channel raises an
interrupt. The process of servicing this interrupt involves flushing all
pending RX DMA descriptors and clearing the teardown completion marker
(TDCM). The am65_cpsw_nuss_rx_packets() function invoked from the RX
NAPI callback services the interrupt. Thus, it is necessary to wait for
this handler to run, drain all packets and clear TDCM, before calling
napi_disable() in am65_cpsw_nuss_common_stop() function post channel
teardown. If napi_disable() executes before ensuring that TDCM is
cleared, the TDCM remains set when the interfaces are down, resulting in
an interrupt storm when the interfaces are brought up again.

Since the interrupt raised to indicate the RX DMA Channel teardown is
specific to the AM62x and AM64x SoCs, add a quirk for it.

Fixes: 4f7cce272403 ("net: ethernet: ti: am65-cpsw: add support for am64x cpsw3g")
Co-developed-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
Link: https://lore.kernel.org/r/20230209084432.189222-1-s-vadapalli@ti.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/ti/am65-cpsw-nuss.c
drivers/net/ethernet/ti/am65-cpsw-nuss.h

index 2298b3c38f8965564c1e6348954453484a46a8a8..37b9a798dd6241faec003e741efc5826254f05c6 100644 (file)
@@ -564,7 +564,15 @@ static int am65_cpsw_nuss_common_stop(struct am65_cpsw_common *common)
                k3_udma_glue_disable_tx_chn(common->tx_chns[i].tx_chn);
        }
 
+       reinit_completion(&common->tdown_complete);
        k3_udma_glue_tdown_rx_chn(common->rx_chns.rx_chn, true);
+
+       if (common->pdata.quirks & AM64_CPSW_QUIRK_DMA_RX_TDOWN_IRQ) {
+               i = wait_for_completion_timeout(&common->tdown_complete, msecs_to_jiffies(1000));
+               if (!i)
+                       dev_err(common->dev, "rx teardown timeout\n");
+       }
+
        napi_disable(&common->napi_rx);
 
        for (i = 0; i < AM65_CPSW_MAX_RX_FLOWS; i++)
@@ -786,6 +794,8 @@ static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_common *common,
 
        if (cppi5_desc_is_tdcm(desc_dma)) {
                dev_dbg(dev, "%s RX tdown flow: %u\n", __func__, flow_idx);
+               if (common->pdata.quirks & AM64_CPSW_QUIRK_DMA_RX_TDOWN_IRQ)
+                       complete(&common->tdown_complete);
                return 0;
        }
 
@@ -2609,7 +2619,7 @@ static const struct am65_cpsw_pdata j721e_pdata = {
 };
 
 static const struct am65_cpsw_pdata am64x_cpswxg_pdata = {
-       .quirks = 0,
+       .quirks = AM64_CPSW_QUIRK_DMA_RX_TDOWN_IRQ,
        .ale_dev_id = "am64-cpswxg",
        .fdqring_mode = K3_RINGACC_RING_MODE_RING,
 };
index 048ed10143c17dbaa834097751f179a3a0f58763..74569c8ed2eca2f329620eaba4a4755555bb8db0 100644 (file)
@@ -84,6 +84,7 @@ struct am65_cpsw_rx_chn {
 };
 
 #define AM65_CPSW_QUIRK_I2027_NO_TX_CSUM BIT(0)
+#define AM64_CPSW_QUIRK_DMA_RX_TDOWN_IRQ BIT(1)
 
 struct am65_cpsw_pdata {
        u32     quirks;