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 A0F52C10F05 for ; Thu, 7 Dec 2023 14:12:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B5E310E8B4; Thu, 7 Dec 2023 14:12:15 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69D9C10E1D6 for ; Thu, 7 Dec 2023 14:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701958331; x=1733494331; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=pPK/uJg0avEPDDOBE8DZ+o9smL1Ughfg1K1Nu/8EiEc=; b=Fp7Zzy5F7rf60meEVt4ZDfHuX7REgWeI5nZ8pzdatrY01eFDSGbkCeX1 2/pUyqHMpZXtQnkS6m5flCeteFwScLyT5yGf4PfFkm6Tgsd1WTxYAyHKL CEHvPXLBV9qPnYaqL2ej8rZNuJzFKM3S1z4VUw+HUq4DwWNh630bt9Plh 0cqgE5R6WrvizT+KOPdtXxWFIkmNZ7N1cwhCbmmcd2qbVBBvQuv8t8Qbf F4l34fozGclFKBaMKD3c2f7CxkAJSzd0cGlUEOvapU4uVGETI6Y6uVOLe nuYf3j52myMkLWC0NPA7KY/CXvFShLG7pNugOt27+VhC7ibnnu3VuAGkE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="12947510" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="12947510" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 06:12:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="721479748" X-IronPort-AV: E=Sophos;i="6.04,256,1695711600"; d="scan'208";a="721479748" Received: from jpoulsen-mobl.ger.corp.intel.com (HELO fedora..) ([10.249.254.234]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 06:12:09 -0800 From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Subject: [PATCH 03/16] drm/gpuvm: export drm_gpuvm_range_valid() Date: Thu, 7 Dec 2023 15:11:43 +0100 Message-ID: <20231207141157.26014-4-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231207141157.26014-1-thomas.hellstrom@linux.intel.com> References: <20231207141157.26014-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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: Danilo Krummrich Drivers may use this function to validate userspace requests in advance, hence export it. Acked-by: Christian König Reviewed-by: Thomas Hellström Reviewed-by: Boris Brezillon Signed-off-by: Danilo Krummrich Link: https://patchwork.freedesktop.org/patch/msgid/20231108001259.15123-4-dakr@redhat.com (cherry picked from commit 9297cfc9405bc6b60540b8b8aaf930b7e449e15a) --- drivers/gpu/drm/drm_gpuvm.c | 14 +++++++++++++- include/drm/drm_gpuvm.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c index 1cbeb4169f9c..dd46d14fd3e6 100644 --- a/drivers/gpu/drm/drm_gpuvm.c +++ b/drivers/gpu/drm/drm_gpuvm.c @@ -649,7 +649,18 @@ drm_gpuvm_in_kernel_node(struct drm_gpuvm *gpuvm, u64 addr, u64 range) return krange && addr < kend && kstart < end; } -static bool +/** + * drm_gpuvm_range_valid() - checks whether the given range is valid for the + * given &drm_gpuvm + * @gpuvm: the GPUVM to check the range for + * @addr: the base address + * @range: the range starting from the base address + * + * Checks whether the range is within the GPUVM's managed boundaries. + * + * Returns: true for a valid range, false otherwise + */ +bool drm_gpuvm_range_valid(struct drm_gpuvm *gpuvm, u64 addr, u64 range) { @@ -657,6 +668,7 @@ drm_gpuvm_range_valid(struct drm_gpuvm *gpuvm, drm_gpuvm_in_mm_range(gpuvm, addr, range) && !drm_gpuvm_in_kernel_node(gpuvm, addr, range); } +EXPORT_SYMBOL_GPL(drm_gpuvm_range_valid); /** * drm_gpuvm_init() - initialize a &drm_gpuvm diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h index baa1a96c038c..ed766dd9d96b 100644 --- a/include/drm/drm_gpuvm.h +++ b/include/drm/drm_gpuvm.h @@ -253,6 +253,7 @@ void drm_gpuvm_init(struct drm_gpuvm *gpuvm, const char *name, const struct drm_gpuvm_ops *ops); void drm_gpuvm_destroy(struct drm_gpuvm *gpuvm); +bool drm_gpuvm_range_valid(struct drm_gpuvm *gpuvm, u64 addr, u64 range); bool drm_gpuvm_interval_empty(struct drm_gpuvm *gpuvm, u64 addr, u64 range); static inline struct drm_gpuva * -- 2.42.0