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 77B03C369C9 for ; Wed, 16 Apr 2025 18:09:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 525AF10E99A; Wed, 16 Apr 2025 18:09:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="g8dWLxtz"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6CAE810E995; Wed, 16 Apr 2025 18:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744826991; x=1776362991; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I7MFE5scuc1PUAYJYHut1zn27lvkW+T30bK679Tjfdw=; b=g8dWLxtz2UOwyY1ayH+warkgN+HwKJx9iwUbvacxuzpROID9uc9jHqYK mHLMVAP5a5hHa7g4GJ6d5U8qzUOFee/p8DIBIYRcXliRhF2CDl2XtuL5u cDg5CZ1PbJO3NHxKf/ZhnM5bMvbCwYkoswU+boEIzh5QzImQtJkPwOfYe gVby+qpYX25fOi2T5otdAvnWgGET0nmtDjBkqGzZDRHK9rwtw8pSO6DF7 QuKbRfTlXKOzQrTucIsEqPEabT5QLa29hWlKoz9x2SicLxI3Q7s2a3+5h hZ/kxD98UvIbolpqu9JCL+8MZEKtfvD2dcgBBOf97u9fxIBA1JsejdeJn w==; X-CSE-ConnectionGUID: wEfFzZHeSrOyNMTLaIWLyw== X-CSE-MsgGUID: Z61CT4MpRkqrFz1hm12LSg== X-IronPort-AV: E=McAfee;i="6700,10204,11405"; a="63799686" X-IronPort-AV: E=Sophos;i="6.15,216,1739865600"; d="scan'208";a="63799686" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2025 11:09:51 -0700 X-CSE-ConnectionGUID: RTkX4t7pQnWBedi8kuopvg== X-CSE-MsgGUID: mmlBSa6HSwC1ZdGXqCuw4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,216,1739865600"; d="scan'208";a="131468157" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2025 11:09:50 -0700 From: Matthew Brost To: intel-xe@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org, thomas.hellstrom@linux.intel.com, himal.prasad.ghimiray@intel.com Subject: [RFC PATCH 1/4] drm/gpusvm: Introduce vram_only flag for VRAM allocation Date: Wed, 16 Apr 2025 11:11:04 -0700 Message-Id: <20250416181107.409538-2-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250416181107.409538-1-matthew.brost@intel.com> References: <20250416181107.409538-1-matthew.brost@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" From: Himal Prasad Ghimiray This commit adds a new flag, vram_only, to the drm_gpusvm structure. The purpose of this flag is to ensure that the get_pages function allocates memory exclusively from the device's VRAM. If the allocation from VRAM fails, the function will return an -EFAULT error. Signed-off-by: Himal Prasad Ghimiray --- drivers/gpu/drm/drm_gpusvm.c | 5 +++++ include/drm/drm_gpusvm.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c index 38431e8360e7..e7d4ada21560 100644 --- a/drivers/gpu/drm/drm_gpusvm.c +++ b/drivers/gpu/drm/drm_gpusvm.c @@ -1454,6 +1454,11 @@ int drm_gpusvm_range_get_pages(struct drm_gpusvm *gpusvm, goto err_unmap; } + if (ctx->vram_only) { + err = -EFAULT; + goto err_unmap; + } + addr = dma_map_page(gpusvm->drm->dev, page, 0, PAGE_SIZE << order, diff --git a/include/drm/drm_gpusvm.h b/include/drm/drm_gpusvm.h index df120b4d1f83..8093cc6ab1f4 100644 --- a/include/drm/drm_gpusvm.h +++ b/include/drm/drm_gpusvm.h @@ -286,6 +286,7 @@ struct drm_gpusvm { * @in_notifier: entering from a MMU notifier * @read_only: operating on read-only memory * @devmem_possible: possible to use device memory + * @vram_only: Use only device memory * * Context that is DRM GPUSVM is operating in (i.e. user arguments). */ @@ -294,6 +295,7 @@ struct drm_gpusvm_ctx { unsigned int in_notifier :1; unsigned int read_only :1; unsigned int devmem_possible :1; + unsigned int vram_only :1; }; int drm_gpusvm_init(struct drm_gpusvm *gpusvm, -- 2.34.1