diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/timers.h b/drivers/gpu/nvgpu/include/nvgpu/posix/timers.h index dc8fa521f..bd614f01b 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/posix/timers.h +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/timers.h @@ -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); \ diff --git a/drivers/gpu/nvgpu/os/posix/timers.c b/drivers/gpu/nvgpu/os/posix/timers.c index 360633fa4..75d9fa498 100644 --- a/drivers/gpu/nvgpu/os/posix/timers.c +++ b/drivers/gpu/nvgpu/os/posix/timers.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-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"), @@ -47,13 +47,18 @@ struct nvgpu_posix_fault_inj *nvgpu_timers_get_fault_injection(void) int nvgpu_timeout_expired_fault_injection(void) { - if (nvgpu_posix_fault_injection_handle_call( - nvgpu_timers_get_fault_injection()) || - nvgpu_posix_is_fault_injection_cntr_set( - nvgpu_timers_get_fault_injection())) { + bool count_set = nvgpu_posix_is_fault_injection_cntr_set( + nvgpu_timers_get_fault_injection()); + + bool fault_enabled = nvgpu_posix_fault_injection_handle_call( + nvgpu_timers_get_fault_injection()); + + if (count_set) { return 0; } - + if (fault_enabled) { + return -ETIMEDOUT; + } return -1; } #endif /* NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT */