Files
nvdriver/kernel-open/nvidia/rmapi_node.h
randomchaos7800-hub 854741c986 fix(rmapi): answer NV2080_CTRL_CMD_BUS_GET_PCI_INFO_V2 (0x2080183c) on pre-GSP GPUs (#590)
* fix(rmapi): answer NV2080_CTRL_CMD_BUS_GET_PCI_INFO_V2 (0x2080183c) on pre-GSP GPUs (#564)

580.196.07 nvidia-smi / NVML asks for 0x2080183c when it reports
pci.bus_id. It is not in the 580.178.04 export table that control_table.rs
is generated from, so a pre-GSP GPU refused it with NV_ERR_NOT_SUPPORTED
(0x56) and `nvidia-smi --query-gpu=pci.bus_id` printed [N/A]. 580.178.04
userspace never sends it, which is why this went unseen.

The 28-byte layout is NV2080_CTRL_BUS_GET_PCI_INFO_V2_PARAMS from
NVIDIA/open-gpu-kernel-modules main (ctrl2080bus.h): the four words of
0x20801801 followed by pciProgrammingInterface, pciSubClass and
pciBaseClass. The class words come from the PCI class code, which the
PCI probe now passes down in RmapiGpu/nv_rs_rmapi_gpu (pdev->class).

Evidence: stock 580.196.07 replies captured with tools/ioctl_capture on an
EVGA GTX 1080 Ti (3842:6696, bus 01) and gdevenyi's ASUS capture on #564
(1043:85f1, bus 02) are reproduced byte for byte by new unit tests that
go through the RM_CONTROL escape path. The bus number is not part of this
reply; pci.bus_id keeps coming from 0x21b, which already matched stock.

0x2080012f is left alone: stock 580.196.07 also answers 0x56 on this
non-ECC GP102 (#371), and master already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HgXrs8WswQymXpCe2YSiEM

* fix(gsp): keep NV2080_CTRL_CMD_BUS_GET_PCI_INFO_V2 (0x2080183c) host-only on the GSP route

The synthetic descriptor added for pre-GSP GPUs made control_info() know
0x2080183c, so the GSP route's validate() would now pass it and forward it
to GSP-RM for an owned mirrored object. Before this PR the command was
unknown to the tables and answered on the host Node. Add it to the existing
host-only list next to 0x00801401 and 0x20808165 so GSP-RM never sees it.

Reported by CodeRabbit on #590.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HgXrs8WswQymXpCe2YSiEM

---------

Co-authored-by: Dino Vitale <chaotikdino@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 06:30:58 -08:00

74 lines
3.4 KiB
C

/* SPDX-License-Identifier: MIT */
#ifndef NV_RS_RMAPI_NODE_H
#define NV_RS_RMAPI_NODE_H
struct device;
struct pci_dev;
struct nv_rs_gpu_owner;
/* Bus-agnostic GPU identity and BAR/IRQ descriptor for PCIe or SoC platform GPUs. */
struct nv_rs_rmapi_gpu_desc {
struct device *dev;
u32 domain;
u8 bus;
u8 slot;
u8 function;
u16 vendor;
u16 device;
u16 subsystem_vendor;
u16 subsystem;
u8 revision;
u32 pci_class; /* pdev->class: base, sub, programming interface */
u32 irq;
u64 bar0;
u64 bar0_size;
u64 bar1;
u64 bar1_size;
u64 bar2;
u64 bar2_size;
u32 boot0;
u8 dma_bits;
int (*read32)(void *cookie, u64 offset, u32 *value);
void (*release)(void *cookie);
void *cookie;
};
/* RM API nodes of the Rust driver: the control node /dev/nvidia-rs-rmapi-ctl and one device
* node /dev/nvidia-rs-rmapi-gpu<minor> per listed GPU. They speak the escape protocol of the
* original's nodes as far as the implementation notes say; they do not use the original's
* names or major number. Process context only. */
int nv_rs_rmapi_node_init(void);
void nv_rs_rmapi_node_exit(void);
/* A PCI function this driver has bound becomes visible to NV_ESC_CARD_INFO and the
* probed-GPU controls and gets its device node. `boot0` is PMC_BOOT_0 as the probe read
* it. Returns the minor number assigned to it or a negative errno. */
int nv_rs_rmapi_node_gpu_add(struct pci_dev *pdev, u32 boot0);
/* Register access for the listed GPU: `read32(cookie, offset, &value)` reads one BAR0
* register. It is called under the node lock, only at the first open of the GPU's device
* node, for the read-only registers the Rust side names (the Jtag word 0x1373a0 and the
* display fuse word 0x21c04 of a GV100). `release(cookie)` is called once, outside the lock,
* when the GPU leaves the node (nv_rs_rmapi_node_gpu_remove or node exit). */
int nv_rs_rmapi_node_gpu_reader(struct pci_dev *pdev,
int (*read32)(void *cookie, u64 offset, u32 *value),
void (*release)(void *cookie), void *cookie);
int nv_rs_rmapi_node_gpu_add_desc(const struct nv_rs_rmapi_gpu_desc *desc);
int nv_rs_rmapi_node_gpu_reader_by_bdf(u32 domain, u8 bus, u8 slot,
int (*read32)(void *cookie, u64 offset, u32 *value),
void (*release)(void *cookie), void *cookie);
int nv_rs_rmapi_node_gpu_runtime(struct pci_dev *pdev, struct nv_rs_gpu_owner *owner);
void nv_rs_rmapi_node_gpu_remove_by_bdf(u32 domain, u8 bus, u8 slot);
void nv_rs_rmapi_node_gpu_remove(struct pci_dev *pdev);
void nv_rs_rmapi_revoke_runtime_userd(u32 gpu_id, bool pm_lost);
void nv_rs_rmapi_runtime_userd_ready(u32 gpu_id, bool verified_pm_resume);
struct device *nv_rs_rmapi_gpu_device_get(u32 gpu_id);
void nv_rs_rmapi_file_post(u64 owner);
unsigned int nv_rs_rmapi_gpu_dma_bits(u32 gpu_id);
void nv_rs_rmapi_gpu_negotiate_dma(u32 gpu_id, unsigned int bits);
void nv_rs_rmapi_update_power_telemetry(u32 gpu_id, u8 idle_mode, u64 transitions,
u64 idle_secs, u32 power_cap_mw);
void nv_rs_rmapi_set_power_cap_mw(u32 gpu_id, u32 power_cap_mw);
void nv_rs_rmapi_set_tensor_fp32_rate(u32 gpu_id, u8 rate);
u32 nv_rs_rmapi_handle_rc_fault(u32 gpu_id, u64 inst_ptr, u64 fault_va, u32 xid_code);
u64 nv_rs_rmapi_os_ctl_fd_owner(s32 descriptor);
int nv_rs_rmapi_kernel_open_gpu(u32 gpu_id);
void nv_rs_rmapi_kernel_close_gpu(u32 gpu_id);
#endif