diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-10-17 16:26:41 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-17 20:17:34 -0400 |
commit | c264c3dee9f20bad1f42ef5821300791291d0f77 (patch) | |
tree | cbd106e8e69163032ab6346672a7cefe1b39da2b | |
parent | a7475906bc496456ded9e4b062f94067fb93057a (diff) |
napi_synchronize: waiting for NAPI
Some drivers with shared NAPI need a synchronization barrier.
Also suggested by Benjamin Herrenschmidt for EMAC.
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | include/linux/netdevice.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 39dd83b183a..a5e2dc1f0d9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -407,6 +407,24 @@ static inline void napi_enable(struct napi_struct *n) | |||
407 | clear_bit(NAPI_STATE_SCHED, &n->state); | 407 | clear_bit(NAPI_STATE_SCHED, &n->state); |
408 | } | 408 | } |
409 | 409 | ||
410 | #ifdef CONFIG_SMP | ||
411 | /** | ||
412 | * napi_synchronize - wait until NAPI is not running | ||
413 | * @n: napi context | ||
414 | * | ||
415 | * Wait until NAPI is done being scheduled on this context. | ||
416 | * Waits till any outstanding processing completes but | ||
417 | * does not disable future activations. | ||
418 | */ | ||
419 | static inline void napi_synchronize(const struct napi_struct *n) | ||
420 | { | ||
421 | while (test_bit(NAPI_STATE_SCHED, &n->state)) | ||
422 | msleep(1); | ||
423 | } | ||
424 | #else | ||
425 | # define napi_synchronize(n) barrier() | ||
426 | #endif | ||
427 | |||
410 | /* | 428 | /* |
411 | * The DEVICE structure. | 429 | * The DEVICE structure. |
412 | * Actually, this whole structure is a big mistake. It mixes I/O | 430 | * Actually, this whole structure is a big mistake. It mixes I/O |