From: Johnny Liu <johnliu@nvidia.com>
To: <thierry.reding@gmail.com>, <jonathanh@nvidia.com>,
<skomatineni@nvidia.com>, <luca.ceresoli@bootlin.com>,
<mperttunen@nvidia.com>, <maarten.lankhorst@linux.intel.com>,
<mripard@kernel.org>, <tzimmermann@suse.de>, <airlied@gmail.com>,
<simona@ffwll.ch>, <robh@kernel.org>, <krzk+dt@kernel.org>,
<conor+dt@kernel.org>
Cc: <linux-media@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
<dri-devel@lists.freedesktop.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Johnny Liu <johnliu@nvidia.com>
Subject: [PATCH v1 5/5] drm/tegra: vic: Register the device with actmon
Date: Tue, 10 Dec 2024 09:45:54 -0800 [thread overview]
Message-ID: <20241210174554.18869-6-johnliu@nvidia.com> (raw)
In-Reply-To: <20241210174554.18869-1-johnliu@nvidia.com>
By registering the vic with actmon, engine load information can be
exported to the user through debugfs for engine profiling purpose.
Signed-off-by: Johnny Liu <johnliu@nvidia.com>
---
drivers/gpu/drm/tegra/vic.c | 39 ++++++++++++++++++++++++++++++++++++-
drivers/gpu/drm/tegra/vic.h | 9 +++++++++
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c
index 332c9b563d3f4..54c9b9b2af0a2 100644
--- a/drivers/gpu/drm/tegra/vic.c
+++ b/drivers/gpu/drm/tegra/vic.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * Copyright (c) 2015, NVIDIA Corporation.
+ * SPDX-FileCopyrightText: Copyright (c) 2015-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#include <linux/clk.h>
@@ -302,6 +302,28 @@ static int vic_load_firmware(struct vic *vic)
return err;
}
+static void vic_actmon_reg_init(struct vic *vic)
+{
+ vic_writel(vic,
+ VIC_TFBIF_ACTMON_ACTIVE_MASK_STARVED |
+ VIC_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
+ VIC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED,
+ NV_PVIC_TFBIF_ACTMON_ACTIVE_MASK);
+ vic_writel(vic,
+ VIC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
+ NV_PVIC_TFBIF_ACTMON_ACTIVE_BORPS);
+}
+
+static void vic_count_weight_init(struct vic *vic, unsigned long rate)
+{
+ struct host1x_client *client = &vic->client.base;
+ u32 weight = 0;
+
+ host1x_actmon_update_client_rate(client, rate, &weight);
+
+ if (weight)
+ vic_writel(vic, weight, NV_PVIC_TFBIF_ACTMON_ACTIVE_WEIGHT);
+}
static int __maybe_unused vic_runtime_resume(struct device *dev)
{
@@ -328,6 +350,10 @@ static int __maybe_unused vic_runtime_resume(struct device *dev)
if (err < 0)
goto assert;
+ vic_actmon_reg_init(vic);
+ vic_count_weight_init(vic, clk_get_rate(vic->clk));
+ host1x_actmon_enable(&vic->client.base);
+
return 0;
assert:
@@ -352,6 +378,8 @@ static int __maybe_unused vic_runtime_suspend(struct device *dev)
clk_disable_unprepare(vic->clk);
+ host1x_actmon_disable(&vic->client.base);
+
return 0;
}
@@ -520,12 +548,20 @@ static int vic_probe(struct platform_device *pdev)
goto exit_falcon;
}
+ err = host1x_actmon_register(&vic->client.base);
+ if (err < 0) {
+ dev_info(&pdev->dev, "failed to register host1x actmon: %d\n", err);
+ goto exit_client;
+ }
+
pm_runtime_enable(dev);
pm_runtime_use_autosuspend(dev);
pm_runtime_set_autosuspend_delay(dev, 500);
return 0;
+exit_client:
+ host1x_client_unregister(&vic->client.base);
exit_falcon:
falcon_exit(&vic->falcon);
@@ -537,6 +573,7 @@ static void vic_remove(struct platform_device *pdev)
struct vic *vic = platform_get_drvdata(pdev);
pm_runtime_disable(&pdev->dev);
+ host1x_actmon_unregister(&vic->client.base);
host1x_client_unregister(&vic->client.base);
falcon_exit(&vic->falcon);
}
diff --git a/drivers/gpu/drm/tegra/vic.h b/drivers/gpu/drm/tegra/vic.h
index acf35aac948b2..905cd7bfde2f6 100644
--- a/drivers/gpu/drm/tegra/vic.h
+++ b/drivers/gpu/drm/tegra/vic.h
@@ -21,6 +21,15 @@
#define CG_IDLE_CG_EN (1 << 6)
#define CG_WAKEUP_DLY_CNT(val) ((val & 0xf) << 16)
+#define NV_PVIC_TFBIF_ACTMON_ACTIVE_MASK 0x0000204c
+#define NV_PVIC_TFBIF_ACTMON_ACTIVE_BORPS 0x00002050
+#define NV_PVIC_TFBIF_ACTMON_ACTIVE_WEIGHT 0x00002054
+
+#define VIC_TFBIF_ACTMON_ACTIVE_MASK_STARVED BIT(0)
+#define VIC_TFBIF_ACTMON_ACTIVE_MASK_STALLED BIT(1)
+#define VIC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED BIT(2)
+#define VIC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE BIT(7)
+
#define VIC_TFBIF_TRANSCFG 0x00002044
#define TRANSCFG_ATT(i, v) (((v) & 0x3) << (i * 4))
#define TRANSCFG_SID_HW 0
--
2.34.1
next prev parent reply other threads:[~2024-12-10 17:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-10 17:45 [PATCH v1 0/5] Support host1x actmon Johnny Liu
2024-12-10 17:45 ` [PATCH v1 1/5] dt-bindings: display: tegra: Add actmon information Johnny Liu
2024-12-13 10:44 ` Krzysztof Kozlowski
2024-12-13 23:29 ` Johnny Liu
2024-12-16 7:26 ` Krzysztof Kozlowski
2024-12-17 1:08 ` Johnny Liu
2024-12-17 5:36 ` Krzysztof Kozlowski
2024-12-10 17:45 ` [PATCH v1 2/5] arm64: " Johnny Liu
2024-12-10 17:45 ` [PATCH v1 3/5] gpu: host1x: Support device monitoring with actmon Johnny Liu
2024-12-17 5:39 ` Krzysztof Kozlowski
2024-12-19 20:29 ` Johnny Liu
2024-12-10 17:45 ` [PATCH v1 4/5] drm/tegra: nvdec: Register the device " Johnny Liu
2024-12-10 17:45 ` Johnny Liu [this message]
2024-12-13 10:42 ` [PATCH v1 0/5] Support host1x actmon Krzysztof Kozlowski
2024-12-13 23:17 ` Johnny Liu
2024-12-16 7:27 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241210174554.18869-6-johnliu@nvidia.com \
--to=johnliu@nvidia.com \
--cc=airlied@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jonathanh@nvidia.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mperttunen@nvidia.com \
--cc=mripard@kernel.org \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=skomatineni@nvidia.com \
--cc=thierry.reding@gmail.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox