diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 3d887d859..7b0db427b 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -1460,6 +1460,9 @@ static int __exit gk20a_remove(struct platform_device *dev) cfb_remove_device(&dev->dev); #endif + if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) + gk20a_scale_exit(dev); + if (g->remove_support) g->remove_support(dev); diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_scale.c b/drivers/gpu/nvgpu/gk20a/gk20a_scale.c index d09a18f84..7efd07bf3 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_scale.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_scale.c @@ -312,6 +312,28 @@ err_get_freqs: g->scale_profile = NULL; } +void gk20a_scale_exit(struct platform_device *pdev) +{ + struct gk20a_platform *platform = platform_get_drvdata(pdev); + struct gk20a *g = platform->g; + int err; + + if (platform->qos_id < PM_QOS_NUM_CLASSES && + platform->qos_id != PM_QOS_RESERVED && + platform->postscale) { + pm_qos_remove_notifier(platform->qos_id, + &g->scale_profile->qos_notify_block); + } + + if (platform->devfreq_governor) { + err = devfreq_remove_device(g->devfreq); + g->devfreq = NULL; + } + + kfree(g->scale_profile); + g->scale_profile = NULL; +} + /* * gk20a_scale_hw_init(dev) * diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_scale.h b/drivers/gpu/nvgpu/gk20a/gk20a_scale.h index 81c23b686..5a9eff978 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_scale.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a_scale.h @@ -35,6 +35,7 @@ struct gk20a_scale_profile { /* Initialization and de-initialization for module */ void gk20a_scale_init(struct platform_device *); +void gk20a_scale_exit(struct platform_device *); void gk20a_scale_hw_init(struct platform_device *pdev); #ifdef CONFIG_GK20A_DEVFREQ