From 544873525d58a4dc4375e56798ae598c832302a7 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Wed, 23 Dec 2015 19:39:42 +0530 Subject: gpu: nvgpu: APIs to enable/disable TSG export below APIs for TSGs : gk20a_enable_tsg() - enable only TSG gk20a_disable_tsg() - disable only TSG gk20a_enable_channel_tsg() - if channel is part of TSG, enable TSG otherwise enable channel gk20a_disable_channel_tsg() - if channel is part of TSG, disable TSG otherwise disable channel Bug 200156699 Change-Id: Icdaca35235c3f323687f839fe32c6c5fe964b230 Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/927131 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 28 ++++++++++++++++++ drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 3 ++ drivers/gpu/nvgpu/gk20a/tsg_gk20a.c | 50 ++++++++++++++++++++++----------- drivers/gpu/nvgpu/gk20a/tsg_gk20a.h | 6 +++- 4 files changed, 69 insertions(+), 18 deletions(-) (limited to 'drivers/gpu') diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 2421307f..53b85ad8 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -446,6 +446,34 @@ void channel_gk20a_disable(struct channel_gk20a *ch) ccsr_channel_enable_clr_true_f()); } +int gk20a_enable_channel_tsg(struct gk20a *g, struct channel_gk20a *ch) +{ + struct tsg_gk20a *tsg; + + if (gk20a_is_channel_marked_as_tsg(ch)) { + tsg = &g->fifo.tsg[ch->tsgid]; + gk20a_enable_tsg(tsg); + } else { + g->ops.fifo.enable_channel(ch); + } + + return 0; +} + +int gk20a_disable_channel_tsg(struct gk20a *g, struct channel_gk20a *ch) +{ + struct tsg_gk20a *tsg; + + if (gk20a_is_channel_marked_as_tsg(ch)) { + tsg = &g->fifo.tsg[ch->tsgid]; + gk20a_disable_tsg(tsg); + } else { + g->ops.fifo.disable_channel(ch); + } + + return 0; +} + void gk20a_channel_abort(struct channel_gk20a *ch, bool channel_preempt) { struct channel_gk20a_job *job, *n; diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index 91ae0e7a..4f0632dd 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -205,6 +205,9 @@ void gk20a_channel_semaphore_wakeup(struct gk20a *g); int gk20a_channel_alloc_priv_cmdbuf(struct channel_gk20a *c, u32 size, struct priv_cmd_entry **entry); +int gk20a_enable_channel_tsg(struct gk20a *g, struct channel_gk20a *ch); +int gk20a_disable_channel_tsg(struct gk20a *g, struct channel_gk20a *ch); + int gk20a_channel_suspend(struct gk20a *g); int gk20a_channel_resume(struct gk20a *g); diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c index 5cd43329..4421744c 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -32,6 +32,36 @@ bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch) return !(ch->tsgid == NVGPU_INVALID_TSG_ID); } +int gk20a_enable_tsg(struct tsg_gk20a *tsg) +{ + struct channel_gk20a *ch; + + mutex_lock(&tsg->ch_list_lock); + list_for_each_entry(ch, &tsg->ch_list, ch_entry) { + gk20a_writel(ch->g, ccsr_channel_r(ch->hw_chid), + gk20a_readl(ch->g, ccsr_channel_r(ch->hw_chid)) + | ccsr_channel_enable_set_true_f()); + } + mutex_unlock(&tsg->ch_list_lock); + + return 0; +} + +int gk20a_disable_tsg(struct tsg_gk20a *tsg) +{ + struct channel_gk20a *ch; + + mutex_lock(&tsg->ch_list_lock); + list_for_each_entry(ch, &tsg->ch_list, ch_entry) { + gk20a_writel(ch->g, ccsr_channel_r(ch->hw_chid), + gk20a_readl(ch->g, ccsr_channel_r(ch->hw_chid)) + | ccsr_channel_enable_clr_true_f()); + } + mutex_unlock(&tsg->ch_list_lock); + + return 0; +} + static bool gk20a_is_channel_active(struct gk20a *g, struct channel_gk20a *ch) { struct fifo_gk20a *f = &g->fifo; @@ -296,40 +326,26 @@ long gk20a_tsg_dev_ioctl(struct file *filp, unsigned int cmd, case NVGPU_IOCTL_TSG_ENABLE: { - struct channel_gk20a *ch; err = gk20a_busy(g->dev); if (err) { gk20a_err(&g->dev->dev, "failed to host gk20a for ioctl cmd: 0x%x", cmd); return err; } - mutex_lock(&tsg->ch_list_lock); - list_for_each_entry(ch, &tsg->ch_list, ch_entry) { - gk20a_writel(ch->g, ccsr_channel_r(ch->hw_chid), - gk20a_readl(ch->g, ccsr_channel_r(ch->hw_chid)) - | ccsr_channel_enable_set_true_f()); - } - mutex_unlock(&tsg->ch_list_lock); + gk20a_enable_tsg(tsg); gk20a_idle(g->dev); break; } case NVGPU_IOCTL_TSG_DISABLE: { - struct channel_gk20a *ch; err = gk20a_busy(g->dev); if (err) { gk20a_err(&g->dev->dev, "failed to host gk20a for ioctl cmd: 0x%x", cmd); return err; } - mutex_lock(&tsg->ch_list_lock); - list_for_each_entry(ch, &tsg->ch_list, ch_entry) { - gk20a_writel(ch->g, ccsr_channel_r(ch->hw_chid), - gk20a_readl(ch->g, ccsr_channel_r(ch->hw_chid)) - | ccsr_channel_enable_clr_true_f()); - } - mutex_unlock(&tsg->ch_list_lock); + gk20a_disable_tsg(tsg); gk20a_idle(g->dev); break; } diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h index 6178daa5..bcc4d0c4 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -20,6 +20,7 @@ bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch); + int gk20a_tsg_dev_release(struct inode *inode, struct file *filp); int gk20a_tsg_dev_open(struct inode *inode, struct file *filp); int gk20a_tsg_open(struct gk20a *g, struct file *filp); @@ -50,4 +51,7 @@ struct tsg_gk20a { struct vm_gk20a *vm; }; +int gk20a_enable_tsg(struct tsg_gk20a *tsg); +int gk20a_disable_tsg(struct tsg_gk20a *tsg); + #endif /* __TSG_GK20A_H_ */ -- cgit v1.2.2