From: Murali Karicheri <m-karicheri2@ti.com>
To: Eric Dumazet <eric.dumazet@gmail.com>, WingMan Kwok <w-kwok2@ti.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] net: netcp: Allocate RX packet buffers using __GFP_DMA
Date: Wed, 29 Jul 2015 17:22:55 -0400 [thread overview]
Message-ID: <55B9442F.6040501@ti.com> (raw)
In-Reply-To: <1438203596.20182.103.camel@edumazet-glaptop2.roam.corp.google.com>
On 07/29/2015 04:59 PM, Eric Dumazet wrote:
> On Wed, 2015-07-29 at 11:10 -0400, WingMan Kwok wrote:
>> The Keystone II DMA hardware can only access addresses in the
>> lower 2 GiB of SDRAM. This patch makes sure the RX buffers are
>> allocated using the __GFP_DMA flag so they meet this requirement.
>>
>> Signed-off-by: WingMan Kwok <w-kwok2@ti.com>
>> Signed-off-by: Reece R. Pollack <x0183204@ti.com>
>> ---
>> drivers/net/ethernet/ti/netcp_core.c | 11 +++++++----
>> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> Following patch gets rid of netdev_alloc_frag() which is not GFP_DMA
> ready (and wont be)
>
Eric,
Thanks for the suggestion.
I think the original assumption was that kmalloc() always allocate a
minimum of 1 page for regular or small sized packets. The usage of
netdev_alloc_frag() is to allocate small sized buffers. However
kmalloc() can return different size buffers (/proc/slabinfo) and your
below code should work fine for our driver. We will rework the patch as
per your suggestion.
Murali
> diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
> index 3ca87f26582a..0971c46d6cd5 100644
> --- a/drivers/net/ethernet/ti/netcp_core.c
> +++ b/drivers/net/ethernet/ti/netcp_core.c
> @@ -808,14 +808,8 @@ static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
> primary_buf_len = SKB_DATA_ALIGN(buf_len) +
> SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
>
> - if (primary_buf_len <= PAGE_SIZE) {
> - bufptr = netdev_alloc_frag(primary_buf_len);
> - pad[1] = primary_buf_len;
> - } else {
> - bufptr = kmalloc(primary_buf_len, GFP_ATOMIC |
> - GFP_DMA32 | __GFP_COLD);
> - pad[1] = 0;
> - }
> + bufptr = kmalloc(primary_buf_len, GFP_ATOMIC | GFP_DMA);
> + pad[1] = 0;
>
> if (unlikely(!bufptr)) {
> dev_warn_ratelimited(netcp->ndev_dev, "Primary RX buffer alloc failed\n");
> @@ -827,7 +821,7 @@ static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
>
> } else {
> /* Allocate a secondary receive queue entry */
> - page = alloc_page(GFP_ATOMIC | GFP_DMA32 | __GFP_COLD);
> + page = alloc_page(GFP_ATOMIC | GFP_DMA | __GFP_COLD);
> if (unlikely(!page)) {
> dev_warn_ratelimited(netcp->ndev_dev, "Secondary page alloc failed\n");
> goto fail;
>
>
>
>
--
Murali Karicheri
Linux Kernel, Keystone
next prev parent reply other threads:[~2015-07-29 21:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-29 15:10 [PATCH 1/2] net: Export __netdev_alloc_frag() to allow gfp_mask flags WingMan Kwok
2015-07-29 15:10 ` [PATCH 2/2] net: netcp: Allocate RX packet buffers using __GFP_DMA WingMan Kwok
2015-07-29 20:59 ` Eric Dumazet
2015-07-29 21:22 ` Murali Karicheri [this message]
2015-07-29 16:31 ` [PATCH 1/2] net: Export __netdev_alloc_frag() to allow gfp_mask flags Eric Dumazet
2015-07-29 20:22 ` Murali Karicheri
2015-07-29 20:37 ` Eric Dumazet
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=55B9442F.6040501@ti.com \
--to=m-karicheri2@ti.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=w-kwok2@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.