diff --git a/drivers/gpu/nvgpu/os/linux/os_linux.h b/drivers/gpu/nvgpu/os/linux/os_linux.h index 902db354d..a7ef5319b 100644 --- a/drivers/gpu/nvgpu/os/linux/os_linux.h +++ b/drivers/gpu/nvgpu/os/linux/os_linux.h @@ -74,6 +74,9 @@ struct nvgpu_os_linux { struct device *dev; struct dgpu_thermal_alert thermal_alert; struct nvgpu_interrupts interrupts; +#ifdef CONFIG_DEVFREQ_THERMAL + struct thermal_cooling_device *cooling; +#endif struct nvgpu_list_node class_list_head; struct nvgpu_list_node cdev_list_head; diff --git a/drivers/gpu/nvgpu/os/linux/scale.c b/drivers/gpu/nvgpu/os/linux/scale.c index bb812d2e4..b89928553 100644 --- a/drivers/gpu/nvgpu/os/linux/scale.c +++ b/drivers/gpu/nvgpu/os/linux/scale.c @@ -17,6 +17,9 @@ */ #include +#ifdef CONFIG_DEVFREQ_THERMAL +#include +#endif #include #include #include @@ -384,6 +387,9 @@ void gk20a_scale_init(struct device *dev) struct gk20a *g = platform->g; struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); struct gk20a_scale_profile *profile; +#ifdef CONFIG_DEVFREQ_THERMAL + struct thermal_cooling_device *cooling; +#endif int err; if (g->scale_profile) @@ -434,6 +440,14 @@ void gk20a_scale_init(struct device *dev) l->devfreq = devfreq; +#ifdef CONFIG_DEVFREQ_THERMAL + cooling = of_devfreq_cooling_register(dev->of_node, devfreq); + if (IS_ERR(cooling)) + dev_info(dev, "Failed to register cooling device\n"); + else + l->cooling = cooling; +#endif + /* create symlink /sys/devices/gpu.0/devfreq_dev */ if (devfreq != NULL) { error = sysfs_create_link(&dev->kobj, @@ -485,6 +499,13 @@ void gk20a_scale_exit(struct device *dev) } #endif +#ifdef CONFIG_DEVFREQ_THERMAL + if (l->cooling) { + devfreq_cooling_unregister(l->cooling); + l->cooling = NULL; + } +#endif + if (platform->devfreq_governor) { sysfs_remove_link(&dev->kobj, "devfreq_dev");