From 8789cafcfb0d1e16ad0b2c61b047d275f2d684b4 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Tue, 21 Aug 2018 10:35:06 -0700 Subject: 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 Reviewed-on: https://git-master.nvidia.com/r/1803975 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/driver_common.c | 3 ++- drivers/gpu/nvgpu/os/linux/ioctl_as.c | 2 +- drivers/gpu/nvgpu/os/linux/ioctl_channel.c | 2 +- drivers/gpu/nvgpu/os/linux/nvhost.c | 11 ++++++----- drivers/gpu/nvgpu/os/linux/pci.c | 2 +- drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) (limited to 'drivers/gpu/nvgpu/os') 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) nvgpu_init_list_node(&g->boardobj_head); nvgpu_init_list_node(&g->boardobjgrp_head); + + __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, platform->has_syncpoints); } static void nvgpu_init_gr_vars(struct gk20a *g) @@ -165,7 +167,6 @@ static void nvgpu_init_pm_vars(struct gk20a *g) g->aggressive_sync_destroy = platform->aggressive_sync_destroy; g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh; - g->has_syncpoints = platform->has_syncpoints; #ifdef CONFIG_NVGPU_SUPPORT_CDE g->has_cde = platform->has_cde; #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( if (!g->ops.fifo.get_sync_ro_map) return -EINVAL; - if (!gk20a_platform_has_syncpoints(g)) + if (!nvgpu_has_syncpoints(g)) return -EINVAL; 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, return -EINVAL; } - if (!gk20a_platform_has_syncpoints(g)) { + if (!nvgpu_has_syncpoints(g)) { nvgpu_err(g, "syncpoints not supported"); return -EINVAL; } 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 @@ #include #include +#include #include "nvhost_priv.h" @@ -45,9 +46,9 @@ int nvgpu_get_nvhost_dev(struct gk20a *g) } } else { - if (g->has_syncpoints) { + if (nvgpu_has_syncpoints(g)) { nvgpu_warn(g, "host1x reference not found. assuming no syncpoints support"); - g->has_syncpoints = false; + __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, false); } return 0; } @@ -263,13 +264,13 @@ int nvgpu_nvhost_syncpt_init(struct gk20a *g) { int err = 0; - if (!g->has_syncpoints) + if (!nvgpu_has_syncpoints(g)) return -ENOSYS; err = nvgpu_get_nvhost_dev(g); if (err) { nvgpu_err(g, "host1x device not available"); - g->has_syncpoints = false; + __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, false); return -ENOSYS; } @@ -279,7 +280,7 @@ int nvgpu_nvhost_syncpt_init(struct gk20a *g) &g->syncpt_unit_size); if (err) { nvgpu_err(g, "Failed to get syncpt interface"); - g->has_syncpoints = false; + __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, false); return -ENOSYS; } 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, } /* Enable Semaphore SHIM on nvlink only for now. */ __nvgpu_set_enabled(g, NVGPU_SUPPORT_NVLINK, false); - g->has_syncpoints = false; + __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, false); } else { err = nvgpu_nvhost_syncpt_init(g); 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) g->aggressive_sync_destroy = platform->aggressive_sync_destroy; g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh; - g->has_syncpoints = platform->has_syncpoints; + __nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, platform->has_syncpoints); g->ptimer_src_freq = platform->ptimer_src_freq; __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, platform->can_railgate_init); g->railgate_delay = platform->railgate_delay_init; -- cgit v1.2.2