mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
* Run GP104 VBIOS Devinit before framebuffer discovery Run the stock-derived Devinit sequence on uninitialized Tesla P4 and GTX 1070 cards before the normal Pascal runtime reads VRAM. Extract the signed PMU boot loader from the stock 580.178.04 object and retain DMA if the PMU fails to quiesce. * Reuse the Pascal firmware pack and recover incomplete GP104 bring-up * Recover retained GP104 PCI owners and reconcile bus setup on rebind * Preserve the next driver's bus mastering after a Devinit drain
88 lines
5.4 KiB
C
88 lines
5.4 KiB
C
/* SPDX-License-Identifier: MIT */
|
|
#ifndef NV_RS_PCI_ADAPTER_H
|
|
#define NV_RS_PCI_ADAPTER_H
|
|
#ifndef NV_RS_PCI_HOST_FIXTURE
|
|
#include <linux/types.h>
|
|
#endif
|
|
struct pci_dev;
|
|
struct device;
|
|
struct nv_rs_pci;
|
|
/* Called only by this driver's PCI probe, after Linux has assigned ownership.
|
|
* Does not initialize engines or claim CUDA readiness. */
|
|
int nv_rs_pci_open(struct pci_dev *pdev, struct nv_rs_pci **out);
|
|
bool nv_rs_pci_get(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_put(struct nv_rs_pci *pci);
|
|
struct device *nv_rs_pci_device(struct nv_rs_pci *pci);
|
|
void *nv_rs_pci_pdev(struct nv_rs_pci *pci);
|
|
bool nv_rs_pci_is_removed(struct nv_rs_pci *pci);
|
|
/* Internal mapping metadata only. Caller retains the PCI lease throughout use;
|
|
* mapped is this driver's kernel mapping, never a userspace-visible address. */
|
|
int nv_rs_pci_bar0_info(struct nv_rs_pci *,u64 *mapped,u64 *physical,u64 *bytes);
|
|
/* Caller quiesces engines/IRQs first; leases retain OS resources until drained. */
|
|
void nv_rs_pci_mark_removed(struct nv_rs_pci *pci);
|
|
int nv_rs_pci_power_get(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_power_put(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_pm_resume_enter(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_pm_resume_leave(struct nv_rs_pci *pci);
|
|
int nv_rs_pci_negotiate_dma(struct nv_rs_pci *pci, unsigned int bits);
|
|
int nv_rs_pci_dma_acquire(struct nv_rs_pci *pci, unsigned int bits);
|
|
int nv_rs_pci_widen_dma(struct nv_rs_pci *pci, unsigned int bits);
|
|
void nv_rs_pci_dma_release(struct nv_rs_pci *pci);
|
|
int nv_rs_pci_bus_master(struct nv_rs_pci *pci, bool enable);
|
|
/* Process-context metadata lookup only; acquires/releases the target PCI ref.
|
|
* Inputs stay wide until validated, before PCI_DEVFN can truncate them. */
|
|
/* Disable bus mastering, verify it in PCI config, and drain pending transactions. */
|
|
int nv_rs_pci_quiesce_dma(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_retain_devinit_dma(struct nv_rs_pci *pci);
|
|
int nv_rs_pci_drain_removed_dma(struct nv_rs_pci *pci);
|
|
int nv_rs_pci_function_present(struct nv_rs_pci *pci, u32 domain, u32 bus,
|
|
u32 slot, u32 function, bool *present);
|
|
/* Read-only target config access. Missing target is ENOENT, disconnected owner
|
|
* or target ENODEV, PCI read failure EIO. A successful ffffffff is a value. */
|
|
int nv_rs_pci_read_config32(struct nv_rs_pci *pci, u32 domain, u32 bus,
|
|
u32 slot, u32 function, u32 offset, u32 *value);
|
|
int nv_rs_pci_bar2_map(struct nv_rs_pci *pci, u64 bytes);
|
|
void nv_rs_pci_bar2_unmap(struct nv_rs_pci *pci);
|
|
int nv_rs_pci_bar2_read32(struct nv_rs_pci *pci, u64 offset, u32 *value);
|
|
int nv_rs_pci_bar2_write32(struct nv_rs_pci *pci, u64 offset, u32 value);
|
|
int nv_rs_pci_bar1_bytes(struct nv_rs_pci *pci, u64 *bytes);
|
|
int nv_rs_pci_bar1_map(struct nv_rs_pci *pci, u64 offset, u64 bytes);
|
|
void nv_rs_pci_bar1_unmap(struct nv_rs_pci *pci);
|
|
int nv_rs_pci_bar1_read32(struct nv_rs_pci *pci, u64 offset, u32 *value);
|
|
int nv_rs_pci_bar1_write32(struct nv_rs_pci *pci, u64 offset, u32 value);
|
|
int nv_rs_pci_bar1_zero(struct nv_rs_pci *pci, u64 offset, u64 bytes);
|
|
int nv_rs_pci_bar1_wc_map(struct nv_rs_pci *pci, u64 offset, u64 bytes);
|
|
void nv_rs_pci_bar1_wc_unmap(struct nv_rs_pci *pci);
|
|
int nv_rs_pci_bar1_wc_read64(struct nv_rs_pci *pci, u64 rel_off, u64 *value);
|
|
int nv_rs_pci_bar1_wc_write64(struct nv_rs_pci *pci, u64 rel_off, u64 value);
|
|
int nv_rs_pci_bar1_wc_write_words(struct nv_rs_pci *pci, u64 rel_off, const u32 *words, u32 count);
|
|
int nv_rs_pci_bar1_wc_fill32(struct nv_rs_pci *pci, u64 rel_off, u32 value, u32 count);
|
|
int nv_rs_pci_bar1_wc_write_vram_ptes(struct nv_rs_pci *pci, u64 rel_off, u64 phys_start,
|
|
u64 step_bytes, u64 flags, u32 count);
|
|
int nv_rs_pci_bar1_wc_write_sysmem_ptes(struct nv_rs_pci *pci, u64 rel_off, const u64 *dmas,
|
|
u64 flags, u32 count);
|
|
int nv_rs_pci_read32(struct nv_rs_pci *pci, u64 offset, u32 *value);
|
|
int nv_rs_pci_write32(struct nv_rs_pci *pci, u64 offset, u32 value);
|
|
int nv_rs_pci_bar0_fill32(struct nv_rs_pci *pci, u64 offset, u32 value, u32 count);
|
|
int nv_rs_pci_bar0_write_vram_ptes(struct nv_rs_pci *pci, u64 offset, u64 phys_start,
|
|
u64 step_bytes, u64 flags, u32 count);
|
|
int nv_rs_pci_bar0_write_sysmem_ptes(struct nv_rs_pci *pci, u64 offset, const u64 *dmas,
|
|
u64 flags, u32 count);
|
|
/* Hardirq callers hold a PCI lease; close/synchronize IRQs before remove.
|
|
* No sleeping or register-RMW serialization is provided by these primitives. */
|
|
int nv_rs_pci_read32_irq(struct nv_rs_pci *pci, u64 offset, u32 *value);
|
|
int nv_rs_pci_write32_irq(struct nv_rs_pci *pci, u64 offset, u32 value);
|
|
unsigned long nv_rs_pci_timer_irq_lock(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_timer_irq_unlock(struct nv_rs_pci *pci, unsigned long flags);
|
|
unsigned long nv_rs_pci_fifo_irq_lock(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_fifo_irq_unlock(struct nv_rs_pci *pci, unsigned long flags);
|
|
void nv_rs_pci_context_wc_flush(void);
|
|
unsigned long nv_rs_pci_context_irq_lock(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_context_irq_unlock(struct nv_rs_pci *pci, unsigned long flags);
|
|
unsigned long nv_rs_pci_pmu_mutex_lock(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_pmu_mutex_unlock(struct nv_rs_pci *pci, unsigned long flags);
|
|
unsigned long nv_rs_pci_pmu_dmem_lock(struct nv_rs_pci *pci);
|
|
void nv_rs_pci_pmu_dmem_unlock(struct nv_rs_pci *pci, unsigned long flags);
|
|
int nv_rs_pci_flush32(struct nv_rs_pci *pci, u64 offset, u32 *value);
|
|
#endif
|