From patchwork Fri Jan 22 10:43:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101143 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp578637lbb; Fri, 22 Jan 2016 02:44:33 -0800 (PST) X-Received: by 10.66.192.42 with SMTP id hd10mr3237890pac.111.1453459472899; Fri, 22 Jan 2016 02:44:32 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ey12si2819691pac.203.2016.01.22.02.44.32; Fri, 22 Jan 2016 02:44:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752855AbcAVKo3 (ORCPT + 4 others); Fri, 22 Jan 2016 05:44:29 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:54598 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753087AbcAVKoW (ORCPT ); Fri, 22 Jan 2016 05:44:22 -0500 Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0M0sl5-1a8CPD2ZQ7-00v6us; Fri, 22 Jan 2016 11:43:48 +0100 From: Arnd Bergmann To: netdev@vger.kernel.org Cc: davem@davemloft.net, Maxime Ripard , Gregory CLEMENT , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] net: simplify napi_synchronize() to avoid warnings Date: Fri, 22 Jan 2016 11:43:44 +0100 Message-ID: <2817787.9jKELuxj8h@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:5QFUI72zmzy5PWT4dWCVSSztvdlKuVH5z6ZPadjuB5IMcxn6eyb E0Z4HsuqGXEYlGcLj5cGSvcCKChKGH8Ciyg3HMhRQPamZRLcqzELzSqqlOyUY/P6no1/C1A GbCR+CRap0OKiiCyfG/Qbrgu7gb3kb+P7ebEUAO1WWEYWtWjP3atowANUFep3fFrY0NJOen LJsyj+PQDvPYy+4qhOarA== X-UI-Out-Filterresults: notjunk:1; V01:K0:U6jPwqVgJ+E=:JpaiQLRy/wgsCjSfFi8Yjr 52421OT06zltPH2Z8n5gbUkGkgAQLOd5z8OP6hrvzRSuWbFUUpCV0ocJjp+JTCSoRsuGh4F8F qORFchDApAyl3BwiqnSXffR7TDANyN48UX4nhnoLo2GGzQfbMZGUzf9h2GPIO5JC6M43Lty5v mdAxiIlf4jMEbj145TWB0N6o8JSfX1JBiN861rmh8vkvUo33iBNBGWnXTJhieiBSd7TB+lsmn WhlBM0PgX/Uq6xi//y+/DjCbK1R+wQ4439wXBYXcxLAytYUYloNEn1RRm2FLY8odLF02OQhMF thEfZPJENe1Yngp8uWN0pKrrhCgKx20jENlu8opYrWPsLBKG9RD6+DrDZ/3qebIlfQ4M9Fghu GkChhXifgXH78bLhca5JkiJ/jRHgh7d8jFKrg/oz/2rcOzCD/GZAkDWZlyMov1CmhbutW1w0t VOoC7pVpmLtpteBPwVTRkJVbwaHT/GPGMt6vNhJrzSvK8lYe4MZ1IDuuuIT36BOovnl+zmg7U D4v8cUaIlBUbO2z7lE0w/0gEb7fjaypbOGTFcO9uo5WmQz3l8U35b3rQy8YrLAdv4fspY3Ns6 r76jbofJvGhRMlLf1dE8pkkQYCW8fVGT43lGvsRUKXV3MCNWR5USaPVQyEDsK3AYLULRhiSMi nfCzfNYlhyrMxndUxVSmOK77LTubAMsMPtznYKBS9f91h4yqi4wQZF8vCXjpweKQnuUNsULC1 FKzZqXCdNcnoMIKV Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The napi_synchronize() function is defined twice: The definition for SMP builds waits for other CPUs to be done, while the uniprocessor variant just contains a barrier and ignores its argument. In the mvneta driver, this leads to a warning about an unused variable when we lookup the NAPI struct of another CPU and then don't use it: ethernet/marvell/mvneta.c: In function 'mvneta_percpu_notifier': ethernet/marvell/mvneta.c:2910:30: error: unused variable 'other_port' [-Werror=unused-variable] There are no other CPUs on a UP build, so that code never runs, but gcc does not know this. The nicest solution seems to be to turn the napi_synchronize() helper into an inline function for the UP case as well, as that leads gcc to not complain about the argument being unused. Once we do that, we can also combine the two cases into a single function definition and use if(IS_ENABLED()) rather than #ifdef to make it look a bit nicer. The warning first came up in linux-4.4, but I failed to catch it earlier. Signed-off-by: Arnd Bergmann Fixes: f86428854480 ("net: mvneta: Statically assign queues to CPUs") diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 5ac140dcb789..289c2314d766 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -512,7 +512,6 @@ static inline void napi_enable(struct napi_struct *n) clear_bit(NAPI_STATE_NPSVC, &n->state); } -#ifdef CONFIG_SMP /** * napi_synchronize - wait until NAPI is not running * @n: napi context @@ -523,12 +522,12 @@ static inline void napi_enable(struct napi_struct *n) */ static inline void napi_synchronize(const struct napi_struct *n) { - while (test_bit(NAPI_STATE_SCHED, &n->state)) - msleep(1); + if (IS_ENABLED(CONFIG_SMP)) + while (test_bit(NAPI_STATE_SCHED, &n->state)) + msleep(1); + else + barrier(); } -#else -# define napi_synchronize(n) barrier() -#endif enum netdev_queue_state_t { __QUEUE_STATE_DRV_XOFF,