gpu: nvgpu: fix MISRA 10.5 issue in timeout code

This change switches nvgpu_timeout_peek_expired() to return a bool
instead of an int to remove advisory rule MISRA 10.5 violations.

MISRA 10.5 states that the value of an expression should not be
cast to an inappropriate essential type.

JIRA NVGPU-3798

Change-Id: I5cf9badaf07493e11a639e47ae4cf221700134ff
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2155617
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Scott Long
2019-07-17 14:52:06 -07:00
committed by mobile promotions
parent 59ac65d8d7
commit 3c7cf8b75a
19 changed files with 34 additions and 34 deletions

View File

@@ -100,7 +100,7 @@ int nvgpu_falcon_wait_for_halt(struct nvgpu_falcon *flcn, unsigned int timeout)
nvgpu_udelay(10);
} while (nvgpu_timeout_expired(&to) == 0);
if (nvgpu_timeout_peek_expired(&to) != 0) {
if (nvgpu_timeout_peek_expired(&to)) {
status = -ETIMEDOUT;
}
@@ -169,7 +169,7 @@ int nvgpu_falcon_mem_scrub_wait(struct nvgpu_falcon *flcn)
nvgpu_udelay(MEM_SCRUBBING_TIMEOUT_DEFAULT);
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
status = -ETIMEDOUT;
}
@@ -616,7 +616,7 @@ int nvgpu_falcon_clear_halt_intr_status(struct nvgpu_falcon *flcn,
nvgpu_udelay(1);
} while (nvgpu_timeout_expired(&to) == 0);
if (nvgpu_timeout_peek_expired(&to) != 0) {
if (nvgpu_timeout_peek_expired(&to)) {
status = -ETIMEDOUT;
}

View File

@@ -982,7 +982,7 @@ static void nvgpu_channel_wdt_handler(struct nvgpu_channel *ch)
if (new_gp_get != gp_get || new_pb_get != pb_get) {
/* Channel has advanced, timer keeps going but resets */
nvgpu_channel_wdt_rewind(ch);
} else if (nvgpu_timeout_peek_expired(&ch->wdt.timer) == 0) {
} else if (!nvgpu_timeout_peek_expired(&ch->wdt.timer)) {
/* Seems stuck but waiting to time out */
} else {
nvgpu_err(g, "Job on channel %d timed out",
@@ -1083,7 +1083,7 @@ static void nvgpu_channel_worker_poll_wakeup_post_process_item(
nvgpu_channel_worker_from_worker(worker);
int ret;
if (nvgpu_timeout_peek_expired(&ch_worker->timeout) != 0) {
if (nvgpu_timeout_peek_expired(&ch_worker->timeout)) {
nvgpu_channel_poll_wdt(g);
ret = nvgpu_timeout_init(g, &ch_worker->timeout,
ch_worker->watchdog_interval,

View File

@@ -114,7 +114,7 @@ int nvgpu_nvlink_minion_load(struct gk20a *g)
/* Service interrupts */
g->ops.nvlink.minion.falcon_isr(g);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
err = -ETIMEDOUT;
goto exit;
}

View File

@@ -198,7 +198,7 @@ int gv100_bios_devinit(struct gk20a *g)
nvgpu_udelay(PMU_BOOT_TIMEOUT_DEFAULT);
} while (!devinit_completed && (nvgpu_timeout_expired(&timeout) == 0));
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
err = -ETIMEDOUT;
goto out;
}

View File

@@ -1,7 +1,7 @@
/*
* GM20B MMU
*
* Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2014-2019, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -65,7 +65,7 @@ int gm20b_bus_bar1_bind(struct gk20a *g, struct nvgpu_mem *bar1_inst)
nvgpu_udelay(5);
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
err = -EINVAL;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2014-2019, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -62,7 +62,7 @@ int gp10b_bus_bar2_bind(struct gk20a *g, struct nvgpu_mem *bar2_inst)
nvgpu_udelay(5);
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
err = -EINVAL;
}

View File

@@ -67,7 +67,7 @@ int bus_tu104_bar2_bind(struct gk20a *g, struct nvgpu_mem *bar2_inst)
nvgpu_udelay(5);
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
err = -EINVAL;
}

View File

@@ -193,7 +193,7 @@ int gm20b_cbc_ctrl(struct gk20a *g, enum nvgpu_cbc_op op,
nvgpu_udelay(5);
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
nvgpu_err(g, "comp tag clear timeout");
err = -EBUSY;
goto out;

View File

@@ -193,7 +193,7 @@ int gp10b_cbc_ctrl(struct gk20a *g, enum nvgpu_cbc_op op,
nvgpu_udelay(5);
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
nvgpu_err(g, "comp tag clear timeout");
err = -EBUSY;
goto out;

View File

@@ -200,7 +200,7 @@ int tu104_cbc_ctrl(struct gk20a *g, enum nvgpu_cbc_op op,
nvgpu_udelay(5);
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
nvgpu_err(g, "comp tag clear timeout");
err = -EBUSY;
goto out;

View File

@@ -147,7 +147,7 @@ int gm20b_fb_tlb_invalidate(struct gk20a *g, struct nvgpu_mem *pdb)
} while (nvgpu_timeout_expired_msg(&timeout,
"wait mmu fifo space") == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
err = -ETIMEDOUT;
goto out;
}

View File

@@ -85,7 +85,7 @@ int gk20a_mm_fb_flush(struct gk20a *g)
}
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
if (g->ops.fb.dump_vpr_info != NULL) {
g->ops.fb.dump_vpr_info(g);
}
@@ -143,7 +143,7 @@ static void gk20a_mm_l2_invalidate_locked(struct gk20a *g)
}
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
nvgpu_warn(g, "l2_system_invalidate too many retries");
}

View File

@@ -252,7 +252,7 @@ int gv100_nvlink_setup_pll(struct gk20a *g, unsigned long link_mask)
} while ((nvgpu_timeout_expired_msg(&timeout, "timeout on pll on") == 0)
&& (links_off != 0U));
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
return -ETIMEDOUT;
}
@@ -318,7 +318,7 @@ static int gv100_nvlink_rxcal_en(struct gk20a *g, unsigned long mask)
} while (nvgpu_timeout_expired_msg(&timeout,
"timeout on rxcal") == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
return -ETIMEDOUT;
}
}
@@ -513,7 +513,7 @@ static int gv100_nvlink_link_sublink_check_change(struct gk20a *g, u32 link_id)
} while (nvgpu_timeout_expired_msg(&timeout,
"timeout on sublink rdy") == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
return -ETIMEDOUT;
}
return err;

View File

@@ -67,7 +67,7 @@ int tu104_nvlink_setup_pll(struct gk20a *g, unsigned long link_mask)
} while (nvgpu_timeout_expired_msg(&timeout,
"Timed out setting pll on link %u",
link_id) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
return -ETIMEDOUT;
}
}

View File

@@ -140,7 +140,7 @@ static int gv100_nvlink_minion_command_complete(struct gk20a *g, u32 link_id)
} while (nvgpu_timeout_expired_msg(&timeout,
"minion cmd timeout") == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
return -ETIMEDOUT;
}

View File

@@ -253,7 +253,7 @@ static int do_xve_set_speed_gp106(struct gk20a *g, u32 next_link_speed)
}
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
err_status = -ETIMEDOUT;
goto done;
}
@@ -331,7 +331,7 @@ static int do_xve_set_speed_gp106(struct gk20a *g, u32 next_link_speed)
}
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
err_status = -ETIMEDOUT;
goto done;
}
@@ -370,7 +370,7 @@ static int do_xve_set_speed_gp106(struct gk20a *g, u32 next_link_speed)
}
} while (nvgpu_timeout_expired(&timeout) == 0);
if (nvgpu_timeout_peek_expired(&timeout) != 0) {
if (nvgpu_timeout_peek_expired(&timeout)) {
err_status = -ETIMEDOUT;
xv_sc_dbg(g, EXEC_CHANGE, " timeout; pl_link_config = 0x%x",
pl_link_config);

View File

@@ -83,7 +83,7 @@ struct nvgpu_timeout {
int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout,
u32 duration, unsigned long flags);
int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout);
bool nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout);
#define nvgpu_timeout_expired(__timeout) \
nvgpu_timeout_expired_msg_impl(__timeout, NVGPU_GET_IP, "")

View File

@@ -161,16 +161,16 @@ int nvgpu_timeout_expired_msg_impl(struct nvgpu_timeout *timeout,
*
* @timeout - The timeout to check.
*
* Returns non-zero if the timeout is expired, zero otherwise. In the case of
* Returns true if the timeout is expired, false otherwise. In the case of
* retry timers this will not increment the underlying retry count. Also if the
* timer has expired no messages will be printed.
*
* This function honors the pre-Si check as well.
*/
int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout)
bool nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout)
{
if (nvgpu_timeout_is_pre_silicon(timeout))
return 0;
return false;
if (timeout->flags & NVGPU_TIMER_RETRY_TIMER)
return timeout->retries.attempted >=

View File

@@ -181,13 +181,13 @@ int nvgpu_timeout_expired_msg_impl(struct nvgpu_timeout *timeout,
return ret;
}
int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout)
bool nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout)
{
if ((timeout->flags & NVGPU_TIMER_RETRY_TIMER) != 0U) {
return (int) (timeout->retries.attempted >=
timeout->retries.max_attempts);
return (timeout->retries.attempted >=
timeout->retries.max_attempts);
} else {
return (int) (time_after(get_time_ns(), timeout->time));
return time_after(get_time_ns(), timeout->time);
}
}