From owner-freebsd-bugs@FreeBSD.ORG Fri Sep 21 06:50:08 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 790BC1065674 for ; Fri, 21 Sep 2012 06:50:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 514EB8FC0A for ; Fri, 21 Sep 2012 06:50:08 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q8L6o8GK093184 for ; Fri, 21 Sep 2012 06:50:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q8L6o8gb093183; Fri, 21 Sep 2012 06:50:08 GMT (envelope-from gnats) Resent-Date: Fri, 21 Sep 2012 06:50:08 GMT Resent-Message-Id: <201209210650.q8L6o8gb093183@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Venkat Duvvuru Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 767CD1065670 for ; Fri, 21 Sep 2012 06:47:59 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 48D9D8FC18 for ; Fri, 21 Sep 2012 06:47:59 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q8L6lxRg003329 for ; Fri, 21 Sep 2012 06:47:59 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id q8L6lxSI003328; Fri, 21 Sep 2012 06:47:59 GMT (envelope-from nobody) Message-Id: <201209210647.q8L6lxSI003328@red.freebsd.org> Date: Fri, 21 Sep 2012 06:47:59 GMT From: Venkat Duvvuru To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/171838: Possible lock reversal and duplicate locks as reported by Witness X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Sep 2012 06:50:08 -0000 >Number: 171838 >Category: misc >Synopsis: Possible lock reversal and duplicate locks as reported by Witness >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Sep 21 06:50:07 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Venkat Duvvuru >Release: 9.0-RELEASE >Organization: Emulex >Environment: FreeBSD root@xxx FreeBsd 9.0-RELEASE FreeBSD 9.0-RELEASE #12: Thu Aug 23 23:42:39 IST 2012 root@root@xxx FreeBsd:/usr/obj/usr/src/sys/GENERIC amd64 >Description: This patch is for Freebsd nic "oce" driver (http://svn.freebsd.org/base/head/sys/dev/oce/) I am attaching a patch which fixes some issues which were reported by witness. Specifically, - Calling mtx_init with same name causes WITNESS to report possible lock reversal and duplicate lock issues. - release mtx_lock before invoking taskqueue_drain. >How-To-Repeat: >Fix: Fix is attached in the form of patch. Patch attached with submission follows: Index: oce_if.c =================================================================== --- oce_if.c (revision 233768) +++ oce_if.c (working copy) @@ -1816,6 +1816,9 @@ } +/* NOTE : This should only be called holding + * DEVICE_LOCK. +*/ static void oce_if_deactivate(POCE_SOFTC sc) { @@ -1845,11 +1848,17 @@ /* Stop intrs and finish any bottom halves pending */ oce_hw_intr_disable(sc); + /* Since taskqueue_drain takes a Gaint Lock, We should not acquire + any other lock. So unlock device lock and require after + completing taskqueue_drain. + */ + UNLOCK(&sc->dev_lock); for (i = 0; i < sc->intr_count; i++) { if (sc->intrs[i].tq != NULL) { taskqueue_drain(sc->intrs[i].tq, &sc->intrs[i].task); } } + LOCK(&sc->dev_lock); /* Delete RX queue in card with flush param */ oce_stop_rx(sc); Index: oce_if.h =================================================================== --- oce_if.h (revision 233768) +++ oce_if.h (working copy) @@ -493,7 +493,7 @@ #define LOCK_CREATE(lock, desc) { \ strncpy((lock)->name, (desc), MAX_LOCK_DESC_LEN); \ (lock)->name[MAX_LOCK_DESC_LEN] = '\0'; \ - mtx_init(&(lock)->mutex, (lock)->name, MTX_NETWORK_LOCK, MTX_DEF); \ + mtx_init(&(lock)->mutex, (lock)->name, NULL, MTX_DEF); \ } #define LOCK_DESTROY(lock) \ if (mtx_initialized(&(lock)->mutex))\ >Release-Note: >Audit-Trail: >Unformatted: