From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBE90EEAA78 for ; Thu, 14 Sep 2023 20:40:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8FF1C10E586; Thu, 14 Sep 2023 20:40:46 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A68910E15D for ; Thu, 14 Sep 2023 20:40:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694724041; x=1726260041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5sJjyDg8N4mSgR0xMgb/8HBxvJfgLUv37agJAouBopQ=; b=D7q7vShUGZiXIu8ra1vYVQH57JkI/1X2eiPCyFwyEHsRfIYruG+Fo3hx sdcqoIZpH/qcWXCcwWQ3KdQmYUfH11CIkPaaa9y7Ea0m+KL6ucE8w3sQ3 tLko4Vx6mWO12OijbHDl3poOBWbg8CpBdACVQgauWfBqkv0NJEZ6q8OLM WSYgH5TJmoKEQFRR/Fn3k/LYHlIG6dgAq2LD2wWNa8Jp/ytIqQBJcqf1m B8/sdF2xWjeiZP57+wtBjzKo6vFYJOczVECiZxeBvLqIyJMq8IYsI4Xqu G0fgxFm8b7BaeklKqFP/pyHVsbYlnfW+qJ88VDRFatSQ1B0GEzORzWthC Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="369369363" X-IronPort-AV: E=Sophos;i="6.02,146,1688454000"; d="scan'208";a="369369363" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 13:40:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="694453573" X-IronPort-AV: E=Sophos;i="6.02,146,1688454000"; d="scan'208";a="694453573" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 13:40:39 -0700 From: Matthew Brost To: Date: Thu, 14 Sep 2023 13:40:48 -0700 Message-Id: <20230914204053.2220281-2-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230914204053.2220281-1-matthew.brost@intel.com> References: <20230914204053.2220281-1-matthew.brost@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Intel-xe] [PATCH 1/6] drm/xe/uapi: Kill XE_VM_PROPERTY_BIND_OP_ERROR_CAPTURE_ADDRESS extension X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rodrigo Vivi Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" From: Rodrigo Vivi This extension is currently not used and it is not aligned with the error handling on async VM_BIND. Let's remove it and along with that, since it was the only extension for the vm_create, remove VM extension entirely. Cc: Thomas Hellström Reviewed-by: Matthew Brost Signed-off-by: Matthew Brost Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_vm.c | 129 +------------------------------------ include/uapi/drm/xe_drm.h | 42 +----------- 2 files changed, 4 insertions(+), 167 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c index 2b225c0692a6..2a69302304e2 100644 --- a/drivers/gpu/drm/xe/xe_vm.c +++ b/drivers/gpu/drm/xe/xe_vm.c @@ -1369,37 +1369,6 @@ static void flush_async_ops(struct xe_vm *vm) flush_work(&vm->async_ops.work); } -static void vm_error_capture(struct xe_vm *vm, int err, - u32 op, u64 addr, u64 size) -{ - struct drm_xe_vm_bind_op_error_capture capture; - u64 __user *address = - u64_to_user_ptr(vm->async_ops.error_capture.addr); - bool in_kthread = !current->mm; - - capture.error = err; - capture.op = op; - capture.addr = addr; - capture.size = size; - - if (in_kthread) { - if (!mmget_not_zero(vm->async_ops.error_capture.mm)) - goto mm_closed; - kthread_use_mm(vm->async_ops.error_capture.mm); - } - - if (copy_to_user(address, &capture, sizeof(capture))) - drm_warn(&vm->xe->drm, "Copy to user failed"); - - if (in_kthread) { - kthread_unuse_mm(vm->async_ops.error_capture.mm); - mmput(vm->async_ops.error_capture.mm); - } - -mm_closed: - wake_up_all(&vm->async_ops.error_capture.wq); -} - static void xe_vm_close(struct xe_vm *vm) { down_write(&vm->lock); @@ -1883,91 +1852,6 @@ static int xe_vm_unbind(struct xe_vm *vm, struct xe_vma *vma, return 0; } -static int vm_set_error_capture_address(struct xe_device *xe, struct xe_vm *vm, - u64 value) -{ - if (XE_IOCTL_DBG(xe, !value)) - return -EINVAL; - - if (XE_IOCTL_DBG(xe, !(vm->flags & XE_VM_FLAG_ASYNC_BIND_OPS))) - return -EOPNOTSUPP; - - if (XE_IOCTL_DBG(xe, vm->async_ops.error_capture.addr)) - return -EOPNOTSUPP; - - vm->async_ops.error_capture.mm = current->mm; - vm->async_ops.error_capture.addr = value; - init_waitqueue_head(&vm->async_ops.error_capture.wq); - - return 0; -} - -typedef int (*xe_vm_set_property_fn)(struct xe_device *xe, struct xe_vm *vm, - u64 value); - -static const xe_vm_set_property_fn vm_set_property_funcs[] = { - [XE_VM_PROPERTY_BIND_OP_ERROR_CAPTURE_ADDRESS] = - vm_set_error_capture_address, -}; - -static int vm_user_ext_set_property(struct xe_device *xe, struct xe_vm *vm, - u64 extension) -{ - u64 __user *address = u64_to_user_ptr(extension); - struct drm_xe_ext_vm_set_property ext; - int err; - - err = __copy_from_user(&ext, address, sizeof(ext)); - if (XE_IOCTL_DBG(xe, err)) - return -EFAULT; - - if (XE_IOCTL_DBG(xe, ext.property >= - ARRAY_SIZE(vm_set_property_funcs)) || - XE_IOCTL_DBG(xe, ext.pad) || - XE_IOCTL_DBG(xe, ext.reserved[0] || ext.reserved[1])) - return -EINVAL; - - return vm_set_property_funcs[ext.property](xe, vm, ext.value); -} - -typedef int (*xe_vm_user_extension_fn)(struct xe_device *xe, struct xe_vm *vm, - u64 extension); - -static const xe_vm_set_property_fn vm_user_extension_funcs[] = { - [XE_VM_EXTENSION_SET_PROPERTY] = vm_user_ext_set_property, -}; - -#define MAX_USER_EXTENSIONS 16 -static int vm_user_extensions(struct xe_device *xe, struct xe_vm *vm, - u64 extensions, int ext_number) -{ - u64 __user *address = u64_to_user_ptr(extensions); - struct xe_user_extension ext; - int err; - - if (XE_IOCTL_DBG(xe, ext_number >= MAX_USER_EXTENSIONS)) - return -E2BIG; - - err = __copy_from_user(&ext, address, sizeof(ext)); - if (XE_IOCTL_DBG(xe, err)) - return -EFAULT; - - if (XE_IOCTL_DBG(xe, ext.pad) || - XE_IOCTL_DBG(xe, ext.name >= - ARRAY_SIZE(vm_user_extension_funcs))) - return -EINVAL; - - err = vm_user_extension_funcs[ext.name](xe, vm, extensions); - if (XE_IOCTL_DBG(xe, err)) - return err; - - if (ext.next_extension) - return vm_user_extensions(xe, vm, ext.next_extension, - ++ext_number); - - return 0; -} - #define ALL_DRM_XE_VM_CREATE_FLAGS (DRM_XE_VM_CREATE_SCRATCH_PAGE | \ DRM_XE_VM_CREATE_COMPUTE_MODE | \ DRM_XE_VM_CREATE_ASYNC_BIND_OPS | \ @@ -1984,6 +1868,9 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data, int err; u32 flags = 0; + if (XE_IOCTL_DBG(xe, args->extensions)) + return -EINVAL; + if (XE_WA(xe_root_mmio_gt(xe), 14016763929)) args->flags |= DRM_XE_VM_CREATE_SCRATCH_PAGE; @@ -2026,14 +1913,6 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data, if (IS_ERR(vm)) return PTR_ERR(vm); - if (args->extensions) { - err = vm_user_extensions(xe, vm, args->extensions, 0); - if (XE_IOCTL_DBG(xe, err)) { - xe_vm_close_and_put(vm); - return err; - } - } - mutex_lock(&xef->vm.lock); err = xa_alloc(&xef->vm.xa, &id, vm, xa_limit_32b, GFP_KERNEL); mutex_unlock(&xef->vm.lock); @@ -2931,8 +2810,6 @@ static void xe_vma_op_work_func(struct work_struct *w) vm_set_async_error(vm, err); up_write(&vm->lock); - if (vm->async_ops.error_capture.addr) - vm_error_capture(vm, err, 0, 0, 0); break; } up_write(&vm->lock); diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h index 00d5cb4ef85e..5cbbb433ce68 100644 --- a/include/uapi/drm/xe_drm.h +++ b/include/uapi/drm/xe_drm.h @@ -480,44 +480,7 @@ struct drm_xe_gem_mmap_offset { __u64 reserved[2]; }; -/** - * struct drm_xe_vm_bind_op_error_capture - format of VM bind op error capture - */ -struct drm_xe_vm_bind_op_error_capture { - /** @error: errno that occurred */ - __s32 error; - - /** @op: operation that encounter an error */ - __u32 op; - - /** @addr: address of bind op */ - __u64 addr; - - /** @size: size of bind */ - __u64 size; -}; - -/** struct drm_xe_ext_vm_set_property - VM set property extension */ -struct drm_xe_ext_vm_set_property { - /** @base: base user extension */ - struct xe_user_extension base; - -#define XE_VM_PROPERTY_BIND_OP_ERROR_CAPTURE_ADDRESS 0 - /** @property: property to set */ - __u32 property; - - /** @pad: MBZ */ - __u32 pad; - - /** @value: property value */ - __u64 value; - - /** @reserved: Reserved */ - __u64 reserved[2]; -}; - struct drm_xe_vm_create { -#define XE_VM_EXTENSION_SET_PROPERTY 0 /** @extensions: Pointer to the first extension struct, if any */ __u64 extensions; @@ -600,10 +563,7 @@ struct drm_xe_vm_bind_op { * practice the bind op is good and will complete. * * If this flag is set and doesn't return an error, the bind op can - * still fail and recovery is needed. If configured, the bind op that - * caused the error will be captured in drm_xe_vm_bind_op_error_capture. - * Once the user sees the error (via a ufence + - * XE_VM_PROPERTY_BIND_OP_ERROR_CAPTURE_ADDRESS), it should free memory + * still fail and recovery is needed. It should free memory * via non-async unbinds, and then restart all queued async binds op via * XE_VM_BIND_OP_RESTART. Or alternatively the user should destroy the * VM. -- 2.34.1