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 4/5] drm/tegra: nvdec: Register the device with actmon
Date: Tue, 10 Dec 2024 09:45:53 -0800 [thread overview]
Message-ID: <20241210174554.18869-5-johnliu@nvidia.com> (raw)
In-Reply-To: <20241210174554.18869-1-johnliu@nvidia.com>
By registering the nvdec 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/nvdec.c | 82 ++++++++++++++++++++++++++++++++++-
1 file changed, 80 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/tegra/nvdec.c b/drivers/gpu/drm/tegra/nvdec.c
index 2d9a0a3f6c381..b7c572484d1be 100644
--- a/drivers/gpu/drm/tegra/nvdec.c
+++ b/drivers/gpu/drm/tegra/nvdec.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * Copyright (c) 2015-2022, NVIDIA Corporation.
+ * SPDX-FileCopyrightText: Copyright (c) 2015-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#include <linux/clk.h>
@@ -22,8 +22,21 @@
#include "riscv.h"
#include "vic.h"
-#define NVDEC_FALCON_DEBUGINFO 0x1094
+#define NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_MASK 0xCAU
+#define NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_BORPS 0xCBU
+#define NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_WEIGHT 0xC9U
+#define NVDEC_FALCON_UCLASS_METHOD_OFFSET 0x40
+#define NVDEC_FALCON_UCLASS_METHOD_DATA 0x44
+#define NVDEC_FALCON_DEBUGINFO 0x1094
#define NVDEC_TFBIF_TRANSCFG 0x2c44
+#define NVDEC_TFBIF_ACTMON_ACTIVE_MASK 0x2c4c
+#define NVDEC_TFBIF_ACTMON_ACTIVE_BORPS 0x2c50
+#define NVDEC_TFBIF_ACTMON_ACTIVE_WEIGHT 0x2c54
+
+#define NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STARVED BIT(0)
+#define NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STALLED BIT(1)
+#define NVDEC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED BIT(2)
+#define NVDEC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE BIT(7)
struct nvdec_config {
const char *firmware;
@@ -306,6 +319,56 @@ static int nvdec_load_falcon_firmware(struct nvdec *nvdec)
return err;
}
+static void nvdec_actmon_reg_init(struct nvdec *nvdec)
+{
+ if (nvdec->config->has_riscv) {
+ nvdec_writel(nvdec,
+ NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_MASK,
+ NVDEC_FALCON_UCLASS_METHOD_OFFSET);
+ nvdec_writel(nvdec,
+ NVDEC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED |
+ NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
+ NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STARVED,
+ NVDEC_FALCON_UCLASS_METHOD_DATA);
+ nvdec_writel(nvdec,
+ NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_BORPS,
+ NVDEC_FALCON_UCLASS_METHOD_OFFSET);
+ nvdec_writel(nvdec,
+ NVDEC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
+ NVDEC_FALCON_UCLASS_METHOD_DATA);
+ } else {
+ nvdec_writel(nvdec,
+ NVDEC_TFBIF_ACTMON_ACTIVE_MASK_DELAYED |
+ NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STALLED |
+ NVDEC_TFBIF_ACTMON_ACTIVE_MASK_STARVED,
+ NVDEC_TFBIF_ACTMON_ACTIVE_MASK);
+ nvdec_writel(nvdec,
+ NVDEC_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE,
+ NVDEC_TFBIF_ACTMON_ACTIVE_BORPS);
+ }
+}
+
+static void nvdec_count_weight_init(struct nvdec *nvdec, unsigned long rate)
+{
+ const struct nvdec_config *config = nvdec->config;
+ struct host1x_client *client = &nvdec->client.base;
+ u32 weight;
+
+ host1x_actmon_update_client_rate(client, rate, &weight);
+
+ if (!weight)
+ return;
+
+ if (!config->has_riscv) {
+ nvdec_writel(nvdec, weight, NVDEC_TFBIF_ACTMON_ACTIVE_WEIGHT);
+ } else {
+ nvdec_writel(nvdec,
+ NVDEC_FW_MTHD_ADDR_ACTMON_ACTIVE_WEIGHT,
+ NVDEC_FALCON_UCLASS_METHOD_OFFSET);
+ nvdec_writel(nvdec, weight, NVDEC_FALCON_UCLASS_METHOD_DATA);
+ }
+}
+
static __maybe_unused int nvdec_runtime_resume(struct device *dev)
{
struct nvdec *nvdec = dev_get_drvdata(dev);
@@ -331,6 +394,10 @@ static __maybe_unused int nvdec_runtime_resume(struct device *dev)
goto disable;
}
+ nvdec_actmon_reg_init(nvdec);
+ nvdec_count_weight_init(nvdec, clk_get_rate(nvdec->clks[0].clk));
+ host1x_actmon_enable(&nvdec->client.base);
+
return 0;
disable:
@@ -346,6 +413,8 @@ static __maybe_unused int nvdec_runtime_suspend(struct device *dev)
clk_bulk_disable_unprepare(nvdec->num_clks, nvdec->clks);
+ host1x_actmon_disable(&nvdec->client.base);
+
return 0;
}
@@ -532,12 +601,20 @@ static int nvdec_probe(struct platform_device *pdev)
goto exit_falcon;
}
+ err = host1x_actmon_register(&nvdec->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(&nvdec->client.base);
exit_falcon:
falcon_exit(&nvdec->falcon);
@@ -549,6 +626,7 @@ static void nvdec_remove(struct platform_device *pdev)
struct nvdec *nvdec = platform_get_drvdata(pdev);
pm_runtime_disable(&pdev->dev);
+ host1x_actmon_unregister(&nvdec->client.base);
host1x_client_unregister(&nvdec->client.base);
falcon_exit(&nvdec->falcon);
}
--
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 ` Johnny Liu [this message]
2024-12-10 17:45 ` [PATCH v1 5/5] drm/tegra: vic: Register the device " Johnny Liu
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-5-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