MLK-21459: mxc-jpeg: Jpeg encoder/decoder multi-instance crash
authorMirela Rabulea <mirela.rabulea@nxp.com>
Tue, 16 Apr 2019 14:36:28 +0000 (17:36 +0300)
committerLeonard Crestez <leonard.crestez@nxp.com>
Thu, 18 Apr 2019 00:00:38 +0000 (03:00 +0300)
commitdbd18f067e1b38dc43a04c592116b1956bf92da3
tree52215735ee7dde1eded1072e9e60cd526ad9dab0
parent593c9ed0e377b43ea1f77984a36172986d7d8f18
MLK-21459: mxc-jpeg: Jpeg encoder/decoder multi-instance crash

Reserve a slot for each context and allocate the slot data at open,
deallocate slot data at release and free that slot.
The device was already holding the array of slots.
The maximum number of slots allowed per device is currently limited to 1
for encoder and 1 for decoder, but the hardware supports 4+4.
Use GFP_ATOMIC for dma_zalloc_coherent, as we are holding a lock.

Also fix potential decoder bug when stm_ctrl is not properly cleared before
setting a new image format. This could be observed when decoding an
yuv420 image (img_fmt=0000b) after an yuv444 image (0011b), but only if
the descriptor is being reused.

Removed some debug logs and updated a comment.

Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Robert Chiras <robert.chiras@nxp.com>
drivers/media/platform/imx8/mxc-jpeg.c
drivers/media/platform/imx8/mxc-jpeg.h