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 drm: Add idr_preload.



details:   https://anonhg.NetBSD.org/src/rev/51985f29273e
branches:  trunk
changeset: 1028466:51985f29273e
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:06:54 2021 +0000

description:
drm: Add idr_preload.

Gone from Linux API -- Linux just assumes that allocation under
mutex, even if it means sleeping, is OK.

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_connector.c   |  6 ++++--
 sys/external/bsd/drm2/dist/drm/drm_dp_aux_dev.c  |  6 ++++--
 sys/external/bsd/drm2/dist/drm/drm_mode_object.c |  6 ++++--
 sys/external/bsd/drm2/dist/drm/i915/gvt/dmabuf.c |  6 ++++--
 sys/external/bsd/drm2/dist/drm/i915/gvt/vgpu.c   |  6 ++++--
 sys/external/bsd/drm2/dist/drm/i915/i915_perf.c  |  7 +++++--
 sys/external/bsd/drm2/dist/drm/vgem/vgem_fence.c |  6 ++++--
 7 files changed, 29 insertions(+), 14 deletions(-)

diffs (227 lines):

diff -r e2f60c5a346d -r 51985f29273e sys/external/bsd/drm2/dist/drm/drm_connector.c
--- a/sys/external/bsd/drm2/dist/drm/drm_connector.c    Sun Dec 19 11:06:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_connector.c    Sun Dec 19 11:06:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_connector.c,v 1.5 2021/12/19 09:51:50 riastradh Exp $      */
+/*     $NetBSD: drm_connector.c,v 1.6 2021/12/19 11:06:54 riastradh Exp $      */
 
 /*
  * Copyright (c) 2016 Intel Corporation
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_connector.c,v 1.5 2021/12/19 09:51:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_connector.c,v 1.6 2021/12/19 11:06:54 riastradh Exp $");
 
 #include <drm/drm_connector.h>
 #include <drm/drm_edid.h>
@@ -2400,6 +2400,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) {
@@ -2410,6 +2411,7 @@
        }
 
        mutex_unlock(&dev->mode_config.idr_mutex);
+       idr_preload_end();
        return tg;
 }
 EXPORT_SYMBOL(drm_mode_create_tile_group);
diff -r e2f60c5a346d -r 51985f29273e sys/external/bsd/drm2/dist/drm/drm_dp_aux_dev.c
--- a/sys/external/bsd/drm2/dist/drm/drm_dp_aux_dev.c   Sun Dec 19 11:06:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_dp_aux_dev.c   Sun Dec 19 11:06:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_dp_aux_dev.c,v 1.2 2021/12/18 23:44:57 riastradh Exp $     */
+/*     $NetBSD: drm_dp_aux_dev.c,v 1.3 2021/12/19 11:06:54 riastradh Exp $     */
 
 /*
  * Copyright © 2015 Intel Corporation
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_dp_aux_dev.c,v 1.2 2021/12/18 23:44:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_dp_aux_dev.c,v 1.3 2021/12/19 11:06:54 riastradh Exp $");
 
 #include <linux/device.h>
 #include <linux/fs.h>
@@ -87,9 +87,11 @@
        atomic_set(&aux_dev->usecount, 1);
        kref_init(&aux_dev->refcount);
 
+       idr_preload(GFP_KERNEL);
        mutex_lock(&aux_idr_mutex);
        index = idr_alloc(&aux_idr, aux_dev, 0, DRM_AUX_MINORS, GFP_KERNEL);
        mutex_unlock(&aux_idr_mutex);
+       idr_preload_end();
        if (index < 0) {
                kfree(aux_dev);
                return ERR_PTR(index);
diff -r e2f60c5a346d -r 51985f29273e sys/external/bsd/drm2/dist/drm/drm_mode_object.c
--- a/sys/external/bsd/drm2/dist/drm/drm_mode_object.c  Sun Dec 19 11:06:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_mode_object.c  Sun Dec 19 11:06:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_mode_object.c,v 1.2 2021/12/18 23:44:57 riastradh Exp $    */
+/*     $NetBSD: drm_mode_object.c,v 1.3 2021/12/19 11:06:54 riastradh Exp $    */
 
 /*
  * Copyright (c) 2016 Intel Corporation
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_mode_object.c,v 1.2 2021/12/18 23:44:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_mode_object.c,v 1.3 2021/12/19 11:06:54 riastradh Exp $");
 
 #include <linux/export.h>
 #include <linux/uaccess.h>
@@ -49,6 +49,7 @@
 
        WARN_ON(!dev->driver->load && dev->registered && !obj_free_cb);
 
+       idr_preload(GFP_KERNEL);
        mutex_lock(&dev->mode_config.idr_mutex);
        ret = idr_alloc(&dev->mode_config.object_idr, register_obj ? obj : NULL,
                        1, 0, GFP_KERNEL);
@@ -65,6 +66,7 @@
                }
        }
        mutex_unlock(&dev->mode_config.idr_mutex);
+       idr_preload_end();
 
        return ret < 0 ? ret : 0;
 }
diff -r e2f60c5a346d -r 51985f29273e sys/external/bsd/drm2/dist/drm/i915/gvt/dmabuf.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gvt/dmabuf.c  Sun Dec 19 11:06:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gvt/dmabuf.c  Sun Dec 19 11:06:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dmabuf.c,v 1.2 2021/12/18 23:45:31 riastradh Exp $     */
+/*     $NetBSD: dmabuf.c,v 1.3 2021/12/19 11:06:55 riastradh Exp $     */
 
 /*
  * Copyright 2017 Intel Corporation. All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dmabuf.c,v 1.2 2021/12/18 23:45:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dmabuf.c,v 1.3 2021/12/19 11:06:55 riastradh Exp $");
 
 #include <linux/dma-buf.h>
 #include <linux/vfio.h>
@@ -486,7 +486,9 @@
 
        dmabuf_obj->vgpu = vgpu;
 
+       idr_preload(GFP_NOWAIT); /* XXX ??? */
        ret = idr_alloc(&vgpu->object_idr, dmabuf_obj, 1, 0, GFP_NOWAIT);
+       idr_preload_end();
        if (ret < 0)
                goto out_free_info;
        gfx_plane_info->dmabuf_id = ret;
diff -r e2f60c5a346d -r 51985f29273e sys/external/bsd/drm2/dist/drm/i915/gvt/vgpu.c
--- a/sys/external/bsd/drm2/dist/drm/i915/gvt/vgpu.c    Sun Dec 19 11:06:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/gvt/vgpu.c    Sun Dec 19 11:06:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vgpu.c,v 1.2 2021/12/18 23:45:31 riastradh Exp $       */
+/*     $NetBSD: vgpu.c,v 1.3 2021/12/19 11:06:55 riastradh Exp $       */
 
 /*
  * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vgpu.c,v 1.2 2021/12/18 23:45:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vgpu.c,v 1.3 2021/12/19 11:06:55 riastradh Exp $");
 
 #include "i915_drv.h"
 #include "gvt.h"
@@ -375,8 +375,10 @@
        if (!vgpu)
                return ERR_PTR(-ENOMEM);
 
+       idr_preload(GFP_KERNEL);
        ret = idr_alloc(&gvt->vgpu_idr, vgpu, IDLE_VGPU_IDR + 1, GVT_MAX_VGPU,
                GFP_KERNEL);
+       idr_preload_end();
        if (ret < 0)
                goto out_free_vgpu;
 
diff -r e2f60c5a346d -r 51985f29273e sys/external/bsd/drm2/dist/drm/i915/i915_perf.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_perf.c   Sun Dec 19 11:06:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_perf.c   Sun Dec 19 11:06:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_perf.c,v 1.2 2021/12/18 23:45:28 riastradh Exp $  */
+/*     $NetBSD: i915_perf.c,v 1.3 2021/12/19 11:06:55 riastradh Exp $  */
 
 /*
  * Copyright © 2015-2016 Intel Corporation
@@ -194,7 +194,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_perf.c,v 1.2 2021/12/18 23:45:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_perf.c,v 1.3 2021/12/19 11:06:55 riastradh Exp $");
 
 #include <linux/anon_inodes.h>
 #include <linux/sizes.h>
@@ -4080,6 +4080,7 @@
                oa_config->flex_regs = regs;
        }
 
+       idr_preload(GFP_KERNEL);
        err = mutex_lock_interruptible(&perf->metrics_lock);
        if (err)
                goto reg_err;
@@ -4112,6 +4113,7 @@
        }
 
        mutex_unlock(&perf->metrics_lock);
+       idr_preload_end();
 
        DRM_DEBUG("Added config %s id=%i\n", oa_config->uuid, oa_config->id);
 
@@ -4119,6 +4121,7 @@
 
 sysfs_err:
        mutex_unlock(&perf->metrics_lock);
+       idr_preload_end();
 reg_err:
        i915_oa_config_put(oa_config);
        DRM_DEBUG("Failed to add new OA config\n");
diff -r e2f60c5a346d -r 51985f29273e sys/external/bsd/drm2/dist/drm/vgem/vgem_fence.c
--- a/sys/external/bsd/drm2/dist/drm/vgem/vgem_fence.c  Sun Dec 19 11:06:44 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/vgem/vgem_fence.c  Sun Dec 19 11:06:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vgem_fence.c,v 1.2 2021/12/18 23:45:44 riastradh Exp $ */
+/*     $NetBSD: vgem_fence.c,v 1.3 2021/12/19 11:06:55 riastradh Exp $ */
 
 /*
  * Copyright 2016 Intel Corporation
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vgem_fence.c,v 1.2 2021/12/18 23:45:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vgem_fence.c,v 1.3 2021/12/19 11:06:55 riastradh Exp $");
 
 #include <linux/dma-buf.h>
 #include <linux/dma-resv.h>
@@ -173,9 +173,11 @@
 
        /* Record the fence in our idr for later signaling */
        if (ret == 0) {
+               idr_preload(GFP_KERNEL);
                mutex_lock(&vfile->fence_mutex);
                ret = idr_alloc(&vfile->fence_idr, fence, 1, 0, GFP_KERNEL);
                mutex_unlock(&vfile->fence_mutex);
+               idr_preload_end();
                if (ret > 0) {
                        arg->out_fence = ret;
                        ret = 0;



Home | Main Index | Thread Index | Old Index