gpu: nvgpu: modify nvgpu_timeout_expired for UT

In the current logic for nvgpu_timeout_expired(), function always
returns 0 if fault injection is enabled. This only helps for testing
timeout not expired scenarios. However, if nvgpu_timeout_expired() is
used in a while(true) loop, it is impossible to break the infinite loop.
This patch modifies nvgpu_timeout_expired() to not expire until fault
injection counter is non-zero. The function will now return -ETIMEDOUT
when fault injection is enabled and counter is zero.

Jira NVGPU-4675

Change-Id: I494031698ade19cf1ec5b75e4dbe5a1157da2aa7
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2275290
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Philip Elcan <pelcan@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2020-01-07 12:42:19 -08:00
committed by Alex Waterman
parent dadf9262d0
commit ddaf1daae4
2 changed files with 14 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2019-2020, 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"),
@@ -105,8 +105,8 @@
*/
#define nvgpu_timeout_expired_msg_impl(timeout, caller, fmt, arg...) \
({ \
int ret_timeout = 0; \
if (is_fault_injection_set != 0) { \
int ret_timeout = is_fault_injection_set; \
if (ret_timeout == -1) { \
if (((timeout)->flags & NVGPU_TIMER_RETRY_TIMER) != 0U) { \
ret_timeout = nvgpu_timeout_expired_msg_retry((timeout),\
caller, fmt, ##arg); \