一,报错分析
该报错通常对应HAL层报错,具体log如下:
10-11 14:37:13.258 E/rga_mm ( 0): RGA_MMU unsupported memory larger than 4G!
10-11 14:37:13.258 E/rga_mm ( 0): scheduler core[4] unsupported mm_flag[0x0]!
10-11 14:37:13.258 E/rga_mm ( 0): rga_mm_map_buffer map virtual address error!
10-11 14:37:13.258 E/rga_mm ( 0): job buffer map failed!
10-11 14:37:13.258 E/rga_mm ( 0): src channel map job buffer failed!
10-11 14:37:13.258 E/rga_mm ( 0): failed to map buffer
10-11 14:37:13.258 E/rga_job ( 0): rga_job_commit: failed to map job info
10-11 14:37:13.258 E/rga_job ( 0): request[43550] task[0] job_commit failed.
10-11 14:37:13.258 E/rga_job ( 0): rga request commit failed!
10-11 14:37:13.258 E/rga ( 0): request[43550] submit failed!
10-11 14:37:13.267 D/fpsdk-jni( 6146): init handler invoke C initHandle method result is error
10-11 14:37:13.267 D/fpsdk-jni( 6146): :::: No Face ::::
10-11 14:37:13.285 W/ServiceManager( 315): Permission failure: android.permission.SYSTEM_CAMERA from uid=10133 pid=6146
10-11 14:37:13.285 E/CameraService( 315): camera callprocess:cc.zenking.edu.zhbp
10-11 14:37:13.285 W/ServiceManager( 315): Permission failure: android.permission.SYSTEM_CAMERA from uid=10133 pid=6146
10-11 14:37:13.285 E/CameraService( 315): camera callprocess:cc.zenking.edu.zhbp
10-11 14:37:13.291 E/rga_mm ( 0): RGA_MMU unsupported memory larger than 4G!
10-11 14:37:13.291 E/rga_mm ( 0): scheduler core[4] unsupported mm_flag[0x0]!
10-11 14:37:13.291 E/rga_mm ( 0): rga_mm_map_buffer map virtual address error!
10-11 14:37:13.291 E/rga_mm ( 0): job buffer map failed!
10-11 14:37:13.291 E/rga_mm ( 0): src channel map job buffer failed!
10-11 14:37:13.288 D/fpsdk_error( 6146): Func: imresize_t(buffer_src, buffer_dst, param.scale_w, param.scale_h, utils::convert_interp_type(param.type), 1), Error: Fatal error: Failed to call RockChipRga interface, query log to find the cause of failure.
10-11 14:37:13.291 E/rga_mm ( 0): failed to map buffer
10-11 14:37:13.291 E/rga_job ( 0): rga_job_commit: failed to map job info
10-11 14:37:13.291 E/rga_job ( 0): request[43553] task[0] job_commit failed.
10-11 14:37:13.291 E/rga_job ( 0): rga request commit failed!
10-11 14:37:13.291 E/rga ( 0): request[43553] submit failed!
10-11 14:37:13.300 D/fpsdk-jni( 6146): init handler invoke C initHandle method result is error
10-11 14:37:13.300 D/fpsdk-jni( 6146): :::: No Face ::::
10-11 14:37:13.312 E/WifiVendorHal( 460): getWifiLinkLayerStats_1_3_Internal(l.973) failed {.code = ERROR_UNKNOWN, .description = unknown error}
10-11 14:37:13.315 D/NetworkController.WifiSignalController( 611): Change in state from: connected=true,enabled=true,level=4,inetCondition=1,iconGroup=IconGroup(Wi-Fi Icons),activityIn=true,activityOut=false,rssi=-44,lastModified=10-11 14:37:07.301,ssid=“Chanjing”,isTransient=false,isDefault=true,statusLabel=null
10-11 14:37:13.315 D/NetworkController.WifiSignalController( 611): to: connected=true,enabled=true,level=4,inetCondition=1,iconGroup=IconGroup(Wi-Fi Icons),activityIn=true,activityOut=true,rssi=-44,lastModified=10-11 14:37:07.301,ssid=“Chanjing”,isTransient=false,isDefault=true,statusLabel=null
10-11 14:37:13.320 W/ServiceManager( 315): Permission failure: android.permission.SYSTEM_CAMERA from uid=10133 pid=6146
10-11 14:37:13.320 E/CameraService( 315): camera callprocess:cc.zenking.edu.zhbp
10-11 14:37:13.321 W/ServiceManager( 315): Permission failure: android.permission.SYSTEM_CAMERA from uid=10133 pid=6146
10-11 14:37:13.321 E/CameraService( 315): camera callprocess:cc.zenking.edu.zhbp
10-11 14:37:13.324 D/fpsdk_error( 6146): Func: imresize_t(buffer_src, buffer_dst, param.scale_w, param.scale_h, utils::convert_interp_type(param.type), 1), Error: Fatal error: Failed to call RockChipRga interface, query log to find the cause of failure.
该报错标识当前配置的图像任务配置的内存无法满足当前匹配到的硬件核心对内存的要求,由于不同的硬件版本的RGA的IOMMU对内存位数的要求不同,当分配的内存超过对应硬件的限制
时,则会出现该该报错。
二,解决方案
当出现该报错时,通常有以下几种场景以及对应的解决方案:
方法1:
在搭载多种RGA的芯片平台(例如RK3588搭载有2颗RGA3核心、1颗RGA2核心)上,没有使用importbuffer_xx接口获取handle,而是直接使用wrapbuffer_xx接口调用im2d api时:
由于没有使用importbuffer_xx来提前映射外部内存到RGA驱动内存,因此在实际任务匹配中无法提前获知内存是否不满足对应核心的限制,因此在高负载场景下可能会出现该报错,建议使用importbuffer_xx提前将外部内存导入到RGA驱动内部
,避免该问题。
方法2:
在搭载多种RGA的芯片平台(例如RK3588搭载有2颗RGA3核心、1颗RGA2核心)上,使用了importbuffer_xx接口获取handle,但是依旧存在该问题:
- 可以检查一下配置的图像任务的参数,确认是否配置了仅有RGA2核心(内存访问受限制的核心)支持的功能或格式,以RK3588为例,color fill功能和YUV422/420 planar格式均是RGA2核心特有的功能和格式,因此该场景下必须分配4G以内内存空间的内存调用RGA。
- 常见的分配4G内存方式可以查看以下示例代码:
rga_allocator_dma32_demo.cpp
/*
* Copyright (C) 2022 Rockchip Electronics Co., Ltd.
* Authors:
* YuQiaowei <cerf.yu@rock-chips.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_NDEBUG 0
#undef LOG_TAG
#define LOG_TAG "rga_allocator_dma32_demo"
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstddef>
#include <cmath>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include "im2d.h"
#include "RgaUtils.h"
#include "utils.h"
#include "dma_alloc.h"
#define LOCAL_FILE_PATH "/data"
int main(void) {
int ret = 0;
int64_t ts;
int dst_width, dst_height, dst_format;
int dst_buf_size;
char *dst_buf;
int dst_dma_fd;
rga_buffer_t dst = {
};
im_rect dst_rect = {
};
rga_buffer_handle_t dst_handle;
dst_width = 1280;
dst_height = 720;
dst_format = RK_FORMAT_RGBA_8888;