From patchwork Thu Jun 27 15:47:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 13714719 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 ABCB0C2BD09 for ; Thu, 27 Jun 2024 15:48:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 230DB6B009A; Thu, 27 Jun 2024 11:48:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DF7B6B009C; Thu, 27 Jun 2024 11:48:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05A586B009D; Thu, 27 Jun 2024 11:48:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DC6F46B009A for ; Thu, 27 Jun 2024 11:48:13 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 68D3EA3D5C for ; Thu, 27 Jun 2024 15:48:13 +0000 (UTC) X-FDA: 82277100066.24.E43554F Received: from mblankhorst.nl (lankhorst.se [141.105.120.124]) by imf16.hostedemail.com (Postfix) with ESMTP id C37C518001D for ; Thu, 27 Jun 2024 15:48:11 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf16.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=1719503277; a=rsa-sha256; cv=none; b=cq48KOcvUvEyhD5NMHwKSkLN/TZEe9b1tYRUUDqciehDKeDePpibRSHMY2B++dIAU1fwAi HQMXKD6daT5UFP1HSrSRY96o88fDdITtV5cbAuHqzJg2PEUEfhE3F+ZamBGptZgR9t+KHQ jnjAx6D6Bq+5R1UrmxyR/vbyMkR88Qk= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf16.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=1719503277; 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=C3jab/nsujH/XyxuYZaarvB+XE0upxWZFBa65SXf6PA=; b=CpVlZu3TW/xCwZtyOjS9FZT8ucW6uX6yJt4QtUiZNiMm8w+CoahCGwdURQ0iKrk07Ho6o3 JFknsIhkI+MqH/v7H1jjGs4QRfpxdEohLuEAynzB+8fxnu6JhreD1tFmWymMPqwn+viXYM cwvovp6Mkr0L+78LJUErP1Mn+jEXP+w= 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 , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: Friedrich Vock , cgroups@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 6/6] drm/xe: Hack to test with mapped pages instead of vram. Date: Thu, 27 Jun 2024 17:47:25 +0200 Message-ID: <20240627154754.74828-7-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627154754.74828-1-maarten.lankhorst@linux.intel.com> References: <20240627154754.74828-1-maarten.lankhorst@linux.intel.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C37C518001D X-Stat-Signature: o4aorfkrfjaiqkj3mx47gw5r4r6en9rn X-Rspam-User: X-HE-Tag: 1719503291-41196 X-HE-Meta: U2FsdGVkX19uQc60N4p6ncRr2VDQQAkRWhirPKpZzdCB1EACUIrYzC8ffoPwmkSRM4CBIjg9X86aKfi3wkafnGLX8zjzLK+2gChG/yjsL4YVZPUsL0o6MjNevrcsX59gJ9wPzsQsEXW1yarpP8jUrf3DgyZMjARP0j/JfmyXwinuIBXzd7NXvvK0l4pYANMmKejufWrWNpqomXw/HVgb1VZhDk/h1zIBqWZlofDNfnRpYvTSZU1gLFdB36J+cTO/733BYGBlsQ+abedeDd11/r0hKOOQE7vX9ubRvxqpnqgXDsREmXCCJU7fZDJmVT8LXOdNk97me9VLjlXEdGzGXV/HjBmogPFJOsK6HJ1EGEOcaSeA1QF6zEiTJnsDO+nBA+nyGWkz23ts3xkuzbbiyZKaAKsH8lsXGrQGBZDU64UQEKM+jkEzdCIj0Q8wK3noO5AHcIxuCq2i0tMiaYE1x0MxvITNIYQSQfb46ujlf8mbY5G9GG5a9HOrG7odVZ4GAgOcPWbJLBGoTNPdk5gUOe5aaiMm9+w3o+hqQ/MF0BqlaK13L6heCTCV+sGg6gBe4UZNA3xiQl/V8iZ6zapgZ4hDQyuuZKDoHIcVcG/iSJP7zfnQ3KZinE7KYmP84R9Jk7t62V/ry1xwFd/dgxMx47YX27VaigWGpVRr1U6hhXaQsR6lGUVGu6DNIxodJQ/uucESfJqvwAs9xWuDiCwo5W6UBmUHQSUdt0JzhR8iIcwUZRg0DU8gN0dNoIkO7UKKSDrUFPBGnW0P9CkLLFpp6fR/ms8IEEDdJhHUzrvfeXzqBVAF3P3gssRzjtIBVn6R722PE8L1/ZjbwRf3DbyXDVPveRDWVILwU941kOUp/xxxzZHIkvmeYdrd2Rl4Fa7hiwhs8o55DQ9Z0hK4RoI+7BFINsKHCi2BN9JYOSS+WInhkI5rqzqQAUNF5+KnNS7WEEQvolwAPTjzUufcwLD KCzr+9e6 hCIw9aI9tXp37KGPxw0JhnE9V3yEfv8hywxTzh62CddMP2p5TSSg4NpaBKvu6YmncUSwC4siWzYrOcrA0Tx7jXUtUCFjdi3oHEGWNFAzEewFGQ0L+lo8PomJzeTb9H7zy7yY1tVQ/soYePlItr0R5Jl2NSAAixR/n/pz3TN43AXF0Lv7FRsatssLBauItdfoTArpd7f3l1/rprgsNvHiiMp9UKObdKElGWmrF0R94QzrqnH7g/KwMGyG04kqHbpRdXuIJRGsA/9vR1OI= 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 --- 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 9844a8edbfe1..20fa8ec8925e 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); }