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/dist/drm Sprinkle idr_preload/idr_prel...



details:   https://anonhg.NetBSD.org/src/rev/a420d427283b
branches:  trunk
changeset: 366250:a420d427283b
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 14:14:28 2018 +0000

description:
Sprinkle idr_preload/idr_preload_end.

Try to do these outside all mutex locks.

Tricky case is i915_gem_context, where the struct mutex is held for a
long time.

diffstat:

 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_bo_list.c |   7 +++++--
 sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ctx.c     |   7 +++++--
 sys/external/bsd/drm2/dist/drm/drm_auth.c                  |   6 ++++--
 sys/external/bsd/drm2/dist/drm/drm_context.c               |   6 ++++--
 sys/external/bsd/drm2/dist/drm/drm_crtc.c                  |   6 ++++--
 sys/external/bsd/drm2/dist/drm/drm_gem.c                   |   8 ++++----
 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c             |   6 ++++--
 sys/external/bsd/drm2/dist/drm/i915/i915_gem_context.c     |  14 +++++++++-----
 sys/external/bsd/drm2/dist/drm/sis/sis_mm.c                |   8 ++++++--
 sys/external/bsd/drm2/dist/drm/via/via_mm.c                |   8 ++++++--
 10 files changed, 51 insertions(+), 25 deletions(-)

diffs (truncated from 403 to 300 lines):

diff -r 486cb6792a27 -r a420d427283b sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_bo_list.c
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_bo_list.c        Mon Aug 27 14:14:13 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_bo_list.c        Mon Aug 27 14:14:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpu_bo_list.c,v 1.3 2018/08/27 14:04:50 riastradh Exp $     */
+/*     $NetBSD: amdgpu_bo_list.c,v 1.4 2018/08/27 14:14:28 riastradh Exp $     */
 
 /*
  * Copyright 2015 Advanced Micro Devices, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_bo_list.c,v 1.3 2018/08/27 14:04:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_bo_list.c,v 1.4 2018/08/27 14:14:28 riastradh Exp $");
 
 #include <drm/drmP.h>
 #include "amdgpu.h"
@@ -47,14 +47,17 @@
        if (!*result)
                return -ENOMEM;
 
+       idr_preload(GFP_KERNEL);
        mutex_lock(&fpriv->bo_list_lock);
        r = idr_alloc(&fpriv->bo_list_handles, *result,
                      1, 0, GFP_KERNEL);
        if (r < 0) {
                mutex_unlock(&fpriv->bo_list_lock);
+               idr_preload_end();
                kfree(*result);
                return r;
        }
+       idr_preload_end();
        *id = r;
 
 #ifdef __NetBSD__
diff -r 486cb6792a27 -r a420d427283b sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ctx.c
--- a/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ctx.c    Mon Aug 27 14:14:13 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ctx.c    Mon Aug 27 14:14:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdgpu_ctx.c,v 1.3 2018/08/27 14:04:50 riastradh Exp $ */
+/*     $NetBSD: amdgpu_ctx.c,v 1.4 2018/08/27 14:14:28 riastradh Exp $ */
 
 /*
  * Copyright 2015 Advanced Micro Devices, Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdgpu_ctx.c,v 1.3 2018/08/27 14:04:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdgpu_ctx.c,v 1.4 2018/08/27 14:14:28 riastradh Exp $");
 
 #include <drm/drmP.h>
 #include "amdgpu.h"
@@ -100,16 +100,19 @@
        if (!ctx)
                return -ENOMEM;
 
+       idr_preload(GFP_KERNEL);
        mutex_lock(&mgr->lock);
        r = idr_alloc(&mgr->ctx_handles, ctx, 1, 0, GFP_KERNEL);
        if (r < 0) {
                mutex_unlock(&mgr->lock);
+               idr_preload_end();
                kfree(ctx);
                return r;
        }
        *id = (uint32_t)r;
        r = amdgpu_ctx_init(adev, false, ctx);
        mutex_unlock(&mgr->lock);
+       idr_preload_end();
 
        return r;
 }
diff -r 486cb6792a27 -r a420d427283b sys/external/bsd/drm2/dist/drm/drm_auth.c
--- a/sys/external/bsd/drm2/dist/drm/drm_auth.c Mon Aug 27 14:14:13 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_auth.c Mon Aug 27 14:14:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_auth.c,v 1.3 2018/08/27 04:58:19 riastradh Exp $   */
+/*     $NetBSD: drm_auth.c,v 1.4 2018/08/27 14:14:29 riastradh Exp $   */
 
 /*
  * Created: Tue Feb  2 08:37:54 1999 by faith%valinux.com@localhost
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_auth.c,v 1.3 2018/08/27 04:58:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_auth.c,v 1.4 2018/08/27 14:14:29 riastradh Exp $");
 
 #include <drm/drmP.h>
 #include "drm_internal.h"
@@ -53,6 +53,7 @@
        struct drm_auth *auth = data;
        int ret = 0;
 
+       idr_preload(GFP_KERNEL);
        mutex_lock(&dev->struct_mutex);
        if (!file_priv->magic) {
                ret = idr_alloc(&file_priv->master->magic_map, file_priv,
@@ -62,6 +63,7 @@
        }
        auth->magic = file_priv->magic;
        mutex_unlock(&dev->struct_mutex);
+       idr_preload_end();
 
        DRM_DEBUG("%u\n", auth->magic);
 
diff -r 486cb6792a27 -r a420d427283b sys/external/bsd/drm2/dist/drm/drm_context.c
--- a/sys/external/bsd/drm2/dist/drm/drm_context.c      Mon Aug 27 14:14:13 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_context.c      Mon Aug 27 14:14:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_context.c,v 1.4 2018/08/27 04:58:19 riastradh Exp $        */
+/*     $NetBSD: drm_context.c,v 1.5 2018/08/27 14:14:29 riastradh Exp $        */
 
 /*
  * Legacy: Generic DRM Contexts
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_context.c,v 1.4 2018/08/27 04:58:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_context.c,v 1.5 2018/08/27 14:14:29 riastradh Exp $");
 
 #include <linux/err.h>
 
@@ -82,10 +82,12 @@
 {
        int ret;
 
+       idr_preload(GFP_KERNEL);
        mutex_lock(&dev->struct_mutex);
        ret = idr_alloc(&dev->ctx_idr, NULL, DRM_RESERVED_CONTEXTS, 0,
                        GFP_KERNEL);
        mutex_unlock(&dev->struct_mutex);
+       idr_preload_end();
        return ret;
 }
 
diff -r 486cb6792a27 -r a420d427283b sys/external/bsd/drm2/dist/drm/drm_crtc.c
--- a/sys/external/bsd/drm2/dist/drm/drm_crtc.c Mon Aug 27 14:14:13 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_crtc.c Mon Aug 27 14:14:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_crtc.c,v 1.8 2018/08/27 06:55:13 riastradh Exp $   */
+/*     $NetBSD: drm_crtc.c,v 1.9 2018/08/27 14:14:29 riastradh Exp $   */
 
 /*
  * Copyright (c) 2006-2008 Intel Corporation
@@ -32,7 +32,7 @@
  *      Jesse Barnes <jesse.barnes%intel.com@localhost>
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_crtc.c,v 1.8 2018/08/27 06:55:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_crtc.c,v 1.9 2018/08/27 14:14:29 riastradh Exp $");
 
 #include <linux/err.h>
 #include <linux/spinlock.h>
@@ -5987,6 +5987,7 @@
        memcpy(tg->group_data, topology, 8);
        tg->dev = dev;
 
+       idr_preload(GFP_KERNEL);
        mutex_lock(&dev->mode_config.idr_mutex);
        ret = idr_alloc(&dev->mode_config.tile_idr, tg, 1, 0, GFP_KERNEL);
        if (ret >= 0) {
@@ -5997,6 +5998,7 @@
        }
 
        mutex_unlock(&dev->mode_config.idr_mutex);
+       idr_preload_end();
        return tg;
 }
 EXPORT_SYMBOL(drm_mode_create_tile_group);
diff -r 486cb6792a27 -r a420d427283b sys/external/bsd/drm2/dist/drm/drm_gem.c
--- a/sys/external/bsd/drm2/dist/drm/drm_gem.c  Mon Aug 27 14:14:13 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_gem.c  Mon Aug 27 14:14:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_gem.c,v 1.8 2018/08/27 07:19:01 riastradh Exp $    */
+/*     $NetBSD: drm_gem.c,v 1.9 2018/08/27 14:14:29 riastradh Exp $    */
 
 /*
  * Copyright © 2008 Intel Corporation
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_gem.c,v 1.8 2018/08/27 07:19:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_gem.c,v 1.9 2018/08/27 14:14:29 riastradh Exp $");
 
 #include <linux/types.h>
 #include <linux/slab.h>
@@ -723,8 +723,8 @@
        if (obj == NULL)
                return -ENOENT;
 
+       idr_preload(GFP_KERNEL);
        mutex_lock(&dev->object_name_lock);
-       idr_preload(GFP_KERNEL);
        /* prevent races with concurrent gem_close. */
        if (obj->handle_count == 0) {
                ret = -ENOENT;
@@ -743,8 +743,8 @@
        ret = 0;
 
 err:
+       mutex_unlock(&dev->object_name_lock);
        idr_preload_end();
-       mutex_unlock(&dev->object_name_lock);
        drm_gem_object_unreference_unlocked(obj);
        return ret;
 }
diff -r 486cb6792a27 -r a420d427283b sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c    Mon Aug 27 14:14:13 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c    Mon Aug 27 14:14:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem.c,v 1.49 2018/08/27 13:44:29 riastradh Exp $  */
+/*     $NetBSD: i915_gem.c,v 1.50 2018/08/27 14:14:29 riastradh Exp $  */
 
 /*
  * Copyright © 2008-2015 Intel Corporation
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem.c,v 1.49 2018/08/27 13:44:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem.c,v 1.50 2018/08/27 14:14:29 riastradh Exp $");
 
 #ifdef __NetBSD__
 #if 0                          /* XXX uvmhist option?  */
@@ -5472,6 +5472,7 @@
        i915.enable_execlists = intel_sanitize_enable_execlists(dev,
                        i915.enable_execlists);
 
+       idr_preload(GFP_KERNEL);        /* gem context */
        mutex_lock(&dev->struct_mutex);
 
        if (IS_VALLEYVIEW(dev)) {
@@ -5530,6 +5531,7 @@
 out_unlock:
        intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
        mutex_unlock(&dev->struct_mutex);
+       idr_preload_end();
 
        return ret;
 }
diff -r 486cb6792a27 -r a420d427283b sys/external/bsd/drm2/dist/drm/i915/i915_gem_context.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem_context.c    Mon Aug 27 14:14:13 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem_context.c    Mon Aug 27 14:14:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_context.c,v 1.8 2018/08/27 06:07:58 riastradh Exp $   */
+/*     $NetBSD: i915_gem_context.c,v 1.9 2018/08/27 14:14:29 riastradh Exp $   */
 
 /*
  * Copyright © 2011-2012 Intel Corporation
@@ -88,7 +88,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_context.c,v 1.8 2018/08/27 06:07:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_context.c,v 1.9 2018/08/27 14:14:29 riastradh Exp $");
 
 #include <linux/err.h>
 #include <drm/drmP.h>
@@ -236,10 +236,8 @@
 
        /* Default context will never have a file_priv */
        if (file_priv != NULL) {
-               idr_preload(GFP_KERNEL);
                ret = idr_alloc(&file_priv->context_idr, ctx,
                                DEFAULT_CONTEXT_HANDLE, 0, GFP_KERNEL);
-               idr_preload_end();
                if (ret < 0)
                        goto err_out;
        } else
@@ -485,9 +483,11 @@
 
        idr_init(&file_priv->context_idr);
 
+       idr_preload(GFP_KERNEL);
        mutex_lock(&dev->struct_mutex);
        ctx = i915_gem_create_context(dev, file_priv);
        mutex_unlock(&dev->struct_mutex);
+       idr_preload_end();
 
        if (IS_ERR(ctx)) {
                idr_destroy(&file_priv->context_idr);
@@ -865,12 +865,16 @@
        if (!contexts_enabled(dev))
                return -ENODEV;
 
+       idr_preload(GFP_KERNEL);
        ret = i915_mutex_lock_interruptible(dev);
-       if (ret)
+       if (ret) {
+               idr_preload_end();
                return ret;
+       }
 
        ctx = i915_gem_create_context(dev, file_priv);
        mutex_unlock(&dev->struct_mutex);



Home | Main Index | Thread Index | Old Index