From: Mason <slash.tmp@free.fr>
To: Mans Rullgard <mans@mansr.com>,
Alexander Duyck <alexander.duyck@gmail.com>
Cc: Netdev <netdev@vger.kernel.org>, Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH v8] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller
Date: Wed, 25 Nov 2015 17:21:16 +0100 [thread overview]
Message-ID: <5655DFFC.2050107@free.fr> (raw)
In-Reply-To: <yw1xh9kaoy0h.fsf@unicorn.mansr.com>
On 25/11/2015 17:16, Måns Rullgård wrote:
> Alexander Duyck writes:
>
>> On Wed, Nov 25, 2015 at 5:04 AM, Måns Rullgård wrote:
>>
>>> Mason writes:
>>>
>>>> On 25/11/2015 13:45, Måns Rullgård wrote:
>>>>
>>>>> Mason wrote:
>>>>>
>>>>>> On 19/11/2015 14:02, Mans Rullgard wrote:
>>>>>>
>>>>>>> + if (dma_mapping_error(&dev->dev, dma_addr)) {
>>>>>>> + skb_free_frag(data);
>>>>>>> + return -ENOMEM;
>>>>>>> + }
>>>>>>
>>>>>> I'm back-porting this driver to 4.1
>>>>>>
>>>>>> skb_free_frag() was introduced in 4.2 by 181edb2bfa22b IIUC.
>>>>>>
>>>>>> +static inline void skb_free_frag(void *addr)
>>>>>> +{
>>>>>> + __free_page_frag(addr);
>>>>>> +}
>>>>>>
>>>>>> Should I just copy the definition of __free_page_frag() ?
>>>>>
>>>>> Looks like it ought to work. Try and find out. Not that you'll ever
>>>>> hit that error condition unless you fake it.
>>>>
>>>> Turns out __free_pages_ok() is static and I'd rather not touch
>>>> mm/page_alloc.c in my back-port.
>>>>
>>>> Since you say the error condition is rare, I think I'll go with
>>>> the code that 181edb2bfa22b replaced (put_page, IIUC).
>>>>
>>>> #include <linux/version.h>
>>>> #if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
>>>> #define skb_free_frag(data) put_page(virt_to_head_page(data))
>>>> #else
>>>> #error DELETE ME NOW (see commit 181edb2bfa22b)
>>>> #endif
>>>
>>> You can simply put_page(page) instead since we already have the
>>> virt_to_head_page() a few lines up.
>>
>> What you could do is use __free_pages instead of __free_pages_ok.
>> Generally you will want to use __free_pages instead of put_page just
>> to avoid a bunch of unnecessary tests and function pointer accesses.
>
> Note that this is on a should-never-happen error path, so there's no
> need to be counting cycles.
Per Mans' advice, I have locally committed this patch:
diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c
index ecc4a334c507..9f929be96b74 100644
--- a/drivers/net/ethernet/aurora/nb8800.c
+++ b/drivers/net/ethernet/aurora/nb8800.c
@@ -39,6 +39,13 @@
#include "nb8800.h"
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
+#define skb_free_frag(data) put_page(page)
+#else
+#error DELETE ME NOW (see commit 181edb2bfa22)
+#endif
+
static void nb8800_tx_done(struct net_device *dev);
static int nb8800_dma_stop(struct net_device *dev);
Regards.
next prev parent reply other threads:[~2015-11-25 16:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-19 13:02 [PATCH v8] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller Mans Rullgard
2015-11-20 16:48 ` David Miller
2015-11-25 12:36 ` Mason
2015-11-25 12:45 ` Måns Rullgård
2015-11-25 13:00 ` Mason
2015-11-25 13:04 ` Måns Rullgård
2015-11-25 16:12 ` Alexander Duyck
2015-11-25 16:16 ` Måns Rullgård
2015-11-25 16:21 ` Mason [this message]
2015-11-25 16:24 ` Måns Rullgård
2015-11-25 12:45 ` Mason
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=5655DFFC.2050107@free.fr \
--to=slash.tmp@free.fr \
--cc=alexander.duyck@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=mans@mansr.com \
--cc=netdev@vger.kernel.org \
/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).