mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: remove nvgpu_channel_joblist_is_empty
channel_joblist_peek() returns NULL if the list is empty. nvgpu_channel_joblist_is_empty() has been used only together with that function; remove it and check against NULL to see whether there are jobs in flight. This removes some duplication, simplifies the call sites slightly, and gets rid of a Coverity nag about a possible NULL pointer from peek that really isn't (when the emptiness was already checked). Jira NVGPU-5772 Change-Id: I814e9c510d99b88e59539359992fb44d4e7ce2ea Signed-off-by: Konsta Hölttä <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2397394 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
1aa64ba899
commit
345eae584d
@@ -688,16 +688,16 @@ void nvgpu_channel_clean_up_jobs(struct nvgpu_channel *c)
|
|||||||
bool completed;
|
bool completed;
|
||||||
|
|
||||||
nvgpu_channel_joblist_lock(c);
|
nvgpu_channel_joblist_lock(c);
|
||||||
if (nvgpu_channel_joblist_is_empty(c)) {
|
job = channel_joblist_peek(c);
|
||||||
|
nvgpu_channel_joblist_unlock(c);
|
||||||
|
|
||||||
|
if (job == NULL) {
|
||||||
/*
|
/*
|
||||||
* No jobs in flight, timeout will remain stopped until
|
* No jobs in flight, timeout will remain stopped until
|
||||||
* new jobs are submitted.
|
* new jobs are submitted.
|
||||||
*/
|
*/
|
||||||
nvgpu_channel_joblist_unlock(c);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
job = channel_joblist_peek(c);
|
|
||||||
nvgpu_channel_joblist_unlock(c);
|
|
||||||
|
|
||||||
completed = nvgpu_fence_is_expired(&job->post_fence);
|
completed = nvgpu_fence_is_expired(&job->post_fence);
|
||||||
if (!completed) {
|
if (!completed) {
|
||||||
@@ -787,13 +787,13 @@ void nvgpu_channel_clean_up_deterministic_job(struct nvgpu_channel *c)
|
|||||||
nvgpu_mutex_acquire(&c->joblist.cleanup_lock);
|
nvgpu_mutex_acquire(&c->joblist.cleanup_lock);
|
||||||
|
|
||||||
nvgpu_channel_joblist_lock(c);
|
nvgpu_channel_joblist_lock(c);
|
||||||
if (nvgpu_channel_joblist_is_empty(c)) {
|
|
||||||
nvgpu_channel_joblist_unlock(c);
|
|
||||||
goto out_unlock;
|
|
||||||
}
|
|
||||||
job = channel_joblist_peek(c);
|
job = channel_joblist_peek(c);
|
||||||
nvgpu_channel_joblist_unlock(c);
|
nvgpu_channel_joblist_unlock(c);
|
||||||
|
|
||||||
|
if (job == NULL) {
|
||||||
|
goto out_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
nvgpu_assert(job->num_mapped_buffers == 0U);
|
nvgpu_assert(job->num_mapped_buffers == 0U);
|
||||||
|
|
||||||
if (!nvgpu_fence_is_expired(&job->post_fence)) {
|
if (!nvgpu_fence_is_expired(&job->post_fence)) {
|
||||||
|
|||||||
@@ -78,15 +78,11 @@ void nvgpu_channel_joblist_unlock(struct nvgpu_channel *c)
|
|||||||
|
|
||||||
struct nvgpu_channel_job *channel_joblist_peek(struct nvgpu_channel *c)
|
struct nvgpu_channel_job *channel_joblist_peek(struct nvgpu_channel *c)
|
||||||
{
|
{
|
||||||
struct nvgpu_channel_job *job = NULL;
|
unsigned int get = c->joblist.pre_alloc.get;
|
||||||
|
unsigned int put = c->joblist.pre_alloc.put;
|
||||||
|
bool empty = get == put;
|
||||||
|
|
||||||
if (!nvgpu_channel_joblist_is_empty(c)) {
|
return empty ? NULL : &c->joblist.pre_alloc.jobs[get];
|
||||||
unsigned int get = c->joblist.pre_alloc.get;
|
|
||||||
|
|
||||||
job = &c->joblist.pre_alloc.jobs[get];
|
|
||||||
}
|
|
||||||
|
|
||||||
return job;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void channel_joblist_add(struct nvgpu_channel *c,
|
void channel_joblist_add(struct nvgpu_channel *c,
|
||||||
@@ -103,11 +99,6 @@ void channel_joblist_delete(struct nvgpu_channel *c,
|
|||||||
(c->joblist.pre_alloc.length);
|
(c->joblist.pre_alloc.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nvgpu_channel_joblist_is_empty(struct nvgpu_channel *c)
|
|
||||||
{
|
|
||||||
return c->joblist.pre_alloc.get == c->joblist.pre_alloc.put;
|
|
||||||
}
|
|
||||||
|
|
||||||
int channel_prealloc_resources(struct nvgpu_channel *c, u32 num_jobs)
|
int channel_prealloc_resources(struct nvgpu_channel *c, u32 num_jobs)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ void channel_joblist_add(struct nvgpu_channel *c,
|
|||||||
struct nvgpu_channel_job *job);
|
struct nvgpu_channel_job *job);
|
||||||
void channel_joblist_delete(struct nvgpu_channel *c,
|
void channel_joblist_delete(struct nvgpu_channel *c,
|
||||||
struct nvgpu_channel_job *job);
|
struct nvgpu_channel_job *job);
|
||||||
bool nvgpu_channel_joblist_is_empty(struct nvgpu_channel *c);
|
|
||||||
|
|
||||||
int channel_prealloc_resources(struct nvgpu_channel *c, u32 num_jobs);
|
int channel_prealloc_resources(struct nvgpu_channel *c, u32 num_jobs);
|
||||||
void channel_free_prealloc_resources(struct nvgpu_channel *c);
|
void channel_free_prealloc_resources(struct nvgpu_channel *c);
|
||||||
|
|||||||
Reference in New Issue
Block a user