gpu: nvgpu: add thermal cooling support

Add devfeq thermal cooling device for GPU software thermal throttling.

Bug 3287074

Change-Id: Ib0b53a58177964dfda3c8993da9c4835e2cb8a6e
Signed-off-by: Rajkumar Kasirajan <rkasirajan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2625659
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-by: Srikar Srimath Tirumala <srikars@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Rajkumar Kasirajan
2021-11-14 23:14:31 +08:00
committed by mobile promotions
parent 616a885079
commit 71cd434f4f
2 changed files with 24 additions and 0 deletions

View File

@@ -74,6 +74,9 @@ struct nvgpu_os_linux {
struct device *dev; struct device *dev;
struct dgpu_thermal_alert thermal_alert; struct dgpu_thermal_alert thermal_alert;
struct nvgpu_interrupts interrupts; 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 class_list_head;
struct nvgpu_list_node cdev_list_head; struct nvgpu_list_node cdev_list_head;

View File

@@ -17,6 +17,9 @@
*/ */
#include <linux/devfreq.h> #include <linux/devfreq.h>
#ifdef CONFIG_DEVFREQ_THERMAL
#include <linux/devfreq_cooling.h>
#endif
#include <linux/export.h> #include <linux/export.h>
#include <linux/pm_qos.h> #include <linux/pm_qos.h>
#include <linux/version.h> #include <linux/version.h>
@@ -384,6 +387,9 @@ void gk20a_scale_init(struct device *dev)
struct gk20a *g = platform->g; struct gk20a *g = platform->g;
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
struct gk20a_scale_profile *profile; struct gk20a_scale_profile *profile;
#ifdef CONFIG_DEVFREQ_THERMAL
struct thermal_cooling_device *cooling;
#endif
int err; int err;
if (g->scale_profile) if (g->scale_profile)
@@ -434,6 +440,14 @@ void gk20a_scale_init(struct device *dev)
l->devfreq = devfreq; 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 */ /* create symlink /sys/devices/gpu.0/devfreq_dev */
if (devfreq != NULL) { if (devfreq != NULL) {
error = sysfs_create_link(&dev->kobj, error = sysfs_create_link(&dev->kobj,
@@ -485,6 +499,13 @@ void gk20a_scale_exit(struct device *dev)
} }
#endif #endif
#ifdef CONFIG_DEVFREQ_THERMAL
if (l->cooling) {
devfreq_cooling_unregister(l->cooling);
l->cooling = NULL;
}
#endif
if (platform->devfreq_governor) { if (platform->devfreq_governor) {
sysfs_remove_link(&dev->kobj, "devfreq_dev"); sysfs_remove_link(&dev->kobj, "devfreq_dev");