From df2100018db1dba730937fe76464a8edf8ebf5dc Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Wed, 28 Feb 2018 03:56:36 -0800 Subject: gpu: nvgpu: allocate separate client managed syncpoint for User We right now allocate a nvgpu managed syncpoint in c->sync and share that with user space But to avoid conflicts between user space and kernel space increments allocate a separate "client managed" syncpoint for User space in c->user_sync Add new API nvgpu_nvhost_get_syncpt_client_managed() to request a client managed syncpoint from nvhost. Note that nvhost/nvgpu do not keep track of MAX/threshold value of this syncpoint Update gk20a_channel_syncpt_create() to receive a flag to indicate whether a User space syncpoint is required or not Unset NVGPU_SUPPORT_USER_SYNCPOINT for gp10b since we don't want to allocate double syncpoints per channel on that platform For gv11b, once we move to use user space submits, support for c->sync will be dropped so we keep using only one syncpoint per channel Bug 200326065 Jira NVGPU-179 Change-Id: I78d94de4276db1c897ea2a4fe4c2db8b2a179722 Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/1665828 Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/channel.c | 2 +- drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 10 +++++----- drivers/gpu/nvgpu/common/linux/nvhost.c | 8 ++++++++ drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 6 +++++- drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 1 + drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c | 25 +++++++++++++++++-------- drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h | 3 ++- drivers/gpu/nvgpu/gp10b/gp10b.c | 1 - drivers/gpu/nvgpu/include/nvgpu/nvhost.h | 2 ++ 9 files changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/channel.c b/drivers/gpu/nvgpu/common/linux/channel.c index a725cd6b..8bfa4cfc 100644 --- a/drivers/gpu/nvgpu/common/linux/channel.c +++ b/drivers/gpu/nvgpu/common/linux/channel.c @@ -444,7 +444,7 @@ static int gk20a_submit_prepare_syncs(struct channel_gk20a *c, if (g->aggressive_sync_destroy_thresh) { nvgpu_mutex_acquire(&c->sync_lock); if (!c->sync) { - c->sync = gk20a_channel_sync_create(c); + c->sync = gk20a_channel_sync_create(c, false); if (!c->sync) { err = -ENOMEM; nvgpu_mutex_release(&c->sync_lock); diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index ab6ac9b9..0acaa61d 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c @@ -972,11 +972,11 @@ static int nvgpu_ioctl_channel_get_user_syncpoint(struct channel_gk20a *ch, } nvgpu_mutex_acquire(&ch->sync_lock); - if (ch->sync) { + if (ch->user_sync) { nvgpu_mutex_release(&ch->sync_lock); } else { - ch->sync = gk20a_channel_sync_create(ch); - if (!ch->sync) { + ch->user_sync = gk20a_channel_sync_create(ch, true); + if (!ch->user_sync) { nvgpu_mutex_release(&ch->sync_lock); return -ENOMEM; } @@ -989,11 +989,11 @@ static int nvgpu_ioctl_channel_get_user_syncpoint(struct channel_gk20a *ch, } } - args->syncpoint_id = ch->sync->syncpt_id(ch->sync); + args->syncpoint_id = ch->user_sync->syncpt_id(ch->user_sync); args->syncpoint_max = nvgpu_nvhost_syncpt_read_maxval(g->nvhost_dev, args->syncpoint_id); if (nvgpu_is_enabled(g, NVGPU_SUPPORT_SYNCPOINT_ADDRESS)) - args->gpu_va = ch->sync->syncpt_address(ch->sync); + args->gpu_va = ch->user_sync->syncpt_address(ch->user_sync); else args->gpu_va = 0; diff --git a/drivers/gpu/nvgpu/common/linux/nvhost.c b/drivers/gpu/nvgpu/common/linux/nvhost.c index 94bbfd70..a76953e3 100644 --- a/drivers/gpu/nvgpu/common/linux/nvhost.c +++ b/drivers/gpu/nvgpu/common/linux/nvhost.c @@ -138,6 +138,14 @@ u32 nvgpu_nvhost_get_syncpt_host_managed( param, syncpt_name); } +u32 nvgpu_nvhost_get_syncpt_client_managed( + struct nvgpu_nvhost_dev *nvhost_dev, + const char *syncpt_name) +{ + return nvhost_get_syncpt_client_managed(nvhost_dev->host1x_pdev, + syncpt_name); +} + int nvgpu_nvhost_syncpt_wait_timeout_ext( struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 thresh, u32 timeout, u32 *value, struct timespec *ts) diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 2f5ea301..2c98797d 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -438,6 +438,10 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) gk20a_channel_sync_destroy(ch->sync); ch->sync = NULL; } + if (ch->user_sync) { + gk20a_channel_sync_destroy(ch->user_sync); + ch->user_sync = NULL; + } nvgpu_mutex_release(&ch->sync_lock); /* @@ -1147,7 +1151,7 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c, if (!g->aggressive_sync_destroy_thresh) { nvgpu_mutex_acquire(&c->sync_lock); - c->sync = gk20a_channel_sync_create(c); + c->sync = gk20a_channel_sync_create(c, false); if (!c->sync) { err = -ENOMEM; nvgpu_mutex_release(&c->sync_lock); diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index db1404a3..edb645b5 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -226,6 +226,7 @@ struct channel_gk20a { struct nvgpu_mutex sync_lock; struct gk20a_channel_sync *sync; + struct gk20a_channel_sync *user_sync; #ifdef CONFIG_TEGRA_GR_VIRTUALIZATION u64 virt_ctx; diff --git a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c index e965a329..9649c573 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c @@ -315,7 +315,7 @@ static void gk20a_channel_syncpt_destroy(struct gk20a_channel_sync *s) } static struct gk20a_channel_sync * -gk20a_channel_syncpt_create(struct channel_gk20a *c) +gk20a_channel_syncpt_create(struct channel_gk20a *c, bool user_managed) { struct gk20a_channel_syncpt *sp; char syncpt_name[32]; @@ -327,11 +327,19 @@ gk20a_channel_syncpt_create(struct channel_gk20a *c) sp->c = c; sp->nvhost_dev = c->g->nvhost_dev; - snprintf(syncpt_name, sizeof(syncpt_name), - "%s_%d", c->g->name, c->chid); + if (user_managed) { + snprintf(syncpt_name, sizeof(syncpt_name), + "%s_%d_user", c->g->name, c->chid); - sp->id = nvgpu_nvhost_get_syncpt_host_managed(sp->nvhost_dev, + sp->id = nvgpu_nvhost_get_syncpt_client_managed(sp->nvhost_dev, + syncpt_name); + } else { + snprintf(syncpt_name, sizeof(syncpt_name), + "%s_%d", c->g->name, c->chid); + + sp->id = nvgpu_nvhost_get_syncpt_host_managed(sp->nvhost_dev, c->chid, syncpt_name); + } if (!sp->id) { nvgpu_kfree(c->g, sp); nvgpu_err(c->g, "failed to get free syncpt"); @@ -892,7 +900,7 @@ static void gk20a_channel_semaphore_destroy(struct gk20a_channel_sync *s) } static struct gk20a_channel_sync * -gk20a_channel_semaphore_create(struct channel_gk20a *c) +gk20a_channel_semaphore_create(struct channel_gk20a *c, bool user_managed) { int asid = -1; struct gk20a_channel_semaphore *sema; @@ -940,13 +948,14 @@ void gk20a_channel_sync_destroy(struct gk20a_channel_sync *sync) sync->destroy(sync); } -struct gk20a_channel_sync *gk20a_channel_sync_create(struct channel_gk20a *c) +struct gk20a_channel_sync *gk20a_channel_sync_create(struct channel_gk20a *c, + bool user_managed) { #ifdef CONFIG_TEGRA_GK20A_NVHOST if (gk20a_platform_has_syncpoints(c->g)) - return gk20a_channel_syncpt_create(c); + return gk20a_channel_syncpt_create(c, user_managed); #endif - return gk20a_channel_semaphore_create(c); + return gk20a_channel_semaphore_create(c, user_managed); } bool gk20a_channel_sync_needs_sync_framework(struct gk20a *g) diff --git a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h index fe1d8526..f4f54145 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h @@ -110,7 +110,8 @@ struct gk20a_channel_sync { }; void gk20a_channel_sync_destroy(struct gk20a_channel_sync *sync); -struct gk20a_channel_sync *gk20a_channel_sync_create(struct channel_gk20a *c); +struct gk20a_channel_sync *gk20a_channel_sync_create(struct channel_gk20a *c, + bool user_managed); bool gk20a_channel_sync_needs_sync_framework(struct gk20a *g); #ifdef CONFIG_SYNC diff --git a/drivers/gpu/nvgpu/gp10b/gp10b.c b/drivers/gpu/nvgpu/gp10b/gp10b.c index d0a21fe5..51dc4301 100644 --- a/drivers/gpu/nvgpu/gp10b/gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/gp10b.c @@ -116,6 +116,5 @@ int gp10b_init_gpu_characteristics(struct gk20a *g) gk20a_init_gpu_characteristics(g); gp10b_detect_ecc_enabled_units(g); __nvgpu_set_enabled(g, NVGPU_SUPPORT_RESCHEDULE_RUNLIST, true); - __nvgpu_set_enabled(g, NVGPU_SUPPORT_USER_SYNCPOINT, true); return 0; } diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h index cb70f436..d5b5831a 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h @@ -65,6 +65,8 @@ void nvgpu_nvhost_syncpt_put_ref_ext(struct nvgpu_nvhost_dev *nvhost_dev, u32 nvgpu_nvhost_get_syncpt_host_managed(struct nvgpu_nvhost_dev *nvhost_dev, u32 param, const char *syncpt_name); +u32 nvgpu_nvhost_get_syncpt_client_managed(struct nvgpu_nvhost_dev *nvhost_dev, + const char *syncpt_name); int nvgpu_nvhost_create_symlink(struct gk20a *g); void nvgpu_nvhost_remove_symlink(struct gk20a *g); -- cgit v1.2.2