Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/net/lib/libshmif * use atomic ops instead of __cpu_...
details: https://anonhg.NetBSD.org/src/rev/b9e78c332884
branches: trunk
changeset: 757012:b9e78c332884
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Aug 10 18:17:12 2010 +0000
description:
* use atomic ops instead of __cpu_simple_luck
* this interface is un-IFF_SIMPLEX
diffstat:
sys/rump/net/lib/libshmif/if_shmem.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diffs (63 lines):
diff -r 79384010c010 -r b9e78c332884 sys/rump/net/lib/libshmif/if_shmem.c
--- a/sys/rump/net/lib/libshmif/if_shmem.c Tue Aug 10 18:06:10 2010 +0000
+++ b/sys/rump/net/lib/libshmif/if_shmem.c Tue Aug 10 18:17:12 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_shmem.c,v 1.12 2010/07/29 22:48:11 pooka Exp $ */
+/* $NetBSD: if_shmem.c,v 1.13 2010/08/10 18:17:12 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -28,9 +28,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.12 2010/07/29 22:48:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.13 2010/08/10 18:17:12 pooka Exp $");
#include <sys/param.h>
+#include <sys/atomic.h>
#include <sys/fcntl.h>
#include <sys/kmem.h>
#include <sys/kthread.h>
@@ -89,6 +90,9 @@
static uint32_t numif;
+#define LOCK_UNLOCKED 0
+#define LOCK_LOCKED 1
+
/*
* This locking needs work and will misbehave severely if:
* 1) the backing memory has to be paged in
@@ -98,14 +102,20 @@
lockbus(struct shmif_sc *sc)
{
- __cpu_simple_lock((__cpu_simple_lock_t *)sc->sc_busmem);
+ while (atomic_cas_uint((void *)sc->sc_busmem,
+ LOCK_UNLOCKED, LOCK_LOCKED) == LOCK_LOCKED)
+ continue;
+ membar_enter();
}
static void
unlockbus(struct shmif_sc *sc)
{
+ unsigned int old;
- __cpu_simple_unlock((__cpu_simple_lock_t *)sc->sc_busmem);
+ membar_exit();
+ old = atomic_swap_uint((void *)sc->sc_busmem, LOCK_UNLOCKED);
+ KASSERT(old == LOCK_LOCKED);
}
static uint32_t
@@ -221,7 +231,7 @@
sprintf(ifp->if_xname, "shmif%d", mynum);
ifp->if_softc = sc;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+ ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST;
ifp->if_init = shmif_init;
ifp->if_ioctl = shmif_ioctl;
ifp->if_start = shmif_start;
Home |
Main Index |
Thread Index |
Old Index