[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241204134410.1161769-8-dev@lankhorst.se>
Date: Wed, 4 Dec 2024 14:44:07 +0100
From: Maarten Lankhorst <dev@...khorst.se>
To: linux-kernel@...r.kernel.org,
intel-xe@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org,
Tejun Heo <tj@...nel.org>,
Zefan Li <lizefan.x@...edance.com>,
Johannes Weiner <hannes@...xchg.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Friedrich Vock <friedrich.vock@....de>,
Maxime Ripard <mripard@...nel.org>
Cc: cgroups@...r.kernel.org,
linux-mm@...ck.org,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maarten Lankhorst <dev@...khorst.se>
Subject: [PATCH v2 7/7] drm/gem: Add cgroup memory accounting for VRAM helper.
From: Maxime Ripard <mripard@...nel.org>
This allows any driver using the VRAM helper to set limits on VRAM using
cgroup.
Signed-off-by: Maxime Ripard <mripard@...nel.org>
Signed-off-by: Maarten Lankhorst <dev@...khorst.se>
---
drivers/gpu/drm/drm_gem_vram_helper.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index 22b1fe9c03b81..70979523ee984 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -925,6 +925,7 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init);
static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
uint64_t vram_base, size_t vram_size)
{
+ struct ttm_resource_manager *man;
int ret;
vmm->vram_base = vram_base;
@@ -939,8 +940,20 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
ret = ttm_range_man_init(&vmm->bdev, TTM_PL_VRAM,
false, vram_size >> PAGE_SHIFT);
- if (ret)
+ if (ret) {
+ ttm_device_fini(&vmm->bdev);
return ret;
+ }
+
+ man = ttm_manager_type(&vmm->bdev, TTM_PL_VRAM);
+ man->cg = drmm_register_region(dev, "vram", size);
+ if (IS_ERR(man->cg)) {
+ ret = PTR_ERR(man->cg);
+
+ ttm_range_man_fini(&vmm->bdev, TTM_PL_VRAM);
+ ttm_device_fini(&vmm->bdev);
+ return ret;
+ }
return 0;
}
--
2.43.0
Powered by blists - more mailing lists