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 ++++++++++++++++++---- drivers/gpu/nvgpu/gk20a/gk20a.h | 1 + drivers/gpu/nvgpu/gp106/hal_gp106.c | 3 +++ drivers/gpu/nvgpu/gp10b/gr_gp10b.h | 1 + drivers/gpu/nvgpu/gp10b/hal_gp10b.c | 1 + drivers/gpu/nvgpu/gv100/hal_gv100.c | 1 + drivers/gpu/nvgpu/gv11b/gr_gv11b.h | 1 + drivers/gpu/nvgpu/gv11b/hal_gv11b.c | 1 + drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c | 1 + drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c | 1 + 13 files changed, 46 insertions(+), 14 deletions(-) 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, diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 2605f954..3b8c5cd2 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -367,6 +367,7 @@ struct gpu_ops { void (*enable_gpc_exceptions)(struct gk20a *g); void (*enable_exceptions)(struct gk20a *g); void (*create_gr_sysfs)(struct gk20a *g); + void (*remove_gr_sysfs)(struct gk20a *g); u32 (*get_lrf_tex_ltc_dram_override)(struct gk20a *g); int (*record_sm_error_state)(struct gk20a *g, u32 gpc, u32 tpc, u32 sm, struct channel_gk20a *fault_ch); diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c index f46f20ef..8af70cf5 100644 --- a/drivers/gpu/nvgpu/gp106/hal_gp106.c +++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c @@ -381,7 +381,10 @@ static const struct gpu_ops gp106_ops = { .update_boosted_ctx = NULL, .set_bes_crop_debug3 = gr_gp10b_set_bes_crop_debug3, .set_bes_crop_debug4 = gr_gp10b_set_bes_crop_debug4, +#ifdef CONFIG_SYSFS .create_gr_sysfs = NULL, + .remove_gr_sysfs = NULL, +#endif .set_ctxsw_preemption_mode = gr_gp106_set_ctxsw_preemption_mode, .load_ctxsw_ucode = gr_gm20b_load_ctxsw_ucode, .fecs_host_int_enable = gr_gk20a_fecs_host_int_enable, diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.h b/drivers/gpu/nvgpu/gp10b/gr_gp10b.h index 61634668..31e1e6e9 100644 --- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.h +++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.h @@ -60,6 +60,7 @@ int gr_gp10b_init_fs_state(struct gk20a *g); int gr_gp10b_alloc_buffer(struct vm_gk20a *vm, size_t size, struct nvgpu_mem *mem); void gr_gp10b_create_sysfs(struct gk20a *g); +void gr_gp10b_remove_sysfs(struct gk20a *g); int gr_gp10b_handle_fecs_error(struct gk20a *g, struct channel_gk20a *__ch, struct gr_gk20a_isr_data *isr_data); diff --git a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c index d8e69dd8..2430be79 100644 --- a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c @@ -341,6 +341,7 @@ static const struct gpu_ops gp10b_ops = { .set_bes_crop_debug3 = gr_gp10b_set_bes_crop_debug3, #ifdef CONFIG_SYSFS .create_gr_sysfs = gr_gp10b_create_sysfs, + .remove_gr_sysfs = gr_gp10b_remove_sysfs, #endif .set_ctxsw_preemption_mode = gr_gp10b_set_ctxsw_preemption_mode, .init_ctxsw_hdr_data = gr_gp10b_init_ctxsw_hdr_data, diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c index b881aaf7..13d0a871 100644 --- a/drivers/gpu/nvgpu/gv100/hal_gv100.c +++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c @@ -413,6 +413,7 @@ static const struct gpu_ops gv100_ops = { .set_bes_crop_debug4 = gr_gp10b_set_bes_crop_debug4, #ifdef CONFIG_SYSFS .create_gr_sysfs = gr_gv11b_create_sysfs, + .remove_gr_sysfs = gr_gv11b_remove_sysfs, #endif .set_ctxsw_preemption_mode = gr_gp10b_set_ctxsw_preemption_mode, .is_etpc_addr = gv11b_gr_pri_is_etpc_addr, diff --git a/drivers/gpu/nvgpu/gv11b/gr_gv11b.h b/drivers/gpu/nvgpu/gv11b/gr_gv11b.h index fb4c8b69..a8dbd3a8 100644 --- a/drivers/gpu/nvgpu/gv11b/gr_gv11b.h +++ b/drivers/gpu/nvgpu/gv11b/gr_gv11b.h @@ -88,6 +88,7 @@ int gr_gv11b_alloc_buffer(struct vm_gk20a *vm, size_t size, void gr_gv11b_program_zcull_mapping(struct gk20a *g, u32 zcull_num_entries, u32 *zcull_map_tiles); void gr_gv11b_create_sysfs(struct gk20a *g); +void gr_gv11b_remove_sysfs(struct gk20a *g); bool gr_gv11b_is_valid_class(struct gk20a *g, u32 class_num); bool gr_gv11b_is_valid_gfx_class(struct gk20a *g, u32 class_num); diff --git a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c index 84d8a811..1a7f0874 100644 --- a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c @@ -370,6 +370,7 @@ static const struct gpu_ops gv11b_ops = { .set_bes_crop_debug4 = gr_gp10b_set_bes_crop_debug4, #ifdef CONFIG_SYSFS .create_gr_sysfs = gr_gv11b_create_sysfs, + .remove_gr_sysfs = gr_gv11b_remove_sysfs, #endif .set_ctxsw_preemption_mode = gr_gv11b_set_ctxsw_preemption_mode, .is_etpc_addr = gv11b_gr_pri_is_etpc_addr, diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c index 6a946a6e..5c210519 100644 --- a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c +++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c @@ -216,6 +216,7 @@ static const struct gpu_ops vgpu_gp10b_ops = { .set_bes_crop_debug4 = gr_gp10b_set_bes_crop_debug4, #ifdef CONFIG_SYSFS .create_gr_sysfs = gr_gp10b_create_sysfs, + .remove_gr_sysfs = gr_gp10b_remove_sysfs, #endif .set_ctxsw_preemption_mode = vgpu_gr_gp10b_set_ctxsw_preemption_mode, diff --git a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c index 09ce2492..fd408e3a 100644 --- a/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c +++ b/drivers/gpu/nvgpu/vgpu/gv11b/vgpu_hal_gv11b.c @@ -232,6 +232,7 @@ static const struct gpu_ops vgpu_gv11b_ops = { .set_bes_crop_debug4 = gr_gp10b_set_bes_crop_debug4, #ifdef CONFIG_SYSFS .create_gr_sysfs = gr_gv11b_create_sysfs, + .remove_gr_sysfs = gr_gv11b_remove_sysfs, #endif .set_ctxsw_preemption_mode = vgpu_gr_gp10b_set_ctxsw_preemption_mode, .is_etpc_addr = gv11b_gr_pri_is_etpc_addr, -- cgit v1.2.2