mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:35:12 +01:00
Move FlatAllocator allocation error handling to the caller
This is a prerequisite for nvmap SMMU memory management, which only frees the memory handles refer to if an allocation fails.
This commit is contained in:
parent
04e5237ec1
commit
97dc053ffd
@ -406,7 +406,7 @@ namespace skyline {
|
||||
if (searchSuccessor != this->blocks.end())
|
||||
allocStart = searchPredecessor->virt;
|
||||
else
|
||||
throw exception("Unexpected allocator state!");
|
||||
return {}; // AS is full
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,10 +65,13 @@ namespace skyline::service::nvdrv::device::nvhost {
|
||||
|
||||
auto &allocator{pageSize == VM::PageSize ? *vm.smallPageAllocator : *vm.bigPageAllocator};
|
||||
|
||||
if (flags.fixed)
|
||||
if (flags.fixed) {
|
||||
allocator.AllocateFixed(static_cast<u32>(offset >> pageSizeBits), pages);
|
||||
else
|
||||
} else {
|
||||
offset = static_cast<u64>(allocator.Allocate(pages)) << pageSizeBits;
|
||||
if (!offset)
|
||||
throw exception("Failed to allocate free space in the GPU AS!");
|
||||
}
|
||||
|
||||
u64 size{static_cast<u64>(pages) * pageSize};
|
||||
|
||||
@ -236,6 +239,9 @@ namespace skyline::service::nvdrv::device::nvhost {
|
||||
u32 pageSizeBits{bigPage ? vm.bigPageSizeBits : VM::PageSizeBits};
|
||||
|
||||
offset = static_cast<u64>(allocator.Allocate(static_cast<u32>(util::AlignUp(size, pageSize) >> pageSizeBits))) << pageSizeBits;
|
||||
if (!offset)
|
||||
throw exception("Failed to allocate free space in the GPU AS!");
|
||||
|
||||
asCtx->gmmu.Map(offset, cpuPtr, size);
|
||||
|
||||
auto mapping{std::make_shared<Mapping>(cpuPtr, offset, size, false, bigPage, false)};
|
||||
|
@ -182,6 +182,8 @@ namespace skyline::service::nvdrv::device::nvhost {
|
||||
|
||||
// Allocate pages in the GPU AS
|
||||
pushBufferAddr = static_cast<u64>(asAllocator->Allocate((static_cast<u32>(pushBufferWords) >> AsGpu::VM::PageSizeBits) + 1)) << AsGpu::VM::PageSizeBits;
|
||||
if (!pushBufferAddr)
|
||||
throw exception("Failed to allocate channel pushbuffer!");
|
||||
|
||||
// Map onto the GPU
|
||||
asCtx->gmmu.Map(pushBufferAddr, reinterpret_cast<u8 *>(pushBufferMemory.data()), pushBufferSize);
|
||||
|
Loading…
Reference in New Issue
Block a user