All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them
@ 2024-04-17  9:54 ` Siddharth Vadapalli
  0 siblings, 0 replies; 6+ messages in thread
From: Siddharth Vadapalli @ 2024-04-17  9:54 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, rogerq, dan.carpenter, robh,
	jpanis, u.kleine-koenig
  Cc: netdev, linux-kernel, linux-arm-kernel, spatton, srk, s-vadapalli

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: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Reported-by: Schuyler Patton <spatton@ti.com>
Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---
Hello,

This patch is based on commit:
96fca68c4fbf Merge tag 'nfsd-6.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
of mainline Linux.

Regards,
Siddharth.

 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index bfba883d4fc4..259d7cb13f6e 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -3260,6 +3260,8 @@ static void am65_cpsw_unregister_devlink(struct am65_cpsw_common *common)
 
 static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
 {
+	struct am65_cpsw_rx_chn *rx_chan = &common->rx_chns;
+	struct am65_cpsw_tx_chn *tx_chan = common->tx_chns;
 	struct device *dev = common->dev;
 	struct am65_cpsw_port *port;
 	int ret = 0, i;
@@ -3272,6 +3274,22 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
 	if (ret)
 		return ret;
 
+	/* The DMA Channels are not guaranteed to be in a clean state.
+	 * Reset and disable them to ensure that they are back to the
+	 * clean state and ready to be used.
+	 */
+	for (i = 0; i < common->tx_ch_num; i++) {
+		k3_udma_glue_reset_tx_chn(tx_chan[i].tx_chn, &tx_chan[i],
+					  am65_cpsw_nuss_tx_cleanup);
+		k3_udma_glue_disable_tx_chn(tx_chan[i].tx_chn);
+	}
+
+	for (i = 0; i < AM65_CPSW_MAX_RX_FLOWS; i++)
+		k3_udma_glue_reset_rx_chn(rx_chan->rx_chn, i, rx_chan,
+					  am65_cpsw_nuss_rx_cleanup, !!i);
+
+	k3_udma_glue_disable_rx_chn(rx_chan->rx_chn);
+
 	ret = am65_cpsw_nuss_register_devlink(common);
 	if (ret)
 		return ret;
-- 
2.40.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net] net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them
@ 2024-04-17  9:54 ` Siddharth Vadapalli
  0 siblings, 0 replies; 6+ messages in thread
From: Siddharth Vadapalli @ 2024-04-17  9:54 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, rogerq, dan.carpenter, robh,
	jpanis, u.kleine-koenig
  Cc: netdev, linux-kernel, linux-arm-kernel, spatton, srk, s-vadapalli

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: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Reported-by: Schuyler Patton <spatton@ti.com>
Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---
Hello,

This patch is based on commit:
96fca68c4fbf Merge tag 'nfsd-6.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
of mainline Linux.

Regards,
Siddharth.

 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index bfba883d4fc4..259d7cb13f6e 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -3260,6 +3260,8 @@ static void am65_cpsw_unregister_devlink(struct am65_cpsw_common *common)
 
 static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
 {
+	struct am65_cpsw_rx_chn *rx_chan = &common->rx_chns;
+	struct am65_cpsw_tx_chn *tx_chan = common->tx_chns;
 	struct device *dev = common->dev;
 	struct am65_cpsw_port *port;
 	int ret = 0, i;
@@ -3272,6 +3274,22 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
 	if (ret)
 		return ret;
 
+	/* The DMA Channels are not guaranteed to be in a clean state.
+	 * Reset and disable them to ensure that they are back to the
+	 * clean state and ready to be used.
+	 */
+	for (i = 0; i < common->tx_ch_num; i++) {
+		k3_udma_glue_reset_tx_chn(tx_chan[i].tx_chn, &tx_chan[i],
+					  am65_cpsw_nuss_tx_cleanup);
+		k3_udma_glue_disable_tx_chn(tx_chan[i].tx_chn);
+	}
+
+	for (i = 0; i < AM65_CPSW_MAX_RX_FLOWS; i++)
+		k3_udma_glue_reset_rx_chn(rx_chan->rx_chn, i, rx_chan,
+					  am65_cpsw_nuss_rx_cleanup, !!i);
+
+	k3_udma_glue_disable_rx_chn(rx_chan->rx_chn);
+
 	ret = am65_cpsw_nuss_register_devlink(common);
 	if (ret)
 		return ret;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them
  2024-04-17  9:54 ` Siddharth Vadapalli
@ 2024-04-17 15:51   ` Roger Quadros
  -1 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2024-04-17 15:51 UTC (permalink / raw)
  To: Siddharth Vadapalli, davem, edumazet, kuba, pabeni,
	dan.carpenter, robh, jpanis, u.kleine-koenig
  Cc: netdev, linux-kernel, linux-arm-kernel, spatton, srk

On 17/04/2024 12:54, Siddharth Vadapalli wrote:
> 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: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Reported-by: Schuyler Patton <spatton@ti.com>
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Reviewed-by: Roger Quadros <rogerq@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them
@ 2024-04-17 15:51   ` Roger Quadros
  0 siblings, 0 replies; 6+ messages in thread
From: Roger Quadros @ 2024-04-17 15:51 UTC (permalink / raw)
  To: Siddharth Vadapalli, davem, edumazet, kuba, pabeni,
	dan.carpenter, robh, jpanis, u.kleine-koenig
  Cc: netdev, linux-kernel, linux-arm-kernel, spatton, srk

On 17/04/2024 12:54, Siddharth Vadapalli wrote:
> 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: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Reported-by: Schuyler Patton <spatton@ti.com>
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Reviewed-by: Roger Quadros <rogerq@kernel.org>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them
  2024-04-17  9:54 ` Siddharth Vadapalli
@ 2024-04-18 17:00   ` patchwork-bot+netdevbpf
  -1 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-18 17:00 UTC (permalink / raw)
  To: Siddharth Vadapalli
  Cc: davem, edumazet, kuba, pabeni, rogerq, dan.carpenter, robh,
	jpanis, u.kleine-koenig, netdev, linux-kernel, linux-arm-kernel,
	spatton, srk

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 17 Apr 2024 15:24:25 +0530 you wrote:
> 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: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Reported-by: Schuyler Patton <spatton@ti.com>
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> 
> [...]

Here is the summary with links:
  - [net] net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them
    https://git.kernel.org/netdev/net/c/c24cd679b075

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them
@ 2024-04-18 17:00   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-18 17:00 UTC (permalink / raw)
  To: Siddharth Vadapalli
  Cc: davem, edumazet, kuba, pabeni, rogerq, dan.carpenter, robh,
	jpanis, u.kleine-koenig, netdev, linux-kernel, linux-arm-kernel,
	spatton, srk

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 17 Apr 2024 15:24:25 +0530 you wrote:
> 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: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Reported-by: Schuyler Patton <spatton@ti.com>
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> 
> [...]

Here is the summary with links:
  - [net] net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them
    https://git.kernel.org/netdev/net/c/c24cd679b075

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-18 17:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17  9:54 [PATCH net] net: ethernet: ti: am65-cpsw-nuss: cleanup DMA Channels before using them Siddharth Vadapalli
2024-04-17  9:54 ` Siddharth Vadapalli
2024-04-17 15:51 ` Roger Quadros
2024-04-17 15:51   ` Roger Quadros
2024-04-18 17:00 ` patchwork-bot+netdevbpf
2024-04-18 17:00   ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.