From patchwork Wed Oct 23 07:52:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 13846621 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81075D2E022 for ; Wed, 23 Oct 2024 07:53:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E757E6B008C; Wed, 23 Oct 2024 03:53:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFEF86B0095; Wed, 23 Oct 2024 03:53:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB57E6B0096; Wed, 23 Oct 2024 03:53:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 949216B008C for ; Wed, 23 Oct 2024 03:53:10 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CA1ED16079D for ; Wed, 23 Oct 2024 07:52:50 +0000 (UTC) X-FDA: 82704101172.14.C1EC8F3 Received: from mblankhorst.nl (lankhorst.se [141.105.120.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 6E7C41C0006 for ; Wed, 23 Oct 2024 07:53:01 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf18.hostedemail.com: domain of mlankhorst@mblankhorst.nl has no SPF policy when checking 141.105.120.124) smtp.mailfrom=mlankhorst@mblankhorst.nl ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729669937; a=rsa-sha256; cv=none; b=3oGM+8mmXoXVIvq5GH9dDUT23xSKJGTYfpkD6HKBeIwz8Y2UNNaE0uC6VY4lN20LFkOGtO 0UyolGOQ7huszF5JHTrj2h4JsL/dCIc+x9Cau3Fv7a8A5ZGo1QFU3txoWbqZjwAT+3bZ8t O7Z7Oywv3RjwUmWLUXKDneiwJmhggqA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf18.hostedemail.com: domain of mlankhorst@mblankhorst.nl has no SPF policy when checking 141.105.120.124) smtp.mailfrom=mlankhorst@mblankhorst.nl ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729669937; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/6iKeHM5xEyYy3QUwUrb8TZP4rb+L03HlgF90ruQ3no=; b=k4egfHfAK0CrpdVlvSepudrTYf7wHAK65civnw+uqSPBldU+OAK1M9ZM29cNIMgybsPasU 29MlcfPRh5gonWHNU9JVY214NqVNx0aO2vrEvV3GbijhlKNXlVQgfXq+3qzVCGY5NDyj0L VUwaBXEkTkbhJnYeOFl7ZuL4H60PWWE= From: Maarten Lankhorst To: intel-xe@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Tejun Heo , Zefan Li , Johannes Weiner , Andrew Morton Cc: Friedrich Vock , cgroups@vger.kernel.org, linux-mm@kvack.org, Maxime Ripard , Maarten Lankhorst Subject: [PATCH 6/7] [HACK] drm/xe: Hack to test with mapped pages instead of vram. Date: Wed, 23 Oct 2024 09:52:59 +0200 Message-ID: <20241023075302.27194-7-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023075302.27194-1-maarten.lankhorst@linux.intel.com> References: <20241023075302.27194-1-maarten.lankhorst@linux.intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 6E7C41C0006 X-Rspamd-Server: rspam01 X-Stat-Signature: me3etmwm4wg66mp9qd6u8qgrgrjp87dj X-HE-Tag: 1729669981-879144 X-HE-Meta: U2FsdGVkX18zQ144i+8Jb0iHIY5RvzdpNUq0Bco1MlyPpwK+vmfz2TwHj6wgNYNuk9Yj30bsWZJuOnt1b0yrk1xukczlvkN0Wh3ZAQQfyjrhS9KhTJdWdlF2QOjMkQiztnTRl3d/R685k/Op7P7GA4tPumN0XpkjesfZGrw2ME+I6JzVYDomPQk8hpX1fwSbTMTUr2ryFpZfGs5NZGc+qSoiYZvAFWSpbH00vW4Hmjlg6U2paa6QfKkw+XMdm/jaqZ8bggxLRfA5/CwDzUU6z1ki5ZBthuBuIt0slVr8uUZjydF59V9HvyEFWBG8JDa0ntBnYCZDJHnJ57BCaa8Dni3RwRcg1lkrChDARvhzFCwl/NU7wdeDmVTypLVU6inAzvzpwyIz6X2SnDqrii9tgj9g3GvLk523AN1ToYxMcTFYsoQo2YQlFZ8hLhjUWfiqQk27DZfjczTAyr4LaPhqTOnPoRpHdCpj2FKIyr48mghWMKXjBvKD9cK7dxJLQ2dTdceI8FrJK4J7Tzt7xRodz7XN8l7oUlnrRQ1JYZnE5jSGEk3q48DhQ+u6wMZHykAoS0LLn6ly3LqKfRcxfWD/st4b+IzOWLV+ldV7qCYQM39edSGdda0ByEBmQubBGARJXLkWIM0J4Wbe9Jow05B8JPsYelkXp49/SwvJJjmgPJJfG2jmi44QP6bflF0VVpoYmNt+xiy3VSluhd3RVcVXo4qvty7ZvcxrBMwV8epsMaN17cVmNRP838y0gIaQRf5hyZmg3XZOuJgE6JeTHQlwOGyvdLc9906Mt7E4oij1f8pugRFYMAd5gsmXl+mSD7KFhgLpjPn/5GWSDD5x4GijnuzPUNg13mGgLiv1sbNIhLA1C2LLC8ADKCosknYo19nh0dC4l5MS4ye5DO8O5SCbwxmjv2a9AFMbXPX3IbpDqfxcWdCwNRR2HOvt+zq1arTQ61WfC0pJEufF/iAxaAM 1+IEmlMO vpn5BAfiJ5IhWBeOxXtWoZwDwMvW/PF/V+trtblTUdLeetNFnphg3nkxUVfvcHR+NsLP16ZLURX9FNQVPJ0Mr+t095nYqV+M4apRKhAB8CEHQi1y+fZfaWtYWG3Yn4FmUGtbRqXuBl/++qJzOB3UdCiYzWagG94iPv7x/dpWuXh+cayUQwGfGLJ1kFt81XCZIItruEp2oZhWpQa6wSPcykfSSzZNUg6t9nJB2fYY0x0etEzjVZY1VcPiMCD9BBKamVTHj1zCdUgjYT1GRfolVwQmZLWqSEa0iP+L/ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We will probably want to make this a proper region in TTM for everything, so that we can charge VRAM twice, once for mapped in sysmem, once for mapped in vram. That way we don't need to deal with evict failing from lack of available memory in mapped. Signed-off-by: Maarten Lankhorst Signed-off-by: Maxime Ripard --- drivers/gpu/drm/xe/xe_ttm_sys_mgr.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_ttm_sys_mgr.c b/drivers/gpu/drm/xe/xe_ttm_sys_mgr.c index 9844a8edbfe19..20fa8ec8925ef 100644 --- a/drivers/gpu/drm/xe/xe_ttm_sys_mgr.c +++ b/drivers/gpu/drm/xe/xe_ttm_sys_mgr.c @@ -101,6 +101,18 @@ static void ttm_sys_mgr_fini(struct drm_device *drm, void *arg) ttm_set_driver_manager(&xe->ttm, XE_PL_TT, NULL); } +static inline void apply_cg(struct xe_device *xe, + struct ttm_resource_manager *man, + u64 gtt_size) +{ + int cgregion = xe->cg.num_regions++; + + xe->cg.regions[cgregion].size = gtt_size; + xe->cg.regions[cgregion].name = "mapped"; + man->cgdev = &xe->cg; + man->cgidx = cgregion; + +} int xe_ttm_sys_mgr_init(struct xe_device *xe) { struct ttm_resource_manager *man = &xe->mem.sys_mgr; @@ -116,6 +128,8 @@ int xe_ttm_sys_mgr_init(struct xe_device *xe) man->func = &xe_ttm_sys_mgr_func; ttm_resource_manager_init(man, &xe->ttm, gtt_size >> PAGE_SHIFT); ttm_set_driver_manager(&xe->ttm, XE_PL_TT, man); + apply_cg(xe, man, gtt_size); + ttm_resource_manager_set_used(man, true); return drmm_add_action_or_reset(&xe->drm, ttm_sys_mgr_fini, xe); }