Skip to content

Commit

Permalink
video: rockchip: vcodec_iommu_ion fix wrong type mask for ion heap
Browse files Browse the repository at this point in the history
Fix system crash casued by failed to allocated ion heap.
On RK3399 EVB:
[    0.924159] Unable to handle kernel NULL pointer dereference at virtual address 00000021
[    0.928269] pgd = ffffff80095b2000
[    0.928574] [00000021] *pgd=00000000f7ffe003, *pud=00000000f7ffe003, *pmd=0000000000000000
[    0.929338] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[    0.929836] Modules linked in:
[    0.930124] CPU: 5 PID: 1 Comm: swapper/0 Not tainted 4.4.194 #7
[    0.930656] Hardware name: rockchip,rk3399-excavator-edp (DT)
[    0.931166] task: ffffffc00a368000 task.stack: ffffffc00a344000
[    0.931696] PC is at ion_handle_validate+0x28/0x6c
[    0.932128] LR is at ion_map_iommu+0x48/0x2c4
[    0.932512] pc : [<ffffff8008811e0c>] lr : [<ffffff8008811fec>] pstate: 80400045

Change-Id: Iff428a745633e2b0188ebe8053baccecc7cdece5
Signed-off-by: Jianqun Xu <[email protected]>
  • Loading branch information
jayxurockchip authored and rkhuangtao committed Jul 16, 2020
1 parent 3610b20 commit 852508f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/video/rockchip/vcodec/vcodec_iommu_ion.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,21 @@ static int vcodec_ion_alloc(struct vcodec_iommu_session_info *session_info,
unsigned int heap_id_mask;

if (iommu_info->mmu_dev)
heap_id_mask = ION_HEAP_TYPE_SYSTEM;
heap_id_mask = ION_HEAP_SYSTEM_MASK;
else
heap_id_mask = ION_HEAP_TYPE_DMA;
heap_id_mask = ION_HEAP_TYPE_DMA_MASK;

ion_buffer = kzalloc(sizeof(*ion_buffer), GFP_KERNEL);
if (!ion_buffer)
return -ENOMEM;

ion_buffer->handle = ion_alloc(ion_info->ion_client, size,
align, heap_id_mask, 0);
if (IS_ERR(ion_buffer->handle)) {
pr_err("%s +%d: fail to alloc ion buffer handle\n", __func__, __LINE__);
kfree(ion_buffer);
return -ENOMEM;
}

INIT_LIST_HEAD(&ion_buffer->list);
mutex_lock(&session_info->list_mutex);
Expand Down

0 comments on commit 852508f

Please sign in to comment.