Commit facc432f authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

net: simplify napi_synchronize() to avoid warnings

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: default avatarArnd Bergmann <arnd@arndb.de>
Fixes: f8642885 ("net: mvneta: Statically assign queues to CPUs")
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9a368aff
...@@ -512,7 +512,6 @@ static inline void napi_enable(struct napi_struct *n) ...@@ -512,7 +512,6 @@ static inline void napi_enable(struct napi_struct *n)
clear_bit(NAPI_STATE_NPSVC, &n->state); clear_bit(NAPI_STATE_NPSVC, &n->state);
} }
#ifdef CONFIG_SMP
/** /**
* napi_synchronize - wait until NAPI is not running * napi_synchronize - wait until NAPI is not running
* @n: napi context * @n: napi context
...@@ -523,12 +522,12 @@ static inline void napi_enable(struct napi_struct *n) ...@@ -523,12 +522,12 @@ static inline void napi_enable(struct napi_struct *n)
*/ */
static inline void napi_synchronize(const struct napi_struct *n) static inline void napi_synchronize(const struct napi_struct *n)
{ {
if (IS_ENABLED(CONFIG_SMP))
while (test_bit(NAPI_STATE_SCHED, &n->state)) while (test_bit(NAPI_STATE_SCHED, &n->state))
msleep(1); msleep(1);
else
barrier();
} }
#else
# define napi_synchronize(n) barrier()
#endif
enum netdev_queue_state_t { enum netdev_queue_state_t {
__QUEUE_STATE_DRV_XOFF, __QUEUE_STATE_DRV_XOFF,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment