sh_eth: advance 'rxdesc' later in sh_eth_ring_format()
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Mon, 7 Mar 2016 22:37:09 +0000 (01:37 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 10 Mar 2016 21:06:49 +0000 (16:06 -0500)
Iff dma_map_single() fails, 'rxdesc'  should point  to the last filled RX
descriptor, so  that it can be marked as the last one, however the driver
would have  already  advanced it by that time. In order to fix that, only
fill  an RX descriptor  once all the data for it is ready.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/renesas/sh_eth.c

index 6fb75a1d68b9cfc1550fbae9528ac50a154dbf4d..2e9a781640549717eae01701bc20361fb85eb551 100644 (file)
@@ -1127,11 +1127,8 @@ static void sh_eth_ring_format(struct net_device *ndev)
                        break;
                sh_eth_set_receive_align(skb);
 
-               /* RX descriptor */
-               rxdesc = &mdp->rx_ring[i];
                /* The size of the buffer is a multiple of 32 bytes. */
                buf_len = ALIGN(mdp->rx_buf_sz, 32);
-               rxdesc->len = cpu_to_le32(buf_len << 16);
                dma_addr = dma_map_single(&ndev->dev, skb->data, buf_len,
                                          DMA_FROM_DEVICE);
                if (dma_mapping_error(&ndev->dev, dma_addr)) {
@@ -1139,6 +1136,10 @@ static void sh_eth_ring_format(struct net_device *ndev)
                        break;
                }
                mdp->rx_skbuff[i] = skb;
+
+               /* RX descriptor */
+               rxdesc = &mdp->rx_ring[i];
+               rxdesc->len = cpu_to_le32(buf_len << 16);
                rxdesc->addr = cpu_to_le32(dma_addr);
                rxdesc->status = cpu_to_le32(RD_RACT | RD_RFP);
 
This page took 0.026263 seconds and 5 git commands to generate.