mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-10 17:54:13 +00:00
m1n1.agx.object: Support setting guard page count
Signed-off-by: Asahi Lina <lina@asahilina.net>
This commit is contained in:
parent
6ce60e875c
commit
17142da838
2 changed files with 6 additions and 2 deletions
|
@ -32,6 +32,7 @@ class GPUContext:
|
||||||
|
|
||||||
# 32K VA pages since buffer manager needs that
|
# 32K VA pages since buffer manager needs that
|
||||||
self.uobj = GPUAllocator(agx, "Userspace", 0x1600000000, 0x100000000, ctx=None,
|
self.uobj = GPUAllocator(agx, "Userspace", 0x1600000000, 0x100000000, ctx=None,
|
||||||
|
guard_pages=1,
|
||||||
va_block=32768, nG=1, AP=0, PXN=1, UXN=1)
|
va_block=32768, nG=1, AP=0, PXN=1, UXN=1)
|
||||||
|
|
||||||
def bind(self, ctx_id):
|
def bind(self, ctx_id):
|
||||||
|
|
|
@ -102,7 +102,7 @@ class GPUObject:
|
||||||
|
|
||||||
class GPUAllocator:
|
class GPUAllocator:
|
||||||
def __init__(self, agx, name, start, size,
|
def __init__(self, agx, name, start, size,
|
||||||
ctx=0, page_size=16384, va_block=None, **kwargs):
|
ctx=0, page_size=16384, va_block=None, guard_pages=1, **kwargs):
|
||||||
self.page_size = page_size
|
self.page_size = page_size
|
||||||
if va_block is None:
|
if va_block is None:
|
||||||
va_block = page_size
|
va_block = page_size
|
||||||
|
@ -111,6 +111,7 @@ class GPUAllocator:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.va = Heap(start, start + size, block=va_block)
|
self.va = Heap(start, start + size, block=va_block)
|
||||||
self.verbose = 1
|
self.verbose = 1
|
||||||
|
self.guard_pages = guard_pages
|
||||||
self.objects = {}
|
self.objects = {}
|
||||||
self.flags = kwargs
|
self.flags = kwargs
|
||||||
|
|
||||||
|
@ -123,8 +124,10 @@ class GPUAllocator:
|
||||||
if name is not None:
|
if name is not None:
|
||||||
obj._name = name
|
obj._name = name
|
||||||
|
|
||||||
|
guard_size = self.page_size * self.guard_pages
|
||||||
|
|
||||||
size_align = align_up(obj._size, self.page_size)
|
size_align = align_up(obj._size, self.page_size)
|
||||||
addr = self.va.malloc(size_align + self.page_size)
|
addr = self.va.malloc(size_align + guard_size)
|
||||||
paddr = self.agx.u.memalign(self.page_size, size_align)
|
paddr = self.agx.u.memalign(self.page_size, size_align)
|
||||||
off = size_align - obj._size
|
off = size_align - obj._size
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue