mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: add fault injection for posix routines
This adds the ability to enable fault injection for some of the POSIX implementation of the nvgpu condition and thread routines. JIRA NVGPU-2679 Change-Id: I6abb9d5ba3fbe8921e48a135e440c179702dcf6b Signed-off-by: Petlozu Pravareshwar <petlozup@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2174647 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
74723c7f62
commit
1e7c3cb038
@@ -35,6 +35,10 @@ struct nvgpu_cond {
|
||||
pthread_condattr_t attr;
|
||||
};
|
||||
|
||||
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
|
||||
struct nvgpu_posix_fault_inj *nvgpu_cond_get_fault_injection(void);
|
||||
#endif
|
||||
|
||||
int nvgpu_cond_timedwait(struct nvgpu_cond *c, unsigned int *ms);
|
||||
void nvgpu_cond_signal_locked(struct nvgpu_cond *cond);
|
||||
int nvgpu_cond_broadcast_locked(struct nvgpu_cond *cond);
|
||||
|
||||
@@ -57,6 +57,10 @@ struct nvgpu_thread {
|
||||
char tname[NVGPU_THREAD_POSIX_MAX_NAMELEN];
|
||||
};
|
||||
|
||||
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
|
||||
struct nvgpu_posix_fault_inj *nvgpu_thread_get_fault_injection(void);
|
||||
#endif
|
||||
|
||||
int nvgpu_thread_create_priority(struct nvgpu_thread *thread,
|
||||
void *data, int (*threadfn)(void *data),
|
||||
int priority, const char *name);
|
||||
|
||||
@@ -22,11 +22,30 @@
|
||||
|
||||
#include <nvgpu/cond.h>
|
||||
#include <nvgpu/static_analysis.h>
|
||||
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
|
||||
#include <nvgpu/posix/posix-fault-injection.h>
|
||||
#endif
|
||||
|
||||
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
|
||||
_Thread_local struct nvgpu_posix_fault_inj cond_fi = {
|
||||
.enabled = false,.counter = 0U,};
|
||||
|
||||
struct nvgpu_posix_fault_inj *nvgpu_cond_get_fault_injection(void)
|
||||
{
|
||||
return &cond_fi;
|
||||
}
|
||||
#endif
|
||||
|
||||
int nvgpu_cond_init(struct nvgpu_cond *cond)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
|
||||
if (nvgpu_posix_fault_injection_handle_call(&cond_fi)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = pthread_condattr_init(&cond->attr);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
|
||||
@@ -23,6 +23,19 @@
|
||||
#include <nvgpu/bug.h>
|
||||
#include <nvgpu/thread.h>
|
||||
#include <nvgpu/os_sched.h>
|
||||
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
|
||||
#include <nvgpu/posix/posix-fault-injection.h>
|
||||
#endif
|
||||
|
||||
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
|
||||
_Thread_local struct nvgpu_posix_fault_inj thread_fi = {
|
||||
.enabled = false,.counter = 0U,};
|
||||
|
||||
struct nvgpu_posix_fault_inj *nvgpu_thread_get_fault_injection(void)
|
||||
{
|
||||
return &thread_fi;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Use pthreads to mostly emulate the Linux kernel APIs. There are some things
|
||||
@@ -61,6 +74,12 @@ int nvgpu_thread_create(struct nvgpu_thread *thread,
|
||||
pthread_attr_t attr;
|
||||
int ret;
|
||||
|
||||
#ifdef NVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
|
||||
if (nvgpu_posix_fault_injection_handle_call(&thread_fi)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
(void) memset(thread, 0, sizeof(*thread));
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user