From 06949c508fed269df90a40535fc672d3c10c0def Mon Sep 17 00:00:00 2001 From: Debarshi Dutta Date: Wed, 28 Aug 2019 12:09:25 +0530 Subject: [PATCH] gpu: nvgpu: Add support for XPU rail split Check if CPU/GPU rails are joint, disable railgating if they are. Add the DT support for T194 and T186 platforms. Disable railgate_enable sysfs node update in the above condition. Bug 200546450 Bug 200545711 Change-Id: I002488f6418805569b0ef0fc3032b58297adeafb Signed-off-by: Debarshi Dutta Reviewed-on: https://git-master.nvidia.com/r/2185221 (cherry picked from commit 1d532589b0a8815b4c4f33b8527fae4b3a5b4bbe in rel-32) Reviewed-on: https://git-master.nvidia.com/r/2190402 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Thomas Fleury Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c | 1 + drivers/gpu/nvgpu/os/linux/platform_gp10b_tegra.c | 13 +++++++++++++ drivers/gpu/nvgpu/os/linux/platform_gv11b_tegra.c | 13 +++++++++++++ drivers/gpu/nvgpu/os/linux/sysfs.c | 8 +++++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c index e5edffa9f..6be3d4d79 100644 --- a/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c +++ b/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c @@ -797,6 +797,7 @@ static int gk20a_tegra_probe(struct device *dev) if (joint_xpu_rail) { nvgpu_log_info(g, "XPU rails are joint\n"); nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, false); + platform->can_railgate_init = false; } platform->g->clk.gpc_pll.id = GK20A_GPC_PLL; diff --git a/drivers/gpu/nvgpu/os/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/os/linux/platform_gp10b_tegra.c index e4a3f7857..46e69448c 100644 --- a/drivers/gpu/nvgpu/os/linux/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/os/linux/platform_gp10b_tegra.c @@ -141,6 +141,8 @@ static void gp10b_tegra_scale_exit(struct device *dev) static int gp10b_tegra_probe(struct device *dev) { struct gk20a_platform *platform = dev_get_drvdata(dev); + bool joint_xpu_rail = false; + struct gk20a *g = platform->g; #ifdef CONFIG_TEGRA_GK20A_NVHOST int ret; @@ -155,6 +157,17 @@ static int gp10b_tegra_probe(struct device *dev) platform->disable_bigpage = !dev->archdata.iommu; +#ifdef CONFIG_OF + joint_xpu_rail = of_property_read_bool(of_chosen, + "nvidia,tegra-joint_xpu_rail"); +#endif + + if (joint_xpu_rail) { + nvgpu_log_info(g, "XPU rails are joint\n"); + platform->can_railgate_init = false; + nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, false); + } + gp10b_tegra_get_clocks(dev); nvgpu_linux_init_clk_support(platform->g); diff --git a/drivers/gpu/nvgpu/os/linux/platform_gv11b_tegra.c b/drivers/gpu/nvgpu/os/linux/platform_gv11b_tegra.c index fd6e6ad37..c373a2f53 100644 --- a/drivers/gpu/nvgpu/os/linux/platform_gv11b_tegra.c +++ b/drivers/gpu/nvgpu/os/linux/platform_gv11b_tegra.c @@ -71,6 +71,8 @@ static int gv11b_tegra_probe(struct device *dev) { struct gk20a_platform *platform = dev_get_drvdata(dev); int err; + bool joint_xpu_rail = false; + struct gk20a *g = platform->g; err = nvgpu_nvhost_syncpt_init(platform->g); if (err) { @@ -84,6 +86,17 @@ static int gv11b_tegra_probe(struct device *dev) platform->disable_bigpage = !dev->archdata.iommu; +#ifdef CONFIG_OF + joint_xpu_rail = of_property_read_bool(of_chosen, + "nvidia,tegra-joint_xpu_rail"); +#endif + + if (joint_xpu_rail) { + nvgpu_log_info(g, "XPU rails are joint\n"); + platform->can_railgate_init = false; + nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, false); + } + gp10b_tegra_get_clocks(dev); nvgpu_linux_init_clk_support(platform->g); diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index 868990ec0..0ad12aa61 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -271,13 +271,19 @@ static ssize_t railgate_enable_store(struct device *dev, unsigned long railgate_enable = 0; /* dev is guaranteed to be valid here. Ok to de-reference */ struct gk20a *g = get_gk20a(dev); + struct gk20a_platform *platform = dev_get_drvdata(dev); bool enabled = nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE); int err; if (kstrtoul(buf, 10, &railgate_enable) < 0) return -EINVAL; - if (railgate_enable && !enabled) { + if (!platform->can_railgate_init) { + nvgpu_err(g, "Railgating is not supported"); + return -EINVAL; + } + + if (railgate_enable) { nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, true); pm_runtime_set_autosuspend_delay(dev, g->railgate_delay); } else if (railgate_enable == 0 && enabled) {