From patchwork Wed Nov 25 16:21:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mason X-Patchwork-Id: 548639 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BDB7A14030F for ; Thu, 26 Nov 2015 03:21:27 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752768AbbKYQVX (ORCPT ); Wed, 25 Nov 2015 11:21:23 -0500 Received: from smtp2-g21.free.fr ([212.27.42.2]:52791 "EHLO smtp2-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752496AbbKYQVW (ORCPT ); Wed, 25 Nov 2015 11:21:22 -0500 Received: from [172.27.0.114] (unknown [83.142.147.193]) (Authenticated sender: slash.tmp) by smtp2-g21.free.fr (Postfix) with ESMTPSA id B60A24B0056; Wed, 25 Nov 2015 17:20:48 +0100 (CET) Subject: Re: [PATCH v8] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller To: Mans Rullgard , Alexander Duyck Cc: Netdev , Eric Dumazet References: <1447938180-19651-1-git-send-email-mans@mansr.com> <5655AB63.40204@free.fr> <5655B0DF.8060000@free.fr> From: Mason Message-ID: <5655DFFC.2050107@free.fr> Date: Wed, 25 Nov 2015 17:21:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39 MIME-Version: 1.0 In-Reply-To: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 >>>> #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: Regards. --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 +#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);