Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/drm open_count is protected by drm_glo...



details:   https://anonhg.NetBSD.org/src/rev/207d7f6da4e8
branches:  trunk
changeset: 364283:207d7f6da4e8
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 06:51:29 2018 +0000

description:
open_count is protected by drm_global_mutex; count_lock is no more.

diffstat:

 sys/external/bsd/drm2/drm/drm_cdevsw.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (81 lines):

diff -r 56fe5118d03b -r 207d7f6da4e8 sys/external/bsd/drm2/drm/drm_cdevsw.c
--- a/sys/external/bsd/drm2/drm/drm_cdevsw.c    Mon Aug 27 06:51:17 2018 +0000
+++ b/sys/external/bsd/drm2/drm/drm_cdevsw.c    Mon Aug 27 06:51:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_cdevsw.c,v 1.5 2018/08/27 06:51:17 riastradh Exp $ */
+/*     $NetBSD: drm_cdevsw.c,v 1.6 2018/08/27 06:51:29 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_cdevsw.c,v 1.5 2018/08/27 06:51:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_cdevsw.c,v 1.6 2018/08/27 06:51:29 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -58,6 +58,7 @@
 #include <linux/pm.h>
 
 #include <drm/drmP.h>
+#include <drm/drm_internal.h>
 #include "../dist/drm/drm_legacy.h"
 
 static dev_type_open(drm_open);
@@ -139,15 +140,15 @@
                goto fail1;
        }
 
-       spin_lock(&dev->count_lock);
+       mutex_lock(&drm_global_mutex);
        if (dev->open_count == INT_MAX) {
-               spin_unlock(&dev->count_lock);
+               mutex_unlock(&drm_global_mutex);
                error = EBUSY;
                goto fail1;
        }
        firstopen = (dev->open_count == 0);
        dev->open_count++;
-       spin_unlock(&dev->count_lock);
+       mutex_lock(&drm_global_mutex);
 
        if (firstopen) {
                /* XXX errno Linux->NetBSD */
@@ -174,11 +175,11 @@
 
 fail3: kmem_free(file, sizeof(*file));
        fd_abort(curproc, fp, fd);
-fail2: spin_lock(&dev->count_lock);
+fail2: mutex_lock(&drm_global_mutex);
        KASSERT(0 < dev->open_count);
        --dev->open_count;
        lastclose = (dev->open_count == 0);
-       spin_unlock(&dev->count_lock);
+       mutex_unlock(&drm_global_mutex);
        if (lastclose)
                (void)drm_lastclose(dev);
 fail1: drm_minor_release(dminor);
@@ -197,11 +198,11 @@
        drm_close_file(file);
        kmem_free(file, sizeof(*file));
 
-       spin_lock(&dev->count_lock);
+       mutex_lock(&drm_global_mutex);
        KASSERT(0 < dev->open_count);
        --dev->open_count;
        lastclose = (dev->open_count == 0);
-       spin_unlock(&dev->count_lock);
+       mutex_unlock(&drm_global_mutex);
 
        if (lastclose)
                (void)drm_lastclose(dev);
@@ -255,7 +256,6 @@
        drm_legacy_sg_cleanup(dev);
        drm_legacy_vma_flush(dev);
        drm_legacy_dma_takedown(dev);
-
        mutex_unlock(&dev->struct_mutex);
 
        drm_legacy_dev_reinit(dev);



Home | Main Index | Thread Index | Old Index