nv: fix boot mem (#16332)

* nv: fix boot mem

* linter
This commit is contained in:
nimlgen
2026-05-22 19:28:38 +03:00
committed by GitHub
parent 5d77a94923
commit 90dbb45563

View File

@@ -145,14 +145,17 @@ class NVDev:
self.mm = NVMemoryManager(self, self.vram_size - (64 << 20), boot_size=(2 << 20), pt_t=NVPageTableEntry, va_bits=bits, va_shifts=shifts,
va_base=0, palloc_ranges=[(x, x) for x in [512 << 20, 2 << 20, 4 << 10]], reserve_ptable=not self.large_bar)
def _alloc_boot_mem(self, size:int, data:bytes|None=None, contiguous:bool=False, sysmem:bool|None=None) -> tuple[MMIOInterface, int, list[int]]:
def _alloc_boot_mem(self, size:int, data:bytes|None=None, contiguous:bool=False, sysmem:bool|None=None) -> tuple[MMIOInterface,int|None,list[int]]:
sz = round_up(size, 0x1000)
if sysmem is True or (sysmem is None and not self.large_bar): view, paddrs = self.pci_dev.alloc_sysmem(size, 0, contiguous=contiguous)
if sysmem is True or (sysmem is None and not self.large_bar):
view, sysaddr = self.pci_dev.alloc_sysmem(size, 0, contiguous=contiguous)
paddr = None
else:
paddr = self.mm.palloc(sz, boot=False)
view, paddrs = self.vram.view(paddr, sz), [self.pci_dev.bar_info(1)[0] + paddr + i * 0x1000 for i in range(sz // 0x1000)]
view = self.vram.view(paddr, sz)
sysaddr = [self.pci_dev.bar_info(1)[0] + paddr + i * 0x1000 for i in range(sz // 0x1000)]
if data is not None: view[:size] = data
return view, paddrs[0], paddrs
return view, paddr, sysaddr
def include(self, name:str, arch:str):
for k,v in getattr(getattr(tinygrad.runtime.autogen.nv_regs, name), arch or 'regs').items():