* [PATCH v2] net: mvneta: fix refilling for Rx DMA buffers
@ 2015-07-19 11:00 Simon Guinot
2015-07-21 7:30 ` David Miller
0 siblings, 1 reply; 10+ messages in thread
From: Simon Guinot @ 2015-07-19 11:00 UTC (permalink / raw)
To: David S. Miller, Thomas Petazzoni
Cc: Jason Cooper, Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
netdev, linux-arm-kernel, Vincent Donnefort, Yoann Sculo, stable
With the actual code, if a memory allocation error happens while
refilling a Rx descriptor, then the original Rx buffer is both passed
to the networking stack (in a SKB) and let in the Rx ring. This leads
to various kernel oops and crashes.
As a fix, this patch moves Rx descriptor refilling ahead of building
SKB with the associated Rx buffer. In case of a memory allocation
failure, data is dropped and the original DMA buffer is put back into
the Rx ring.
Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Fixes: c5aff18204da ("net: mvneta: driver for Marvell Armada 370/XP network unit")
Cc: <stable@vger.kernel.org> # v3.8+
Tested-by: Yoann Sculo <yoann@sculo.fr>
---
drivers/net/ethernet/marvell/mvneta.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
Changes for v2:
- Update commit message.
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index ce5f7f9cff06..ac3da11e63a0 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1455,7 +1455,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
struct mvneta_rx_queue *rxq)
{
struct net_device *dev = pp->dev;
- int rx_done, rx_filled;
+ int rx_done;
u32 rcvd_pkts = 0;
u32 rcvd_bytes = 0;
@@ -1466,7 +1466,6 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
rx_todo = rx_done;
rx_done = 0;
- rx_filled = 0;
/* Fairness NAPI loop */
while (rx_done < rx_todo) {
@@ -1477,7 +1476,6 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
int rx_bytes, err;
rx_done++;
- rx_filled++;
rx_status = rx_desc->status;
rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE);
data = (unsigned char *)rx_desc->buf_cookie;
@@ -1517,6 +1515,14 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
continue;
}
+ /* Refill processing */
+ err = mvneta_rx_refill(pp, rx_desc);
+ if (err) {
+ netdev_err(dev, "Linux processing - Can't refill\n");
+ rxq->missed++;
+ goto err_drop_frame;
+ }
+
skb = build_skb(data, pp->frag_size > PAGE_SIZE ? 0 : pp->frag_size);
if (!skb)
goto err_drop_frame;
@@ -1536,14 +1542,6 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
mvneta_rx_csum(pp, rx_status, skb);
napi_gro_receive(&pp->napi, skb);
-
- /* Refill processing */
- err = mvneta_rx_refill(pp, rx_desc);
- if (err) {
- netdev_err(dev, "Linux processing - Can't refill\n");
- rxq->missed++;
- rx_filled--;
- }
}
if (rcvd_pkts) {
@@ -1556,7 +1554,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
}
/* Update rxq management counters */
- mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_filled);
+ mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_done);
return rx_done;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] net: mvneta: fix refilling for Rx DMA buffers
2015-07-19 11:00 [PATCH v2] net: mvneta: fix refilling for Rx DMA buffers Simon Guinot
@ 2015-07-21 7:30 ` David Miller
[not found] ` <CAA-51jPPDHfE1uT2NuJ53wWTvEgh7DcW0K0-xZgQdjAD2CC04w@mail.gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: David Miller @ 2015-07-21 7:30 UTC (permalink / raw)
To: simon.guinot
Cc: thomas.petazzoni, jason, andrew, gregory.clement,
sebastian.hesselbarth, netdev, linux-arm-kernel, vdonnefort,
yoann, stable
From: Simon Guinot <simon.guinot@sequanux.org>
Date: Sun, 19 Jul 2015 13:00:53 +0200
> With the actual code, if a memory allocation error happens while
> refilling a Rx descriptor, then the original Rx buffer is both passed
> to the networking stack (in a SKB) and let in the Rx ring. This leads
> to various kernel oops and crashes.
>
> As a fix, this patch moves Rx descriptor refilling ahead of building
> SKB with the associated Rx buffer. In case of a memory allocation
> failure, data is dropped and the original DMA buffer is put back into
> the Rx ring.
>
> Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> Fixes: c5aff18204da ("net: mvneta: driver for Marvell Armada 370/XP network unit")
> Cc: <stable@vger.kernel.org> # v3.8+
> Tested-by: Yoann Sculo <yoann@sculo.fr>
Applied, thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] net: mvneta: fix refilling for Rx DMA buffers
[not found] ` <CAA-51jPPDHfE1uT2NuJ53wWTvEgh7DcW0K0-xZgQdjAD2CC04w@mail.gmail.com>
@ 2015-09-14 22:13 ` Simon Guinot
2015-09-14 22:16 ` Oren Laskin
2015-09-15 20:36 ` Simon Guinot
1 sibling, 1 reply; 10+ messages in thread
From: Simon Guinot @ 2015-09-14 22:13 UTC (permalink / raw)
To: Oren Laskin
Cc: David Miller, thomas.petazzoni, andrew, jason, netdev, vdonnefort,
stable, Gregory CLEMENT, yoann, linux-arm-kernel,
sebastian.hesselbarth
[-- Attachment #1: Type: text/plain, Size: 2255 bytes --]
Hi Oren,
On Mon, Sep 14, 2015 at 01:22:12PM -0700, Oren Laskin wrote:
> I had to undo this change on my Amada 370 based board. It was causing
> corrupt data to make it through on large downloads. I'm using wget to get
> the same 30MB file many times and the SHA would occasionally be different.
During your tests, can you see some "Linux processing - Can't refill"
messages along with the data corruptions ?
> I tracked it down to this commit. In it, I would find on the order of a
> few hundred bytes to simply be wrong data.
I am little bit surprised here. For me, this patch is very simple and
does the exact opposite. It does fix kernel crashes and data corruptions
in case of refilling errors. This can happen for example if you run
large data transfers with jumbo frames enabled...
But anyway, I'll try to reproduce the issue tomorrow. I only have to
wget the same file (size 30MB) in a loop and to check its md5sum ?
That's it ? And how long should I wait for the error ?
Thanks,
Simon
>
> Thanks,
>
> Oren
>
> On Tue, Jul 21, 2015 at 12:30 AM, David Miller <davem@davemloft.net> wrote:
>
> > From: Simon Guinot <simon.guinot@sequanux.org>
> > Date: Sun, 19 Jul 2015 13:00:53 +0200
> >
> > > With the actual code, if a memory allocation error happens while
> > > refilling a Rx descriptor, then the original Rx buffer is both passed
> > > to the networking stack (in a SKB) and let in the Rx ring. This leads
> > > to various kernel oops and crashes.
> > >
> > > As a fix, this patch moves Rx descriptor refilling ahead of building
> > > SKB with the associated Rx buffer. In case of a memory allocation
> > > failure, data is dropped and the original DMA buffer is put back into
> > > the Rx ring.
> > >
> > > Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> > > Fixes: c5aff18204da ("net: mvneta: driver for Marvell Armada 370/XP
> > network unit")
> > > Cc: <stable@vger.kernel.org> # v3.8+
> > > Tested-by: Yoann Sculo <yoann@sculo.fr>
> >
> > Applied, thanks.
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> >
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] net: mvneta: fix refilling for Rx DMA buffers
2015-09-14 22:13 ` Simon Guinot
@ 2015-09-14 22:16 ` Oren Laskin
2015-09-14 22:46 ` Simon Guinot
2015-09-15 9:09 ` Vincent Donnefort
0 siblings, 2 replies; 10+ messages in thread
From: Oren Laskin @ 2015-09-14 22:16 UTC (permalink / raw)
To: Simon Guinot
Cc: David Miller, thomas.petazzoni, andrew, jason, netdev, vdonnefort,
stable, Gregory CLEMENT, yoann, linux-arm-kernel,
sebastian.hesselbarth
I would hit this error on my Armada 370 board about 20% of the time
after downloading a 30MB file to /tmp. We're running a 1 Gb SGMII
link. I would hit this in less than a minute before removing this
commit from my tree. I've now been running this test in a loop for a
few hours with no problems.
It was somewhat hard to diagnose since files I used scp didn't see the
issues (or at least as quickly). I set up an http program to serve a
file and replicated the problem with wget and found it.
Oren
On Mon, Sep 14, 2015 at 3:13 PM, Simon Guinot <simon.guinot@sequanux.org> wrote:
> Hi Oren,
>
> On Mon, Sep 14, 2015 at 01:22:12PM -0700, Oren Laskin wrote:
>> I had to undo this change on my Amada 370 based board. It was causing
>> corrupt data to make it through on large downloads. I'm using wget to get
>> the same 30MB file many times and the SHA would occasionally be different.
>
> During your tests, can you see some "Linux processing - Can't refill"
> messages along with the data corruptions ?
>
>> I tracked it down to this commit. In it, I would find on the order of a
>> few hundred bytes to simply be wrong data.
>
> I am little bit surprised here. For me, this patch is very simple and
> does the exact opposite. It does fix kernel crashes and data corruptions
> in case of refilling errors. This can happen for example if you run
> large data transfers with jumbo frames enabled...
>
> But anyway, I'll try to reproduce the issue tomorrow. I only have to
> wget the same file (size 30MB) in a loop and to check its md5sum ?
> That's it ? And how long should I wait for the error ?
>
> Thanks,
>
> Simon
>
>>
>> Thanks,
>>
>> Oren
>>
>> On Tue, Jul 21, 2015 at 12:30 AM, David Miller <davem@davemloft.net> wrote:
>>
>> > From: Simon Guinot <simon.guinot@sequanux.org>
>> > Date: Sun, 19 Jul 2015 13:00:53 +0200
>> >
>> > > With the actual code, if a memory allocation error happens while
>> > > refilling a Rx descriptor, then the original Rx buffer is both passed
>> > > to the networking stack (in a SKB) and let in the Rx ring. This leads
>> > > to various kernel oops and crashes.
>> > >
>> > > As a fix, this patch moves Rx descriptor refilling ahead of building
>> > > SKB with the associated Rx buffer. In case of a memory allocation
>> > > failure, data is dropped and the original DMA buffer is put back into
>> > > the Rx ring.
>> > >
>> > > Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
>> > > Fixes: c5aff18204da ("net: mvneta: driver for Marvell Armada 370/XP
>> > network unit")
>> > > Cc: <stable@vger.kernel.org> # v3.8+
>> > > Tested-by: Yoann Sculo <yoann@sculo.fr>
>> >
>> > Applied, thanks.
>> >
>> > _______________________________________________
>> > 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] 10+ messages in thread
* Re: [PATCH v2] net: mvneta: fix refilling for Rx DMA buffers
2015-09-14 22:16 ` Oren Laskin
@ 2015-09-14 22:46 ` Simon Guinot
2015-09-15 9:09 ` Vincent Donnefort
1 sibling, 0 replies; 10+ messages in thread
From: Simon Guinot @ 2015-09-14 22:46 UTC (permalink / raw)
To: Oren Laskin
Cc: David Miller, thomas.petazzoni, andrew, jason, netdev, vdonnefort,
stable, Gregory CLEMENT, yoann, linux-arm-kernel,
sebastian.hesselbarth
[-- Attachment #1: Type: text/plain, Size: 3761 bytes --]
On Mon, Sep 14, 2015 at 03:16:50PM -0700, Oren Laskin wrote:
> I would hit this error on my Armada 370 board about 20% of the time
> after downloading a 30MB file to /tmp. We're running a 1 Gb SGMII
> link. I would hit this in less than a minute before removing this
> commit from my tree. I've now been running this test in a loop for a
> few hours with no problems.
Outch.
At the time I have tested this patch with several runs of 20 wget/md5sum
of a 1GB file (with jumbo frames enabled or not). I have also used this
program: http://git.lacie-nas.org/?p=netsum.git;a=summary. It allows to
detect data corruption over network very quickly.
It is very weird, I should have seen something...
Moreover I understand that you reproduce the issue very quickly and
without any refilling errors. It is also quite weird because the patch
does basically nothing in a such case.
BTW, which hardware are you using exactly ?
Definitively I'll have a closer look at it tomorrow.
Simon
>
> It was somewhat hard to diagnose since files I used scp didn't see the
> issues (or at least as quickly). I set up an http program to serve a
> file and replicated the problem with wget and found it.
>
> Oren
>
> On Mon, Sep 14, 2015 at 3:13 PM, Simon Guinot <simon.guinot@sequanux.org> wrote:
> > Hi Oren,
> >
> > On Mon, Sep 14, 2015 at 01:22:12PM -0700, Oren Laskin wrote:
> >> I had to undo this change on my Amada 370 based board. It was causing
> >> corrupt data to make it through on large downloads. I'm using wget to get
> >> the same 30MB file many times and the SHA would occasionally be different.
> >
> > During your tests, can you see some "Linux processing - Can't refill"
> > messages along with the data corruptions ?
> >
> >> I tracked it down to this commit. In it, I would find on the order of a
> >> few hundred bytes to simply be wrong data.
> >
> > I am little bit surprised here. For me, this patch is very simple and
> > does the exact opposite. It does fix kernel crashes and data corruptions
> > in case of refilling errors. This can happen for example if you run
> > large data transfers with jumbo frames enabled...
> >
> > But anyway, I'll try to reproduce the issue tomorrow. I only have to
> > wget the same file (size 30MB) in a loop and to check its md5sum ?
> > That's it ? And how long should I wait for the error ?
> >
> > Thanks,
> >
> > Simon
> >
> >>
> >> Thanks,
> >>
> >> Oren
> >>
> >> On Tue, Jul 21, 2015 at 12:30 AM, David Miller <davem@davemloft.net> wrote:
> >>
> >> > From: Simon Guinot <simon.guinot@sequanux.org>
> >> > Date: Sun, 19 Jul 2015 13:00:53 +0200
> >> >
> >> > > With the actual code, if a memory allocation error happens while
> >> > > refilling a Rx descriptor, then the original Rx buffer is both passed
> >> > > to the networking stack (in a SKB) and let in the Rx ring. This leads
> >> > > to various kernel oops and crashes.
> >> > >
> >> > > As a fix, this patch moves Rx descriptor refilling ahead of building
> >> > > SKB with the associated Rx buffer. In case of a memory allocation
> >> > > failure, data is dropped and the original DMA buffer is put back into
> >> > > the Rx ring.
> >> > >
> >> > > Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> >> > > Fixes: c5aff18204da ("net: mvneta: driver for Marvell Armada 370/XP
> >> > network unit")
> >> > > Cc: <stable@vger.kernel.org> # v3.8+
> >> > > Tested-by: Yoann Sculo <yoann@sculo.fr>
> >> >
> >> > Applied, thanks.
> >> >
> >> > _______________________________________________
> >> > linux-arm-kernel mailing list
> >> > linux-arm-kernel@lists.infradead.org
> >> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> >> >
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] net: mvneta: fix refilling for Rx DMA buffers
2015-09-14 22:16 ` Oren Laskin
2015-09-14 22:46 ` Simon Guinot
@ 2015-09-15 9:09 ` Vincent Donnefort
1 sibling, 0 replies; 10+ messages in thread
From: Vincent Donnefort @ 2015-09-15 9:09 UTC (permalink / raw)
To: Oren Laskin
Cc: thomas.petazzoni, andrew, Simon Guinot, netdev, stable,
sebastian.hesselbarth, Gregory CLEMENT, yoann, David Miller,
linux-arm-kernel, jason
Hi Oren,
On Mon, Sep 14, 2015 at 03:16:50PM -0700, Oren Laskin wrote:
> I would hit this error on my Armada 370 board about 20% of the time
> after downloading a 30MB file to /tmp. We're running a 1 Gb SGMII
> link. I would hit this in less than a minute before removing this
> commit from my tree. I've now been running this test in a loop for a
> few hours with no problems.
I didn't managed to reproduce the issue on a a370-rd board.
What defconfig file are you using? If not mvebu_v7_defconfig, can you
give a try with it?
What kind of hardware are you using?
--
Vincent.
>
> It was somewhat hard to diagnose since files I used scp didn't see the
> issues (or at least as quickly). I set up an http program to serve a
> file and replicated the problem with wget and found it.
>
> Oren
>
> On Mon, Sep 14, 2015 at 3:13 PM, Simon Guinot <simon.guinot@sequanux.org> wrote:
> > Hi Oren,
> >
> > On Mon, Sep 14, 2015 at 01:22:12PM -0700, Oren Laskin wrote:
> >> I had to undo this change on my Amada 370 based board. It was causing
> >> corrupt data to make it through on large downloads. I'm using wget to get
> >> the same 30MB file many times and the SHA would occasionally be different.
> >
> > During your tests, can you see some "Linux processing - Can't refill"
> > messages along with the data corruptions ?
> >
> >> I tracked it down to this commit. In it, I would find on the order of a
> >> few hundred bytes to simply be wrong data.
> >
> > I am little bit surprised here. For me, this patch is very simple and
> > does the exact opposite. It does fix kernel crashes and data corruptions
> > in case of refilling errors. This can happen for example if you run
> > large data transfers with jumbo frames enabled...
> >
> > But anyway, I'll try to reproduce the issue tomorrow. I only have to
> > wget the same file (size 30MB) in a loop and to check its md5sum ?
> > That's it ? And how long should I wait for the error ?
> >
> > Thanks,
> >
> > Simon
> >
> >>
> >> Thanks,
> >>
> >> Oren
> >>
> >> On Tue, Jul 21, 2015 at 12:30 AM, David Miller <davem@davemloft.net> wrote:
> >>
> >> > From: Simon Guinot <simon.guinot@sequanux.org>
> >> > Date: Sun, 19 Jul 2015 13:00:53 +0200
> >> >
> >> > > With the actual code, if a memory allocation error happens while
> >> > > refilling a Rx descriptor, then the original Rx buffer is both passed
> >> > > to the networking stack (in a SKB) and let in the Rx ring. This leads
> >> > > to various kernel oops and crashes.
> >> > >
> >> > > As a fix, this patch moves Rx descriptor refilling ahead of building
> >> > > SKB with the associated Rx buffer. In case of a memory allocation
> >> > > failure, data is dropped and the original DMA buffer is put back into
> >> > > the Rx ring.
> >> > >
> >> > > Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> >> > > Fixes: c5aff18204da ("net: mvneta: driver for Marvell Armada 370/XP
> >> > network unit")
> >> > > Cc: <stable@vger.kernel.org> # v3.8+
> >> > > Tested-by: Yoann Sculo <yoann@sculo.fr>
> >> >
> >> > Applied, thanks.
> >> >
> >> > _______________________________________________
> >> > 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] 10+ messages in thread
* Re: [PATCH v2] net: mvneta: fix refilling for Rx DMA buffers
[not found] ` <CAA-51jPPDHfE1uT2NuJ53wWTvEgh7DcW0K0-xZgQdjAD2CC04w@mail.gmail.com>
2015-09-14 22:13 ` Simon Guinot
@ 2015-09-15 20:36 ` Simon Guinot
2015-09-15 20:41 ` [PATCH] net: mvneta: fix DMA buffer unmapping in mvneta_rx() Simon Guinot
1 sibling, 1 reply; 10+ messages in thread
From: Simon Guinot @ 2015-09-15 20:36 UTC (permalink / raw)
To: Oren Laskin
Cc: David Miller, thomas.petazzoni, andrew, jason, netdev, vdonnefort,
stable, Gregory CLEMENT, yoann, linux-arm-kernel,
sebastian.hesselbarth
[-- Attachment #1: Type: text/plain, Size: 1914 bytes --]
On Mon, Sep 14, 2015 at 01:22:12PM -0700, Oren Laskin wrote:
> I had to undo this change on my Amada 370 based board. It was causing
> corrupt data to make it through on large downloads. I'm using wget to get
> the same 30MB file many times and the SHA would occasionally be different.
> I tracked it down to this commit. In it, I would find on the order of a
> few hundred bytes to simply be wrong data.
Hi Oren,
Well, you are right. This patch actually introduces a pretty serious
bug. I still don't understand how I missed that in a first place and
I apologize for the inconvenience.
Anyway, I am about to send a patch fixing the issue. Please, can you
test it ?
Thanks in advance,
Simon
> On Tue, Jul 21, 2015 at 12:30 AM, David Miller <davem@davemloft.net> wrote:
>
> > From: Simon Guinot <simon.guinot@sequanux.org>
> > Date: Sun, 19 Jul 2015 13:00:53 +0200
> >
> > > With the actual code, if a memory allocation error happens while
> > > refilling a Rx descriptor, then the original Rx buffer is both passed
> > > to the networking stack (in a SKB) and let in the Rx ring. This leads
> > > to various kernel oops and crashes.
> > >
> > > As a fix, this patch moves Rx descriptor refilling ahead of building
> > > SKB with the associated Rx buffer. In case of a memory allocation
> > > failure, data is dropped and the original DMA buffer is put back into
> > > the Rx ring.
> > >
> > > Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> > > Fixes: c5aff18204da ("net: mvneta: driver for Marvell Armada 370/XP
> > network unit")
> > > Cc: <stable@vger.kernel.org> # v3.8+
> > > Tested-by: Yoann Sculo <yoann@sculo.fr>
> >
> > Applied, thanks.
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> >
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] net: mvneta: fix DMA buffer unmapping in mvneta_rx()
2015-09-15 20:36 ` Simon Guinot
@ 2015-09-15 20:41 ` Simon Guinot
2015-09-15 21:19 ` Oren Laskin
2015-09-15 21:55 ` David Miller
0 siblings, 2 replies; 10+ messages in thread
From: Simon Guinot @ 2015-09-15 20:41 UTC (permalink / raw)
To: David Miller, Oren Laskin
Cc: Jason Cooper, Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
Thomas Petazzoni, Vincent Donnefort, Yoann Sculo,
Sebastien Rannou, linux-arm-kernel, netdev, Simon Guinot, stable
This patch fixes a regression introduced by the commit a84e32894191
("net: mvneta: fix refilling for Rx DMA buffers"). Due to this commit
the newly allocated Rx buffers are DMA-unmapped in place of those passed
to the networking stack. Obviously, this causes data corruptions.
This patch fixes the issue by ensuring that the right Rx buffers are
DMA-unmapped.
Reported-by: Oren Laskin <oren@igneous.io>
Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Fixes: a84e32894191 ("net: mvneta: fix refilling for Rx DMA buffers")
Cc: <stable@vger.kernel.org> # v3.8+
---
drivers/net/ethernet/marvell/mvneta.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 62e48bc0cb23..03e052a1cf5a 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1479,6 +1479,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
struct mvneta_rx_desc *rx_desc = mvneta_rxq_next_desc_get(rxq);
struct sk_buff *skb;
unsigned char *data;
+ dma_addr_t phys_addr;
u32 rx_status;
int rx_bytes, err;
@@ -1486,6 +1487,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
rx_status = rx_desc->status;
rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE);
data = (unsigned char *)rx_desc->buf_cookie;
+ phys_addr = rx_desc->buf_phys_addr;
if (!mvneta_rxq_desc_is_first_last(rx_status) ||
(rx_status & MVNETA_RXD_ERR_SUMMARY)) {
@@ -1534,7 +1536,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
if (!skb)
goto err_drop_frame;
- dma_unmap_single(dev->dev.parent, rx_desc->buf_phys_addr,
+ dma_unmap_single(dev->dev.parent, phys_addr,
MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
rcvd_pkts++;
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] net: mvneta: fix DMA buffer unmapping in mvneta_rx()
2015-09-15 20:41 ` [PATCH] net: mvneta: fix DMA buffer unmapping in mvneta_rx() Simon Guinot
@ 2015-09-15 21:19 ` Oren Laskin
2015-09-15 21:55 ` David Miller
1 sibling, 0 replies; 10+ messages in thread
From: Oren Laskin @ 2015-09-15 21:19 UTC (permalink / raw)
To: Simon Guinot
Cc: David Miller, Jason Cooper, Andrew Lunn, Gregory Clement,
Sebastian Hesselbarth, Thomas Petazzoni, Vincent Donnefort,
Yoann Sculo, Sebastien Rannou, linux-arm-kernel, netdev, stable
This fixes the regression we saw.
Tested-by: Oren Laskin <oren@igneous.io>
On Tue, Sep 15, 2015 at 1:41 PM, Simon Guinot <simon.guinot@sequanux.org> wrote:
> This patch fixes a regression introduced by the commit a84e32894191
> ("net: mvneta: fix refilling for Rx DMA buffers"). Due to this commit
> the newly allocated Rx buffers are DMA-unmapped in place of those passed
> to the networking stack. Obviously, this causes data corruptions.
>
> This patch fixes the issue by ensuring that the right Rx buffers are
> DMA-unmapped.
>
> Reported-by: Oren Laskin <oren@igneous.io>
> Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> Fixes: a84e32894191 ("net: mvneta: fix refilling for Rx DMA buffers")
> Cc: <stable@vger.kernel.org> # v3.8+
> ---
> drivers/net/ethernet/marvell/mvneta.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
> index 62e48bc0cb23..03e052a1cf5a 100644
> --- a/drivers/net/ethernet/marvell/mvneta.c
> +++ b/drivers/net/ethernet/marvell/mvneta.c
> @@ -1479,6 +1479,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
> struct mvneta_rx_desc *rx_desc = mvneta_rxq_next_desc_get(rxq);
> struct sk_buff *skb;
> unsigned char *data;
> + dma_addr_t phys_addr;
> u32 rx_status;
> int rx_bytes, err;
>
> @@ -1486,6 +1487,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
> rx_status = rx_desc->status;
> rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE);
> data = (unsigned char *)rx_desc->buf_cookie;
> + phys_addr = rx_desc->buf_phys_addr;
>
> if (!mvneta_rxq_desc_is_first_last(rx_status) ||
> (rx_status & MVNETA_RXD_ERR_SUMMARY)) {
> @@ -1534,7 +1536,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
> if (!skb)
> goto err_drop_frame;
>
> - dma_unmap_single(dev->dev.parent, rx_desc->buf_phys_addr,
> + dma_unmap_single(dev->dev.parent, phys_addr,
> MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
>
> rcvd_pkts++;
> --
> 2.1.4
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] net: mvneta: fix DMA buffer unmapping in mvneta_rx()
2015-09-15 20:41 ` [PATCH] net: mvneta: fix DMA buffer unmapping in mvneta_rx() Simon Guinot
2015-09-15 21:19 ` Oren Laskin
@ 2015-09-15 21:55 ` David Miller
1 sibling, 0 replies; 10+ messages in thread
From: David Miller @ 2015-09-15 21:55 UTC (permalink / raw)
To: simon.guinot
Cc: oren, jason, andrew, gregory.clement, sebastian.hesselbarth,
thomas.petazzoni, vdonnefort, yoann, mxs, linux-arm-kernel,
netdev, stable
From: Simon Guinot <simon.guinot@sequanux.org>
Date: Tue, 15 Sep 2015 22:41:21 +0200
> This patch fixes a regression introduced by the commit a84e32894191
> ("net: mvneta: fix refilling for Rx DMA buffers"). Due to this commit
> the newly allocated Rx buffers are DMA-unmapped in place of those passed
> to the networking stack. Obviously, this causes data corruptions.
>
> This patch fixes the issue by ensuring that the right Rx buffers are
> DMA-unmapped.
>
> Reported-by: Oren Laskin <oren@igneous.io>
> Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> Fixes: a84e32894191 ("net: mvneta: fix refilling for Rx DMA buffers")
Applied, thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-09-15 21:55 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-19 11:00 [PATCH v2] net: mvneta: fix refilling for Rx DMA buffers Simon Guinot
2015-07-21 7:30 ` David Miller
[not found] ` <CAA-51jPPDHfE1uT2NuJ53wWTvEgh7DcW0K0-xZgQdjAD2CC04w@mail.gmail.com>
2015-09-14 22:13 ` Simon Guinot
2015-09-14 22:16 ` Oren Laskin
2015-09-14 22:46 ` Simon Guinot
2015-09-15 9:09 ` Vincent Donnefort
2015-09-15 20:36 ` Simon Guinot
2015-09-15 20:41 ` [PATCH] net: mvneta: fix DMA buffer unmapping in mvneta_rx() Simon Guinot
2015-09-15 21:19 ` Oren Laskin
2015-09-15 21:55 ` David Miller
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).