Skip to content

Commit

Permalink
LF-12723 mxc IPUv3: device: Set ipu_task_thread affinity properly
Browse files Browse the repository at this point in the history
The ipu_task_thread thread ran by kthread_run() could be excuted
before kthread_run() returns especially when 'nosmp' or 'maxcpus=1'
kernel bootup parameters are used.  So, in this case, the thread[0]
or thread[1] entries in struct ipu_soc are not yet set before
ipu_task_thread() references them to set thread affinity, hence a
NULL pointer de-referencing issue happens.  Fix this by referencing
*current* task in ipu_task_thread() instead of the uninitialized
thread[0] or thread[1] entries.

This fixes an old bug introduced by the below commit in linux-imx:
commit 0d36f8226d22 ("ENGR00175724-2 IPU: change ipu_device thread
process mode to interrupt mode.")

Signed-off-by: Liu Ying <[email protected]>
Reviewed-by: Sandor Yu <[email protected]>
Acked-by: Jason Liu <[email protected]>
  • Loading branch information
Liu Ying authored and FrancescoFerraro committed Dec 17, 2024
1 parent f52a6aa commit a847020
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/mxc/ipu3/ipu_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -3259,8 +3259,7 @@ static int ipu_task_thread(void *argv)
if (!data->is_vdoa) {
cpu = cpumask_first(cpu_online_mask);
cpumask_set_cpu(cpu, &cpu_mask);
ret = sched_setaffinity(data->ipu->thread[data->id]->pid,
&cpu_mask);
ret = sched_setaffinity(current->pid, &cpu_mask);
if (ret < 0) {
pr_err("%s: sched_setaffinity fail:%d.\n", __func__, ret);
}
Expand Down

0 comments on commit a847020

Please sign in to comment.