Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lmc(4) mutex locking
On Wed, Jun 25, 2008 at 07:05:11PM -0700, Gregory McGarry wrote:
> To remove gcc extensions from the lmc(4) driver, I converted the driver to
> mutexes. Does it look correct? Can anybody test it?
> -- Gregory McGarry <g.mcgarry%ieee.org@localhost>
>
>
>
> Get the name you always wanted with the new y7mail email address.
> www.yahoo7.com.au/mail
> Index: if_lmc.c
> ===================================================================
> RCS file: /cvsroot/src/sys/dev/pci/if_lmc.c,v
> retrieving revision 1.42
> diff -u -r1.42 if_lmc.c
> --- if_lmc.c 12 Jun 2008 22:44:47 -0000 1.42
> +++ if_lmc.c 26 Jun 2008 02:04:08 -0000
> @@ -7167,7 +7167,7 @@
> }
>
> /* Initialize the top-half and bottom-half locks. */
> - __cpu_simple_lock_init(&sc->top_lock);
> + mutex_init(&sc->top_lock, MUTEX_DEFAULT, IPL_NET);
IPL_VM
> @@ -1055,10 +1055,9 @@
> # define WRITE_CSR(sc, csr, val) bus_space_write_4((sc)->csr_tag,
> (sc)->csr_handle, csr, val)
> # define NAME_UNIT device_xname(&sc->dev)
> # define BOOT_VERBOSE (boothowto & AB_VERBOSE)
> -# define TOP_LOCK(sc) ({ while
> (__cpu_simple_lock_try(&(sc)->top_lock)==0) \
> - tsleep((sc), PCATCH|PZERO, DEVICE_NAME, 1); 0;
> })
> -# define TOP_TRYLOCK(sc) __cpu_simple_lock_try(&(sc)->top_lock)
> -# define TOP_UNLOCK(sc) __cpu_simple_unlock (&(sc)->top_lock)
> +# define TOP_LOCK(sc) (mutex_enter(&(sc)->top_lock), 0)
> +# define TOP_TRYLOCK(sc) mutex_tryenter(&(sc)->top_lock)
> +# define TOP_UNLOCK(sc) mutex_exit(&(sc)->top_lock)
> # define BOTTOM_TRYLOCK(sc) __cpu_simple_lock_try(&(sc)->bottom_lock)
> # define BOTTOM_UNLOCK(sc) __cpu_simple_unlock (&(sc)->bottom_lock)
> # define CHECK_CAP kauth_authorize_generic(curlwp->l_cred,
> KAUTH_GENERIC_ISSUSER, NULL)
mutex_spin_enter + mutex_spin_exit
> @@ -1290,7 +1289,11 @@
> void *irq_cookie;
> void *sdh_cookie;
> struct mbuf *tx_mbuf; /* hang mbuf here while
> building dma descs */
> +#if defined(__NetBSD__)
> + kmutex_t top_lock; /* lock card->watchdog vs ioctls
> */
> +#else
> __cpu_simple_lock_t top_lock; /* lock card->watchdog vs
> ioctls */
> +#endif
> __cpu_simple_lock_t bottom_lock; /* lock buf queues & descriptor rings
> */
> #endif /* __NetBSD__ || __OpenBSD__ */
The #ifdefs are probably not worth it. Otherwise it looks fine to me.
Andrew
Home |
Main Index |
Thread Index |
Old Index