diff options
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 9 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.h | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 63 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/tsg_gk20a.c | 9 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/nvgpu_common.c | 5 |
5 files changed, 75 insertions, 13 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 40d6d91c..6cbbdeb0 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c | |||
@@ -44,9 +44,6 @@ | |||
44 | 44 | ||
45 | #define NVMAP_HANDLE_PARAM_SIZE 1 | 45 | #define NVMAP_HANDLE_PARAM_SIZE 1 |
46 | 46 | ||
47 | #define NVGPU_CHANNEL_MIN_TIMESLICE_US 1000 | ||
48 | #define NVGPU_CHANNEL_MAX_TIMESLICE_US 50000 | ||
49 | |||
50 | /* | 47 | /* |
51 | * Although channels do have pointers back to the gk20a struct that they were | 48 | * Although channels do have pointers back to the gk20a struct that they were |
52 | * created under in cases where the driver is killed that pointer can be bad. | 49 | * created under in cases where the driver is killed that pointer can be bad. |
@@ -3345,14 +3342,16 @@ int gk20a_channel_set_priority(struct channel_gk20a *ch, u32 priority) | |||
3345 | 3342 | ||
3346 | int gk20a_channel_set_timeslice(struct channel_gk20a *ch, u32 timeslice) | 3343 | int gk20a_channel_set_timeslice(struct channel_gk20a *ch, u32 timeslice) |
3347 | { | 3344 | { |
3345 | struct gk20a *g = ch->g; | ||
3346 | |||
3348 | if (gk20a_is_channel_marked_as_tsg(ch)) { | 3347 | if (gk20a_is_channel_marked_as_tsg(ch)) { |
3349 | gk20a_err(dev_from_gk20a(ch->g), | 3348 | gk20a_err(dev_from_gk20a(ch->g), |
3350 | "invalid operation for TSG!\n"); | 3349 | "invalid operation for TSG!\n"); |
3351 | return -EINVAL; | 3350 | return -EINVAL; |
3352 | } | 3351 | } |
3353 | 3352 | ||
3354 | if (timeslice < NVGPU_CHANNEL_MIN_TIMESLICE_US || | 3353 | if (timeslice < g->min_timeslice_us || |
3355 | timeslice > NVGPU_CHANNEL_MAX_TIMESLICE_US) | 3354 | timeslice > g->max_timeslice_us) |
3356 | return -EINVAL; | 3355 | return -EINVAL; |
3357 | 3356 | ||
3358 | ch->timeslice_us = timeslice; | 3357 | ch->timeslice_us = timeslice; |
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index cf147ae8..ff8ffc4f 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h | |||
@@ -840,6 +840,8 @@ struct gk20a { | |||
840 | u32 timeslice_low_priority_us; | 840 | u32 timeslice_low_priority_us; |
841 | u32 timeslice_medium_priority_us; | 841 | u32 timeslice_medium_priority_us; |
842 | u32 timeslice_high_priority_us; | 842 | u32 timeslice_high_priority_us; |
843 | u32 min_timeslice_us; | ||
844 | u32 max_timeslice_us; | ||
843 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4,4,0) | 845 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4,4,0) |
844 | u32 runlist_interleave; | 846 | u32 runlist_interleave; |
845 | #else | 847 | #else |
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c index a2980354..307fb681 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * GK20A Graphics | 4 | * GK20A Graphics |
5 | * | 5 | * |
6 | * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved. | 6 | * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms and conditions of the GNU General Public License, | 9 | * under the terms and conditions of the GNU General Public License, |
@@ -756,6 +756,63 @@ static ssize_t tpc_fs_mask_read(struct device *dev, | |||
756 | 756 | ||
757 | static DEVICE_ATTR(tpc_fs_mask, ROOTRW, tpc_fs_mask_read, tpc_fs_mask_store); | 757 | static DEVICE_ATTR(tpc_fs_mask, ROOTRW, tpc_fs_mask_read, tpc_fs_mask_store); |
758 | 758 | ||
759 | static ssize_t min_timeslice_us_read(struct device *dev, | ||
760 | struct device_attribute *attr, char *buf) | ||
761 | { | ||
762 | struct gk20a *g = get_gk20a(dev); | ||
763 | |||
764 | return snprintf(buf, PAGE_SIZE, "%u\n", g->min_timeslice_us); | ||
765 | } | ||
766 | |||
767 | static ssize_t min_timeslice_us_store(struct device *dev, | ||
768 | struct device_attribute *attr, const char *buf, size_t count) | ||
769 | { | ||
770 | struct gk20a *g = get_gk20a(dev); | ||
771 | unsigned long val; | ||
772 | |||
773 | if (kstrtoul(buf, 10, &val) < 0) | ||
774 | return -EINVAL; | ||
775 | |||
776 | if (val > g->max_timeslice_us) | ||
777 | return -EINVAL; | ||
778 | |||
779 | g->min_timeslice_us = val; | ||
780 | |||
781 | return count; | ||
782 | } | ||
783 | |||
784 | static DEVICE_ATTR(min_timeslice_us, ROOTRW, min_timeslice_us_read, | ||
785 | min_timeslice_us_store); | ||
786 | |||
787 | static ssize_t max_timeslice_us_read(struct device *dev, | ||
788 | struct device_attribute *attr, char *buf) | ||
789 | { | ||
790 | struct gk20a *g = get_gk20a(dev); | ||
791 | |||
792 | return snprintf(buf, PAGE_SIZE, "%u\n", g->max_timeslice_us); | ||
793 | } | ||
794 | |||
795 | static ssize_t max_timeslice_us_store(struct device *dev, | ||
796 | struct device_attribute *attr, const char *buf, size_t count) | ||
797 | { | ||
798 | struct gk20a *g = get_gk20a(dev); | ||
799 | unsigned long val; | ||
800 | |||
801 | if (kstrtoul(buf, 10, &val) < 0) | ||
802 | return -EINVAL; | ||
803 | |||
804 | if (val < g->min_timeslice_us) | ||
805 | return -EINVAL; | ||
806 | |||
807 | g->max_timeslice_us = val; | ||
808 | |||
809 | return count; | ||
810 | } | ||
811 | |||
812 | static DEVICE_ATTR(max_timeslice_us, ROOTRW, max_timeslice_us_read, | ||
813 | max_timeslice_us_store); | ||
814 | |||
815 | |||
759 | void gk20a_remove_sysfs(struct device *dev) | 816 | void gk20a_remove_sysfs(struct device *dev) |
760 | { | 817 | { |
761 | struct gk20a *g = get_gk20a(dev); | 818 | struct gk20a *g = get_gk20a(dev); |
@@ -782,6 +839,8 @@ void gk20a_remove_sysfs(struct device *dev) | |||
782 | device_remove_file(dev, &dev_attr_aelpg_enable); | 839 | device_remove_file(dev, &dev_attr_aelpg_enable); |
783 | device_remove_file(dev, &dev_attr_allow_all); | 840 | device_remove_file(dev, &dev_attr_allow_all); |
784 | device_remove_file(dev, &dev_attr_tpc_fs_mask); | 841 | device_remove_file(dev, &dev_attr_tpc_fs_mask); |
842 | device_remove_file(dev, &dev_attr_min_timeslice_us); | ||
843 | device_remove_file(dev, &dev_attr_max_timeslice_us); | ||
785 | 844 | ||
786 | if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) { | 845 | if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) { |
787 | sysfs_remove_link(&g->host1x_dev->dev.kobj, dev_name(dev)); | 846 | sysfs_remove_link(&g->host1x_dev->dev.kobj, dev_name(dev)); |
@@ -822,6 +881,8 @@ void gk20a_create_sysfs(struct device *dev) | |||
822 | error |= device_create_file(dev, &dev_attr_aelpg_enable); | 881 | error |= device_create_file(dev, &dev_attr_aelpg_enable); |
823 | error |= device_create_file(dev, &dev_attr_allow_all); | 882 | error |= device_create_file(dev, &dev_attr_allow_all); |
824 | error |= device_create_file(dev, &dev_attr_tpc_fs_mask); | 883 | error |= device_create_file(dev, &dev_attr_tpc_fs_mask); |
884 | error |= device_create_file(dev, &dev_attr_min_timeslice_us); | ||
885 | error |= device_create_file(dev, &dev_attr_max_timeslice_us); | ||
825 | 886 | ||
826 | if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) { | 887 | if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) { |
827 | error |= sysfs_create_link(&g->host1x_dev->dev.kobj, | 888 | error |= sysfs_create_link(&g->host1x_dev->dev.kobj, |
diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c index 3b2cca0d..81a4b78e 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
@@ -26,9 +26,6 @@ | |||
26 | 26 | ||
27 | #include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h> | 27 | #include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h> |
28 | 28 | ||
29 | #define NVGPU_TSG_MIN_TIMESLICE_US 1000 | ||
30 | #define NVGPU_TSG_MAX_TIMESLICE_US 50000 | ||
31 | |||
32 | struct tsg_private { | 29 | struct tsg_private { |
33 | struct gk20a *g; | 30 | struct gk20a *g; |
34 | struct tsg_gk20a *tsg; | 31 | struct tsg_gk20a *tsg; |
@@ -367,8 +364,8 @@ int gk20a_tsg_set_timeslice(struct tsg_gk20a *tsg, u32 timeslice) | |||
367 | { | 364 | { |
368 | struct gk20a *g = tsg->g; | 365 | struct gk20a *g = tsg->g; |
369 | 366 | ||
370 | if (timeslice < NVGPU_TSG_MIN_TIMESLICE_US || | 367 | if (timeslice < g->min_timeslice_us || |
371 | timeslice > NVGPU_TSG_MAX_TIMESLICE_US) | 368 | timeslice > g->max_timeslice_us) |
372 | return -EINVAL; | 369 | return -EINVAL; |
373 | 370 | ||
374 | gk20a_channel_get_timescale_from_timeslice(g, timeslice, | 371 | gk20a_channel_get_timescale_from_timeslice(g, timeslice, |
diff --git a/drivers/gpu/nvgpu/nvgpu_common.c b/drivers/gpu/nvgpu/nvgpu_common.c index a2673b26..7c12616f 100644 --- a/drivers/gpu/nvgpu/nvgpu_common.c +++ b/drivers/gpu/nvgpu/nvgpu_common.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
@@ -69,6 +69,9 @@ static void nvgpu_init_timeslice(struct gk20a *g) | |||
69 | g->timeslice_low_priority_us = 1300; | 69 | g->timeslice_low_priority_us = 1300; |
70 | g->timeslice_medium_priority_us = 2600; | 70 | g->timeslice_medium_priority_us = 2600; |
71 | g->timeslice_high_priority_us = 5200; | 71 | g->timeslice_high_priority_us = 5200; |
72 | |||
73 | g->min_timeslice_us = 1000; | ||
74 | g->max_timeslice_us = 50000; | ||
72 | } | 75 | } |
73 | 76 | ||
74 | static void nvgpu_init_pm_vars(struct gk20a *g) | 77 | static void nvgpu_init_pm_vars(struct gk20a *g) |