i915_gem_userptr.c revision 1.5
11.5Sriastrad/* $NetBSD: i915_gem_userptr.c,v 1.5 2021/12/19 12:10:34 riastradh Exp $ */ 21.1Sriastrad 31.1Sriastrad/*- 41.1Sriastrad * Copyright (c) 2018 The NetBSD Foundation, Inc. 51.1Sriastrad * All rights reserved. 61.1Sriastrad * 71.1Sriastrad * This code is derived from software contributed to The NetBSD Foundation 81.1Sriastrad * by Taylor R. Campbell. 91.1Sriastrad * 101.1Sriastrad * Redistribution and use in source and binary forms, with or without 111.1Sriastrad * modification, are permitted provided that the following conditions 121.1Sriastrad * are met: 131.1Sriastrad * 1. Redistributions of source code must retain the above copyright 141.1Sriastrad * notice, this list of conditions and the following disclaimer. 151.1Sriastrad * 2. Redistributions in binary form must reproduce the above copyright 161.1Sriastrad * notice, this list of conditions and the following disclaimer in the 171.1Sriastrad * documentation and/or other materials provided with the distribution. 181.1Sriastrad * 191.1Sriastrad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Sriastrad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Sriastrad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Sriastrad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Sriastrad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Sriastrad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Sriastrad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Sriastrad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Sriastrad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Sriastrad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Sriastrad * POSSIBILITY OF SUCH DAMAGE. 301.1Sriastrad */ 311.1Sriastrad 321.1Sriastrad#include <sys/cdefs.h> 331.5Sriastrad__KERNEL_RCSID(0, "$NetBSD: i915_gem_userptr.c,v 1.5 2021/12/19 12:10:34 riastradh Exp $"); 341.1Sriastrad 351.1Sriastrad#include "i915_drv.h" 361.3Sriastrad#include "../dist/drm/i915/gem/i915_gem_ioctls.h" 371.1Sriastrad 381.5Sriastrad#include <linux/nbsd-namespace.h> 391.5Sriastrad 401.5Sriastrad/* 411.5Sriastrad * XXX this file is dumb and maybe shouldn't exist; it exists because 421.5Sriastrad * riastradh is a lazybones 431.5Sriastrad */ 441.5Sriastrad 451.1Sriastradint 461.5Sriastradi915_gem_init_userptr(struct drm_i915_private *dev_priv) 471.1Sriastrad{ 481.5Sriastrad mutex_init(&dev_priv->mm_lock); 491.5Sriastrad hash_init(dev_priv->mm_structs); 501.5Sriastrad 511.5Sriastrad dev_priv->mm.userptr_wq = 521.5Sriastrad alloc_workqueue("i915-userptr-acquire", 531.5Sriastrad WQ_HIGHPRI | WQ_UNBOUND, 541.5Sriastrad 0); 551.5Sriastrad if (!dev_priv->mm.userptr_wq) 561.5Sriastrad return -ENOMEM; 571.5Sriastrad 581.1Sriastrad return 0; 591.1Sriastrad} 601.1Sriastrad 611.4Sriastradvoid 621.5Sriastradi915_gem_cleanup_userptr(struct drm_i915_private *dev_priv) 631.4Sriastrad{ 641.5Sriastrad destroy_workqueue(dev_priv->mm.userptr_wq); 651.5Sriastrad mutex_destroy(&dev_priv->mm_lock); 661.4Sriastrad} 671.4Sriastrad 681.1Sriastradint 691.1Sriastradi915_gem_userptr_ioctl(struct drm_device *dev, void *data, 701.1Sriastrad struct drm_file *file) 711.1Sriastrad{ 721.1Sriastrad return -ENODEV; 731.1Sriastrad} 74