diff --git a/NativeAdrenoSubmit.cpp b/NativeAdrenoSubmit.cpp index 288c3bf..21c16b4 100644 --- a/NativeAdrenoSubmit.cpp +++ b/NativeAdrenoSubmit.cpp @@ -19,9 +19,11 @@ extern "C" {volatile uint32_t native_adreno_wc_audit[6];} /* Fence waits: [0] calls, [1] timeouts, [2] the fence of the last timed-out wait, [3] the fence value the GPU had written then, [4] the newest fence handed out, * [5] the newest completed, [6] waits for a fence no job holds (observeFence path), [7] the last fence refused as never submitted. */ extern "C" {volatile uint32_t native_adreno_fence_wait[8];} -/* The CP's state once a fence stopped advancing (NativeAdrenoRing::stallState): [0] the fence, [1] how many fences had stalled, then the - * ring's words. Taken at the tenth timed-out wait of a fence that is the next to complete, once per fence. */ -extern "C" {volatile uint32_t native_adreno_stall[2+NativeAdrenoRingStallWords];} +/* The CP's state once a fence stopped advancing (NativeAdrenoRing::stallState): [0] the fence, [1] the timed-out waits of it so far, then + * the ring's words. Taken at the 10th and again at the 1000th timed-out wait of the fence that is the next to complete. native_adreno_stall_mem + * holds, from the same moment, the SMMU context's FSR, FAR (lo, hi) and FSYNR0, then 16 words of the BR and of the BV IB1 from 12 words + * before the fetch address (the CP prefetches, so the waiting packet lies before it). */ +extern "C" {volatile uint32_t native_adreno_stall[2+NativeAdrenoRingStallWords];volatile uint32_t native_adreno_stall_mem[4+32];} static uint32_t stall_fence,stall_timeouts; /* The IBs of the last submissions: [slot] fence, iova low/high, bytes, then the first 28 dwords of the first IB (read as the kernel maps it). */ extern "C" {volatile uint32_t native_adreno_ib_log[4][4+28];volatile uint32_t native_adreno_ib_log_count;} @@ -216,11 +218,16 @@ void NativeAdrenoSubmit::noteStall(uint32_t observed) { const uint32_t next=observed+1; /* the fence the CP is working on */ if(next!=stall_fence) {stall_fence=next;stall_timeouts=0;} - if(++stall_timeouts!=10 || native_adreno_stall[0]==next)return; - uint32_t words[NativeAdrenoRingStallWords]={}; + if(++stall_timeouts!=10 && stall_timeouts!=1000)return; + uint32_t words[NativeAdrenoRingStallWords]={},mem[4+32]={}; if(ring_->stallState(words))return; + (void)vm_->faultState(mem); + const uint64_t br=((uint64_t)words[11]<<32|words[10])-48,bv=(uint64_t)words[17]-48; /* BV IB1 base: low word only */ + (void)vm_->peekWords(br,&mem[4],16); + (void)vm_->peekWords(((uint64_t)words[11]<<32)|bv,&mem[20],16); + for(uint32_t i=0;i<4+32;++i)native_adreno_stall_mem[i]=mem[i]; for(uint32_t i=0;icontext_offset)offset=region.state->context_offset; + if(!offset)return kIOReturnNotReady; + static const uint32_t regs[4]={0x58,0x60,0x64,0x68}; + for(unsigned i=0;i<4;++i)if(io_.read32(io_.cookie,(size_t)offset+regs[i],&out[i]))return kIOReturnIOError; + return kIOReturnSuccess; +} IOReturn NativeAdrenoVm::holdJob(uint64_t handle) { if(!attached_ || poisoned_)return kIOReturnNotReady; diff --git a/NativeAdrenoVm.h b/NativeAdrenoVm.h index be6820b..9239e3b 100644 --- a/NativeAdrenoVm.h +++ b/NativeAdrenoVm.h @@ -115,6 +115,8 @@ public: IOReturn describe(uint64_t handle,uint64_t *iova,size_t *bytes,unsigned *permissions) const; /* Up to `count` dwords of a mapped kernel-owned BO at a GPU address (through the kernel's own mapping), for the board log. */ IOReturn peekWords(uint64_t iova,uint32_t *out,size_t count) const; + /* The context bank's fault record for the board log: FSR, FAR (lo, hi) and FSYNR0. Reads only; never clears a fault. */ + IOReturn faultState(uint32_t out[4]) const; /* Only a scheduler's actual successful GPU completion may call this. * A timeout, interrupt bit alone or CPU-written timestamp is insufficient. */ IOReturn retireJobAfterCompletion(uint64_t handle);