camerad: an ISP IOMMU handle of 0 is valid (#39376)

This commit is contained in:
Adeeb Shihadeh
2026-11-28 11:05:35 -06:00
committed by firestar5683
parent ed46cc28a5
commit 79a68a08e9
2 changed files with 9 additions and 10 deletions
+7 -8
View File
@@ -97,13 +97,12 @@ void *alloc_w_mmu_hdl(int video0_fd, int len, uint32_t *handle, int align, int f
mem_mgr_alloc_cmd.align = align;
mem_mgr_alloc_cmd.flags = flags;
mem_mgr_alloc_cmd.num_hdl = 0;
if (mmu_hdl != 0) {
mem_mgr_alloc_cmd.mmu_hdls[0] = mmu_hdl;
mem_mgr_alloc_cmd.num_hdl++;
}
if (mmu_hdl2 != 0) {
mem_mgr_alloc_cmd.mmu_hdls[1] = mmu_hdl2;
mem_mgr_alloc_cmd.num_hdl++;
// -1 is the only invalid IOMMU handle: the kernel makes them (context bank index << 16) | 16 random bits, and the
// ISP's bank is index 0, so its handle is 0 on 1 boot in 65536
for (int hdl : {mmu_hdl, mmu_hdl2}) {
if (hdl != -1) {
mem_mgr_alloc_cmd.mmu_hdls[mem_mgr_alloc_cmd.num_hdl++] = hdl;
}
}
do_cam_control(video0_fd, CAM_REQ_MGR_ALLOC_BUF, &mem_mgr_alloc_cmd, sizeof(mem_mgr_alloc_cmd));
@@ -1221,7 +1220,7 @@ void SpectraCamera::configICP() {
release(m->video0_fd, cfg_handle);
// BPS has a lot of buffers to init
bps_cmd.init(m, 464, 0x20, true, m->icp_device_iommu, 0, ife_buf_depth);
bps_cmd.init(m, 464, 0x20, true, m->icp_device_iommu, -1, ife_buf_depth);
// BPSIQSettings struct
uint32_t settings_size = sizeof(bps_settings[0]) / sizeof(bps_settings[0][0]);
+2 -2
View File
@@ -58,7 +58,7 @@ int device_config(int fd, int32_t session_handle, int32_t dev_handle, uint64_t p
int device_control(int fd, int op_code, int session_handle, int dev_handle);
int do_cam_control(int fd, int op_code, void *handle, int size);
void *alloc_w_mmu_hdl(int video0_fd, int len, uint32_t *handle, int align = 8, int flags = CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE,
int mmu_hdl = 0, int mmu_hdl2 = 0);
int mmu_hdl = -1, int mmu_hdl2 = -1);
void release(int video0_fd, uint32_t handle);
class MemoryManager {
@@ -106,7 +106,7 @@ public:
}
}
void init(SpectraMaster *m, int s, int a, bool shared_access, int mmu_hdl = 0, int mmu_hdl2 = 0, int count = 1) {
void init(SpectraMaster *m, int s, int a, bool shared_access, int mmu_hdl = -1, int mmu_hdl2 = -1, int count = 1) {
video_fd = m->video0_fd;
size = s;
alignment = a;