From patchwork Fri Mar 1 22:49:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Brost X-Patchwork-Id: 13579216 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 88CABC54E58 for ; Fri, 1 Mar 2024 22:49:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D099810ED74; Fri, 1 Mar 2024 22:49:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Mlbpmkok"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2BBA310ED6E; Fri, 1 Mar 2024 22:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709333352; x=1740869352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IrXy3/HMqneGquGtKBpQ1rrLkPt9qOmW7CvwNEfyaH4=; b=MlbpmkoklQju4spCmxFXFAT98vuwD0tzPgKCkQszhSUZ9JM5qHAe5eHr 37/oJmNV/TgJrjTaIejOhiMBE8KdIetKajbPR+Ol6OBU9tlalduPdImp9 AWidxdvSGoN1tdQ8CBZlnwTagKhdjAaKxlFLej3l5pCF/KzaNjKioBVpt TE9sbDs23/sXyBhw8I+DnpKDQ1HvzlgTxGxDMS5zZxsnh/3u1KLFmNRDx 95w/rEKf09oLqw5Khum+c9WhJyJ93xegpC2Gu5q6ooYLC+BBxvNBsy1gs j+eVIbHqZ4URfWc6UmQCoMh0WbVMKNCZC21i/pxF7wImAffVsYl8UFM8k g==; X-IronPort-AV: E=McAfee;i="6600,9927,11000"; a="3752202" X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="3752202" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 14:49:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="45870693" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 14:49:12 -0800 From: Matthew Brost To: Cc: dri-devel@lists.freedesktop.org, Matthew Brost , =?utf-8?q?Thomas_Hellstr=C3=B6m?= Subject: [PATCH v3 1/4] drm/xe: Remove used xe_sync_entry_wait Date: Fri, 1 Mar 2024 14:49:16 -0800 Message-Id: <20240301224919.271153-2-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301224919.271153-1-matthew.brost@intel.com> References: <20240301224919.271153-1-matthew.brost@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" xe_sync_entry_wait is no longer used, remove it. Signed-off-by: Matthew Brost Reviewed-by: Thomas Hellström --- drivers/gpu/drm/xe/xe_sync.c | 8 -------- drivers/gpu/drm/xe/xe_sync.h | 1 - 2 files changed, 9 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c index 02c9577fe418..c836a5f3a1ea 100644 --- a/drivers/gpu/drm/xe/xe_sync.c +++ b/drivers/gpu/drm/xe/xe_sync.c @@ -200,14 +200,6 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef, return 0; } -int xe_sync_entry_wait(struct xe_sync_entry *sync) -{ - if (sync->fence) - dma_fence_wait(sync->fence, true); - - return 0; -} - int xe_sync_entry_add_deps(struct xe_sync_entry *sync, struct xe_sched_job *job) { int err; diff --git a/drivers/gpu/drm/xe/xe_sync.h b/drivers/gpu/drm/xe/xe_sync.h index 0fd0d51208e6..cb88715ac9af 100644 --- a/drivers/gpu/drm/xe/xe_sync.h +++ b/drivers/gpu/drm/xe/xe_sync.h @@ -22,7 +22,6 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef, struct xe_sync_entry *sync, struct drm_xe_sync __user *sync_user, unsigned int flags); -int xe_sync_entry_wait(struct xe_sync_entry *sync); int xe_sync_entry_add_deps(struct xe_sync_entry *sync, struct xe_sched_job *job); void xe_sync_entry_signal(struct xe_sync_entry *sync, From patchwork Fri Mar 1 22:49:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Brost X-Patchwork-Id: 13579217 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 E4752C5478C for ; Fri, 1 Mar 2024 22:49:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7A9F10ED7B; Fri, 1 Mar 2024 22:49:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="gFJCGGbM"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 509FC10ED6D; Fri, 1 Mar 2024 22:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709333352; x=1740869352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bVnzSSL+ptFR9bScjPRTeSZMt2zxy6inczOzPb5j+ac=; b=gFJCGGbMB2c+JHcnjFxYxCiEPk4Y+BClNCv8IiEaBb6IMeOhBjso7Phg Y2rQeFfELo4aPqaA5TfPs6xVRKfcvZ9nlmQRG5LLRPWF+0Cm8e2G+0g2V 2xRnZeGhY7oP5J2wpO+xAvkIsc2rAweNgEN2diybriOaF/QoEScPynaq8 qQ5+OdkqyeikB/LTJDald2TKrCJnjoCFMo1VuChNJaU8A4hRLH+GHAYZD WpFdDMIoHsmFp7PsQG8NK70gtUA7VgjFJ08NKp3gqduGO1adIHOCbHbRf HA9EOino7U1h0YDy225zfU+u1iK1YUIebSjp44Fs7QGDXWsN2nfCwiVGZ w==; X-IronPort-AV: E=McAfee;i="6600,9927,11000"; a="3752203" X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="3752203" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 14:49:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="45870697" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 14:49:12 -0800 From: Matthew Brost To: Cc: dri-devel@lists.freedesktop.org, Matthew Brost , =?utf-8?q?Thomas_Hellstr=C3=B6m?= Subject: [PATCH v3 2/4] drm/xe: Validate user fence during creation Date: Fri, 1 Mar 2024 14:49:17 -0800 Message-Id: <20240301224919.271153-3-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301224919.271153-1-matthew.brost@intel.com> References: <20240301224919.271153-1-matthew.brost@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Fail invalidate addresses during user fence creation. Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs") Signed-off-by: Matthew Brost Reviewed-by: Thomas Hellström --- drivers/gpu/drm/xe/xe_sync.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c index c836a5f3a1ea..c20e1f9ad267 100644 --- a/drivers/gpu/drm/xe/xe_sync.c +++ b/drivers/gpu/drm/xe/xe_sync.c @@ -53,14 +53,18 @@ static struct xe_user_fence *user_fence_create(struct xe_device *xe, u64 addr, u64 value) { struct xe_user_fence *ufence; + u64 __user *ptr = u64_to_user_ptr(addr); + + if (!access_ok(ptr, sizeof(ptr))) + return ERR_PTR(-EFAULT); ufence = kmalloc(sizeof(*ufence), GFP_KERNEL); if (!ufence) - return NULL; + return ERR_PTR(-ENOMEM); ufence->xe = xe; kref_init(&ufence->refcount); - ufence->addr = u64_to_user_ptr(addr); + ufence->addr = ptr; ufence->value = value; ufence->mm = current->mm; mmgrab(ufence->mm); @@ -183,8 +187,8 @@ int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef, } else { sync->ufence = user_fence_create(xe, sync_in.addr, sync_in.timeline_value); - if (XE_IOCTL_DBG(xe, !sync->ufence)) - return -ENOMEM; + if (XE_IOCTL_DBG(xe, IS_ERR(sync->ufence))) + return PTR_ERR(sync->ufence); } break; From patchwork Fri Mar 1 22:49:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Brost X-Patchwork-Id: 13579218 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 C7273C5475B for ; Fri, 1 Mar 2024 22:49:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 94B1F10ED78; Fri, 1 Mar 2024 22:49:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="aeiatVOR"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 868D510ED6E; Fri, 1 Mar 2024 22:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709333352; x=1740869352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GifNcnItbOhdzeX3AKpyvdmQlRjwyF1Lkip9nwSS/9Y=; b=aeiatVORuLuz7Uv9kGMZ/IRkvo/1VyxyUbRzJqhMlLWTJnC+rjAJfsnr blIYPhWgdNHSD5wLZa4oZPgVwvX5Fr3WQR3ICALfyal6rOIpTyb06KSmk ejdMMjMzSvRljcCUEHycVWW2jtqQ0mTmtWGgsVWOIwrnSonOhZh9tV8fW xz/9IbVFoa2506gwvyqvVwpMCXX3kp0bCZEqrjqTfpbYj8gzEN/RAoH5V DrDvnZPutO6Myu9MGTrf/ed+H5oI5V26KD49stufs0aXIgrtSY1Cadzn2 HrL6B3AG/MypaE3TaSVKiDTCMEKoIdnUXWHCMx6tlk+QLtQSFg4eWiCl7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11000"; a="3752204" X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="3752204" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 14:49:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="45870701" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 14:49:12 -0800 From: Matthew Brost To: Cc: dri-devel@lists.freedesktop.org, Matthew Brost Subject: [PATCH v3 3/4] drm/xe: Get page on user fence creation Date: Fri, 1 Mar 2024 14:49:18 -0800 Message-Id: <20240301224919.271153-4-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301224919.271153-1-matthew.brost@intel.com> References: <20240301224919.271153-1-matthew.brost@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Attempt to get page on user fence creation and kmap_local_page on signaling. Should reduce latency and can ensure 64 bit atomicity compared to copy_to_user. v2: - Prefault page and drop ref (Thomas) - Use set_page_dirty_lock (Thomas) - try_cmpxchg64 loop (Thomas) v3: - Initialize use_page (CI) Signed-off-by: Matthew Brost --- drivers/gpu/drm/xe/xe_sync.c | 54 +++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c index c20e1f9ad267..bf348d50a0b6 100644 --- a/drivers/gpu/drm/xe/xe_sync.c +++ b/drivers/gpu/drm/xe/xe_sync.c @@ -6,6 +6,7 @@ #include "xe_sync.h" #include +#include #include #include #include @@ -28,6 +29,7 @@ struct xe_user_fence { u64 __user *addr; u64 value; int signalled; + bool use_page; }; static void user_fence_destroy(struct kref *kref) @@ -53,7 +55,9 @@ static struct xe_user_fence *user_fence_create(struct xe_device *xe, u64 addr, u64 value) { struct xe_user_fence *ufence; + struct page *page; u64 __user *ptr = u64_to_user_ptr(addr); + int ret; if (!access_ok(ptr, sizeof(ptr))) return ERR_PTR(-EFAULT); @@ -69,19 +73,55 @@ static struct xe_user_fence *user_fence_create(struct xe_device *xe, u64 addr, ufence->mm = current->mm; mmgrab(ufence->mm); + /* Prefault page */ + ret = get_user_pages_fast(addr, 1, FOLL_WRITE, &page); + if (ret == 1) { + ufence->use_page = true; + put_page(page); + } else { + ufence->use_page = false; + } + return ufence; } static void user_fence_worker(struct work_struct *w) { struct xe_user_fence *ufence = container_of(w, struct xe_user_fence, worker); - - if (mmget_not_zero(ufence->mm)) { - kthread_use_mm(ufence->mm); - if (copy_to_user(ufence->addr, &ufence->value, sizeof(ufence->value))) - XE_WARN_ON("Copy to user failed"); - kthread_unuse_mm(ufence->mm); - mmput(ufence->mm); + struct mm_struct *mm = ufence->mm; + + if (mmget_not_zero(mm)) { + kthread_use_mm(mm); + if (ufence->use_page) { + struct page *page; + int ret; + + ret = get_user_pages_fast((unsigned long)ufence->addr, + 1, FOLL_WRITE, &page); + if (ret == 1) { + u64 *ptr; + u64 old = 0; + void *va; + + va = kmap_local_page(page); + ptr = va + offset_in_page(ufence->addr); + while (!try_cmpxchg64(ptr, &old, ufence->value)) + continue; + kunmap_local(va); + + set_page_dirty_lock(page); + put_page(page); + } else { + ufence->use_page = false; + } + } + if (!ufence->use_page) { + if (copy_to_user(ufence->addr, &ufence->value, + sizeof(ufence->value))) + drm_warn(&ufence->xe->drm, "copy_to_user failed\n"); + } + kthread_unuse_mm(mm); + mmput(mm); } wake_up_all(&ufence->xe->ufence_wq); From patchwork Fri Mar 1 22:49:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Brost X-Patchwork-Id: 13579219 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 7FE3AC5478C for ; Fri, 1 Mar 2024 22:49:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A336710ED7C; Fri, 1 Mar 2024 22:49:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="FRnSrpos"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB55310ED6F; Fri, 1 Mar 2024 22:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709333353; x=1740869353; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XltqW6vAZ7JzWd8rMGWQu+HNePLzg41nm+jv31gYHVA=; b=FRnSrposHqodkBTSFjpEIda1qEd+7fukPDCtVfGrue9dMLXIsEeOms5D ZmsUK64EJb+irehCHR6T01vt2YHpBwkO+La8HLXhf7YysZhzgVIgqtjql yVfF1gowthwBQCJn8z6TbsloTNXmNU+B5N1GSTPXNzN+Ce67B7MeeE6Lc SQXnHqbrohB0Gg20CWDKA4RPNTcd0KRQvQu6fzXSaWhV66ot13juClYGn 9b7AA0Ct1udL6rzrDXQkxHyFhvUKL0frb1+f21Z09iT70v32AylhvmLel cNc1JfDB08sEbOscVTRCGXND8pY2+hwblrtj+aiYy1TWokfmHJ2yqvtUT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11000"; a="3752205" X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="3752205" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 14:49:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,197,1705392000"; d="scan'208";a="45870703" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2024 14:49:12 -0800 From: Matthew Brost To: Cc: dri-devel@lists.freedesktop.org, Matthew Brost , =?utf-8?q?Thomas_Hellstr=C3=B6m?= Subject: [PATCH v3 4/4] drm/xe: Use get_user / put_user with memory barriers for ufence Date: Fri, 1 Mar 2024 14:49:19 -0800 Message-Id: <20240301224919.271153-5-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301224919.271153-1-matthew.brost@intel.com> References: <20240301224919.271153-1-matthew.brost@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Better aligns with atomic semantics than copy to/from user. Suggested-by: Thomas Hellström Signed-off-by: Matthew Brost --- drivers/gpu/drm/xe/xe_sync.c | 6 +++--- drivers/gpu/drm/xe/xe_wait_user_fence.c | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c index bf348d50a0b6..d6d2c8c19f71 100644 --- a/drivers/gpu/drm/xe/xe_sync.c +++ b/drivers/gpu/drm/xe/xe_sync.c @@ -116,9 +116,9 @@ static void user_fence_worker(struct work_struct *w) } } if (!ufence->use_page) { - if (copy_to_user(ufence->addr, &ufence->value, - sizeof(ufence->value))) - drm_warn(&ufence->xe->drm, "copy_to_user failed\n"); + if (put_user(ufence->value, ufence->addr)) + drm_warn(&ufence->xe->drm, "put_user failed\n"); + smp_mb(); } kthread_unuse_mm(mm); mmput(mm); diff --git a/drivers/gpu/drm/xe/xe_wait_user_fence.c b/drivers/gpu/drm/xe/xe_wait_user_fence.c index f69721339201..af5b9a634c21 100644 --- a/drivers/gpu/drm/xe/xe_wait_user_fence.c +++ b/drivers/gpu/drm/xe/xe_wait_user_fence.c @@ -17,11 +17,13 @@ static int do_compare(u64 addr, u64 value, u64 mask, u16 op) { + u64 __user *ptr = u64_to_user_ptr(addr); u64 rvalue; int err; bool passed; - err = copy_from_user(&rvalue, u64_to_user_ptr(addr), sizeof(rvalue)); + smp_mb(); + err = get_user(rvalue, ptr); if (err) return -EFAULT;