mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
Add native /proc/driver/nvidia/{params,version,gpus/<bdf>} procfs entries for bare-metal runtime
This commit is contained in:
@ -15,6 +15,8 @@
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/poll.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/vmalloc.h>
|
||||
@ -106,6 +108,7 @@ struct nv_rs_rmapi_file {
|
||||
struct nv_rs_rmapi_gpu_node {
|
||||
struct miscdevice misc;
|
||||
char name[32];
|
||||
char bdf[32];
|
||||
bool live;
|
||||
unsigned int generation;
|
||||
u64 bar0, bar0_size, bar1, bar1_size;
|
||||
@ -114,6 +117,9 @@ struct nv_rs_rmapi_gpu_node {
|
||||
void (*release)(void *cookie);
|
||||
void *cookie;
|
||||
struct nv_rs_gpu_owner *owner;
|
||||
#ifdef CONFIG_PROC_FS
|
||||
struct proc_dir_entry *proc_dir;
|
||||
#endif
|
||||
};
|
||||
#define NV_RS_RMAPI_ATTACH_REGISTERS 32
|
||||
/* Indexed by the minor number the Rust table gave the GPU; guarded by nv_rs_rmapi_lock. */
|
||||
@ -227,6 +233,49 @@ static DEFINE_MUTEX(nv_rs_sysmem_pool_lock);
|
||||
static LIST_HEAD(nv_rs_sysmem_pool);
|
||||
static unsigned long nv_rs_sysmem_pool_pages;
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
static struct proc_dir_entry *nv_rs_proc_nvidia;
|
||||
static struct proc_dir_entry *nv_rs_proc_gpus;
|
||||
|
||||
static int nv_rs_proc_params_show(struct seq_file *m, void *v)
|
||||
{
|
||||
(void)v;
|
||||
seq_puts(m, "ModifyDeviceFiles: 0\nDeviceFileUID: 0\nDeviceFileGID: 0\nDeviceFileMode: 438\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nv_rs_proc_version_show(struct seq_file *m, void *v)
|
||||
{
|
||||
(void)v;
|
||||
seq_puts(m, "NVRM version: nvdriver (clean-room Rust) 580.178.04 (GSP-RM 620.70.06)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nv_rs_proc_init(void)
|
||||
{
|
||||
if (!nv_rs_runtime_engines())
|
||||
return;
|
||||
nv_rs_proc_nvidia = proc_mkdir("driver/nvidia", NULL);
|
||||
if (!nv_rs_proc_nvidia)
|
||||
return;
|
||||
proc_create_single("params", 0444, nv_rs_proc_nvidia, nv_rs_proc_params_show);
|
||||
proc_create_single("version", 0444, nv_rs_proc_nvidia, nv_rs_proc_version_show);
|
||||
nv_rs_proc_gpus = proc_mkdir("gpus", nv_rs_proc_nvidia);
|
||||
}
|
||||
|
||||
static void nv_rs_proc_exit(void)
|
||||
{
|
||||
if (nv_rs_proc_nvidia) {
|
||||
proc_remove(nv_rs_proc_nvidia);
|
||||
nv_rs_proc_nvidia = NULL;
|
||||
nv_rs_proc_gpus = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static inline void nv_rs_proc_init(void) {}
|
||||
static inline void nv_rs_proc_exit(void) {}
|
||||
#endif
|
||||
|
||||
static struct page *nv_rs_sysmem_pool_pop(void)
|
||||
{
|
||||
struct page *page = NULL;
|
||||
@ -1136,6 +1185,13 @@ int nv_rs_rmapi_node_gpu_add(struct pci_dev *pdev, u32 boot0)
|
||||
}
|
||||
nv_rs_modeset_register_gpu(((gpu.domain & 0xffffU) << 16) | ((u32)gpu.bus << 8) | (u32)gpu.slot,
|
||||
gpu.domain, gpu.bus, gpu.slot, gpu.function, &pdev->dev);
|
||||
#ifdef CONFIG_PROC_FS
|
||||
if (nv_rs_proc_gpus) {
|
||||
snprintf(node->bdf, sizeof(node->bdf), "%04x:%02x:%02x.%u",
|
||||
gpu.domain, gpu.bus, gpu.slot, gpu.function);
|
||||
node->proc_dir = proc_mkdir(node->bdf, nv_rs_proc_gpus);
|
||||
}
|
||||
#endif
|
||||
return minor;
|
||||
}
|
||||
|
||||
@ -1211,8 +1267,15 @@ void nv_rs_rmapi_node_gpu_remove(struct pci_dev *pdev)
|
||||
mutex_unlock(&nv_rs_rmapi_lock);
|
||||
if (owner)
|
||||
nv_rs_gpu_owner_runtime_stop(owner);
|
||||
if (minor >= 0)
|
||||
if (minor >= 0) {
|
||||
#ifdef CONFIG_PROC_FS
|
||||
if (nv_rs_rmapi_gpu_nodes[minor].proc_dir) {
|
||||
proc_remove(nv_rs_rmapi_gpu_nodes[minor].proc_dir);
|
||||
nv_rs_rmapi_gpu_nodes[minor].proc_dir = NULL;
|
||||
}
|
||||
#endif
|
||||
misc_deregister(&nv_rs_rmapi_gpu_nodes[minor].misc);
|
||||
}
|
||||
nv_rs_modeset_unregister_gpu((((u32)pci_domain_nr(pdev->bus) & 0xffffU) << 16) |
|
||||
((u32)pdev->bus->number << 8) | (u32)PCI_SLOT(pdev->devfn));
|
||||
if (release)
|
||||
@ -1317,6 +1380,8 @@ int nv_rs_rmapi_node_init(void)
|
||||
if (result) {
|
||||
nv_rs_rmapi_state = NULL;
|
||||
kvfree(state);
|
||||
} else {
|
||||
nv_rs_proc_init();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -1342,6 +1407,7 @@ void nv_rs_rmapi_node_exit(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
nv_rs_proc_exit();
|
||||
misc_deregister(&nv_rs_rmapi_device);
|
||||
/* Every file is released by now, and with it every client and its memory objects: the
|
||||
* list is empty and no record exists. Anything else is a leak: it is reported, and
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
},
|
||||
"largest_conservative_function_stack_bytes": 1000,
|
||||
"object_sha256": "80cf37925fe137cb2817c8f4339c43691190f25ea9d693cf1af1312ef7fc8119",
|
||||
"module_sha256": "eb330d03fd3e77f5d681986cde00c6c5520f50ab0e11d7381aabb7e43f708d6f",
|
||||
"module_sha256": "056c7f8e44e15f3843cb424b50e9621fa8de041d3f8a80c5dbf99321e3eaecd0",
|
||||
"undefined_kernel_symbols": [
|
||||
" U acpi_evaluate_object",
|
||||
" U alloc_pages",
|
||||
@ -140,6 +140,9 @@
|
||||
" U __preempt_count",
|
||||
" U prepare_to_wait_event",
|
||||
" U _printk",
|
||||
" U proc_create_single_data",
|
||||
" U proc_mkdir",
|
||||
" U proc_remove",
|
||||
" U __put_task_struct",
|
||||
" U pv_ops",
|
||||
" U queue_delayed_work_on",
|
||||
@ -154,6 +157,7 @@
|
||||
" U request_threaded_irq",
|
||||
" U schedule",
|
||||
" U schedule_timeout",
|
||||
" U seq_puts",
|
||||
" U set_memory_uc",
|
||||
" U set_memory_wb",
|
||||
" U sme_me_mask",
|
||||
@ -184,9 +188,9 @@
|
||||
" U wait_for_completion_timeout",
|
||||
" U __wake_up",
|
||||
" U wake_up_process",
|
||||
" U __x86_indirect_thunk_r13",
|
||||
" U __x86_indirect_thunk_r14",
|
||||
" U __x86_indirect_thunk_rax",
|
||||
" U __x86_indirect_thunk_rbx",
|
||||
" U __x86_indirect_thunk_rcx",
|
||||
" U __x86_return_thunk"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user