Commit Graph

7 Commits

Author SHA1 Message Date
Liu Ying
d4c4988333 LF-12723 mxc IPUv3: device: Set ipu_task_thread affinity properly
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 <victor.liu@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-11-11 14:12:41 +08:00
Liu Ying
66d617735f LF-9723 mxc: ipu3: ipu_common: Check source channel id against {proc,disp}_src_sel array sizes
The source channel id is used as array index to access {proc,disp}_src_sel
arrays in ipu_link_channels().  Check the source channel id against the
array sizes to avoid overrun on the arrays.

This fixes Coverity issues: CID 33330173 and CID 33330174.

Cc: Sandor Yu <Sandor.yu@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 15:56:27 +08:00
Liu Ying
d6605b3334 LF-9707 mxc: ipu3: prg: Check return value of regmap_field_read()
regmap_field_read() could fail by returning negative value, so check
the return value and return from assign_prg_chan() directly with that
return value if error happens.

This fixes Coverity issue: CID 22841751.

Cc: Sandor Yu <Sandor.yu@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 15:56:27 +08:00
Liu Ying
40e1c9f1f0 LF-9705 mxc: ipu3: ipu_pixel_clk: Replace kzalloc() with devm_kzalloc()
Since functions clk_register_{mux,div,gate}_pix_clk() are called from
ipu_probe(), replace kzalloc() with devm_kzalloc() in those functions
to avoid resource leak.

This fixes Coverity issues: CID 22841505, CID 22841827 and CID 22841841.

Cc: Sandor Yu <Sandor.yu@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 15:56:27 +08:00
Liu Ying
1e308b384d LF-9704 mxc: ipu3: ipu_common: Get channel ID properly by get_chan_id()
Introduce get_chan_id() to get channel ID and check if the channel
ID is valid to make coverity happy.

This fixes Coverity issues: CID 29825, CID 29826, CID 28366222,
CID 28366349, CID 28366376, CID 28366401, CID 28366422 and CID 28366454.

Cc: Sandor Yu <Sandor.yu@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 15:56:27 +08:00
Sandor Yu
d506794219 mxc: ipu3: Add a determine_rate hook
The iMX ipu3 pixel clock implements a mux with a set_parent hook, but
doesn't provide a determine_rate implementation.

This is a bit odd, since set_parent() is there to, as its name implies,
change the parent of a clock. However, the most likely candidates to
trigger that parent change are either the assigned-clock-parents device
tree property or a call to clk_set_rate(), with determine_rate()
figuring out which parent is the best suited for a given rate.

The other trigger would be a call to clk_set_parent(), but it's far less
used, and it doesn't look like there's any obvious user for that clock.

Similarly, it doesn't look like the device tree using that clock driver
uses any of the assigned-clock properties on that clock.

So, the set_parent hook is effectively unused, possibly because of an
oversight. However, it could also be an explicit decision by the
original author to avoid any reparenting but through an explicit call to
clk_set_parent().

The latter case would be equivalent to setting the determine_rate
implementation to clk_hw_determine_rate_no_reparent(). Indeed, if no
determine_rate implementation is provided, clk_round_rate() (through
clk_core_round_rate_nolock()) will call itself on the parent if
CLK_SET_RATE_PARENT is set, and will not change the clock rate
otherwise.

And if it was an oversight, then we are at least explicit about our
behavior now and it can be further refined down the line.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
2023-10-30 15:56:26 +08:00
Liu Ying
430015db3d mxc: IPU3: Forward IPUv3 common driver from imx_4.19.y kernel
This patch forwards IPUv3 common driver from imx_4.19.y kernel.
This includs IPUv3 common, IPUv3 prefetch engine and VDOA support.

Reviewed-by: Sandor Yu <Sandor.yu@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
[ Aisheng: squash legacy patches ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
[ Liu Ying: Use platform_get_irq() to get vdoa irq, not platform_get_resource() ]
[ Liu Ying: Check bypass_reset to do internal reset in ipu_probe() ]
Signed-off-by: Liu Ying <victor.liu@nxp.com>
[ Liu Ying: Set ipu->online to false if device_reset() fails ]
Signed-off-by: Liu Ying <victor.liu@nxp.com>
[ Liu Ying: Call dev_err_probe() if device_reset() fails in ipu_probe() ]
Signed-off-by: Liu Ying <victor.liu@nxp.com>
[ Robby Cai: Update class_create() api ]
Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:56:26 +08:00