summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-08-21 13:35:06 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-27 18:04:38 -0400
commit8789cafcfb0d1e16ad0b2c61b047d275f2d684b4 (patch)
tree34092ee2fcedbfbe719c9984c5f5f06807632158
parentc6eae929fd74f11ab13d469a38bffd4e8ba50fb5 (diff)
gpu: nvgpu: Standardize HAS_SYNCPOINTs check
Nvgpu uses many ways to check if sync points are enabled. The four ways used to be: platform->has_syncpoints g->has_syncpoints nvgpu_is_enabled(g, NVPGU_HAS_SYNCPOINTS) gk20a_platform_has_syncpoints() This patch standardizes all usage to now be nvgpu_has_syncpoints() which is based on gk20a_platform_has_syncpoints() - just renamed to be general to nvgpu. All usage of the other forms have now been consolidated. However, under the hood nvgpu_has_syncpoints() does check the is_enabled flag. This flag is now set where g->has_syncpoints used to be set based on the platform data. The basic dependency chain is this: nvgpu_has_syncpoints -> NVGPU_HAS_SYNCPOINTS -> platform->has_syncpoints However, note: there are several places where syncpoints can be disabled if some other driver initialization fails (for ex. host1x). Also note that nvgpu_has_syncpoints() also considers a disable variable set by debugfs. Bug 2327574 Change-Id: Ia2375a80f5f2e27285e6175568dd13e6bb25fd33 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1803975 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/common/mm/vm.c4
-rw-r--r--drivers/gpu/nvgpu/common/sync/channel_sync.c14
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c6
-rw-r--r--drivers/gpu/nvgpu/gv100/hal_gv100.c2
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/gk20a.h10
-rw-r--r--drivers/gpu/nvgpu/os/linux/driver_common.c3
-rw-r--r--drivers/gpu/nvgpu/os/linux/ioctl_as.c2
-rw-r--r--drivers/gpu/nvgpu/os/linux/ioctl_channel.c2
-rw-r--r--drivers/gpu/nvgpu/os/linux/nvhost.c11
-rw-r--r--drivers/gpu/nvgpu/os/linux/pci.c2
-rw-r--r--drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c2
11 files changed, 29 insertions, 29 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c
index 1e6c4601..7f0b3d10 100644
--- a/drivers/gpu/nvgpu/common/mm/vm.c
+++ b/drivers/gpu/nvgpu/common/mm/vm.c
@@ -225,7 +225,7 @@ static int nvgpu_init_sema_pool(struct vm_gk20a *vm)
225 /* 225 /*
226 * Don't waste the memory on semaphores if we don't need them. 226 * Don't waste the memory on semaphores if we don't need them.
227 */ 227 */
228 if (nvgpu_is_enabled(g, NVGPU_HAS_SYNCPOINTS)) { 228 if (nvgpu_has_syncpoints(g)) {
229 return 0; 229 return 0;
230 } 230 }
231 231
@@ -609,7 +609,7 @@ static void __nvgpu_vm_remove(struct vm_gk20a *vm)
609 * pool involves unmapping a GMMU mapping which means aquiring the 609 * pool involves unmapping a GMMU mapping which means aquiring the
610 * update_gmmu_lock. 610 * update_gmmu_lock.
611 */ 611 */
612 if (!nvgpu_is_enabled(g, NVGPU_HAS_SYNCPOINTS)) { 612 if (!nvgpu_has_syncpoints(g)) {
613 if (vm->sema_pool) { 613 if (vm->sema_pool) {
614 nvgpu_semaphore_pool_unmap(vm->sema_pool, vm); 614 nvgpu_semaphore_pool_unmap(vm->sema_pool, vm);
615 nvgpu_semaphore_pool_put(vm->sema_pool); 615 nvgpu_semaphore_pool_put(vm->sema_pool);
diff --git a/drivers/gpu/nvgpu/common/sync/channel_sync.c b/drivers/gpu/nvgpu/common/sync/channel_sync.c
index 116e5701..b40de834 100644
--- a/drivers/gpu/nvgpu/common/sync/channel_sync.c
+++ b/drivers/gpu/nvgpu/common/sync/channel_sync.c
@@ -658,7 +658,7 @@ struct nvgpu_channel_sync *nvgpu_channel_sync_create(struct channel_gk20a *c,
658 bool user_managed) 658 bool user_managed)
659{ 659{
660#ifdef CONFIG_TEGRA_GK20A_NVHOST 660#ifdef CONFIG_TEGRA_GK20A_NVHOST
661 if (gk20a_platform_has_syncpoints(c->g)) 661 if (nvgpu_has_syncpoints(c->g))
662 return channel_sync_syncpt_create(c, user_managed); 662 return channel_sync_syncpt_create(c, user_managed);
663#endif 663#endif
664 return channel_sync_semaphore_create(c, user_managed); 664 return channel_sync_semaphore_create(c, user_managed);
@@ -666,5 +666,15 @@ struct nvgpu_channel_sync *nvgpu_channel_sync_create(struct channel_gk20a *c,
666 666
667bool nvgpu_channel_sync_needs_os_fence_framework(struct gk20a *g) 667bool nvgpu_channel_sync_needs_os_fence_framework(struct gk20a *g)
668{ 668{
669 return !gk20a_platform_has_syncpoints(g); 669 return !nvgpu_has_syncpoints(g);
670}
671
672bool nvgpu_has_syncpoints(struct gk20a *g)
673{
674#ifdef CONFIG_TEGRA_GK20A_NVHOST
675 return nvgpu_is_enabled(g, NVGPU_HAS_SYNCPOINTS) &&
676 !g->disable_syncpoints;
677#else
678 return false;
679#endif
670} 680}
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 1cad8dcb..39318f66 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -391,7 +391,7 @@ int gk20a_finalize_poweron(struct gk20a *g)
391 } 391 }
392 392
393#if defined(CONFIG_TEGRA_GK20A_NVHOST) 393#if defined(CONFIG_TEGRA_GK20A_NVHOST)
394 if (gk20a_platform_has_syncpoints(g) && g->syncpt_unit_size) { 394 if (nvgpu_has_syncpoints(g) && g->syncpt_unit_size) {
395 if (!nvgpu_mem_is_valid(&g->syncpt_mem)) { 395 if (!nvgpu_mem_is_valid(&g->syncpt_mem)) {
396 nr_pages = DIV_ROUND_UP(g->syncpt_unit_size, PAGE_SIZE); 396 nr_pages = DIV_ROUND_UP(g->syncpt_unit_size, PAGE_SIZE);
397 __nvgpu_mem_create_from_phys(g, &g->syncpt_mem, 397 __nvgpu_mem_create_from_phys(g, &g->syncpt_mem,
@@ -461,10 +461,6 @@ int gk20a_init_gpu_characteristics(struct gk20a *g)
461 __nvgpu_set_enabled(g, NVGPU_SUPPORT_SPARSE_ALLOCS, true); 461 __nvgpu_set_enabled(g, NVGPU_SUPPORT_SPARSE_ALLOCS, true);
462 } 462 }
463 463
464 if (gk20a_platform_has_syncpoints(g)) {
465 __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, true);
466 }
467
468 /* 464 /*
469 * Fast submits are supported as long as the user doesn't request 465 * Fast submits are supported as long as the user doesn't request
470 * anything that depends on job tracking. (Here, fast means strictly no 466 * anything that depends on job tracking. (Here, fast means strictly no
diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c
index 7cd466c3..da89d2b5 100644
--- a/drivers/gpu/nvgpu/gv100/hal_gv100.c
+++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c
@@ -261,7 +261,7 @@ int gv100_init_gpu_characteristics(struct gk20a *g)
261 261
262 __nvgpu_set_enabled(g, NVGPU_SUPPORT_TSG_SUBCONTEXTS, true); 262 __nvgpu_set_enabled(g, NVGPU_SUPPORT_TSG_SUBCONTEXTS, true);
263 __nvgpu_set_enabled(g, NVGPU_SUPPORT_GET_TEMPERATURE, true); 263 __nvgpu_set_enabled(g, NVGPU_SUPPORT_GET_TEMPERATURE, true);
264 if (g->has_syncpoints) { 264 if (nvgpu_has_syncpoints(g)) {
265 __nvgpu_set_enabled(g, NVGPU_SUPPORT_SYNCPOINT_ADDRESS, true); 265 __nvgpu_set_enabled(g, NVGPU_SUPPORT_SYNCPOINT_ADDRESS, true);
266 __nvgpu_set_enabled(g, NVGPU_SUPPORT_USER_SYNCPOINT, true); 266 __nvgpu_set_enabled(g, NVGPU_SUPPORT_USER_SYNCPOINT, true);
267 } 267 }
diff --git a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h
index 8d7ccfa8..8627fddd 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h
@@ -1485,7 +1485,6 @@ struct gk20a {
1485 unsigned int aggressive_sync_destroy_thresh; 1485 unsigned int aggressive_sync_destroy_thresh;
1486 bool aggressive_sync_destroy; 1486 bool aggressive_sync_destroy;
1487 1487
1488 bool has_syncpoints;
1489 /* Debugfs knob for forcing syncpt support off in runtime. */ 1488 /* Debugfs knob for forcing syncpt support off in runtime. */
1490 u32 disable_syncpoints; 1489 u32 disable_syncpoints;
1491 1490
@@ -1758,13 +1757,6 @@ void nvgpu_wait_for_deferred_interrupts(struct gk20a *g);
1758struct gk20a * __must_check gk20a_get(struct gk20a *g); 1757struct gk20a * __must_check gk20a_get(struct gk20a *g);
1759void gk20a_put(struct gk20a *g); 1758void gk20a_put(struct gk20a *g);
1760 1759
1761static inline bool gk20a_platform_has_syncpoints(struct gk20a *g) 1760bool nvgpu_has_syncpoints(struct gk20a *g);
1762{
1763#ifdef CONFIG_TEGRA_GK20A_NVHOST
1764 return g->has_syncpoints && !g->disable_syncpoints;
1765#else
1766 return false;
1767#endif
1768}
1769 1761
1770#endif /* GK20A_H */ 1762#endif /* GK20A_H */
diff --git a/drivers/gpu/nvgpu/os/linux/driver_common.c b/drivers/gpu/nvgpu/os/linux/driver_common.c
index 539f0559..cf7877e2 100644
--- a/drivers/gpu/nvgpu/os/linux/driver_common.c
+++ b/drivers/gpu/nvgpu/os/linux/driver_common.c
@@ -92,6 +92,8 @@ static void nvgpu_init_vars(struct gk20a *g)
92 92
93 nvgpu_init_list_node(&g->boardobj_head); 93 nvgpu_init_list_node(&g->boardobj_head);
94 nvgpu_init_list_node(&g->boardobjgrp_head); 94 nvgpu_init_list_node(&g->boardobjgrp_head);
95
96 __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, platform->has_syncpoints);
95} 97}
96 98
97static void nvgpu_init_gr_vars(struct gk20a *g) 99static void nvgpu_init_gr_vars(struct gk20a *g)
@@ -165,7 +167,6 @@ static void nvgpu_init_pm_vars(struct gk20a *g)
165 167
166 g->aggressive_sync_destroy = platform->aggressive_sync_destroy; 168 g->aggressive_sync_destroy = platform->aggressive_sync_destroy;
167 g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh; 169 g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh;
168 g->has_syncpoints = platform->has_syncpoints;
169#ifdef CONFIG_NVGPU_SUPPORT_CDE 170#ifdef CONFIG_NVGPU_SUPPORT_CDE
170 g->has_cde = platform->has_cde; 171 g->has_cde = platform->has_cde;
171#endif 172#endif
diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_as.c b/drivers/gpu/nvgpu/os/linux/ioctl_as.c
index f63a2317..3fa8aa2c 100644
--- a/drivers/gpu/nvgpu/os/linux/ioctl_as.c
+++ b/drivers/gpu/nvgpu/os/linux/ioctl_as.c
@@ -281,7 +281,7 @@ static int nvgpu_as_ioctl_get_sync_ro_map(
281 if (!g->ops.fifo.get_sync_ro_map) 281 if (!g->ops.fifo.get_sync_ro_map)
282 return -EINVAL; 282 return -EINVAL;
283 283
284 if (!gk20a_platform_has_syncpoints(g)) 284 if (!nvgpu_has_syncpoints(g))
285 return -EINVAL; 285 return -EINVAL;
286 286
287 err = g->ops.fifo.get_sync_ro_map(vm, &base_gpuva, &sync_size); 287 err = g->ops.fifo.get_sync_ro_map(vm, &base_gpuva, &sync_size);
diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c
index dd69c590..45d49474 100644
--- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c
+++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c
@@ -1014,7 +1014,7 @@ static int nvgpu_ioctl_channel_get_user_syncpoint(struct channel_gk20a *ch,
1014 return -EINVAL; 1014 return -EINVAL;
1015 } 1015 }
1016 1016
1017 if (!gk20a_platform_has_syncpoints(g)) { 1017 if (!nvgpu_has_syncpoints(g)) {
1018 nvgpu_err(g, "syncpoints not supported"); 1018 nvgpu_err(g, "syncpoints not supported");
1019 return -EINVAL; 1019 return -EINVAL;
1020 } 1020 }
diff --git a/drivers/gpu/nvgpu/os/linux/nvhost.c b/drivers/gpu/nvgpu/os/linux/nvhost.c
index ccb830cc..2becae54 100644
--- a/drivers/gpu/nvgpu/os/linux/nvhost.c
+++ b/drivers/gpu/nvgpu/os/linux/nvhost.c
@@ -21,6 +21,7 @@
21 21
22#include <nvgpu/gk20a.h> 22#include <nvgpu/gk20a.h>
23#include <nvgpu/nvhost.h> 23#include <nvgpu/nvhost.h>
24#include <nvgpu/enabled.h>
24 25
25#include "nvhost_priv.h" 26#include "nvhost_priv.h"
26 27
@@ -45,9 +46,9 @@ int nvgpu_get_nvhost_dev(struct gk20a *g)
45 } 46 }
46 47
47 } else { 48 } else {
48 if (g->has_syncpoints) { 49 if (nvgpu_has_syncpoints(g)) {
49 nvgpu_warn(g, "host1x reference not found. assuming no syncpoints support"); 50 nvgpu_warn(g, "host1x reference not found. assuming no syncpoints support");
50 g->has_syncpoints = false; 51 __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, false);
51 } 52 }
52 return 0; 53 return 0;
53 } 54 }
@@ -263,13 +264,13 @@ int nvgpu_nvhost_syncpt_init(struct gk20a *g)
263{ 264{
264 int err = 0; 265 int err = 0;
265 266
266 if (!g->has_syncpoints) 267 if (!nvgpu_has_syncpoints(g))
267 return -ENOSYS; 268 return -ENOSYS;
268 269
269 err = nvgpu_get_nvhost_dev(g); 270 err = nvgpu_get_nvhost_dev(g);
270 if (err) { 271 if (err) {
271 nvgpu_err(g, "host1x device not available"); 272 nvgpu_err(g, "host1x device not available");
272 g->has_syncpoints = false; 273 __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, false);
273 return -ENOSYS; 274 return -ENOSYS;
274 } 275 }
275 276
@@ -279,7 +280,7 @@ int nvgpu_nvhost_syncpt_init(struct gk20a *g)
279 &g->syncpt_unit_size); 280 &g->syncpt_unit_size);
280 if (err) { 281 if (err) {
281 nvgpu_err(g, "Failed to get syncpt interface"); 282 nvgpu_err(g, "Failed to get syncpt interface");
282 g->has_syncpoints = false; 283 __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, false);
283 return -ENOSYS; 284 return -ENOSYS;
284 } 285 }
285 286
diff --git a/drivers/gpu/nvgpu/os/linux/pci.c b/drivers/gpu/nvgpu/os/linux/pci.c
index 3b73b539..2e456abc 100644
--- a/drivers/gpu/nvgpu/os/linux/pci.c
+++ b/drivers/gpu/nvgpu/os/linux/pci.c
@@ -795,7 +795,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
795 } 795 }
796 /* Enable Semaphore SHIM on nvlink only for now. */ 796 /* Enable Semaphore SHIM on nvlink only for now. */
797 __nvgpu_set_enabled(g, NVGPU_SUPPORT_NVLINK, false); 797 __nvgpu_set_enabled(g, NVGPU_SUPPORT_NVLINK, false);
798 g->has_syncpoints = false; 798 __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, false);
799 } else { 799 } else {
800 err = nvgpu_nvhost_syncpt_init(g); 800 err = nvgpu_nvhost_syncpt_init(g);
801 if (err) { 801 if (err) {
diff --git a/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c b/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c
index 9cb40fb4..e01178ed 100644
--- a/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c
+++ b/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c
@@ -80,7 +80,7 @@ static void vgpu_init_vars(struct gk20a *g, struct gk20a_platform *platform)
80 80
81 g->aggressive_sync_destroy = platform->aggressive_sync_destroy; 81 g->aggressive_sync_destroy = platform->aggressive_sync_destroy;
82 g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh; 82 g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh;
83 g->has_syncpoints = platform->has_syncpoints; 83 __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, platform->has_syncpoints);
84 g->ptimer_src_freq = platform->ptimer_src_freq; 84 g->ptimer_src_freq = platform->ptimer_src_freq;
85 __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, platform->can_railgate_init); 85 __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, platform->can_railgate_init);
86 g->railgate_delay = platform->railgate_delay_init; 86 g->railgate_delay = platform->railgate_delay_init;