linux/drivers/media/platform
Bryan O'Donoghue 08b1cf474b media: venus: core, venc, vdec: Fix probe dependency error
Commit aaaa93eda6 ("media] media: venus: venc: add video encoder files")
is the last in a series of three commits to add core.c vdec.c and venc.c
adding core, encoder and decoder.

The encoder and decoder check for core drvdata as set and return -EPROBE_DEFER
if it has not been set, however both the encoder and decoder rely on
core.v4l2_dev as valid.

core.v4l2_dev will not be valid until v4l2_device_register() has completed
in core.c's probe().

Normally this is never seen however, Dmitry reported the following
backtrace when compiling drivers and firmware directly into a kernel image.

[    5.259968] Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
[    5.269850] sd 0:0:0:3: [sdd] Optimal transfer size 524288 bytes
[    5.275505] Workqueue: events deferred_probe_work_func
[    5.275513] pstate: 60400005 (nZCv daif +PAN -UAO -TCO BTYPE=--)
[    5.441211] usb 2-1: new SuperSpeedPlus Gen 2 USB device number 2 using xhci-hcd
[    5.442486] pc : refcount_warn_saturate+0x140/0x148
[    5.493756] hub 2-1:1.0: USB hub found
[    5.496266] lr : refcount_warn_saturate+0x140/0x148
[    5.500982] hub 2-1:1.0: 4 ports detected
[    5.503440] sp : ffff80001067b730
[    5.503442] x29: ffff80001067b730
[    5.592660] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[    5.598478] x28: ffff6c6bc1c379b8
[    5.598480] x27: ffffa5c673852960 x26: ffffa5c673852000
[    5.598484] x25: ffff6c6bc1c37800 x24: 0000000000000001
[    5.810652] x23: 0000000000000000 x22: ffffa5c673bc7118
[    5.813777] hub 1-1:1.0: USB hub found
[    5.816108] x21: ffffa5c674440000 x20: 0000000000000001
[    5.820846] hub 1-1:1.0: 4 ports detected
[    5.825415] x19: ffffa5c6744f4000 x18: ffffffffffffffff
[    5.825418] x17: 0000000000000000 x16: 0000000000000000
[    5.825421] x15: 00000a4810c193ba x14: 0000000000000000
[    5.825424] x13: 00000000000002b8 x12: 000000000000f20a
[    5.825427] x11: 000000000000f20a x10: 0000000000000038
[    5.845447] usb 2-1.1: new SuperSpeed Gen 1 USB device number 3 using xhci-hcd
[    5.845904]
[    5.845905] x9 : 0000000000000000 x8 : ffff6c6d36fae780
[    5.871208] x7 : ffff6c6d36faf240 x6 : 0000000000000000
[    5.876664] x5 : 0000000000000004 x4 : 0000000000000085
[    5.882121] x3 : 0000000000000119 x2 : ffffa5c6741ef478
[    5.887578] x1 : 3acbb3926faf5f00 x0 : 0000000000000000
[    5.893036] Call trace:
[    5.895551]  refcount_warn_saturate+0x140/0x148
[    5.900202]  __video_register_device+0x64c/0xd10
[    5.904944]  venc_probe+0xc4/0x148
[    5.908444]  platform_probe+0x68/0xe0
[    5.912210]  really_probe+0x118/0x3e0
[    5.915977]  driver_probe_device+0x5c/0xc0
[    5.920187]  __device_attach_driver+0x98/0xb8
[    5.924661]  bus_for_each_drv+0x68/0xd0
[    5.928604]  __device_attach+0xec/0x148
[    5.932547]  device_initial_probe+0x14/0x20
[    5.936845]  bus_probe_device+0x9c/0xa8
[    5.940788]  device_add+0x3e8/0x7c8
[    5.944376]  of_device_add+0x4c/0x60
[    5.948056]  of_platform_device_create_pdata+0xbc/0x140
[    5.953425]  of_platform_bus_create+0x17c/0x3c0
[    5.958078]  of_platform_populate+0x80/0x110
[    5.962463]  venus_probe+0x2ec/0x4d8
[    5.966143]  platform_probe+0x68/0xe0
[    5.969907]  really_probe+0x118/0x3e0
[    5.973674]  driver_probe_device+0x5c/0xc0
[    5.977882]  __device_attach_driver+0x98/0xb8
[    5.982356]  bus_for_each_drv+0x68/0xd0
[    5.986298]  __device_attach+0xec/0x148
[    5.990242]  device_initial_probe+0x14/0x20
[    5.994539]  bus_probe_device+0x9c/0xa8
[    5.998481]  deferred_probe_work_func+0x74/0xb0
[    6.003132]  process_one_work+0x1e8/0x360
[    6.007254]  worker_thread+0x208/0x478
[    6.011106]  kthread+0x150/0x158
[    6.014431]  ret_from_fork+0x10/0x30
[    6.018111] ---[ end trace f074246b1ecdb466 ]---

This patch fixes by

- Only setting drvdata after v4l2_device_register() completes
- Moving v4l2_device_register() so that suspend/reume in core::probe()
  stays as-is
- Changes pm_ops->core_function() to take struct venus_core not struct
  device
- Minimal rework of v4l2_device_*register in probe/remove

Reported-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-03-22 09:37:02 +01:00
..
allegro-dvt media: allegro: add support for HEVC encoding 2021-01-27 16:15:04 +01:00
am437x media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
atmel media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
cadence media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
coda media: coda: Convert the driver to DT-only 2020-12-03 07:37:59 +01:00
davinci media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
exynos-gsc media: Add V4L2_TYPE_IS_CAPTURE helper 2020-07-19 08:13:24 +02:00
exynos4-is media: fix incorrect kernel doc usages 2021-03-11 11:59:44 +01:00
marvell-ccic media: marvell-ccic: power up the device on mclk enable 2021-02-06 09:31:03 +01:00
meson/ge2d media: meson/ge2d: set ret to -ENOMEM 2021-01-27 08:32:16 +01:00
mtk-jpeg media: platform: add missing put_device() call in mtk_jpeg_probe() and mtk_jpeg_remove() 2020-11-16 10:31:16 +01:00
mtk-mdp media: mtk-mdp: Do not zero reserved fields 2021-01-27 13:18:29 +01:00
mtk-vcodec media: fix incorrect kernel doc usages 2021-03-11 11:59:44 +01:00
mtk-vpu media: fix incorrect kernel doc usages 2021-03-11 11:59:44 +01:00
omap media: videobuf2: Move frame_vector into media subsystem 2021-01-12 14:15:31 +01:00
omap3isp media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
qcom media: venus: core, venc, vdec: Fix probe dependency error 2021-03-22 09:37:02 +01:00
rcar-vin media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
rockchip media: rkisp1: rsz: crash fix when setting src format 2021-03-11 11:59:45 +01:00
s3c-camif media: s3c-camif: use semicolons rather than commas to separate statements 2020-11-16 10:31:06 +01:00
s5p-g2d media: s5p-g2d: Fix a memory leak in an error handling path in 'g2d_probe()' 2020-07-19 08:14:00 +02:00
s5p-jpeg media: s5p-jpeg: handle error condition in s5p_jpeg_probe 2020-12-03 07:45:49 +01:00
s5p-mfc media: s5p-mfc: Use display delay and display enable std controls 2021-03-22 09:09:03 +01:00
sti media: platform: sti: make a const arrays static, makes object smaller 2021-03-11 11:59:42 +01:00
stm32 media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
sunxi media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
ti-vpe media: ti-vpe: Simplify bool comparison 2021-03-11 11:59:44 +01:00
vsp1 media: fix incorrect kernel doc usages 2021-03-11 11:59:44 +01:00
xilinx media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
aspeed-video.c media: aspeed: fix clock handling logic 2021-03-11 11:59:45 +01:00
fsl-viu.c media: use getter/setter functions 2021-03-11 11:59:42 +01:00
imx-pxp.c
imx-pxp.h
Kconfig media: mtk: fix mtk-smi dependency 2021-03-11 11:59:43 +01:00
m2m-deinterlace.c
Makefile media: allegro: move driver out of staging 2021-01-04 13:19:40 +01:00
mx2_emmaprp.c media: mx2_emmaprp: Fix memleak in emmaprp_probe 2020-09-26 10:15:39 +02:00
pxa_camera.c media: use getter/setter functions 2021-03-11 11:59:42 +01:00
rcar-fcp.c media: platform: fcp: Fix a reference count leak. 2020-09-27 10:52:52 +02:00
rcar_drif.c media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00
rcar_fdp1.c media: fdp1: Do not zero reserved fields 2021-01-27 13:18:45 +01:00
rcar_jpu.c media: jpu: Do not zero reserved fields 2021-01-27 13:19:03 +01:00
renesas-ceu.c Devicetree updates for v5.12: 2021-02-22 10:05:12 -08:00
sh_vou.c media: sh_vou: Drop bogus __refdata annotation 2021-01-12 18:16:09 +01:00
via-camera.c
via-camera.h
video-mux.c media: v4l2-async: Improve v4l2_async_notifier_add_*_subdev() API 2021-02-06 09:18:53 +01:00