From 0840137ad6fdd9ee9da25e8e35d15cf3782c8c50 Mon Sep 17 00:00:00 2001 From: Johnny Liu Date: Tue, 3 Oct 2023 06:37:59 +0000 Subject: [PATCH] drm/tegra: Enable actmon for OFA OFA has unit actmon monitoring its active time. Enabling actmon for OFA to export load information of OFA. Bug 4310958 Signed-off-by: Johnny Liu Change-Id: I8df79f266da71c0cc248e603a07fec7508cbb8ce Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2990240 Reviewed-by: Mikko Perttunen GVS: Gerrit_Virtual_Submit --- drivers/gpu/drm/tegra/ofa.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/gpu/drm/tegra/ofa.c b/drivers/gpu/drm/tegra/ofa.c index 95ad4d04..86220a5f 100644 --- a/drivers/gpu/drm/tegra/ofa.c +++ b/drivers/gpu/drm/tegra/ofa.c @@ -25,9 +25,16 @@ #include "hwpm.h" #define OFA_TFBIF_TRANSCFG 0x1444 +#define OFA_TFBIF_ACTMON_ACTIVE_MASK 0x144c +#define OFA_TFBIF_ACTMON_ACTIVE_BORPS 0x1450 #define OFA_SAFETY_RAM_INIT_REQ 0x3320 #define OFA_SAFETY_RAM_INIT_DONE 0x3324 +#define OFA_TFBIF_ACTMON_ACTIVE_MASK_STARVED BIT(0) +#define OFA_TFBIF_ACTMON_ACTIVE_MASK_STALLED BIT(1) +#define OFA_TFBIF_ACTMON_ACTIVE_MASK_DELAYED BIT(2) +#define OFA_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE BIT(7) + struct ofa_config { const char *firmware; unsigned int version; @@ -199,6 +206,18 @@ cleanup: return err; } +static void ofa_actmon_reg_init(struct ofa *ofa) +{ + ofa_writel(ofa, + OFA_TFBIF_ACTMON_ACTIVE_MASK_STARVED | + OFA_TFBIF_ACTMON_ACTIVE_MASK_STALLED | + OFA_TFBIF_ACTMON_ACTIVE_MASK_DELAYED, + OFA_TFBIF_ACTMON_ACTIVE_MASK); + + ofa_writel(ofa, + OFA_TFBIF_ACTMON_ACTIVE_BORPS_ACTIVE, + OFA_TFBIF_ACTMON_ACTIVE_BORPS); +} static __maybe_unused int ofa_runtime_resume(struct device *dev) { @@ -219,6 +238,10 @@ static __maybe_unused int ofa_runtime_resume(struct device *dev) if (err < 0) goto disable; + ofa_actmon_reg_init(ofa); + + host1x_actmon_enable(&ofa->client.base); + return 0; disable: @@ -234,6 +257,8 @@ static __maybe_unused int ofa_runtime_suspend(struct device *dev) clk_disable_unprepare(ofa->clk); + host1x_actmon_disable(&ofa->client.base); + return 0; } @@ -370,6 +395,10 @@ static int ofa_probe(struct platform_device *pdev) goto exit_falcon; } + err = host1x_actmon_register(&ofa->client.base); + if (err < 0) + dev_info(dev, "failed to register host1x actmon: %d\n", err); + ofa->hwpm.dev = dev; ofa->hwpm.regs = ofa->regs; tegra_drm_hwpm_register(&ofa->hwpm, pdev->resource[0].start, @@ -396,6 +425,8 @@ static int ofa_remove(struct platform_device *pdev) tegra_drm_hwpm_unregister(&ofa->hwpm, pdev->resource[0].start, TEGRA_DRM_HWPM_IP_OFA); + host1x_actmon_unregister(&ofa->client.base); + host1x_client_unregister(&ofa->client.base); falcon_exit(&ofa->falcon);