From owner-svn-src-head@FreeBSD.ORG Fri Apr 12 17:41:24 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DC852D9D; Fri, 12 Apr 2013 17:41:24 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CF32213E5; Fri, 12 Apr 2013 17:41:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3CHfOW8092138; Fri, 12 Apr 2013 17:41:24 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3CHfODp092136; Fri, 12 Apr 2013 17:41:24 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201304121741.r3CHfODp092136@svn.freebsd.org> From: Jim Harris Date: Fri, 12 Apr 2013 17:41:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249418 - head/sys/dev/nvme X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Apr 2013 17:41:24 -0000 Author: jimharris Date: Fri Apr 12 17:41:24 2013 New Revision: 249418 URL: http://svnweb.freebsd.org/changeset/base/249418 Log: Add a mutex to each namespace, for general locking operations on the namespace. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_ns.c head/sys/dev/nvme/nvme_private.h Modified: head/sys/dev/nvme/nvme_ns.c ============================================================================== --- head/sys/dev/nvme/nvme_ns.c Fri Apr 12 17:36:48 2013 (r249417) +++ head/sys/dev/nvme/nvme_ns.c Fri Apr 12 17:41:24 2013 (r249418) @@ -300,6 +300,17 @@ nvme_ns_construct(struct nvme_namespace ns->ctrlr = ctrlr; ns->id = id; + /* + * Namespaces are reconstructed after a controller reset, so check + * to make sure we only call mtx_init once on each mtx. + * + * TODO: Move this somewhere where it gets called at controller + * construction time, which is not invoked as part of each + * controller reset. + */ + if (!mtx_initialized(&ns->lock)) + mtx_init(&ns->lock, "nvme ns lock", NULL, MTX_DEF); + #ifdef CHATHAM2 if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID) nvme_ns_populate_chatham_data(ns); Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Fri Apr 12 17:36:48 2013 (r249417) +++ head/sys/dev/nvme/nvme_private.h Fri Apr 12 17:41:24 2013 (r249418) @@ -238,6 +238,7 @@ struct nvme_namespace { uint16_t flags; struct cdev *cdev; void *cons_cookie[NVME_MAX_CONSUMERS]; + struct mtx lock; }; /*