mirror of
https://github.com/UniXNU/NativeAdreno.git
synced 2026-11-19 14:04:21 +03:00
fix(memory): keep the pool's zero fill out of the driver's lock
A BoAlloc prepares its pages before it takes the driver's lock, and the pool's allocation runs there with its zero fill, which maps the run in the kernel map. When the preparation gave nothing, allocateSystem asked the pool a second time under the lock, so a VM mapping, a zero fill and an unmap ran while every other client's submit, map and wait queued behind. The lock path now always offers its (possibly empty) prepared pages, and allocateSystem leaves the pool alone when it was offered any: the VM's pages take the request there, as they did before the pool. Not run on hardware.
This commit is contained in:
@@ -280,7 +280,9 @@ IOReturn NativeAdrenoMemory::allocateSystem(size_t bytes,unsigned bits,size_t bu
|
||||
bool cleaned=false;
|
||||
if(prepared && prepared->held() && prepared->bytes==bytes && prepared->write_combined==write_combined) {
|
||||
descriptor_=prepared->descriptor;grant_=prepared->grant;cleaned=prepared->cleaned;*prepared=NativeAdrenoSystemPages{};
|
||||
} else if(NativeAdrenoPoolAllocate(bytes,UINT64_C(1)<<bits,write_combined,&grant_)!=kIOReturnSuccess) {
|
||||
} else if(prepared || NativeAdrenoPoolAllocate(bytes,UINT64_C(1)<<bits,write_combined,&grant_)!=kIOReturnSuccess) {
|
||||
/* A caller that offers prepared pages holds the driver's lock: the pool's zero fill maps its run in the kernel map and is not
|
||||
* done under it (prepareSystem already asked the pool, outside the lock). */
|
||||
grant_=nullptr;descriptor_=systemDescriptor(bytes,write_combined);
|
||||
}
|
||||
if(grant_) {
|
||||
|
||||
@@ -856,7 +856,8 @@ static IOReturn runCore(AGXDeviceUserClient *connection,uint32_t method,const vo
|
||||
lockTimed(lockWait);
|
||||
locked=mach_absolute_time();
|
||||
spans=native_adreno_bo_memory[1];
|
||||
if(connection->live_)connection->core_->offerSystemPages(pages.held()?&pages:nullptr);
|
||||
/* Offered for every BoAlloc, held or not: allocateSystem then knows it runs under the lock and leaves the pool alone. */
|
||||
if(connection->live_)connection->core_->offerSystemPages(alloc?&pages:nullptr);
|
||||
if(connection->live_ && freeing)connection->core_->collectFreedPages(&freed);
|
||||
status=connection->live_?connection->core_->dispatch(method,input,input_size,output,output_size,&g.clock):kIOReturnNotReady;
|
||||
if(connection->live_)connection->core_->offerSystemPages(nullptr);
|
||||
|
||||
Reference in New Issue
Block a user