From owner-svn-src-projects@FreeBSD.ORG Tue Aug 24 20:41:05 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8549A1065747; Tue, 24 Aug 2010 20:41:05 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 747038FC1F; Tue, 24 Aug 2010 20:41:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7OKf5B1087200; Tue, 24 Aug 2010 20:41:05 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7OKf5BV087194; Tue, 24 Aug 2010 20:41:05 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201008242041.o7OKf5BV087194@svn.freebsd.org> From: Jeff Roberson Date: Tue, 24 Aug 2010 20:41:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211771 - projects/ofed/head/sys/ofed/include/linux X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2010 20:41:05 -0000 Author: jeff Date: Tue Aug 24 20:41:05 2010 New Revision: 211771 URL: http://svn.freebsd.org/changeset/base/211771 Log: - Zero all locks before calling the appropriate init function as linux passes uninitialized memory in when locks are created and bsd expects it to be zeroed. This is much more reliable than converting all necessary sites to zero. Sponsored by: Isilon Systems, iX Systems, and Panasas Modified: projects/ofed/head/sys/ofed/include/linux/mutex.h projects/ofed/head/sys/ofed/include/linux/rwlock.h projects/ofed/head/sys/ofed/include/linux/rwsem.h projects/ofed/head/sys/ofed/include/linux/semaphore.h projects/ofed/head/sys/ofed/include/linux/spinlock.h Modified: projects/ofed/head/sys/ofed/include/linux/mutex.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/mutex.h Tue Aug 24 20:40:12 2010 (r211770) +++ projects/ofed/head/sys/ofed/include/linux/mutex.h Tue Aug 24 20:41:05 2010 (r211771) @@ -38,8 +38,6 @@ typedef struct mutex { struct sx sx; } mutex_t; -#define mutex_init(_m) sx_init_flags(&(_m)->sx, \ - "lnxmtx", SX_NOWITNESS) #define mutex_lock(_m) sx_xlock(&(_m)->sx) #define mutex_lock_nested(_m, _s) mutex_lock(_m) #define mutex_lock_interruptible(_m) ({ mutex_lock((_m)); 0; }) @@ -50,4 +48,14 @@ typedef struct mutex { mutex_t lock; \ SX_SYSINIT_FLAGS(lock, &(lock).sx, "lnxmtx", SX_NOWITNESS) +static inline void +linux_mutex_init(mutex_t *m) +{ + + memset(&m->sx, 0, sizeof(m->sx)); + sx_init_flags(&m->sx, "lnxmtx", SX_NOWITNESS); +} + +#define mutex_init linux_mutex_init + #endif /* _LINUX_MUTEX_H_ */ Modified: projects/ofed/head/sys/ofed/include/linux/rwlock.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/rwlock.h Tue Aug 24 20:40:12 2010 (r211770) +++ projects/ofed/head/sys/ofed/include/linux/rwlock.h Tue Aug 24 20:41:05 2010 (r211771) @@ -35,7 +35,6 @@ typedef struct { struct rwlock rw; } rwlock_t; -#define rwlock_init(_l) rw_init_flags(&(_l)->rw, "lnxrw", RW_NOWITNESS) #define read_lock(_l) rw_rlock(&(_l)->rw) #define write_lock(_l) rw_wlock(&(_l)->rw) #define read_unlock(_l) rw_runlock(&(_l)->rw) @@ -53,4 +52,12 @@ typedef struct { #define write_unlock_irqrestore(lock, flags) \ do { write_unlock(lock); } while (0) +static inline void +rwlock_init(rwlock_t *lock) +{ + + memset(&lock->rw, 0, sizeof(lock->rw)); + rw_init_flags(&lock->rw, "lnxrw", RW_NOWITNESS); +} + #endif /* _LINUX_RWLOCK_H_ */ Modified: projects/ofed/head/sys/ofed/include/linux/rwsem.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/rwsem.h Tue Aug 24 20:40:12 2010 (r211770) +++ projects/ofed/head/sys/ofed/include/linux/rwsem.h Tue Aug 24 20:41:05 2010 (r211771) @@ -36,8 +36,6 @@ struct rw_semaphore { struct sx sx; }; -#define init_rwsem(_rw) sx_init_flags(&(_rw)->sx, \ - "lnxrwsem", SX_NOWITNESS) #define down_write(_rw) sx_xlock(&(_rw)->sx) #define up_write(_rw) sx_xunlock(&(_rw)->sx) #define down_read(_rw) sx_slock(&(_rw)->sx) @@ -47,4 +45,12 @@ struct rw_semaphore { #define downgrade_write(_rw) sx_downgrade(&(_rw)->sx) #define down_read_nested(_rw, _sc) down_read(_rw) +static inline void +init_rwsem(struct rw_semaphore *rw) +{ + + memset(&rw->sx, 0, sizeof(rw->sx)); + sx_init_flags(&rw->sx, "lnxrwsem", SX_NOWITNESS); +} + #endif /* _LINUX_RWSEM_H_ */ Modified: projects/ofed/head/sys/ofed/include/linux/semaphore.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/semaphore.h Tue Aug 24 20:40:12 2010 (r211770) +++ projects/ofed/head/sys/ofed/include/linux/semaphore.h Tue Aug 24 20:41:05 2010 (r211771) @@ -49,6 +49,7 @@ static inline void linux_sema_init(struct semaphore *sem, int val) { + memset(&sem->sema, 0, sizeof(sem->sema)); sema_init(&sem->sema, val, "lnxsema"); } @@ -56,6 +57,7 @@ static inline void init_MUTEX(struct semaphore *sem) { + memset(&sem->sema, 0, sizeof(sem->sema)); sema_init(&sem->sema, 1, "lnxsema"); } Modified: projects/ofed/head/sys/ofed/include/linux/spinlock.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/spinlock.h Tue Aug 24 20:40:12 2010 (r211770) +++ projects/ofed/head/sys/ofed/include/linux/spinlock.h Tue Aug 24 20:41:05 2010 (r211771) @@ -42,8 +42,6 @@ typedef struct { struct mtx m; } spinlock_t; -#define spin_lock_init(_l) mtx_init(&(_l)->m, "lnxspin", NULL, \ - MTX_DEF | MTX_NOWITNESS) #define spin_lock(_l) mtx_lock(&(_l)->m) #define spin_unlock(_l) mtx_unlock(&(_l)->m) #define spin_lock_nested(_l, _n) mtx_lock_flags(&(_l)->m, MTX_DUPOK) @@ -54,6 +52,14 @@ typedef struct { #define spin_unlock_irqrestore(lock, flags) \ do { spin_unlock(lock); } while (0) +static inline void +spin_lock_init(spinlock_t *lock) +{ + + memset(&lock->m, 0, sizeof(lock->m)); + mtx_init(&lock->m, "lnxspin", NULL, MTX_DEF | MTX_NOWITNESS); +} + #define DEFINE_SPINLOCK(lock) \ spinlock_t lock; \ MTX_SYSINIT(lock, &(lock).m, "lnxspin", MTX_DEF)