From 8963318b140d8ad7a98281bf083c23f08735c57e Mon Sep 17 00:00:00 2001 From: Nitin Kumbhar Date: Wed, 30 May 2018 14:32:41 +0530 Subject: gpu: nvgpu: add remove_gr_sysfs gpu op Add remove_gr_sys() op to gpu_ops to reverse steps done in create_gr_sysfs(). Make gv11b_tegra_remove() specific to gv11b instead to properly remove sysfs nodes. This also helps in having gv11b specific remove steps. Also, update platform remove function of dGPU i.e. nvgpu_pci_tegra_remove() to remove sysfs nodes. This adds parity with iGPU platform remove. Bug 1987855 Change-Id: Ibbaffac5c24346709347f86444a951461894354d Signed-off-by: Nitin Kumbhar Reviewed-on: https://git-master.nvidia.com/r/1735987 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/pci.c | 5 ++++ .../gpu/nvgpu/common/linux/platform_gp10b_tegra.c | 13 ++++++----- .../gpu/nvgpu/common/linux/platform_gp10b_tegra.h | 4 +--- .../gpu/nvgpu/common/linux/platform_gv11b_tegra.c | 27 ++++++++++++++++++---- 4 files changed, 35 insertions(+), 14 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c index 6b3f1092..6caf5ad9 100644 --- a/drivers/gpu/nvgpu/common/linux/pci.c +++ b/drivers/gpu/nvgpu/common/linux/pci.c @@ -52,6 +52,11 @@ static int nvgpu_pci_tegra_probe(struct device *dev) static int nvgpu_pci_tegra_remove(struct device *dev) { + struct gk20a *g = get_gk20a(dev); + + if (g->ops.gr.remove_gr_sysfs) + g->ops.gr.remove_gr_sysfs(g); + return 0; } diff --git a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c index 5d7ee84d..a2506341 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c @@ -67,8 +67,6 @@ static struct { {"gpu", GPCCLK_INIT_RATE}, {"gpu_sys", 204000000} }; -static void gr_gp10b_remove_sysfs(struct device *dev); - /* * gp10b_tegra_get_clocks() * @@ -174,9 +172,12 @@ static int gp10b_tegra_late_probe(struct device *dev) return 0; } -int gp10b_tegra_remove(struct device *dev) +static int gp10b_tegra_remove(struct device *dev) { - gr_gp10b_remove_sysfs(dev); + struct gk20a *g = get_gk20a(dev); + + if (g->ops.gr.remove_gr_sysfs) + g->ops.gr.remove_gr_sysfs(g); /* deinitialise tegra specific scaling quirks */ gp10b_tegra_scale_exit(dev); @@ -792,9 +793,9 @@ void gr_gp10b_create_sysfs(struct gk20a *g) dev_err(dev, "Failed to create sysfs attributes!\n"); } -static void gr_gp10b_remove_sysfs(struct device *dev) +void gr_gp10b_remove_sysfs(struct gk20a *g) { - struct gk20a *g = get_gk20a(dev); + struct device *dev = dev_from_gk20a(g); if (!g->ecc.gr.sm_lrf_single_err_count.counters) return; diff --git a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.h b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.h index 05832e87..725bd0cf 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.h +++ b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -43,6 +43,4 @@ void gp10b_ecc_stat_remove(struct device *dev, struct gk20a_ecc_stat *ecc_stat, struct device_attribute *dev_attr_array); -int gp10b_tegra_remove(struct device *dev); - #endif diff --git a/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c index df760478..f681fe4b 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c +++ b/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c @@ -44,7 +44,15 @@ #include "platform_gk20a_tegra.h" #include "gv11b/gr_gv11b.h" -static void gr_gv11b_remove_sysfs(struct device *dev); +static void gv11b_tegra_scale_exit(struct device *dev) +{ + struct gk20a_platform *platform = gk20a_get_platform(dev); + struct gk20a_scale_profile *profile = platform->g->scale_profile; + + if (profile) + tegra_bwmgr_unregister( + (struct tegra_bwmgr_client *)profile->private_data); +} static int gv11b_tegra_probe(struct device *dev) { @@ -82,11 +90,19 @@ static int gv11b_tegra_late_probe(struct device *dev) return 0; } + static int gv11b_tegra_remove(struct device *dev) { - gp10b_tegra_remove(dev); + struct gk20a *g = get_gk20a(dev); + + if (g->ops.gr.remove_gr_sysfs) + g->ops.gr.remove_gr_sysfs(g); + + gv11b_tegra_scale_exit(dev); - gr_gv11b_remove_sysfs(dev); +#ifdef CONFIG_TEGRA_GK20A_NVHOST + nvgpu_free_nvhost_dev(get_gk20a(dev)); +#endif return 0; } @@ -498,12 +514,13 @@ void gr_gv11b_create_sysfs(struct gk20a *g) dev_err(dev, "Failed to create gv11b sysfs attributes!\n"); } -static void gr_gv11b_remove_sysfs(struct device *dev) +void gr_gv11b_remove_sysfs(struct gk20a *g) { - struct gk20a *g = get_gk20a(dev); + struct device *dev = dev_from_gk20a(g); if (!g->ecc.gr.sm_l1_tag_corrected_err_count.counters) return; + gr_gp10b_remove_sysfs(g); gr_gp10b_ecc_stat_remove(dev, 0, -- cgit v1.2.2