summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os
diff options
context:
space:
mode:
authorSeema Khowala <seemaj@nvidia.com>2018-10-19 15:08:46 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2019-02-13 16:19:37 -0500
commit220860d04383489a8e75684802a2ced1323831df (patch)
tree123e92d8b1781afa6de32bc2615ae5835b389f4d /drivers/gpu/nvgpu/os
parent18643ac1357a845d204d6dabd98359a0ab0509a7 (diff)
gpu: nvgpu: rename has_timedout and make it thread safe
Currently has_timedout variable is protected by wmb at places where it is being set and there is no correspoding rmb whenever has_timedout variable is read. This is prone to errors for concurrent execution. This change is supposed to fix this issue. Rename has_timedout variable of channel struct to ch_timedout. Also to avoid rmb every time ch_timedout is read, ch_timedout_spinlock is added to protect ch_timedout variable for taking care of concurrent execution. Bug 2404865 Bug 2092051 Change-Id: I0bee9f50af0a48720aa8b54cbc3af97ef9f6df00 Signed-off-by: Seema Khowala <seemaj@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1930935 Signed-off-by: Debarshi Dutta <ddutta@nvidia.com> (cherry picked from commit 1f54ea09e3445d9ca3cf7a69b4967849cc9defc8 in dev-kernel) Reviewed-on: https://git-master.nvidia.com/r/2016975 GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: Bibek Basu <bbasu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/os')
-rw-r--r--drivers/gpu/nvgpu/os/linux/cde.c5
-rw-r--r--drivers/gpu/nvgpu/os/linux/ioctl_channel.c17
-rw-r--r--drivers/gpu/nvgpu/os/linux/ioctl_tsg.c2
3 files changed, 15 insertions, 9 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/cde.c b/drivers/gpu/nvgpu/os/linux/cde.c
index a15ef560..7b2cba7d 100644
--- a/drivers/gpu/nvgpu/os/linux/cde.c
+++ b/drivers/gpu/nvgpu/os/linux/cde.c
@@ -1272,7 +1272,7 @@ __releases(&cde_app->mutex)
1272 nvgpu_log_info(g, "double finish cde context %p on channel %p", 1272 nvgpu_log_info(g, "double finish cde context %p on channel %p",
1273 cde_ctx, ch); 1273 cde_ctx, ch);
1274 1274
1275 if (ch->has_timedout) { 1275 if (gk20a_channel_check_timedout(ch)) {
1276 if (cde_ctx->is_temporary) { 1276 if (cde_ctx->is_temporary) {
1277 nvgpu_warn(g, 1277 nvgpu_warn(g,
1278 "cde: channel had timed out" 1278 "cde: channel had timed out"
@@ -1299,8 +1299,9 @@ __releases(&cde_app->mutex)
1299 msecs_to_jiffies(CTX_DELETE_TIME)); 1299 msecs_to_jiffies(CTX_DELETE_TIME));
1300 } 1300 }
1301 1301
1302 if (!ch->has_timedout) 1302 if (!gk20a_channel_check_timedout(ch)) {
1303 gk20a_cde_ctx_release(cde_ctx); 1303 gk20a_cde_ctx_release(cde_ctx);
1304 }
1304} 1305}
1305 1306
1306static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx) 1307static int gk20a_cde_load(struct gk20a_cde_ctx *cde_ctx)
diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c
index 45d49474..d0d4b1af 100644
--- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c
+++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c
@@ -636,8 +636,9 @@ static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch,
636 int ret = 0; 636 int ret = 0;
637 637
638 /* do not wait if channel has timed out */ 638 /* do not wait if channel has timed out */
639 if (ch->has_timedout) 639 if (gk20a_channel_check_timedout(ch)) {
640 return -ETIMEDOUT; 640 return -ETIMEDOUT;
641 }
641 642
642 dmabuf = dma_buf_get(id); 643 dmabuf = dma_buf_get(id);
643 if (IS_ERR(dmabuf)) { 644 if (IS_ERR(dmabuf)) {
@@ -656,7 +657,8 @@ static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch,
656 657
657 ret = NVGPU_COND_WAIT_INTERRUPTIBLE( 658 ret = NVGPU_COND_WAIT_INTERRUPTIBLE(
658 &ch->semaphore_wq, 659 &ch->semaphore_wq,
659 *semaphore == payload || ch->has_timedout, 660 *semaphore == payload ||
661 gk20a_channel_check_timedout(ch),
660 timeout); 662 timeout);
661 663
662 dma_buf_kunmap(dmabuf, offset >> PAGE_SHIFT, data); 664 dma_buf_kunmap(dmabuf, offset >> PAGE_SHIFT, data);
@@ -680,8 +682,9 @@ static int gk20a_channel_wait(struct channel_gk20a *ch,
680 682
681 nvgpu_log_fn(g, " "); 683 nvgpu_log_fn(g, " ");
682 684
683 if (ch->has_timedout) 685 if (gk20a_channel_check_timedout(ch)) {
684 return -ETIMEDOUT; 686 return -ETIMEDOUT;
687 }
685 688
686 switch (args->type) { 689 switch (args->type) {
687 case NVGPU_WAIT_TYPE_NOTIFIER: 690 case NVGPU_WAIT_TYPE_NOTIFIER:
@@ -716,7 +719,8 @@ static int gk20a_channel_wait(struct channel_gk20a *ch,
716 * calling this ioctl */ 719 * calling this ioctl */
717 remain = NVGPU_COND_WAIT_INTERRUPTIBLE( 720 remain = NVGPU_COND_WAIT_INTERRUPTIBLE(
718 &ch->notifier_wq, 721 &ch->notifier_wq,
719 notif->status == 0 || ch->has_timedout, 722 notif->status == 0 ||
723 gk20a_channel_check_timedout(ch),
720 args->timeout); 724 args->timeout);
721 725
722 if (remain == 0 && notif->status != 0) { 726 if (remain == 0 && notif->status != 0) {
@@ -786,8 +790,9 @@ static int gk20a_ioctl_channel_submit_gpfifo(
786 profile = gk20a_fifo_profile_acquire(ch->g); 790 profile = gk20a_fifo_profile_acquire(ch->g);
787 gk20a_fifo_profile_snapshot(profile, PROFILE_IOCTL_ENTRY); 791 gk20a_fifo_profile_snapshot(profile, PROFILE_IOCTL_ENTRY);
788 792
789 if (ch->has_timedout) 793 if (gk20a_channel_check_timedout(ch)) {
790 return -ETIMEDOUT; 794 return -ETIMEDOUT;
795 }
791 796
792 nvgpu_get_fence_args(&args->fence, &fence); 797 nvgpu_get_fence_args(&args->fence, &fence);
793 submit_flags = 798 submit_flags =
@@ -1249,7 +1254,7 @@ long gk20a_channel_ioctl(struct file *filp,
1249 } 1254 }
1250 case NVGPU_IOCTL_CHANNEL_GET_TIMEDOUT: 1255 case NVGPU_IOCTL_CHANNEL_GET_TIMEDOUT:
1251 ((struct nvgpu_get_param_args *)buf)->value = 1256 ((struct nvgpu_get_param_args *)buf)->value =
1252 ch->has_timedout; 1257 gk20a_channel_check_timedout(ch);
1253 break; 1258 break;
1254 case NVGPU_IOCTL_CHANNEL_ENABLE: 1259 case NVGPU_IOCTL_CHANNEL_ENABLE:
1255 err = gk20a_busy(ch->g); 1260 err = gk20a_busy(ch->g);
diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c
index b0cdf5e5..c5079bd6 100644
--- a/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c
+++ b/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c
@@ -141,7 +141,7 @@ static int gk20a_tsg_unbind_channel_fd(struct tsg_gk20a *tsg, int ch_fd)
141 * Mark the channel timedout since channel unbound from TSG 141 * Mark the channel timedout since channel unbound from TSG
142 * has no context of its own so it can't serve any job 142 * has no context of its own so it can't serve any job
143 */ 143 */
144 ch->has_timedout = true; 144 gk20a_channel_set_timedout(ch);
145 145
146out: 146out:
147 gk20a_channel_put(ch); 147 gk20a_channel_put(ch);