From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47B07C9830B for ; Wed, 23 Sep 2026 20:45:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 06C6F10F1A2; Wed, 23 Sep 2026 20:45:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="sw+334CD"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 55C2A10F1B6; Wed, 23 Sep 2026 20:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Message-Id:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:From:Reply-To; bh=v37rkaUZTRI5hByycFnxjEKGQY09R0bH4YFjHSkOjVc=; b=sw+334CDjz6vVrKFy0zYnBv3Lo spbioiBMqrtdjQMz4XK07xYgI/s57Lsu0nnFhSuBVBFbTcsfQeZnkojb3SNHGsuuGVqg5nALRXxYy rNwh0pchMUFrMaoqX1hewjAwu8u7Wt5Ih4hS41rV6V6CiD1cT7qQ4HoDag18QMF6xBb/ZqCTawPfJ 1Icnr2HT3f/diW+ckGcr6jz/pkNwGwAuoBgMsu3GPvTqbp+L8ikC9EAhDZt0wgF8nQcrHLT4H5kZU vdrqDHFoAfZ/vZcAQcagSek5/djVlani4ggvP8ilOHbQrxLSCF7gB2K1MzeMp5i64/YlsegtNvfPD KhugaWIg==; Received: from 179-125-72-1-dinamico.pombonet.net.br ([179.125.72.1] helo=[127.0.0.1]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1x9Tq6-006KVk-76; Wed, 23 Sep 2026 22:45:14 +0200 From: Thadeu Lima de Souza Cascardo Date: Wed, 23 Sep 2026 17:44:40 -0300 Subject: [PATCH i-g-t v7 5/9] lib/amdgpu: add amdgpu_cgroup_region_name MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260923-dmem_max-v7-5-194ea47bbb4d@igalia.com> References: <20260923-dmem_max-v7-0-194ea47bbb4d@igalia.com> In-Reply-To: <20260923-dmem_max-v7-0-194ea47bbb4d@igalia.com> To: igt-dev@lists.freedesktop.org Cc: siqueira@igalia.com, Thadeu Lima de Souza Cascardo , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Christian Koenig , maarten.lankhorst@linux.intel.com, =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Kamil Konieczny , Janusz Krzysztofik , Vitaly Prosyak , Natalie Vock , Tvrtko Ursulin , kernel-dev@igalia.com X-Mailer: b4 0.16-dev-62088 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" The amdgpu dmem region name uses its PCI address, just like the one from Xe, but there is only a single VRAM region. Signed-off-by: Thadeu Lima de Souza Cascardo Reviewed-by: Tvrtko Ursulin --- lib/amdgpu/amd_memory.c | 25 +++++++++++++++++++++++++ lib/amdgpu/amd_memory.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/lib/amdgpu/amd_memory.c b/lib/amdgpu/amd_memory.c index 12fe23c65ab2..2da4a8a4baee 100644 --- a/lib/amdgpu/amd_memory.c +++ b/lib/amdgpu/amd_memory.c @@ -30,9 +30,11 @@ #include #include #include +#include #include #include #include +#include "igt_device.h" /** * @@ -679,6 +681,29 @@ bool virtual_free_memory(void *address, unsigned int size) } } +/** + * amdgpu_cgroup_region_name() - Build the dmem cgroup region name for an amdgpu. + * @fd: amdgpu device fd. + * + * Constructs the full dmem cgroup region path for VRAM on the device + * identified by @fd. The returned string has the form + * ``drm//vram`` (e.g. ``drm/0000:03:00.0/vram``), matching + * the name registered by the kernel driver via drmm_cgroup_register_region(). + * + * Return: A newly allocated string that the caller must free(), or %NULL if + * @region is not tracked by the dmem cgroup controller. + */ +char *amdgpu_cgroup_region_name(int fd) +{ + char pci_slot[NAME_MAX]; + char *name; + + igt_device_get_pci_slot_name(fd, pci_slot); + + igt_assert(asprintf(&name, "drm/%s/vram", pci_slot) > 0); + return name; +} + /** * Wait for specific value in memory with timeout */ diff --git a/lib/amdgpu/amd_memory.h b/lib/amdgpu/amd_memory.h index e26c85bc4b0a..de169e580c1b 100644 --- a/lib/amdgpu/amd_memory.h +++ b/lib/amdgpu/amd_memory.h @@ -105,6 +105,8 @@ void bool virtual_free_memory(void *address, unsigned int size); +char *amdgpu_cgroup_region_name(int fd); + bool wait_on_value(unsigned int *ptr, unsigned int expected); #endif -- 2.47.3