gpu: nvgpu: remove direct tsg retrieval from fifo

Added
- nvgpu_tsg_check_and_get_from_id
- nvgpu_tsg_get_from_id

And removed direct accesses to f->tsg array.

Jira NVGPU-3156

Change-Id: I8610e19c1a6e06521c16a1ec0c3a7a011978d0b7
Signed-off-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2101251
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Debarshi Dutta
2019-03-29 16:40:02 +05:30
committed by mobile promotions
parent 124cdb4509
commit 965062c2bc
12 changed files with 52 additions and 28 deletions

View File

@@ -167,9 +167,10 @@ static int gk20a_sched_dev_ioctl_get_tsgs_by_pid(struct gk20a_sched_ctrl *sched,
nvgpu_mutex_acquire(&sched->status_lock);
for (tsgid = 0; tsgid < f->num_channels; tsgid++) {
if (NVGPU_SCHED_ISSET(tsgid, sched->active_tsg_bitmap)) {
tsg = &f->tsg[tsgid];
if (tsg->tgid == tgid)
tsg = nvgpu_tsg_get_from_id(g, tsgid);
if (tsg->tgid == tgid) {
NVGPU_SCHED_SET(tsgid, bitmap);
}
}
}
nvgpu_mutex_release(&sched->status_lock);
@@ -198,7 +199,7 @@ static int gk20a_sched_dev_ioctl_get_params(struct gk20a_sched_ctrl *sched,
nvgpu_speculation_barrier();
tsg = &f->tsg[tsgid];
tsg = nvgpu_tsg_get_from_id(g, tsgid);
if (!nvgpu_ref_get_unless_zero(&tsg->refcount))
return -ENXIO;
@@ -233,7 +234,7 @@ static int gk20a_sched_dev_ioctl_tsg_set_timeslice(
nvgpu_speculation_barrier();
tsg = &f->tsg[tsgid];
tsg = nvgpu_tsg_get_from_id(g, tsgid);
if (!nvgpu_ref_get_unless_zero(&tsg->refcount))
return -ENXIO;
@@ -268,7 +269,7 @@ static int gk20a_sched_dev_ioctl_tsg_set_runlist_interleave(
nvgpu_speculation_barrier();
tsg = &f->tsg[tsgid];
tsg = nvgpu_tsg_get_from_id(g, tsgid);
if (!nvgpu_ref_get_unless_zero(&tsg->refcount))
return -ENXIO;
@@ -336,7 +337,7 @@ static int gk20a_sched_dev_ioctl_get_tsg(struct gk20a_sched_ctrl *sched,
nvgpu_speculation_barrier();
tsg = &f->tsg[tsgid];
tsg = nvgpu_tsg_get_from_id(g, tsgid);
if (!nvgpu_ref_get_unless_zero(&tsg->refcount))
return -ENXIO;
@@ -382,7 +383,7 @@ static int gk20a_sched_dev_ioctl_put_tsg(struct gk20a_sched_ctrl *sched,
NVGPU_SCHED_CLR(tsgid, sched->ref_tsg_bitmap);
nvgpu_mutex_release(&sched->status_lock);
tsg = &f->tsg[tsgid];
tsg = nvgpu_tsg_get_from_id(g, tsgid);
nvgpu_ref_put(&tsg->refcount, nvgpu_ioctl_tsg_release);
return 0;
@@ -527,7 +528,7 @@ int gk20a_sched_dev_release(struct inode *inode, struct file *filp)
/* release any reference to TSGs */
for (tsgid = 0; tsgid < f->num_channels; tsgid++) {
if (NVGPU_SCHED_ISSET(tsgid, sched->ref_tsg_bitmap)) {
tsg = &f->tsg[tsgid];
tsg = nvgpu_tsg_get_from_id(g, tsgid);
nvgpu_ref_put(&tsg->refcount, nvgpu_ioctl_tsg_release);
}
}