diff mbox

net: bcmgenet: fix uncleaned dma flags

Message ID 1440040627-59949-1-git-send-email-jaedon.shin@gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Jaedon Shin Aug. 20, 2015, 3:17 a.m. UTC
Clean the dma flags of multiq ring buffer int the interface stop
process. This patch fixes that the genet is not running while the
interface is re-enabled.

$ ifup eth0 - running after booting
$ ifdown eth0
$ ifup eth0 - not running and occur tx_timeout

The bcmgenet_dma_disable() in bcmgenet_open() do clean ring16 dma flag
only. If the genet has multiq, the dma register is not cleaned. and
bcmgenet_init_dma() is not done correctly. in case
GENET_V2(tx_queues=4), tdma_ctrl has 0x1e after running
bcmgenet_dma_disable().

Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Florian Fainelli Aug. 20, 2015, 10:04 p.m. UTC | #1
On 19/08/15 20:17, Jaedon Shin wrote:
> Clean the dma flags of multiq ring buffer int the interface stop
> process. This patch fixes that the genet is not running while the
> interface is re-enabled.
> 
> $ ifup eth0 - running after booting
> $ ifdown eth0
> $ ifup eth0 - not running and occur tx_timeout
> 
> The bcmgenet_dma_disable() in bcmgenet_open() do clean ring16 dma flag
> only. If the genet has multiq, the dma register is not cleaned. and
> bcmgenet_init_dma() is not done correctly. in case
> GENET_V2(tx_queues=4), tdma_ctrl has 0x1e after running
> bcmgenet_dma_disable().

It sounds like this should be moved to bcmgenet_dma_disable() where we
are already modifying DMA_CTRL and returning a dma_ctrl value back to
the caller, or at the very last bcmgenet_dma_teardown().

Thanks!

> 
> Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
> ---
>  drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 64c1e9db6b0b..81bde6fa70b7 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -2174,6 +2174,8 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv)
>  
>  static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
>  {
> +	u32 dma_ctrl;
> +	u32 reg;
>  	int i;
>  
>  	bcmgenet_fini_rx_napi(priv);
> @@ -2182,6 +2184,20 @@ static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
>  	/* disable DMA */
>  	bcmgenet_dma_teardown(priv);
>  
> +	dma_ctrl = 0;
> +	for (i = 0; i < priv->hw_params->rx_queues; i++)
> +		dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT));
> +	reg = bcmgenet_rdma_readl(priv, DMA_CTRL);
> +	reg &= ~dma_ctrl;
> +	bcmgenet_rdma_writel(priv, reg, DMA_CTRL);
> +
> +	dma_ctrl = 0;
> +	for (i = 0; i < priv->hw_params->tx_queues; i++)
> +		dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT));
> +	reg = bcmgenet_tdma_readl(priv, DMA_CTRL);
> +	reg &= ~dma_ctrl;
> +	bcmgenet_tdma_writel(priv, reg, DMA_CTRL);
> +
>  	for (i = 0; i < priv->num_tx_bds; i++) {
>  		if (priv->tx_cbs[i].skb != NULL) {
>  			dev_kfree_skb(priv->tx_cbs[i].skb);
>
Jaedon Shin Aug. 21, 2015, 1:12 a.m. UTC | #2
> 2015. 8. 21., 오전 7:04, Florian Fainelli <f.fainelli@gmail.com> 작성:
> 
> On 19/08/15 20:17, Jaedon Shin wrote:
>> Clean the dma flags of multiq ring buffer int the interface stop
>> process. This patch fixes that the genet is not running while the
>> interface is re-enabled.
>> 
>> $ ifup eth0 - running after booting
>> $ ifdown eth0
>> $ ifup eth0 - not running and occur tx_timeout
>> 
>> The bcmgenet_dma_disable() in bcmgenet_open() do clean ring16 dma flag
>> only. If the genet has multiq, the dma register is not cleaned. and
>> bcmgenet_init_dma() is not done correctly. in case
>> GENET_V2(tx_queues=4), tdma_ctrl has 0x1e after running
>> bcmgenet_dma_disable().
> 
> It sounds like this should be moved to bcmgenet_dma_disable() where we
> are already modifying DMA_CTRL and returning a dma_ctrl value back to
> the caller, or at the very last bcmgenet_dma_teardown().
> 
> Thanks!
> 

I will send the changes immediately.

Thanks.

>> 
>> Signed-off-by: Jaedon Shin <jaedon.shin@gmail.com>
>> ---
>> drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>> 
>> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
>> index 64c1e9db6b0b..81bde6fa70b7 100644
>> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
>> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
>> @@ -2174,6 +2174,8 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv)
>> 
>> static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
>> {
>> +	u32 dma_ctrl;
>> +	u32 reg;
>> 	int i;
>> 
>> 	bcmgenet_fini_rx_napi(priv);
>> @@ -2182,6 +2184,20 @@ static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
>> 	/* disable DMA */
>> 	bcmgenet_dma_teardown(priv);
>> 
>> +	dma_ctrl = 0;
>> +	for (i = 0; i < priv->hw_params->rx_queues; i++)
>> +		dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT));
>> +	reg = bcmgenet_rdma_readl(priv, DMA_CTRL);
>> +	reg &= ~dma_ctrl;
>> +	bcmgenet_rdma_writel(priv, reg, DMA_CTRL);
>> +
>> +	dma_ctrl = 0;
>> +	for (i = 0; i < priv->hw_params->tx_queues; i++)
>> +		dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT));
>> +	reg = bcmgenet_tdma_readl(priv, DMA_CTRL);
>> +	reg &= ~dma_ctrl;
>> +	bcmgenet_tdma_writel(priv, reg, DMA_CTRL);
>> +
>> 	for (i = 0; i < priv->num_tx_bds; i++) {
>> 		if (priv->tx_cbs[i].skb != NULL) {
>> 			dev_kfree_skb(priv->tx_cbs[i].skb);
>> 
> 
> 
> -- 
> Florian

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 64c1e9db6b0b..81bde6fa70b7 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2174,6 +2174,8 @@  static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv)
 
 static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
 {
+	u32 dma_ctrl;
+	u32 reg;
 	int i;
 
 	bcmgenet_fini_rx_napi(priv);
@@ -2182,6 +2184,20 @@  static void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
 	/* disable DMA */
 	bcmgenet_dma_teardown(priv);
 
+	dma_ctrl = 0;
+	for (i = 0; i < priv->hw_params->rx_queues; i++)
+		dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT));
+	reg = bcmgenet_rdma_readl(priv, DMA_CTRL);
+	reg &= ~dma_ctrl;
+	bcmgenet_rdma_writel(priv, reg, DMA_CTRL);
+
+	dma_ctrl = 0;
+	for (i = 0; i < priv->hw_params->tx_queues; i++)
+		dma_ctrl |= (1 << (i + DMA_RING_BUF_EN_SHIFT));
+	reg = bcmgenet_tdma_readl(priv, DMA_CTRL);
+	reg &= ~dma_ctrl;
+	bcmgenet_tdma_writel(priv, reg, DMA_CTRL);
+
 	for (i = 0; i < priv->num_tx_bds; i++) {
 		if (priv->tx_cbs[i].skb != NULL) {
 			dev_kfree_skb(priv->tx_cbs[i].skb);