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 769F9C3ABAA for ; Tue, 29 Apr 2025 10:17:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 07D3410E41C; Tue, 29 Apr 2025 10:17:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ZIStRFDy"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8745710E419 for ; Tue, 29 Apr 2025 10:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1745921846; x=1777457846; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OtJlf/S/NLBKiL/9DBZjPOrBjXGmBRtnN+LmkLD8E18=; b=ZIStRFDyq+Ti5DaqjMSTaT2aHzIGWhBGVSSimDpxjt3i7sJbauJYPRYq 87ZMkwxkh4E7hF8DXo51tDm1YFRpoAvPXt++ZGoK5kbL3gWSb+5+lO+cX RfFxP8GnCzQNuYfiOjcEKcAjPyHrbtdTE6egEwFGbUphxAIHAmbd6n0cQ FS1DH23wATfzdZ4eZhaF9ILxlRdKjY22oqVWKR6oLREMXS19pvqE4Tup1 zwVdenIglEyoq0YWgKyOrs/Z438YsaVGnaZCREfMq1Lz28cTu5Ih2Igdp DhfZwtNfL5x/xrK2PZFD6iKNJlpipO7sAIb7WLIAcBmrDcu/Zv3l0Zk6h g==; X-CSE-ConnectionGUID: Gdj9L42hRoW8ncZwADKjPw== X-CSE-MsgGUID: u+4igqjaR02sGKuhGaP/OA== X-IronPort-AV: E=McAfee;i="6700,10204,11417"; a="47243172" X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="47243172" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2025 03:17:26 -0700 X-CSE-ConnectionGUID: CQiFzG+lT7KsfyRqPZEmTg== X-CSE-MsgGUID: TvN+bxrBSeSXsDMdHKvrcA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,248,1739865600"; d="scan'208";a="134287526" Received: from unknown (HELO himal-Super-Server.iind.intel.com) ([10.190.239.34]) by orviesa007.jf.intel.com with ESMTP; 29 Apr 2025 03:17:23 -0700 From: Himal Prasad Ghimiray To: intel-xe@lists.freedesktop.org Cc: matthew.brost@intel.com, thomas.hellstrom@linux.intel.com, Himal Prasad Ghimiray Subject: [PATCH v5 01/20] drm/gpusvm: Introduce devmem_only flag for allocation Date: Tue, 29 Apr 2025 16:12:14 +0530 Message-Id: <20250429104233.215602-2-himal.prasad.ghimiray@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250429104233.215602-1-himal.prasad.ghimiray@intel.com> References: <20250429104233.215602-1-himal.prasad.ghimiray@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" This commit adds a new flag, devmem_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 memory. If the allocation from device memory fails, the function will return an -EFAULT error. v3: - s/vram_only/devmem_only/ Signed-off-by: Matthew Brost Signed-off-by: Himal Prasad Ghimiray Reviewed-by: Matthew Brost --- 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..edf107809d20 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->devmem_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..9fd25fc880a4 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 + * @devmem_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 devmem_only :1; }; int drm_gpusvm_init(struct drm_gpusvm *gpusvm, -- 2.34.1