Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 May 2016 17:41:25 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r299960 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201605161741.u4GHfPRD070586@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon May 16 17:41:25 2016
New Revision: 299960
URL: https://svnweb.freebsd.org/changeset/base/299960

Log:
  Only lock Giant when needed in the LinuxKPI.
  
  Suggested by:	ngie @
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/device.h

Modified: head/sys/compat/linuxkpi/common/include/linux/device.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/device.h	Mon May 16 17:32:28 2016	(r299959)
+++ head/sys/compat/linuxkpi/common/include/linux/device.h	Mon May 16 17:41:25 2016	(r299960)
@@ -333,10 +333,11 @@ device_unregister(struct device *dev)
 	bsddev = dev->bsddev;
 	dev->bsddev = NULL;
 
-	mtx_lock(&Giant);
-	if (bsddev != NULL)
+	if (bsddev != NULL) {
+		mtx_lock(&Giant);
 		device_delete_child(device_get_parent(bsddev), bsddev);
-	mtx_unlock(&Giant);
+		mtx_unlock(&Giant);
+	}
 	put_device(dev);
 }
 
@@ -348,10 +349,11 @@ device_del(struct device *dev)
 	bsddev = dev->bsddev;
 	dev->bsddev = NULL;
 
-	mtx_lock(&Giant);
-	if (bsddev != NULL)
+	if (bsddev != NULL) {
+		mtx_lock(&Giant);
 		device_delete_child(device_get_parent(bsddev), bsddev);
-	mtx_unlock(&Giant);
+		mtx_unlock(&Giant);
+	}
 }
 
 struct device *device_create(struct class *class, struct device *parent,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605161741.u4GHfPRD070586>