Skip to content

Commit c24cd67

Browse files
Siddharth-Vadapalli-at-TIkuba-moo
authored andcommitted
net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them
The TX and RX DMA Channels used by the driver to exchange data with CPSW are not guaranteed to be in a clean state during driver initialization. The Bootloader could have used the same DMA Channels without cleaning them up in the event of failure. Thus, reset and disable the DMA Channels to ensure that they are in a clean state before using them. Fixes: 93a7653 ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver") Reported-by: Schuyler Patton <[email protected]> Signed-off-by: Siddharth Vadapalli <[email protected]> Reviewed-by: Roger Quadros <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 56f7861 commit c24cd67

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/net/ethernet/ti/am65-cpsw-nuss.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,6 +2793,8 @@ static void am65_cpsw_unregister_devlink(struct am65_cpsw_common *common)
27932793

27942794
static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
27952795
{
2796+
struct am65_cpsw_rx_chn *rx_chan = &common->rx_chns;
2797+
struct am65_cpsw_tx_chn *tx_chan = common->tx_chns;
27962798
struct device *dev = common->dev;
27972799
struct am65_cpsw_port *port;
27982800
int ret = 0, i;
@@ -2805,6 +2807,22 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
28052807
if (ret)
28062808
return ret;
28072809

2810+
/* The DMA Channels are not guaranteed to be in a clean state.
2811+
* Reset and disable them to ensure that they are back to the
2812+
* clean state and ready to be used.
2813+
*/
2814+
for (i = 0; i < common->tx_ch_num; i++) {
2815+
k3_udma_glue_reset_tx_chn(tx_chan[i].tx_chn, &tx_chan[i],
2816+
am65_cpsw_nuss_tx_cleanup);
2817+
k3_udma_glue_disable_tx_chn(tx_chan[i].tx_chn);
2818+
}
2819+
2820+
for (i = 0; i < AM65_CPSW_MAX_RX_FLOWS; i++)
2821+
k3_udma_glue_reset_rx_chn(rx_chan->rx_chn, i, rx_chan,
2822+
am65_cpsw_nuss_rx_cleanup, !!i);
2823+
2824+
k3_udma_glue_disable_rx_chn(rx_chan->rx_chn);
2825+
28082826
ret = am65_cpsw_nuss_register_devlink(common);
28092827
if (ret)
28102828
return ret;

0 commit comments

Comments
 (0)