devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Salter <msalter@redhat.com>
To: Iyappan Subramanian <isubramanian@apm.com>
Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org,
	patches@apm.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, gregkh@linuxfoundation.org,
	Keyur Chudgar <kchudgar@apm.com>,
	davem@davemloft.net, jcm@redhat.com, Ravi Patel <rapatel@apm.com>
Subject: Re: [PATCH v3 4/4] drivers: net: Add APM X-Gene SoC ethernet driver support.
Date: Fri, 25 Apr 2014 09:13:43 -0400	[thread overview]
Message-ID: <1398431623.3010.76.camel@deneb.redhat.com> (raw)
In-Reply-To: <1397702368-4846-5-git-send-email-isubramanian@apm.com>

On Wed, 2014-04-16 at 19:39 -0700, Iyappan Subramanian wrote:
> +static int xgene_enet_refill_bufpool(struct xgene_enet_desc_ring *buf_pool,
> +                                    u32 nbuf)
> +{
> +       struct sk_buff *skb;
> +       struct xgene_enet_desc16 *desc;
> +       struct net_device *ndev;
> +       struct device *dev;
> +       dma_addr_t dma_addr;
> +       u32 tail = buf_pool->tail;
> +       u32 slots = buf_pool->slots - 1;
> +       int i, ret = 0;
> +       u16 bufdatalen = BUF_LEN_CODE_2K | (SKB_BUFFER_SIZE & GENMASK(11, 0));
> +
> +       ndev = buf_pool->ndev;
> +       dev = ndev_to_dev(buf_pool->ndev);
> +
> +       for (i = 0; i < nbuf; i++) {
> +               desc = &buf_pool->desc16[tail];
> +
> +               skb = netdev_alloc_skb_ip_align(ndev, XGENE_ENET_MAX_MTU);
> +               if (unlikely(!skb)) {
> +                       netdev_err(ndev, "Could not allocate skb");
> +                       ret = -ENOMEM;
> +                       goto out;
> +               }
> +               buf_pool->rx_skb[tail] = skb;
> +
> +               dma_addr = dma_map_single(dev, skb->data, skb->len,
> +                                         DMA_TO_DEVICE);

Shouldn't this be:

               dma_addr = dma_map_single(dev, skb->data, XGENE_ENET_MAX_MTU,
                                         DMA_TO_DEVICE);

You just allocated the skb and nothing is in it, so ->len is zero.

> +
> +static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
> +                               struct xgene_enet_desc *desc)
> +{
> +       struct net_device *ndev = rx_ring->ndev;
> +       struct device *dev = ndev_to_dev(rx_ring->ndev);
> +       struct xgene_enet_desc_ring *buf_pool = rx_ring->buf_pool;
> +       u32 datalen, skb_index;
> +       struct sk_buff *skb;
> +       dma_addr_t pa;
> +       size_t len;
> +       int ret = 0;
> +
> +       skb_index = get_desc(desc, USERINFO);
> +       skb = buf_pool->rx_skb[skb_index];
> +       prefetch(skb->data - NET_IP_ALIGN);
> +
> +       /* Strip off CRC as HW isn't doing this */
> +       datalen = get_desc(desc, BUFDATALEN);
> +       datalen -= 4;
> +       skb_put(skb, datalen);
> +
> +       pa = (dma_addr_t)get_desc(desc, DATAADDR);
> +       len = get_desc(desc, BUFDATALEN);
> +       dma_unmap_single(dev, pa, len, DMA_TO_DEVICE);
> +

And here, should be:

	dma_unmap_single(dev, pa, XGENE_ENET_MAX_MTU, DMA_TO_DEVICE);

You want to unmap the whole buffer, not just the part actually used.

The underlying code works with pages, so the existing code may work by
chance, but you get err_printks is you turn on dma debug.

--Mark

  parent reply	other threads:[~2014-04-25 13:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-17  2:39 [PATCH v3 0/4] net: Add APM X-Gene SoC Ethernet driver support Iyappan Subramanian
2014-04-17  2:39 ` [PATCH v3 1/4] MAINTAINERS: Add entry for APM X-Gene SoC ethernet driver Iyappan Subramanian
     [not found]   ` <1397702368-4846-2-git-send-email-isubramanian-qTEPVZfXA3Y@public.gmane.org>
2014-04-17  3:18     ` Joe Perches
2014-04-21  0:56       ` Javier Martinez Canillas
     [not found]         ` <CABxcv=mj+phHmyg2U2jW51mLTwBN9Au791m-GtqU5BXDPy7Gtg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-24  0:51           ` Iyappan Subramanian
2014-04-17  2:39 ` [PATCH v3 2/4] Documentation: dts: Add bindings " Iyappan Subramanian
2014-04-17  2:39 ` [PATCH v3 3/4] " Iyappan Subramanian
2014-04-17  2:39 ` [PATCH v3 4/4] drivers: net: Add APM X-Gene SoC ethernet driver support Iyappan Subramanian
2014-04-17  3:16   ` Joe Perches
2014-04-24  0:46     ` Iyappan Subramanian
2014-04-25 13:13   ` Mark Salter [this message]
     [not found]     ` <1398431623.3010.76.camel-PDpCo7skNiwAicBL8TP8PQ@public.gmane.org>
2014-04-25 21:04       ` Iyappan Subramanian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1398431623.3010.76.camel@deneb.redhat.com \
    --to=msalter@redhat.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=isubramanian@apm.com \
    --cc=jcm@redhat.com \
    --cc=kchudgar@apm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=patches@apm.com \
    --cc=rapatel@apm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).