Files
nvdriver/kernel-open/nvidia/software_manager_adapter.c
Eric Hartford 33ff608a88 Add MIT LICENSE and unify repository SPDX/Cargo/module licensing
- Add root LICENSE (MIT License, Copyright (c) 2026 QuixiAI / Eric Hartford).
- Set license = "MIT" in workspace Cargo.toml and member crates (zero non-MIT dependencies).
- Update all kernel-open/ and tests/vm/ SPDX headers to MIT and EXPORT_SYMBOL_GPL -> EXPORT_SYMBOL.
- Use MODULE_LICENSE("Dual MIT/GPL") in Linux .ko modules so Linux modpost permits linking against the kernel's own EXPORT_SYMBOL_GPL symbols while keeping the repository source 100% MIT.

Closes #12.
2026-12-01 00:20:02 +00:00

33 lines
980 B
C

/* SPDX-License-Identifier: MIT */
#ifdef NV_RS_SOFTWARE_MANAGER_FIXTURE
#include "fixture.h"
#else
#include <linux/compiler.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#endif
#include "software_manager_adapter.h"
static DEFINE_MUTEX(manager_lock);
static struct task_struct *manager_owner;
int nv_rs_software_manager_lock(void)
{
if (in_interrupt() || irqs_disabled() || in_atomic())
return -EWOULDBLOCK;
/* A current task cannot exit or be reused while its synchronous owner
* frame holds this mutex. Other tasks only compare, never dereference it. */
if (READ_ONCE(manager_owner) == current)
return -EDEADLK;
mutex_lock(&manager_lock);
WRITE_ONCE(manager_owner, current);
return 0;
}
void nv_rs_software_manager_unlock(void)
{
if (WARN_ON(READ_ONCE(manager_owner) != current))
return;
WRITE_ONCE(manager_owner, NULL);
mutex_unlock(&manager_lock);
}