From 17d1ecc43c5a2cc0d1fa68aa2d79d87bff2755b3 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Thu, 16 Jul 2020 23:48:54 +0530 Subject: [PATCH] gpu: nvgpu: remove bpmp powergate calls for t186 and t194 and update is_railgated With Generic Power Domains (genpd), bpmp driver will manage the GPU powergating. With the nvgpu idle/unidle flows updated for VPR with genpd/RPM, the usage of the below tegra bpmp calls can be removed from nvgpu from railgate APIs for t186 and t194. Note that genpd is available in k4.14 onwards, so this will work on current downstream kernel. tegra_bpmp_running tegra_powergate_is_powered tegra_powergate_partition tegra_unpowergate_partition Runtime suspended state indicates that the device is railgated. Update the t186 and t194 is_railgated handlers with this. t210 railgate/unrailgate will be still managed by nvgpu as bpmp support is not present. Bug 200602747 JIRA NVGPU-5356 Change-Id: Iadfd794cb51bc41ca927b84fc212ac766d60094d Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2376642 GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions Reviewed-by: Deepak Nibade Reviewed-by: Sachin Nikam Reviewed-by: mobile promotions --- .../gpu/nvgpu/os/linux/platform_gp10b_tegra.c | 31 +++------- .../gpu/nvgpu/os/linux/platform_gv11b_tegra.c | 56 +++---------------- 2 files changed, 18 insertions(+), 69 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/os/linux/platform_gp10b_tegra.c index 43bdc8654..0cb3dfd7e 100644 --- a/drivers/gpu/nvgpu/os/linux/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/os/linux/platform_gp10b_tegra.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef CONFIG_TEGRA_BWMGR #include #endif @@ -28,8 +29,6 @@ #include #ifdef CONFIG_NV_TEGRA_BPMP -#include -#include #include #endif /* CONFIG_NV_TEGRA_BPMP */ @@ -261,12 +260,14 @@ static int gp10b_tegra_remove(struct device *dev) static bool gp10b_tegra_is_railgated(struct device *dev) { + struct gk20a *g = get_gk20a(dev); bool ret = false; -#ifdef TEGRA186_POWER_DOMAIN_GPU - if (tegra_bpmp_running()) - ret = !tegra_powergate_is_powered(TEGRA186_POWER_DOMAIN_GPU); -#endif + if (pm_runtime_status_suspended(dev)) { + ret = true; + } + + nvgpu_log(g, gpu_dbg_info, "railgated? %s", ret ? "yes" : "no"); return ret; } @@ -305,17 +306,10 @@ static int gp10b_tegra_railgate(struct device *dev) tegra_bwmgr_set_emc( (struct tegra_bwmgr_client *)profile->private_data, 0, TEGRA_BWMGR_SET_EMC_FLOOR); -#endif +#endif /* CONFIG_TEGRA_BWMGR */ -#ifdef TEGRA186_POWER_DOMAIN_GPU - if (tegra_bpmp_running() && - tegra_powergate_is_powered(TEGRA186_POWER_DOMAIN_GPU)) { - gp10b_tegra_clks_control(dev, false); - tegra_powergate_partition(TEGRA186_POWER_DOMAIN_GPU); - } -#else gp10b_tegra_clks_control(dev, false); -#endif + return 0; } @@ -327,14 +321,7 @@ static int gp10b_tegra_unrailgate(struct device *dev) struct gk20a_scale_profile *profile = platform->g->scale_profile; #endif -#ifdef TEGRA186_POWER_DOMAIN_GPU - if (tegra_bpmp_running()) { - ret = tegra_unpowergate_partition(TEGRA186_POWER_DOMAIN_GPU); - gp10b_tegra_clks_control(dev, true); - } -#else gp10b_tegra_clks_control(dev, true); -#endif #ifdef CONFIG_TEGRA_BWMGR /* to start with set emc frequency floor to max rate*/ diff --git a/drivers/gpu/nvgpu/os/linux/platform_gv11b_tegra.c b/drivers/gpu/nvgpu/os/linux/platform_gv11b_tegra.c index 60fe84531..4d5658a7f 100644 --- a/drivers/gpu/nvgpu/os/linux/platform_gv11b_tegra.c +++ b/drivers/gpu/nvgpu/os/linux/platform_gv11b_tegra.c @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef CONFIG_TEGRA_BWMGR #include #endif @@ -32,11 +33,6 @@ #include -#ifdef CONFIG_NV_TEGRA_BPMP -#include -#include -#endif /* CONFIG_NV_TEGRA_BPMP */ - #include "platform_gk20a.h" #include "clk.h" #include "scale.h" @@ -150,19 +146,15 @@ static int gv11b_tegra_remove(struct device *dev) static bool gv11b_tegra_is_railgated(struct device *dev) { - bool ret = false; -#ifdef TEGRA194_POWER_DOMAIN_GPU struct gk20a *g = get_gk20a(dev); + bool ret = false; - if (tegra_bpmp_running()) { - nvgpu_log(g, gpu_dbg_info, "bpmp running"); - ret = !tegra_powergate_is_powered(TEGRA194_POWER_DOMAIN_GPU); - - nvgpu_log(g, gpu_dbg_info, "railgated? %s", ret ? "yes" : "no"); - } else { - nvgpu_log(g, gpu_dbg_info, "bpmp not running"); + if (pm_runtime_status_suspended(dev)) { + ret = true; } -#endif + + nvgpu_log(g, gpu_dbg_info, "railgated? %s", ret ? "yes" : "no"); + return ret; } @@ -181,24 +173,10 @@ static int gv11b_tegra_railgate(struct device *dev) tegra_bwmgr_set_emc( (struct tegra_bwmgr_client *)profile->private_data, 0, TEGRA_BWMGR_SET_EMC_FLOOR); -#endif +#endif /* CONFIG_TEGRA_BWMGR */ -#ifdef TEGRA194_POWER_DOMAIN_GPU - if (tegra_bpmp_running()) { - nvgpu_log(g, gpu_dbg_info, "bpmp running"); - if (!tegra_powergate_is_powered(TEGRA194_POWER_DOMAIN_GPU)) { - nvgpu_log(g, gpu_dbg_info, "powergate is not powered"); - return 0; - } - gp10b_tegra_clks_control(dev, false); - nvgpu_log(g, gpu_dbg_info, "powergate_partition"); - tegra_powergate_partition(TEGRA194_POWER_DOMAIN_GPU); - } else { - nvgpu_log(g, gpu_dbg_info, "bpmp not running"); - } -#else gp10b_tegra_clks_control(dev, false); -#endif + return 0; } @@ -209,24 +187,8 @@ static int gv11b_tegra_unrailgate(struct device *dev) struct gk20a_platform *platform = gk20a_get_platform(dev); struct gk20a_scale_profile *profile = platform->g->scale_profile; #endif -#ifdef TEGRA194_POWER_DOMAIN_GPU - struct gk20a *g = get_gk20a(dev); - if (tegra_bpmp_running()) { - nvgpu_log(g, gpu_dbg_info, "bpmp running"); - ret = tegra_unpowergate_partition(TEGRA194_POWER_DOMAIN_GPU); - if (ret) { - nvgpu_log(g, gpu_dbg_info, - "unpowergate partition failed"); - return ret; - } - gp10b_tegra_clks_control(dev, true); - } else { - nvgpu_log(g, gpu_dbg_info, "bpmp not running"); - } -#else gp10b_tegra_clks_control(dev, true); -#endif #ifdef CONFIG_TEGRA_BWMGR /* to start with set emc frequency floor to max rate*/