From nobody Fri Jan 31 02:24:33 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DC491E284B; Thu, 30 Jan 2025 17:29:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258187; cv=pass; b=Ndvu06Trs1X3gdn5qTZW+iMSbFHOn2l605+6QMd+HDwWZBI/vpiWX+JEv3IUYF2n23vL2QVZaqC3OOKBMimfDeHT7unG/yPGUTOcVMlJZPmD3MFx5hrIXdziJ9kW3AypbtzZrahJlCVFJHrABZ7YHqEyDnM2CFPCWkIwPddE6Xo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258187; c=relaxed/simple; bh=++sDyCZc/yi0yL9Y3edgcU98BfXwKTCf2/oKnn7rR3A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TDkVMjj3MdCIMJQQnuzLumBgsMUPMMcqXdOGB2mmOfGaGS0URovcmglfEd5XGXfz7NampjUbdus1m/R9671/kQQvPtVGbxxk9oiM3n11M3BAT1XDdMGtuXO1k4r/DVeUtB554m/26LpayaWLnRpfYWn9r/c70gjBa+AI5v7BNds= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b=N1b8U1vt; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="N1b8U1vt" ARC-Seal: i=1; a=rsa-sha256; t=1738258157; cv=none; d=zohomail.com; s=zohoarc; b=K0mcm3ZZVkIa2qRv/vGsJQ793dJM9sTSGClvlhjgb7nlQiljTSYKPq2+dFb+66Lx0Fl9H+p4bM1qqz6xm4qWpBUHGXtXvmHe5y2m32zu7xY0Lod9gxyz/BNb0BtLmT8RFAWa55K00B+HePHoaeD2QgOt52nbnPrJyC4o8KRT7J0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738258157; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=5MJd8R69SbdNulHkmKCs63pHS989RsRUWoZsRccqpIk=; b=R3FgPIwWME8kzcb/kMWiplOu/72pttiwcSh91NcL6siTDq545SXDOm/woqp7ZZH1UKXXXF47gweklearZjyOhd83ytB0p3iD++ZI/J+v64VXJY0tymlkFbynRWnh18QZtHCDcrIO9m+dlR3Aip7HtIgRy4tnJyV/3ALZIX/TFng= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1738258157; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=5MJd8R69SbdNulHkmKCs63pHS989RsRUWoZsRccqpIk=; b=N1b8U1vts3zaRJ7wBx9g/6YhEWhcAUo6SlGINMK4ryqPiRflSKQHpmPhIZLMdpNI id4aoG8htyZDl/T5pIanEpqbGYDgGxBAjLZHj3dckZZcFyRv+Iwg3Kyeq5sgNu+pklo pynxEqnruF+SAo42pS7mt9++i6bQ+rn9J0gT+TYM= Received: by mx.zohomail.com with SMTPS id 1738258154340806.4685254117666; Thu, 30 Jan 2025 09:29:14 -0800 (PST) From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= To: David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jonathan Corbet , Boris Brezillon , Steven Price , Liviu Dudau Cc: kernel@collabora.com, Tvrtko Ursulin , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Subject: [PATCH v10 1/5] Documentation/gpu: Clarify format of driver-specific fidnfo keys Date: Thu, 30 Jan 2025 17:28:09 +0000 Message-ID: <20250130172851.941597-2-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250130172851.941597-1-adrian.larumbe@collabora.com> References: <20250130172851.941597-1-adrian.larumbe@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This change reflects de facto usage by amdgpu, as exemplified by commit d6530c33a978 ("drm/amdgpu: expose more memory stats in fdinfo"). Cc: Tvrtko Ursulin Acked-by: Tvrtko Ursulin Signed-off-by: Adri=C3=A1n Larumbe --- Documentation/gpu/drm-usage-stats.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-= usage-stats.rst index 2717cb2a597e..2b5393ed7692 100644 --- a/Documentation/gpu/drm-usage-stats.rst +++ b/Documentation/gpu/drm-usage-stats.rst @@ -21,7 +21,10 @@ File format specification =20 - File shall contain one key value pair per one line of text. - Colon character (`:`) must be used to delimit keys and values. -- All keys shall be prefixed with `drm-`. +- All standardised keys shall be prefixed with `drm-`. +- Driver-specific keys shall be prefixed with `driver_name-`, where + driver_name should ideally be the same as the `name` field in + `struct drm_driver`, although this is not mandatory. - Whitespace between the delimiter and first non-whitespace character shal= l be ignored when parsing. - Keys are not allowed to contain whitespace characters. --=20 2.47.1 From nobody Fri Jan 31 02:24:33 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CFA21EF090; Thu, 30 Jan 2025 17:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258190; cv=pass; b=TPQVWVOXKINgxEm1fsKKVyKzgTdu5Mwax4a31+0YEeuxQUbXrvoWDg1KTZV+mj1yLRHy7EjS4sfYPv50gmUSRdIv16U2FFtJRP9bobjdNrcg8kct9WYmFE4vA3uYP0GIqA0Wk86EwwxSwK5G6XON7deQj6d355ETY/gmtU9ay1Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258190; c=relaxed/simple; bh=WPgPlRMCC9RXZMMybf1yjyC0MgVeFUjNWsuEItR5Cfw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Sn+3Oce4Xuae7LKM3T/j4paUYsod+ceTWdiFQkEQSoZ0ksKlaDAfy7ow0QbWXW24I6RI/29V1pMB1ib6X+6AKibMXvMdI+QAt1x7nt9hVL+TZ8VAFKoP7UfuhVhlDrFuui5Q3BwrFnlT1hmFL8ZyZj61KOEr2FUUvxMhI47V25k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b=bD97INN/; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="bD97INN/" ARC-Seal: i=1; a=rsa-sha256; t=1738258161; cv=none; d=zohomail.com; s=zohoarc; b=bbIcmJM9h6rRy30JmGFykvnn5plTBbtjEWYUPrcfJ9FPqjsZlwW/+3y3Fr37Vk4heCYR5o3C4wNZieKj7LewLd6+k/ovX5evqqPfztXdLpW7MtgouO5AMa/763EsAGhlXYILm5wJKMLEjRVOABs+lFOgKWSU5wCZw6Y9wLHOFTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738258161; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=WecdrsCmMp75CaXmESnd3WuWIXHueLuOQCyE/Ugf6pY=; b=jgl5RDD1LwIY67AsL6NH8DZqkWaFK36d8FaxF3LF5Fui3p3aNorLc+31vWs+AFEDslyw6iuz4Xg/MIoI0r30M0nQ7UUj/YtBT1xkER/ZKTBe011xwtkAybC8ZThywijDmVXfOtC1q20/++IY8CzMOmUWjzvxGfH0OFI/xbrVPvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1738258161; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=WecdrsCmMp75CaXmESnd3WuWIXHueLuOQCyE/Ugf6pY=; b=bD97INN//H4VD98XgEEpBiVJuTzzvCajPh2sRKUVX8T7h87U4SZI9rMnq9z/tQS8 u4Wj8H+kthK/o2va1MVJKzLVtd0L9DHk/gB2NJQCWR+DS8Y/ogJejTzJurZVOxhu9PM JqHyx3Fo9vOtI/9r32S4+6QqzXoS+WEbPiwR4jdY= Received: by mx.zohomail.com with SMTPS id 1738258158032668.901835177617; Thu, 30 Jan 2025 09:29:18 -0800 (PST) From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= To: David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jonathan Corbet , Boris Brezillon , Steven Price , Liviu Dudau Cc: kernel@collabora.com, Tvrtko Ursulin , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Subject: [PATCH v10 2/5] drm/file: Add fdinfo helper for printing regions with prefix Date: Thu, 30 Jan 2025 17:28:10 +0000 Message-ID: <20250130172851.941597-3-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250130172851.941597-1-adrian.larumbe@collabora.com> References: <20250130172851.941597-1-adrian.larumbe@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This is motivated by the desire of some drivers (eg. Panthor) to print the size of internal memory regions with a prefix that reflects the driver name, as suggested in the previous documentation commit. That means adding a new argument to print_size and making it available for DRM users. Cc: Tvrtko Ursulin Reviewed-by: Tvrtko Ursulin Signed-off-by: Adri=C3=A1n Larumbe --- drivers/gpu/drm/drm_file.c | 27 +++++++++++++++++++-------- include/drm/drm_file.h | 5 +++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index cb5f22f5bbb6..f584abcd13cb 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -830,8 +830,12 @@ void drm_send_event(struct drm_device *dev, struct drm= _pending_event *e) } EXPORT_SYMBOL(drm_send_event); =20 -static void print_size(struct drm_printer *p, const char *stat, - const char *region, u64 sz) + +void drm_fdinfo_print_size(struct drm_printer *p, + const char *prefix, + const char *stat, + const char *region, + u64 sz) { const char *units[] =3D {"", " KiB", " MiB"}; unsigned u; @@ -842,8 +846,10 @@ static void print_size(struct drm_printer *p, const ch= ar *stat, sz =3D div_u64(sz, SZ_1K); } =20 - drm_printf(p, "drm-%s-%s:\t%llu%s\n", stat, region, sz, units[u]); + drm_printf(p, "%s-%s-%s:\t%llu%s\n", + prefix, stat, region, sz, units[u]); } +EXPORT_SYMBOL(drm_fdinfo_print_size); =20 /** * drm_print_memory_stats - A helper to print memory stats @@ -858,15 +864,20 @@ void drm_print_memory_stats(struct drm_printer *p, enum drm_gem_object_status supported_status, const char *region) { - print_size(p, "total", region, stats->private + stats->shared); - print_size(p, "shared", region, stats->shared); - print_size(p, "active", region, stats->active); + const char *prefix =3D "drm"; + + drm_fdinfo_print_size(p, prefix, "total", region, + stats->private + stats->shared); + drm_fdinfo_print_size(p, prefix, "shared", region, stats->shared); + drm_fdinfo_print_size(p, prefix, "active", region, stats->active); =20 if (supported_status & DRM_GEM_OBJECT_RESIDENT) - print_size(p, "resident", region, stats->resident); + drm_fdinfo_print_size(p, prefix, "resident", region, + stats->resident); =20 if (supported_status & DRM_GEM_OBJECT_PURGEABLE) - print_size(p, "purgeable", region, stats->purgeable); + drm_fdinfo_print_size(p, prefix, "purgeable", region, + stats->purgeable); } EXPORT_SYMBOL(drm_print_memory_stats); =20 diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index f0ef32e9fa5e..001ae553e8c3 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -494,6 +494,11 @@ struct drm_memory_stats { =20 enum drm_gem_object_status; =20 +void drm_fdinfo_print_size(struct drm_printer *p, + const char *prefix, + const char *stat, + const char *region, + u64 sz); void drm_print_memory_stats(struct drm_printer *p, const struct drm_memory_stats *stats, enum drm_gem_object_status supported_status, --=20 2.47.1 From nobody Fri Jan 31 02:24:33 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DE051F03D0; Thu, 30 Jan 2025 17:29:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258192; cv=pass; b=V69SeNkPG4xo1TCu90ZC8xxXFowGxIt46VYu7q01i6BUHTDrxfc3V9pLDPFhYqjG1cFWXo+PD+OGI+S0dguAYu23cLv/DwoEE+4kLB/Q0GIk+nVf1Uaa6sXc8nkBz3JXXMSV8KIEFznf1ZgsCWC2dCGds/zt/T+Vy8yzR7wO8S0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258192; c=relaxed/simple; bh=2wbzaaZExy6uq0S/2ADIS1O4J9vXWWNqIZ8b9NWjcY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gzHYK0t5eX962Bok/7w6WqE0NfzQjjXau1kyRB8hecl3nnXw3Qvo6vbVeawm+WeD6D3AdqeSyDlr1AQTJvxvbsCMzsS8PjccGH/u73YeLa0WvGbVRCbkf0nL8g40PjgzxIy39IWAE7NPjbwhi6kULpWBXMEFY93LKJk3JNpUyJU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b=jyf9Swd9; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="jyf9Swd9" ARC-Seal: i=1; a=rsa-sha256; t=1738258165; cv=none; d=zohomail.com; s=zohoarc; b=KFtNQV+67AR3anMWXrDBlv8bdefFK1XLZkZHoQAGVwk9WgC3umUAbk4ElKqrtoTOnsKG88CW1KLnX3fp+dFmkQUfwOn90wt5ESwJnfuXWQSwpzopMca1v5Q5cdfZK9jvbf6J4Omx8naVGSOFWsWpfC0tOJ3Cj/7ANi5604Rf+Ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738258165; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=P4G4FNk+thYEQVmBbLx+BZp51fKM+Lmb3gOUtOuFZEY=; b=GL/+mQrmnoLTLKmOEo78twwYygThUerL52JVMohfCv0f7g+O/UvqOOxfE/dlWBEL5RgSJQKHVoIiQLvQdlyC2rvB01E3kU28G80xzTnUro7G9RSFYOpfhRq0Hhoh/5d2DmwUFciZF7HHzJVsnjwVmNI4t85lAuSrig9AHsNoUxM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1738258165; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=P4G4FNk+thYEQVmBbLx+BZp51fKM+Lmb3gOUtOuFZEY=; b=jyf9Swd95rztxreoEg1BY/5LpjUeWyPQcOZhqSYPh1QUcHe1HrgL5S9Uw6dbOvqV Wz/wH8GHCPayJs0q4auXeKK+cQ8MBgM/UsYGeFWfEcTriNnRinJgGlUasKhnIr3NKju 1YqZiurpl/iSux7aReKRHjgyKOvVzZZ+R2Bb4phU= Received: by mx.zohomail.com with SMTPS id 1738258162170235.93290112713225; Thu, 30 Jan 2025 09:29:22 -0800 (PST) From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= To: David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jonathan Corbet , Boris Brezillon , Steven Price , Liviu Dudau Cc: kernel@collabora.com, Tvrtko Ursulin , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Mihail Atanassov Subject: [PATCH v10 3/5] drm/panthor: Expose size of driver internal BO's over fdinfo Date: Thu, 30 Jan 2025 17:28:11 +0000 Message-ID: <20250130172851.941597-4-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250130172851.941597-1-adrian.larumbe@collabora.com> References: <20250130172851.941597-1-adrian.larumbe@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This will display the sizes of kenrel BO's bound to an open file, which are otherwise not exposed to UM through a handle. The sizes recorded are as follows: - Per group: suspend buffer, protm-suspend buffer, syncobjcs - Per queue: ringbuffer, profiling slots, firmware interface - For all heaps in all heap pools across all VM's bound to an open file, record size of all heap chuks, and for each pool the gpu_context BO too. This does not record the size of FW regions, as these aren't bound to a specific open file and remain active through the whole life of the driver. Reviewed-by: Liviu Dudau Reviewed-by: Mihail Atanassov Reviewed-by: Steven Price Reviewed-by: Boris Brezillon Signed-off-by: Adri=C3=A1n Larumbe --- drivers/gpu/drm/panthor/panthor_drv.c | 14 +++++++ drivers/gpu/drm/panthor/panthor_heap.c | 26 ++++++++++++ drivers/gpu/drm/panthor/panthor_heap.h | 2 + drivers/gpu/drm/panthor/panthor_mmu.c | 33 +++++++++++++++ drivers/gpu/drm/panthor/panthor_mmu.h | 3 ++ drivers/gpu/drm/panthor/panthor_sched.c | 56 ++++++++++++++++++++++++- drivers/gpu/drm/panthor/panthor_sched.h | 3 ++ 7 files changed, 136 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/pantho= r/panthor_drv.c index ac7e53f6e3f0..d5f98598d8d7 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1457,12 +1457,26 @@ static void panthor_gpu_show_fdinfo(struct panthor_= device *ptdev, drm_printf(p, "drm-curfreq-panthor:\t%lu Hz\n", ptdev->current_frequency); } =20 +static void panthor_show_internal_memory_stats(struct drm_printer *p, stru= ct drm_file *file) +{ + char *drv_name =3D file->minor->dev->driver->name; + struct panthor_file *pfile =3D file->driver_priv; + struct drm_memory_stats stats =3D {0}; + + panthor_fdinfo_gather_group_mem_info(pfile, &stats); + panthor_vm_heaps_sizes(pfile, &stats); + + drm_fdinfo_print_size(p, drv_name, "resident", "memory", stats.resident); + drm_fdinfo_print_size(p, drv_name, "active", "memory", stats.active); +} + static void panthor_show_fdinfo(struct drm_printer *p, struct drm_file *fi= le) { struct drm_device *dev =3D file->minor->dev; struct panthor_device *ptdev =3D container_of(dev, struct panthor_device,= base); =20 panthor_gpu_show_fdinfo(ptdev, file->driver_priv, p); + panthor_show_internal_memory_stats(p, file); =20 drm_show_memory_stats(p, file); } diff --git a/drivers/gpu/drm/panthor/panthor_heap.c b/drivers/gpu/drm/panth= or/panthor_heap.c index 3796a9eb22af..db0285ce5812 100644 --- a/drivers/gpu/drm/panthor/panthor_heap.c +++ b/drivers/gpu/drm/panthor/panthor_heap.c @@ -603,3 +603,29 @@ void panthor_heap_pool_destroy(struct panthor_heap_poo= l *pool) =20 panthor_heap_pool_put(pool); } + +/** + * panthor_heap_pool_size() - Calculate size of all chunks across all heap= s in a pool + * @pool: Pool whose total chunk size to calculate. + * + * This function adds the size of all heap chunks across all heaps in the + * argument pool. It also adds the size of the gpu contexts kernel bo. + * It is meant to be used by fdinfo for displaying the size of internal + * driver BO's that aren't exposed to userspace through a GEM handle. + * + */ +size_t panthor_heap_pool_size(struct panthor_heap_pool *pool) +{ + struct panthor_heap *heap; + unsigned long i; + size_t size =3D 0; + + down_read(&pool->lock); + xa_for_each(&pool->xa, i, heap) + size +=3D heap->chunk_size * heap->chunk_count; + up_read(&pool->lock); + + size +=3D pool->gpu_contexts->obj->size; + + return size; +} diff --git a/drivers/gpu/drm/panthor/panthor_heap.h b/drivers/gpu/drm/panth= or/panthor_heap.h index 25a5f2bba445..e3358d4e8edb 100644 --- a/drivers/gpu/drm/panthor/panthor_heap.h +++ b/drivers/gpu/drm/panthor/panthor_heap.h @@ -27,6 +27,8 @@ struct panthor_heap_pool * panthor_heap_pool_get(struct panthor_heap_pool *pool); void panthor_heap_pool_put(struct panthor_heap_pool *pool); =20 +size_t panthor_heap_pool_size(struct panthor_heap_pool *pool); + int panthor_heap_grow(struct panthor_heap_pool *pool, u64 heap_gpu_va, u32 renderpasses_in_flight, diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/pantho= r/panthor_mmu.c index c3f0b0225cf9..064c40dc3bdf 100644 --- a/drivers/gpu/drm/panthor/panthor_mmu.c +++ b/drivers/gpu/drm/panthor/panthor_mmu.c @@ -1941,6 +1941,39 @@ struct panthor_heap_pool *panthor_vm_get_heap_pool(s= truct panthor_vm *vm, bool c return pool; } =20 +/** + * panthor_vm_heaps_sizes() - Calculate size of all heap chunks across all + * heaps over all the heap pools in a VM + * @pfile: File. + * @stats: Memory stats to be updated. + * + * Calculate all heap chunk sizes in all heap pools bound to a VM. If the = VM + * is active, record the size as active as well. + */ +void panthor_vm_heaps_sizes(struct panthor_file *pfile, struct drm_memory_= stats *stats) +{ + struct panthor_vm *vm; + unsigned long i; + + if (!pfile->vms) + return; + + xa_lock(&pfile->vms->xa); + xa_for_each(&pfile->vms->xa, i, vm) { + size_t size =3D 0; + + mutex_lock(&vm->heaps.lock); + if (vm->heaps.pool) + size =3D panthor_heap_pool_size(vm->heaps.pool); + mutex_unlock(&vm->heaps.lock); + + stats->resident +=3D size; + if (vm->as.id >=3D 0) + stats->active +=3D size; + } + xa_unlock(&pfile->vms->xa); +} + static u64 mair_to_memattr(u64 mair, bool coherent) { u64 memattr =3D 0; diff --git a/drivers/gpu/drm/panthor/panthor_mmu.h b/drivers/gpu/drm/pantho= r/panthor_mmu.h index 8d21e83d8aba..fc274637114e 100644 --- a/drivers/gpu/drm/panthor/panthor_mmu.h +++ b/drivers/gpu/drm/panthor/panthor_mmu.h @@ -9,6 +9,7 @@ =20 struct drm_exec; struct drm_sched_job; +struct drm_memory_stats; struct panthor_gem_object; struct panthor_heap_pool; struct panthor_vm; @@ -37,6 +38,8 @@ int panthor_vm_flush_all(struct panthor_vm *vm); struct panthor_heap_pool * panthor_vm_get_heap_pool(struct panthor_vm *vm, bool create); =20 +void panthor_vm_heaps_sizes(struct panthor_file *pfile, struct drm_memory_= stats *stats); + struct panthor_vm *panthor_vm_get(struct panthor_vm *vm); void panthor_vm_put(struct panthor_vm *vm); struct panthor_vm *panthor_vm_create(struct panthor_device *ptdev, bool fo= r_mcu, diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/pant= hor/panthor_sched.c index ef4bec7ff9c7..f3c6ca4dc11c 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -618,7 +618,7 @@ struct panthor_group { */ struct panthor_kernel_bo *syncobjs; =20 - /** @fdinfo: Per-file total cycle and timestamp values reference. */ + /** @fdinfo: Per-file info exposed through /proc//fdinfo */ struct { /** @data: Total sampled values for jobs in queues from this group. */ struct panthor_gpu_usage data; @@ -628,6 +628,9 @@ struct panthor_group { * and job post-completion processing function */ struct mutex lock; + + /** @fdinfo.kbo_sizes: Aggregate size of private kernel BO's held by the= group. */ + size_t kbo_sizes; } fdinfo; =20 /** @state: Group state. */ @@ -3365,6 +3368,29 @@ group_create_queue(struct panthor_group *group, return ERR_PTR(ret); } =20 +static void add_group_kbo_sizes(struct panthor_device *ptdev, + struct panthor_group *group) +{ + struct panthor_queue *queue; + int i; + + if (drm_WARN_ON(&ptdev->base, IS_ERR_OR_NULL(group))) + return; + if (drm_WARN_ON(&ptdev->base, ptdev !=3D group->ptdev)) + return; + + group->fdinfo.kbo_sizes +=3D group->suspend_buf->obj->size; + group->fdinfo.kbo_sizes +=3D group->protm_suspend_buf->obj->size; + group->fdinfo.kbo_sizes +=3D group->syncobjs->obj->size; + + for (i =3D 0; i < group->queue_count; i++) { + queue =3D group->queues[i]; + group->fdinfo.kbo_sizes +=3D queue->ringbuf->obj->size; + group->fdinfo.kbo_sizes +=3D queue->iface.mem->obj->size; + group->fdinfo.kbo_sizes +=3D queue->profiling.slots->obj->size; + } +} + #define MAX_GROUPS_PER_POOL 128 =20 int panthor_group_create(struct panthor_file *pfile, @@ -3489,6 +3515,7 @@ int panthor_group_create(struct panthor_file *pfile, } mutex_unlock(&sched->reset.lock); =20 + add_group_kbo_sizes(group->ptdev, group); mutex_init(&group->fdinfo.lock); =20 return gid; @@ -3606,6 +3633,33 @@ void panthor_group_pool_destroy(struct panthor_file = *pfile) pfile->groups =3D NULL; } =20 +/** + * panthor_fdinfo_gather_group_mem_info() - Retrieve aggregate size of all= private kernel BO's + * belonging to all the groups owned by an open Panthor file + * @pfile: File. + * @stats: Memory statistics to be updated. + * + */ +void +panthor_fdinfo_gather_group_mem_info(struct panthor_file *pfile, + struct drm_memory_stats *stats) +{ + struct panthor_group_pool *gpool =3D pfile->groups; + struct panthor_group *group; + unsigned long i; + + if (IS_ERR_OR_NULL(gpool)) + return; + + xa_lock(&gpool->xa); + xa_for_each(&gpool->xa, i, group) { + stats->resident +=3D group->fdinfo.kbo_sizes; + if (group->csg_id >=3D 0) + stats->active +=3D group->fdinfo.kbo_sizes; + } + xa_unlock(&gpool->xa); +} + static void job_release(struct kref *ref) { struct panthor_job *job =3D container_of(ref, struct panthor_job, refcoun= t); diff --git a/drivers/gpu/drm/panthor/panthor_sched.h b/drivers/gpu/drm/pant= hor/panthor_sched.h index 5ae6b4bde7c5..e650a445cf50 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.h +++ b/drivers/gpu/drm/panthor/panthor_sched.h @@ -9,6 +9,7 @@ struct dma_fence; struct drm_file; struct drm_gem_object; struct drm_sched_job; +struct drm_memory_stats; struct drm_panthor_group_create; struct drm_panthor_queue_create; struct drm_panthor_group_get_state; @@ -36,6 +37,8 @@ void panthor_job_update_resvs(struct drm_exec *exec, stru= ct drm_sched_job *job); =20 int panthor_group_pool_create(struct panthor_file *pfile); void panthor_group_pool_destroy(struct panthor_file *pfile); +void panthor_fdinfo_gather_group_mem_info(struct panthor_file *pfile, + struct drm_memory_stats *stats); =20 int panthor_sched_init(struct panthor_device *ptdev); void panthor_sched_unplug(struct panthor_device *ptdev); --=20 2.47.1 From nobody Fri Jan 31 02:24:33 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 163E61EEA38; Thu, 30 Jan 2025 17:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258195; cv=pass; b=SFSRlIfJWFxK6sdpjykF2+8nWOUJFfvceV1ek7IeOUz+QFvIji4butaCUevUYHWLvrSzFMuU+rPfwL8JkXEe+zcch9EMzmNMBGF5/F1OX5fL/pupInL19W6c4AGC5rcuEFj3E2YXTfdQX2WFifAtqmenIc3t5JKo6UqSgrdfsYY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258195; c=relaxed/simple; bh=+ytlbxanqKXQoq654hT86yilOdoDjjJKwJIt1kbMwPI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Dsq24LCgylytyAuvDzZ4+b8PIRaQv/nuISjKeEj3utbD9cCcRHqvjj0TB/PzAVETZy1u2QOlZWbTuZSQxH1df43IE10UTO1ys/sqixSOXzBAmdaoMOTa2ssra+GaPhYXHLdm881B/yAnDJSqcyaF94NDuePfoU1HP9oNccRD2uM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b=G/W94IiB; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="G/W94IiB" ARC-Seal: i=1; a=rsa-sha256; t=1738258169; cv=none; d=zohomail.com; s=zohoarc; b=ks8nP71+ZTi8sM9LOrDE9oieuHGkflR2EAeETY6WQpGO926djVJ1XTTYGqRXZkYWP21CHWywAVTdrr8KZoiu+YNokhTiqNjCBmamAnvbJwfFhQZM05aEoYv3HcYsE9ReZo3JQlhY2tGacz21O7lLZ+GuKfGMYMkYY9jTnh6Pfr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738258169; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=0WA6J/EhS4KkqUnGdo0KmY73cb+vgz8J3JE8d3pK9ns=; b=fKyh/LH3OkFLNLO6QWulY7cMQaUvYPP3lps3zRk/nCLUrYH0GFyS2zAwR+xFlHVqezdf6yuEYYZmvhrHTMsx7iUoQWSfwRTKBanuC9mcv8sZPUbEwaXzCaFnFQx0M1su1r2PPyvobseyK+3yWvtPW2rxWdf/+omOStck7aWKzxc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1738258169; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=0WA6J/EhS4KkqUnGdo0KmY73cb+vgz8J3JE8d3pK9ns=; b=G/W94IiBWevvl+55HsBpJt7bA+XiIHot4po/T336doNsAwyQ0W0ABKVKr8kkK5IB OO2I7Hsp6kE6HcK6HDgGYOwINM4oAe4LKWl5p0pmj39JcdmU5Dw4gWO8Y+gEnfuODmw JqISOzUcPdnABU4TxFF0Z4ZIbfEMlwV+s3OoDBrA= Received: by mx.zohomail.com with SMTPS id 1738258166225175.1611096687751; Thu, 30 Jan 2025 09:29:26 -0800 (PST) From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= To: David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jonathan Corbet , Boris Brezillon , Steven Price , Liviu Dudau Cc: kernel@collabora.com, Tvrtko Ursulin , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Mihail Atanassov Subject: [PATCH v10 4/5] Documentation/gpu: Add fdinfo meanings of panthor-*-memory tags Date: Thu, 30 Jan 2025 17:28:12 +0000 Message-ID: <20250130172851.941597-5-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250130172851.941597-1-adrian.larumbe@collabora.com> References: <20250130172851.941597-1-adrian.larumbe@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable A previous commit enabled display of driver-internal kernel BO sizes through the device file's fdinfo interface. Expand the description of the relevant driver-specific key:value pairs with the definitions of the new panthor-*-memory ones. Reviewed-by: Mihail Atanassov Reviewed-by: Liviu Dudau Reviewed-by: Steven Price Signed-off-by: Adri=C3=A1n Larumbe --- Documentation/gpu/panthor.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/gpu/panthor.rst b/Documentation/gpu/panthor.rst index 3f8979fa2b86..7a841741278f 100644 --- a/Documentation/gpu/panthor.rst +++ b/Documentation/gpu/panthor.rst @@ -26,6 +26,8 @@ the currently possible format options: drm-cycles-panthor: 94439687187 drm-maxfreq-panthor: 1000000000 Hz drm-curfreq-panthor: 1000000000 Hz + panthor-resident-memory: 10396 KiB + panthor-active-memory: 10396 KiB drm-total-memory: 16480 KiB drm-shared-memory: 0 drm-active-memory: 16200 KiB @@ -44,3 +46,11 @@ driver by writing into the appropriate sysfs node:: =20 Where `N` is a bit mask where cycle and timestamp sampling are respectively enabled by the first and second bits. + +Possible `panthor-*-memory` keys are: `active` and `resident`. +These values convey the sizes of the internal driver-owned shmem BO's that +aren't exposed to user-space through a DRM handle, like queue ring buffers, +sync object arrays and heap chunks. Because they are all allocated and pin= ned +at creation time, only `panthor-resident-memory` is necessary to tell us t= heir +size. `panthor-active-memory` shows the size of kernel BO's associated with +VM's and groups currently being scheduled for execution by the GPU. --=20 2.47.1 From nobody Fri Jan 31 02:24:33 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2C871EF0AB; Thu, 30 Jan 2025 17:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258216; cv=pass; b=Z2N4CaPKP1A1/MWG7+0YeGhCU4J7N8JZFvV0jELgVameE+DXrFW9eaB324YPQNzyAOaUIR79d6rkQ0g4Mh3jyBXkgEk9CyyCjU6wNpf8T5Vt4JRwUVyDmEA7AuzBOJgluS5zaPxpHL3PlYkEMRQ3I8/aZCuYjT67IdUbKBItDOc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738258216; c=relaxed/simple; bh=1fgguBGZqx6t+pTxfQu9adrSJCSSJkTXqTPvFN/QrYk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OGOw11Hu9+f55h/lPNtG9Q4lWMFGegM/ikWPaV+k+eSc7pkSmxAibf3YKJ1FU6a++3cQUMwzRHZFQfvoWTKs/5b4Z8/IsT7mxGklFuuzYfUoM9FWIGuE72gIYRCgCiWcOCpvWsWFGuzlQwWXecMSh70zykSKWrj3wPcyJhRNi28= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b=kgsFQRXk; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="kgsFQRXk" ARC-Seal: i=1; a=rsa-sha256; t=1738258188; cv=none; d=zohomail.com; s=zohoarc; b=VQAKzV9mcUTO6J8jy5cc+UMQyftB3RHW95WiG7yLlMh06/WLVOAr+LIRuGC6/Fh45zxpHkEJA5dZotRn1YRRkI0SuKWFV2gpUujEPlUnVzDSgKMsbX5ARPmpDAY+JNaurEHatw0ovCXg+7LTRPgYTc1QIPIKlF/a60VjUC4Fu40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738258188; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=oe9yz0LUgW/HyWP7QYNCqzc/hVt9PtaAICLV4Q8wDfo=; b=i9C7pnx4rUKNzocCoYHPAHenweKpOK2qYTYpp4u7ugE0rt0Yk5Rm6R9iQwpECXZzOcXojJiVnWtHvgzPaHt7nhuM3UJ9JPeU0jraJusKZPfEnZE8Y+8RNbxodYZnqNWJyOre9WPTDBuAXdMaZuZON51EwKLUr8/1RpsAqaE7IK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1738258188; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=oe9yz0LUgW/HyWP7QYNCqzc/hVt9PtaAICLV4Q8wDfo=; b=kgsFQRXk1Pl9A90mfMshBGa9FRinEQx17r3QHzoZYjLCtLmD0libdXyjGuTkebzq J2UeyUGrQXry5OE7+TXCc6tCh5doFm9p+WjELyGSdsAHriBGD4+UrfARDVmvAXU9pgs D3BHQeGpRlyP1IGJ1RV+BYOmM0FGCQP1ajM7SkmQ= Received: by mx.zohomail.com with SMTPS id 1738258170262965.1122189634012; Thu, 30 Jan 2025 09:29:30 -0800 (PST) From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= To: David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jonathan Corbet , Boris Brezillon , Steven Price , Liviu Dudau Cc: kernel@collabora.com, Tvrtko Ursulin , Tvrtko Ursulin , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Subject: [PATCH v10 5/5] drm/panthor: Fix race condition when gathering fdinfo group samples Date: Thu, 30 Jan 2025 17:28:13 +0000 Message-ID: <20250130172851.941597-6-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250130172851.941597-1-adrian.larumbe@collabora.com> References: <20250130172851.941597-1-adrian.larumbe@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Commit e16635d88fa0 ("drm/panthor: add DRM fdinfo support") failed to protect access to groups with an xarray lock, which could lead to use-after-free errors. Fixes: e16635d88fa0 ("drm/panthor: add DRM fdinfo support") Reviewed-by: Boris Brezillon Reviewed-by: Steven Price Signed-off-by: Adri=C3=A1n Larumbe --- drivers/gpu/drm/panthor/panthor_sched.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/pant= hor/panthor_sched.c index f3c6ca4dc11c..6d49b4f40f58 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -2865,6 +2865,7 @@ void panthor_fdinfo_gather_group_samples(struct panth= or_file *pfile) if (IS_ERR_OR_NULL(gpool)) return; =20 + xa_lock(&gpool->xa); xa_for_each(&gpool->xa, i, group) { mutex_lock(&group->fdinfo.lock); pfile->stats.cycles +=3D group->fdinfo.data.cycles; @@ -2873,6 +2874,7 @@ void panthor_fdinfo_gather_group_samples(struct panth= or_file *pfile) group->fdinfo.data.time =3D 0; mutex_unlock(&group->fdinfo.lock); } + xa_unlock(&gpool->xa); } =20 static void group_sync_upd_work(struct work_struct *work) --=20 2.47.1