From patchwork Thu Mar 21 15:17:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 13598869 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 D7B85C54E68 for ; Thu, 21 Mar 2024 15:18:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7320C10E782; Thu, 21 Mar 2024 15:18:38 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="UFwmgme6"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5309510E359; Thu, 21 Mar 2024 15:18:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711034318; x=1742570318; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=vTq6eMlEVlwDOrRT3eh/Y4LPJlYJFenbxEIwPcIxpYQ=; b=UFwmgme66tdUMNeXjr6SqEpzI3nz+G3xdb25BSnbnQdI2hQgg1hviAp5 opn/BwpZ34WfgIiiMTI6ijw7ZH8e3jwp8NQjV1R9tcMG1CHra3WMPJHQz 3tcSurHnTVXLzIFBP96hQ3Uj6+0/4DW5501jiDnMJMSwKoUVipIkzthMH YsTw5P44OlxAZQcv0StDS3TS5xNLkclIXH7c+qWGGVDBZERZ99zdeguQ/ jo8hCfP71RHbNsjah/nrNgkoOEZdtu259zM5GSWbBEbiujEgw50v6Rn1+ 9YOeuzujOkQqkOguEkdH6o48wEJ2CnX5efYzOVbsPAs0hCkmyi65aPYeu Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11020"; a="9813520" X-IronPort-AV: E=Sophos;i="6.07,143,1708416000"; d="scan'208";a="9813520" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2024 08:18:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,143,1708416000"; d="scan'208";a="51976905" Received: from unknown (HELO intel.com) ([10.247.118.192]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2024 08:18:30 -0700 From: Andi Shyti To: intel-gfx , dri-devel Cc: Andi Shyti , Andi Shyti , Andrzej Hajda , Chris Wilson , Lionel Landwerlin , Michal Mrozek , Nirmoy Das , stable@vger.kernel.org Subject: [PATCH v2] drm/i915/gt: Report full vm address range Date: Thu, 21 Mar 2024 16:17:26 +0100 Message-ID: <20240321151726.207866-1-andi.shyti@linux.intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Commit 9bb66c179f50 ("drm/i915: Reserve some kernel space per vm") has reserved an object for kernel space usage. Userspace, though, needs to know the full address range. In the former patch the reserved space was substructed from the total amount of the VM space. Add it back when the user requests the GTT size through ioctl (I915_CONTEXT_PARAM_GTT_SIZE). Fixes: 9bb66c179f50 ("drm/i915: Reserve some kernel space per vm") Signed-off-by: Andi Shyti Cc: Andrzej Hajda Cc: Chris Wilson Cc: Lionel Landwerlin Cc: Michal Mrozek Cc: Nirmoy Das Cc: # v6.2+ Acked-by: Michal Mrozek Acked-by: Lionel Landwerlin --- Hi, Just proposing a different implementation that doesn't affect i915 internally but provides the same result. Instead of not substracting the space during the reservation, I add it back during the ioctl call. All the "vm->rsvd.vma->node.size" looks a bit ugly, but that's how it is. Maybe a comment can help to understand better why there is this addition. I kept the Ack from Michal and Lionel, because the outcome from userspace perspactive doesn't really change. Andi drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c index 81f65cab1330..60d9e7fe33b3 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c @@ -2454,7 +2454,7 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data, case I915_CONTEXT_PARAM_GTT_SIZE: args->size = 0; vm = i915_gem_context_get_eb_vm(ctx); - args->value = vm->total; + args->value = vm->total + vm->rsvd.vma->node.size; i915_vm_put(vm); break;