mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
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 1f54ea09e3
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>
This commit is contained in:
committed by
mobile promotions
parent
18643ac135
commit
220860d043
@@ -636,8 +636,9 @@ static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch,
|
||||
int ret = 0;
|
||||
|
||||
/* do not wait if channel has timed out */
|
||||
if (ch->has_timedout)
|
||||
if (gk20a_channel_check_timedout(ch)) {
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
dmabuf = dma_buf_get(id);
|
||||
if (IS_ERR(dmabuf)) {
|
||||
@@ -656,7 +657,8 @@ static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch,
|
||||
|
||||
ret = NVGPU_COND_WAIT_INTERRUPTIBLE(
|
||||
&ch->semaphore_wq,
|
||||
*semaphore == payload || ch->has_timedout,
|
||||
*semaphore == payload ||
|
||||
gk20a_channel_check_timedout(ch),
|
||||
timeout);
|
||||
|
||||
dma_buf_kunmap(dmabuf, offset >> PAGE_SHIFT, data);
|
||||
@@ -680,8 +682,9 @@ static int gk20a_channel_wait(struct channel_gk20a *ch,
|
||||
|
||||
nvgpu_log_fn(g, " ");
|
||||
|
||||
if (ch->has_timedout)
|
||||
if (gk20a_channel_check_timedout(ch)) {
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
switch (args->type) {
|
||||
case NVGPU_WAIT_TYPE_NOTIFIER:
|
||||
@@ -716,7 +719,8 @@ static int gk20a_channel_wait(struct channel_gk20a *ch,
|
||||
* calling this ioctl */
|
||||
remain = NVGPU_COND_WAIT_INTERRUPTIBLE(
|
||||
&ch->notifier_wq,
|
||||
notif->status == 0 || ch->has_timedout,
|
||||
notif->status == 0 ||
|
||||
gk20a_channel_check_timedout(ch),
|
||||
args->timeout);
|
||||
|
||||
if (remain == 0 && notif->status != 0) {
|
||||
@@ -786,8 +790,9 @@ static int gk20a_ioctl_channel_submit_gpfifo(
|
||||
profile = gk20a_fifo_profile_acquire(ch->g);
|
||||
gk20a_fifo_profile_snapshot(profile, PROFILE_IOCTL_ENTRY);
|
||||
|
||||
if (ch->has_timedout)
|
||||
if (gk20a_channel_check_timedout(ch)) {
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
nvgpu_get_fence_args(&args->fence, &fence);
|
||||
submit_flags =
|
||||
@@ -1249,7 +1254,7 @@ long gk20a_channel_ioctl(struct file *filp,
|
||||
}
|
||||
case NVGPU_IOCTL_CHANNEL_GET_TIMEDOUT:
|
||||
((struct nvgpu_get_param_args *)buf)->value =
|
||||
ch->has_timedout;
|
||||
gk20a_channel_check_timedout(ch);
|
||||
break;
|
||||
case NVGPU_IOCTL_CHANNEL_ENABLE:
|
||||
err = gk20a_busy(ch->g);
|
||||
|
||||
Reference in New Issue
Block a user