From patchwork Thu Jun 27 15:47:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 13714718 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 EC39CC2BD09 for ; Thu, 27 Jun 2024 15:48:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 319F06B0099; Thu, 27 Jun 2024 11:48:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A06A6B009A; Thu, 27 Jun 2024 11:48:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F6826B009C; Thu, 27 Jun 2024 11:48:13 -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 E65F76B0099 for ; Thu, 27 Jun 2024 11:48:12 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 85FD0A0B43 for ; Thu, 27 Jun 2024 15:48:12 +0000 (UTC) X-FDA: 82277100024.07.52DC62F Received: from mblankhorst.nl (lankhorst.se [141.105.120.124]) by imf21.hostedemail.com (Postfix) with ESMTP id EA7201C0012 for ; Thu, 27 Jun 2024 15:48:10 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf21.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=1719503278; a=rsa-sha256; cv=none; b=bx065BstrWAdVkkR5xQZcOXnzI4z0RR+CDbOoE7b0frFAdAqCaAzaILv002meO91RUX7WH YDmi3J1RRTCVGM5raAyvokjM8cyAGAomQB5DMPhDCYNl6zByOHzkBiKxwio/VPyf/vjtSI 2D5wsZz14lukyuiId3gqZdh5fW+zIk8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf21.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=1719503278; 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=ve8LLrR7QK2UWxet92F6IrCINGp8NU1IxhY7RHhdh7A=; b=E48VY38IO0d7CFk6GczPKNL3WNy3/E+DYVIBU9w1XCidqGu326esabYsjC7pmNbjJsQXha hq17MYvEPa7Jj/uMTKRCXWPtUIeU2L0+IdYbEdt5bxqwrIZMqhYR/jmr4V1uURDzfP6glk w3ci30KNG4qcjBA/ESnDPZXIcaff2Y4= 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 , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter Cc: Friedrich Vock , cgroups@vger.kernel.org, linux-mm@kvack.org, Maarten Lankhorst , amd-gfx@lists.freedesktop.org Subject: [RFC PATCH 5/6] drm/amdgpu: Add cgroups implementation Date: Thu, 27 Jun 2024 17:47:24 +0200 Message-ID: <20240627154754.74828-6-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-Queue-Id: EA7201C0012 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 7wwtnnagq48wjqw9ryih7mmtf5eazgz7 X-HE-Tag: 1719503290-653514 X-HE-Meta: U2FsdGVkX1+rsfKnTH7mm9VHivNDbdNO5JlmwEc59+k4qylC3XcTxs/A3/KX18K5cQ6MFIKzdC8kAWzTLXJd78/NEW61jI/GktAJUFus7sgZ25n3SN9f22DPFWYihvYyRZitgv8DpW5CTKQ3/kqCZPZU+ImVOIF0KQ3MEcidgws5UvfEZfewGQ15t2IkqgQnFTbm5rSN6ZPWZy42oB7SYQKs6gOtHjCSWg7MxOhk2KeyqlPukURgThztFWuGvQD95chR1r5leOCN3dlsxJmymmaWLi8kAl/NKNAofNpIUyBvgbdC9W+a3G9BgMUXq+nsJu/Z8J6iJXF/3jtynTyvEepbspKxW26j3TkLLT6rlPsiBtR48ggV0yI91VEENYBV5oQJtHCN3ySJOXCTZ0eH5rW0oFpKPxB/TSxJWeIfErDh1CC1HxroEtcmT2RBPssIAQ180bmek9r3w+imHbH4GwKd4yGz4V7xHae9r8X8f+niVxS0hN7GHA7SV1u62IaYtPv8dpjYn4dHnuRMD3QjjoFB4VtPswAE6LJHl5SdUy/Aarn6gJR6Yu6jfpjBFKbz9Dz7wIfDb4jNpHVftd+0YjBPBKbCj4e5QF5O89suY3sgfrUp2EobKbWL4d80ntI30rBMNtpp0g5hddKj3dVLpmh8dG3rgRoGlDOwpgTg+cOCThgdCyn0wuUz14kJdeI998C3w58yA20PsukNVK3UUMeiL2l0DduPWgc1Jbk9DMqeqDwhbtlYRLeAkhQNTkJRevoh47pm9sm8m6JhRDczlOhmYucmC/liq+S8FFgDKRAAXxqwchKD1zO/7kaG2/wZSPROAWsql33i0KS4cRHfDHUIbXY01mbKUzfJj0J+exvb2B07cSsYQvTo3i3B8ijVm9VRrf6bz2I/vaMoG7FY2rlBbQdFhIe6byywTMAdUFoP41PoWxlgZHn4VeF/u8a+7r/vwgGlrxydUKCkqpw VXYJ/iPd 2/l+N41G09VajK8xtOoD+mgCe/g74syzLcpbPyRnjP/7WuSxtDbwJwLeU4xO7Pviv7/0Q/nYOoIR/oyiTz7tQ8vbA52ZXSUkf8BN8mcsgv0l1HWuY/KDMZzKAX/zZyZ+bYLMenFFWb9T1+gBqP5ZaAd8fQ7D6Hc2d0w0L7sNDkUACwKUwMsiEkmILmihVJnT+vK8bYxm68ZSkTGZ2Zi2nAbTvhnnGIDWtm74biLQeibcCIGjjNHYPUVk5csz23tv17EGWnVgTv46Ad6s= 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: Similar to xe, enable some simple management of VRAM only. Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index f87d53e183c3..9ec55f05bfd5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -43,6 +43,7 @@ #include "amdgpu_ctx.h" #include +#include #include #include #include @@ -836,6 +837,7 @@ struct amdgpu_device { struct device *dev; struct pci_dev *pdev; struct drm_device ddev; + struct drmcgroup_device cg; #ifdef CONFIG_DRM_AMD_ACP struct amdgpu_acp acp; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index e785f128411d..1afe28016d40 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1856,6 +1856,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) return r; } + r = drmmcg_register_device(adev_to_drm(adev), &adev->cg); + if (r) { + DRM_ERROR("Failed initializing cgroup allocator.\n"); + return r; + } + /* Change the size here instead of the init above so only lpfn is affected */ amdgpu_ttm_set_buffer_funcs_status(adev, false); #ifdef CONFIG_64BIT diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c index 6c30eceec896..b207af0bff3a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -895,6 +895,12 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) DRM_INFO("Setup dummy vram mgr\n"); } + adev->cg.regions[0].size = adev->gmc.real_vram_size; + adev->cg.regions[0].name = "vram"; + adev->cg.num_regions++; + man->cgdev = &adev->cg; + man->cgidx = 0; + ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, &mgr->manager); ttm_resource_manager_set_used(man, true); return 0;