int32_t cmdqRecFlushAndReadRegister(cmdqRecHandle handle, uint32_t regCount, uint32_t *addrArray, uint32_t *valueArray) { int32_t status; cmdqCommandStruct desc = { 0 }; status = cmdq_rec_finalize_command(handle, false); if (status < 0) { return status; } CMDQ_MSG("Submit task scenario: %d, priority: %d, engine: 0x%llx, buffer: 0x%p, size: %d\n", handle->scenario, handle->priority, handle->engineFlag, handle->pBuffer, handle->blockSize); desc.scenario = handle->scenario; desc.priority = handle->priority; desc.engineFlag = handle->engineFlag; desc.pVABase = (cmdqU32Ptr_t)(unsigned long)handle->pBuffer; desc.blockSize = handle->blockSize; desc.regRequest.count = regCount; desc.regRequest.regAddresses = (cmdqU32Ptr_t)(unsigned long)addrArray; desc.regValue.count = regCount; desc.regValue.regValues = (cmdqU32Ptr_t)(unsigned long)valueArray; /* secure path */ cmdq_rec_setup_sec_data_of_command_desc_by_rec_handle(&desc, handle); /* profile marker */ cmdq_rec_setup_profile_marker_data(&desc, handle); return cmdqCoreSubmitTask(&desc); }
int32_t cmdqRecFlushAndReadRegister(cmdqRecHandle handle, uint32_t regCount, uint32_t *addrArray, uint32_t *valueArray) { int32_t status; cmdqCommandStruct desc = { 0 }; status = cmdq_rec_finalize_command(handle, false); if (status < 0) { return status; } CMDQ_MSG("Submit task scenario: %d, priority: %d, engine: 0x%llx, buffer: 0x%p, size: %d\n", handle->scenario, handle->priority, handle->engineFlag, handle->pBuffer, handle->blockSize); desc.scenario = handle->scenario; desc.priority = handle->priority; desc.engineFlag = handle->engineFlag; desc.pVABase = handle->pBuffer; desc.blockSize = handle->blockSize; desc.regRequest.count = regCount; desc.regRequest.regAddresses = addrArray; desc.regValue.count = regCount; desc.regValue.regValues = valueArray; return cmdqCoreSubmitTask(&desc); }
int32_t cmdqRecFlush(cmdqRecHandle handle) { int32_t status; cmdqCommandStruct desc = { 0 }; status = cmdq_rec_finalize_command(handle, false); if (status < 0) { return status; } CMDQ_MSG("Submit task scenario: %d, priority: %d, engine: 0x%llx, buffer: 0x%p, size: %d\n", handle->scenario, handle->priority, handle->engineFlag, handle->pBuffer, handle->blockSize); desc.scenario = handle->scenario; desc.priority = handle->priority; desc.engineFlag = handle->engineFlag; desc.pVABase = (cmdqU32Ptr_t)(unsigned long)handle->pBuffer; desc.blockSize = handle->blockSize; /* secure path */ cmdq_rec_setup_sec_data_of_command_desc_by_rec_handle(&desc, handle); /* profile marker */ cmdq_rec_setup_profile_marker_data(&desc, handle); return cmdqCoreSubmitTask(&desc); }
int32_t cmdqRecFlush(cmdqRecHandle handle) { int32_t status; cmdqCommandStruct desc = { 0 }; status = cmdq_rec_finalize_command(handle, false); if (status < 0) { return status; } CMDQ_MSG("Submit task scenario: %d, priority: %d, engine: 0x%llx, buffer: 0x%p, size: %d\n", handle->scenario, handle->priority, handle->engineFlag, handle->pBuffer, handle->blockSize); desc.scenario = handle->scenario; desc.priority = handle->priority; desc.engineFlag = handle->engineFlag; desc.pVABase = handle->pBuffer; desc.blockSize = handle->blockSize; return cmdqCoreSubmitTask(&desc); }
static long cmdq_driver_process_command_request(cmdqCommandStruct *pCommand) { int32_t status = 0; uint32_t *userRegValue = NULL; uint32_t userRegCount = 0; if (pCommand->regRequest.count != pCommand->regValue.count) { CMDQ_ERR("mismatch regRequest and regValue\n"); return -EFAULT; } /* allocate secure medatata */ status = cmdq_driver_create_secure_medadata(pCommand); if (0 != status) return status; /* backup since we are going to replace these */ userRegValue = CMDQ_U32_PTR(pCommand->regValue.regValues); userRegCount = pCommand->regValue.count; /* create kernel-space address buffer */ status = cmdq_driver_create_reg_address_buffer(pCommand); if (0 != status) { /* free secure path metadata */ cmdq_driver_destroy_secure_medadata(pCommand); return status; } /* create kernel-space value buffer */ pCommand->regValue.regValues = (cmdqU32Ptr_t) (unsigned long) kzalloc(pCommand->regRequest.count * sizeof(uint32_t), GFP_KERNEL); pCommand->regValue.count = pCommand->regRequest.count; if (NULL == CMDQ_U32_PTR(pCommand->regValue.regValues)) { kfree(CMDQ_U32_PTR(pCommand->regRequest.regAddresses)); return -ENOMEM; } /* scenario id fixup */ cmdq_core_fix_command_scenario_for_user_space(pCommand); status = cmdqCoreSubmitTask(pCommand); if (0 > status) { CMDQ_ERR("Submit user commands for execution failed = %d\n", status); cmdq_driver_destroy_secure_medadata(pCommand); kfree(CMDQ_U32_PTR(pCommand->regRequest.regAddresses)); kfree(CMDQ_U32_PTR(pCommand->regValue.regValues)); return -EFAULT; } /* notify kernel space dump callback */ if (0 != pCommand->debugRegDump) { status = cmdqCoreDebugRegDumpEnd(pCommand->debugRegDump, pCommand->regRequest.count - userRegCount, CMDQ_U32_PTR(pCommand->regValue.regValues) + userRegCount); if (0 != status) { /* Error status print */ CMDQ_ERR("cmdqCoreDebugRegDumpEnd returns %d\n", status); } } /* copy back to user space buffer */ if (userRegValue && userRegCount) { /* copy results back to user space */ CMDQ_VERBOSE("regValue[0] is %d\n", CMDQ_U32_PTR(pCommand->regValue.regValues)[0]); if (copy_to_user (userRegValue, CMDQ_U32_PTR(pCommand->regValue.regValues), userRegCount * sizeof(uint32_t))) { CMDQ_ERR("Copy REGVALUE to user space failed\n"); } } /* free allocated kernel buffers */ kfree(CMDQ_U32_PTR(pCommand->regRequest.regAddresses)); kfree(CMDQ_U32_PTR(pCommand->regValue.regValues)); if (pCommand->readAddress.count > 0) cmdq_driver_process_read_address_request(&pCommand->readAddress); /* free allocated secure metadata */ cmdq_driver_destroy_secure_medadata(pCommand); return 0; }