* [PATCH] ll_temac: Reset dma descriptors on ndo_open
@ 2013-09-27 11:24 Ricardo Ribalda Delgado
2013-10-01 4:21 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2013-09-27 11:24 UTC (permalink / raw)
To: David S. Miller, Joe Perches, Jingoo Han, Greg Kroah-Hartman,
Bill Pemberton, netdev, linux-kernel
Cc: Ricardo Ribalda Delgado
The dma descriptors are only initialized on the probe function.
If a packet is on the buffer when temac_stop is called, the dma
descriptors can be left on a incorrect status where no other package can
be sent.
So an interface could be left in an usable state after ifdow/ifup.
This patch makes sure that the descriptors are in a proper status when
the device is started.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
drivers/net/ethernet/xilinx/ll_temac_main.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index b88121f..8bae87f 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -229,6 +229,25 @@ static void temac_dma_bd_release(struct net_device *ndev)
}
/**
+ * temac_dma_bd_reset - Reset buffer descriptor rings
+ */
+static void temac_dma_bd_reset(struct net_device *ndev)
+{
+ struct temac_local *lp = netdev_priv(ndev);
+ int i;
+
+ for (i = 0; i < TX_BD_NUM; i++)
+ lp->tx_bd_v[i].app0 = 0;
+
+ lp->tx_bd_ci = 0;
+ lp->tx_bd_next = 0;
+ lp->tx_bd_tail = 0;
+ lp->rx_bd_ci = 0;
+
+ return;
+}
+
+/**
* temac_dma_bd_init - Setup buffer descriptor rings
*/
static int temac_dma_bd_init(struct net_device *ndev)
@@ -864,6 +883,8 @@ static int temac_open(struct net_device *ndev)
if (rc)
goto err_rx_irq;
+ temac_dma_bd_reset(ndev);
+
return 0;
err_rx_irq:
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ll_temac: Reset dma descriptors on ndo_open
2013-09-27 11:24 [PATCH] ll_temac: Reset dma descriptors on ndo_open Ricardo Ribalda Delgado
@ 2013-10-01 4:21 ` David Miller
2013-10-01 5:46 ` Ricardo Ribalda Delgado
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2013-10-01 4:21 UTC (permalink / raw)
To: ricardo.ribalda; +Cc: joe, jg1.han, gregkh, wfp5p, netdev, linux-kernel
From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Date: Fri, 27 Sep 2013 13:24:28 +0200
> The dma descriptors are only initialized on the probe function.
>
> If a packet is on the buffer when temac_stop is called, the dma
> descriptors can be left on a incorrect status where no other package can
> be sent.
>
> So an interface could be left in an usable state after ifdow/ifup.
>
> This patch makes sure that the descriptors are in a proper status when
> the device is started.
>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
This analysis is not correct.
In the current driver, the descriptors are allocated and initialized
in the open function, not the probe function.
I'm not applying this patch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ll_temac: Reset dma descriptors on ndo_open
2013-10-01 4:21 ` David Miller
@ 2013-10-01 5:46 ` Ricardo Ribalda Delgado
2013-10-01 6:01 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2013-10-01 5:46 UTC (permalink / raw)
To: David Miller; +Cc: joe, jg1.han, Greg Kroah-Hartman, wfp5p, netdev, LKML
Hello David
lp->tx_bd_ci, lp->tx_bd_next... are only initialized to zero on
temac_of_probe (inside alloc_etherdev). Those vars are used to index
the dma descriptors.
The initialization of lp->tx_bd_v[i].app0 = 0; is redundant, because
it is already done on dma_zalloc_coherent in temac_dma_bd_init called
on open.
What if I move
lp->tx_bd_ci = 0;
lp->tx_bd_next = 0;
lp->tx_bd_tail = 0;
lp->rx_bd_ci = 0;
to temac_dma_bd_init? Will this be more correct?
Without this patch a script like these kills the card in 1-10 iterations:
ifdown eth0
ifdown eth1
while true
do
ifconfig eth1 10.100.10.100
udhcpc -i eth0
ping 192.168.2.1 -c 5 || break
ifconfig eth0 down
ifconfig eth0 10.100.10.100
udhcpc -i eth1
ping 192.168.2.1 -c 5 || break
ifconfig eth1 down
done
Regards
On Tue, Oct 1, 2013 at 6:21 AM, David Miller <davem@davemloft.net> wrote:
> From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> Date: Fri, 27 Sep 2013 13:24:28 +0200
>
>> The dma descriptors are only initialized on the probe function.
>>
>> If a packet is on the buffer when temac_stop is called, the dma
>> descriptors can be left on a incorrect status where no other package can
>> be sent.
>>
>> So an interface could be left in an usable state after ifdow/ifup.
>>
>> This patch makes sure that the descriptors are in a proper status when
>> the device is started.
>>
>> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
>
> This analysis is not correct.
>
> In the current driver, the descriptors are allocated and initialized
> in the open function, not the probe function.
>
> I'm not applying this patch.
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ll_temac: Reset dma descriptors on ndo_open
2013-10-01 5:46 ` Ricardo Ribalda Delgado
@ 2013-10-01 6:01 ` David Miller
2013-10-01 6:18 ` Ricardo Ribalda Delgado
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2013-10-01 6:01 UTC (permalink / raw)
To: ricardo.ribalda; +Cc: joe, jg1.han, gregkh, wfp5p, netdev, linux-kernel
From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Date: Tue, 1 Oct 2013 07:46:31 +0200
> What if I move
> lp->tx_bd_ci = 0;
> lp->tx_bd_next = 0;
> lp->tx_bd_tail = 0;
> lp->rx_bd_ci = 0;
>
> to temac_dma_bd_init? Will this be more correct?
Yes, that would be a lot better.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ll_temac: Reset dma descriptors on ndo_open
2013-10-01 6:01 ` David Miller
@ 2013-10-01 6:18 ` Ricardo Ribalda Delgado
0 siblings, 0 replies; 5+ messages in thread
From: Ricardo Ribalda Delgado @ 2013-10-01 6:18 UTC (permalink / raw)
To: David Miller; +Cc: joe, jg1.han, Greg Kroah-Hartman, wfp5p, netdev, LKML
Just send a v2 of the patch
http://patchwork.ozlabs.org/patch/279339/
Thanks!
On Tue, Oct 1, 2013 at 8:01 AM, David Miller <davem@davemloft.net> wrote:
> From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> Date: Tue, 1 Oct 2013 07:46:31 +0200
>
>> What if I move
>> lp->tx_bd_ci = 0;
>> lp->tx_bd_next = 0;
>> lp->tx_bd_tail = 0;
>> lp->rx_bd_ci = 0;
>>
>> to temac_dma_bd_init? Will this be more correct?
>
> Yes, that would be a lot better.
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-01 6:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-27 11:24 [PATCH] ll_temac: Reset dma descriptors on ndo_open Ricardo Ribalda Delgado
2013-10-01 4:21 ` David Miller
2013-10-01 5:46 ` Ricardo Ribalda Delgado
2013-10-01 6:01 ` David Miller
2013-10-01 6:18 ` Ricardo Ribalda Delgado
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).