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 F1E82CD343F for ; Tue, 12 May 2026 21:52:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF9D810EC30; Tue, 12 May 2026 21:52:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="PKdorqcr"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B3AF10EC29; Tue, 12 May 2026 21:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=I6Lp4nixbOv2LqJ07br1/AHEIE91d9ecDtIof3D1v7A=; b=PKdorqcrSAQQpy36TSnWGgNriR 27wZXNiZKVcZuTUIJ63VnMvoiudoc+KORULExydrfPQ0UEt/6IvfOjf2Sabdh0z0iCoBMBvF0w5zm fpjgwtZ7kYwq+/JDkddCLXDtdfeORXl6pSQiMmKKpByOeiyW3EB/PjSce3etJ3T/fUWUpVuSd9qS4 uWu1oVSeg9n8BxIvPvKlBCH/ntGwVNksTFHQhLqngZST3r4gAISyurMyuN6vzSpq1IqGN0o15FGO7 /d5UDrPHyAGsWMS/LyWfC0KuuoRxB0ZA+GqZlkpI4fZq82GF44NbAJ0TbWm58KoICbDEtQX7g/06c wYsUGqnw==; Received: from 179-242-241-236.3g.claro.net.br ([179.242.241.236] helo=quatroqueijos.cascardo.eti.br) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wMv1m-009frh-IO; Tue, 12 May 2026 23:52:34 +0200 From: Thadeu Lima de Souza Cascardo To: igt-dev@lists.freedesktop.org Cc: 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=20Hellstr=C3=B6m?= , Natalie Vock , kernel-dev@igalia.com, Tvrtko Ursulin , Thadeu Lima de Souza Cascardo Subject: [PATCH i-g-t 4/8] amdgpu: add amdgpu_cgroup_region_name Date: Tue, 12 May 2026 18:51:51 -0300 Message-ID: <20260512215156.4083082-5-cascardo@igalia.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260512215156.4083082-1-cascardo@igalia.com> References: <20260512215156.4083082-1-cascardo@igalia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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