Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: imx7_mipi_csis: fix racy entity pads init

Setting the media entity pads after the async register subdev can be
racy with probe complete callback. So, make sure that the media pads
are initialized before the probe complete is called.

For that move the media entity pads initialization to the registered
subdev internal operation.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

authored by

Rui Miguel Silva and committed by
Mauro Carvalho Chehab
03006bd0 6002e0be

+16 -8
+16 -8
drivers/staging/media/imx/imx7-mipi-csis.c
··· 784 784 return IRQ_HANDLED; 785 785 } 786 786 787 + static int mipi_csis_registered(struct v4l2_subdev *mipi_sd) 788 + { 789 + struct csi_state *state = mipi_sd_to_csis_state(mipi_sd); 790 + 791 + state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK; 792 + state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; 793 + 794 + return media_entity_pads_init(&state->mipi_sd.entity, CSIS_PADS_NUM, 795 + state->pads); 796 + } 797 + 787 798 static const struct v4l2_subdev_core_ops mipi_csis_core_ops = { 788 799 .log_status = mipi_csis_log_status, 789 800 }; ··· 818 807 .core = &mipi_csis_core_ops, 819 808 .video = &mipi_csis_video_ops, 820 809 .pad = &mipi_csis_pad_ops, 810 + }; 811 + 812 + static const struct v4l2_subdev_internal_ops mipi_csis_internal_ops = { 813 + .registered = mipi_csis_registered, 821 814 }; 822 815 823 816 static int mipi_csis_parse_dt(struct platform_device *pdev, ··· 884 869 885 870 mipi_sd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; 886 871 mipi_sd->entity.ops = &mipi_csis_entity_ops; 872 + mipi_sd->internal_ops = &mipi_csis_internal_ops; 887 873 888 874 mipi_sd->dev = &pdev->dev; 889 875 ··· 1006 990 if (ret < 0) 1007 991 goto disable_clock; 1008 992 1009 - state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK; 1010 - state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; 1011 - ret = media_entity_pads_init(&state->mipi_sd.entity, CSIS_PADS_NUM, 1012 - state->pads); 1013 - if (ret < 0) 1014 - goto unregister_subdev; 1015 - 1016 993 memcpy(state->events, mipi_csis_events, sizeof(state->events)); 1017 994 1018 995 mipi_csis_debugfs_init(state); ··· 1025 1016 unregister_all: 1026 1017 mipi_csis_debugfs_exit(state); 1027 1018 media_entity_cleanup(&state->mipi_sd.entity); 1028 - unregister_subdev: 1029 1019 v4l2_async_unregister_subdev(&state->mipi_sd); 1030 1020 disable_clock: 1031 1021 mipi_csis_clk_disable(state);