背景
- 在闪光灯初始化阶段客制化了一个buffer,下发到kernel的闪光灯驱动中用于保存读取闪光灯寄存器的值。
- 功能测试都是正常的,但是一旦开始批量跑产线老化测试会有1/4500左右概率的后主摄拍照卡住。
- 定位根因是闪光灯初始化失败,进一步原因就是客制化的buffer申请失败。
具体流程
camxsensornode.cpp: ProcessingNodeFinalizeInitialization()
camxsensornode.cpp -> camxsensornode.cpp: m_pThreadManager->RegisterJobFamily();\n线程回调函数
camxsensornode.cpp -> camxsensornode.cpp: SensorThreadJobCallback()
camxsensornode.cpp -> camxsensornode.cpp: case SensorPostJobCommand::InitializeSensor:
camxsensornode.cpp -> camxsensornode.cpp: case SensorPostJobCommand::SubModulesCreate:
camxsensornode.cpp -> camxsensornode.cpp: SensorNode::CreateSensorSubmodules()
camxsensornode.cpp -> camxsensornode.cpp: SensorNode::CreateFlashResources()
camxsensornode.cpp -> camxnode.cpp: CreateCmdBufferManager() x n
camxnode.cpp -> camxcmdbuffermanager.cpp : CmdBufferManager::Create()
camxcmdbuffermanager.cpp -> camxcmdbuffermanager.cpp: pCmdBufferManager->\nInitialize(pBufferManagerName, pParams);
camxcmdbuffermanager.cpp -> camxcmdbuffermanager.cpp: InitializePool();
camxcmdbuffermanager.cpp -> camxcslhw.cpp: CSLAlloc()
note right of camxcslhw.cpp: CSLAllocHW()...
camxcmdbuffermanager.cpp <-- camxcslhw.cpp
camxnode.cpp <-- camxcmdbuffermanager.cpp
camxsensornode.cpp <-- camxnode.cpp:
camxsensornode.cpp -> camxflash.cpp: Flash::Create(&createData)
camxflash.cpp -> camxflash.cpp: pCreateData->pFlash->Initialize(pCreateData)
camxflash.cpp -> camxflash.cpp: CreateInitializePacket()
camxflash.cpp -> camxcmdbuffermanager.cpp: m_pPacketManager->GetBuffer(&pResource)
camxcmdbuffermanager.cpp --> camxflash.cpp
camxflash.cpp -> camxflash.cpp: PopulateImageBuffer()
camxflash.cpp -> camximagebuffermanager.cpp: ImageBufferManager::Create(\n"FlashRegisterRead",&createData,\npFlashImageBufferManager)
camximagebuffermanager.cpp -> camximagebuffermanager.cpp: pImageBufferManager->Initialize();
camximagebuffermanager.cpp -> camxmempoolmgr.cpp: MemPoolMgr::RegisterBufferManager();
camxmempoolmgr.cpp -> camxmempoolmgr.cpp: pMemPoolMgr->RegisterNewMemPoolGroup();
camxmempoolmgr.cpp -> camxmempoolgroup.cpp: pMemPoolGroup->Initialize()
camxmempoolgroup.cpp --> camxmempoolmgr.cpp
camxmempoolmgr.cpp -> camxmempoolgroup.cpp: pMemPoolGroup->RegisterBufferManager();
camxmempoolgroup.cpp --> camxmempoolmgr.cpp
camxmempoolmgr.cpp --> camximagebuffermanager.cpp
note left of camxmempoolmgr.cpp: ------------先注册内存池组,再进行初始化内存,通过FLAG来管理----------
camximagebuffermanager.cpp -> camximagebuffermanager.cpp: pImageBufferManager->InitializeBuffers();
camximagebuffermanager.cpp -> camximagebuffer.cpp: pBuffer->Allocate();
camximagebuffer.cpp -> camxmempoolmgr.cpp: MemPoolMgr::GetBufferFromPool();
camxmempoolmgr.cpp -> camxmempoolgroup.cpp: pMemPoolGroup->GetBufferFromPool()
camxmempoolgroup.cpp -> camxmempoolgroup.cpp: ActivateBufferManager();
camxmempoolgroup.cpp -> camxmempoolgroup.cpp: UpdateMemPoolGroupBufferCounts();
camxmempoolgroup.cpp -> camxmempoolgroup.cpp: AllocateBuffers(1);
camxmempoolgroup.cpp -> camxcsl.cpp: CSLAlloc(pBuffer->name,...)
camxcsl.cpp --> camxflash.cpp: 正确的分配完内存,可顺利打开相机拍照。FlashRegisterRead申请的内存池组的flag,有概率被异步的TFE修改会导致分配内存失败。可以通过添加标志位bNeedDedicatedBuffers=TRUE,来设置专属内存组
note right of camxsensornode.cpp: 开启新的线程
camxsensornode.cpp -> camxsensornode.cpp:SensorPostJobCommand::ConfigureSensor:
camxsensornode.cpp -> camxsensornode.cpp:SensorPostJobCommand::ReadRequest:...
正确的分配完内存,可顺利打开相机拍照。FlashRegisterRead申请的内存池组的flag,有概率被异步的TFE修改会导致分配内存失败。可以通过添加标志位bNeedDedicatedBuffers=TRUE,来设置专属内存组
If self shrinking is disabled or heap type is EGL for this group, its better to have it as a dedicated
group for this Buffer Manager set m_bDedicatedGroup to TRUE in such case, so that IsMatchingGroup for
this group would fail for any future Buffer Manager registers
翻译如下: