From patchwork Wed Oct 23 07:52:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 13846620 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 7104FD2E01E for ; Wed, 23 Oct 2024 07:53:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DBF26B008A; Wed, 23 Oct 2024 03:53:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A15D6B008C; 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 17D596B0092; Wed, 23 Oct 2024 03:53:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D5F556B008A for ; Wed, 23 Oct 2024 03:53:09 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9C3FBAB6F9 for ; Wed, 23 Oct 2024 07:52:35 +0000 (UTC) X-FDA: 82704100626.27.7269F93 Received: from mblankhorst.nl (lankhorst.se [141.105.120.124]) by imf14.hostedemail.com (Postfix) with ESMTP id E02A710000F for ; Wed, 23 Oct 2024 07:52:48 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=none (imf14.hostedemail.com: domain of mlankhorst@mblankhorst.nl has no SPF policy when checking 141.105.120.124) smtp.mailfrom=mlankhorst@mblankhorst.nl; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729669786; 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=IStRVWjuQ2ViCFyq4NjdNtG3RiDf7KbHOrMvbs+vNeA=; b=VTCltBbyfR7U2YaNWgQkuXwtvykH3quzRL7lI8Eko1WLBUfLaZ2ZdruYmQUK19jLejm8wI s9Y3yw34cmyVIOglOS8/PdrbVFi9wHS4Hrbl5qSfI1n7ky1yZgAedl1Qmib5rkLStuswkS x1YqvFvSK8hbJlj+47xno6Xo/o5897I= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=none (imf14.hostedemail.com: domain of mlankhorst@mblankhorst.nl has no SPF policy when checking 141.105.120.124) smtp.mailfrom=mlankhorst@mblankhorst.nl; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729669786; a=rsa-sha256; cv=none; b=UsOesaa4UKPw+ZeEG1Zl2FZBx14mS+7eh/n2JjKDLGnvG4oUfE71VWvZWa4Ls+5gnIrMRo kBQD9uAwJ+mYIq8dP4IqmqPT/OjUwFe70mFqSqJkG+E16/kZbL/rbhsRDSV0G4Yw7i4rOx sUtBPXb40sn78IkT9kqf2nYmxE15nP8= 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 5/7] drm/amdgpu: Add cgroups implementation Date: Wed, 23 Oct 2024 09:52:58 +0200 Message-ID: <20241023075302.27194-6-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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E02A710000F X-Stat-Signature: iuosude8exeswhks7y7xw9qhfshufuuq X-Rspam-User: X-HE-Tag: 1729669968-294449 X-HE-Meta: U2FsdGVkX1+oPITVO3nWxf2xIOpbyVWUFFr2X+IezKUwI+ej67o0fhO0TSGeESUFvGPDpQ0kl36LuUQCZiKYxxr6ryifNKtk0tJ3dsTzFKtFQgFvJQHRaCV4OVB61+BaAALrmUdtXTPBy+P98FHKs9HANWxI8Kng2hReyC+9Q0qQBCVGitXkdPT9CmOb9FWECVkLt6YDQ+Y6CNx66wsUgl5rU0ZGq35ksmgv0xhR49QA577uerTVHA1cDYCQXgTNylXa5V2bky146gawF7q64UUbwmquhlIP8TwItptM/iY/ZCDsQyYzWkpCCoCD2K1d3r6rGcwHFFaIL3tVe8a82RutnASv8FgMqXhQyM7dD+RVzmLemErR13QyFKqhe1G6ysCxXvCmqt/qZ2zRwx1yZIVlhWEtnay3ttNVJlRwsNU4Xrk/+Ds4cXknBm562aw/MXjbZvcC/CfaVAmww81+JfTBNWTxRIwNegDOMUBkoiOEyv9F5RTPYKxqeElqtxSq94z8mG3koluiec5X3Ceq5tWdsd/u4sjiLL/o1XC8CsIZaOzS2rafbt0IuVa/KdO3thWWma1DWLIZZOZLaWzimNTl7gRzVsNCsv/7B3wzyElrkfIY7yFsALMH8SLVWbM6SKU200nvlBKOB0dQHR8v5JGZJK17mPeywTYN+CTIBg9T2rcPTzhHxFJrK09UfZqpiiRyKtqHHfZZMSqX8ilydcoG7muUhhrM/XYYaxOq9wPblpQdLI+qWSoY14bywlUoqT6PaW1JrVzN6RRQbz6CGqkFGfR934nPwSKmkAYCLNch1rLjcIFXCvmy2c0Lk97se2jXsNGREDS6T4CuypSE8H4Lo09l8UEYmWeMhWgsX02BwsYJvidVbw3aHERYCp46JkkegtchrwyuTQBAMabPUVVREloWXSkqKvjPFUmFEdn6gKclUW71jrXTzmscJcAAQEe7iQlWzhcCMJmw90Q c9egY4Rv 3/MCBeiw0h8thx9NEp21nEXCfoo+xJBYuTUuQU2OM55uJ/uCzb7p6aLLZ47yxOSPcu7G4X8dn36GLIN32sM1jaYwlGS3T6Iu++nMwXljYG5d/ju2UvNMeBfozNRK8MG2aXmrmcphKb3MJYSjRQkWBU0Eg4n6qdqN/7QwyDq5plfPzAqzDQUcUnkJp3mU/zmx5wClphPcsRQ94hszGjDBHZ63hrRs7j7WSwKKUY1B4HyKOpfhNe7jW6A447Q9+u6oJK07z 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. Co-developed-by: Maxime Ripard Signed-off-by: Maxime Ripard 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 9b1e0ede05a45..27c11e43f8e9e 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 @@ -835,6 +836,7 @@ struct amdgpu_device { struct device *dev; struct pci_dev *pdev; struct drm_device ddev; + struct dev_cgroup_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 74adb983ab03e..3f6554c7aac2f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1874,6 +1874,12 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) return r; } + r = drmm_cgroup_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 7d26a962f811c..44d560bef5b7d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c @@ -927,6 +927,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;