Commit 03006bd0 authored by Rui Miguel Silva's avatar Rui Miguel Silva Committed by Mauro Carvalho Chehab

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: default avatarRui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 6002e0be
...@@ -784,6 +784,17 @@ static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id) ...@@ -784,6 +784,17 @@ static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int mipi_csis_registered(struct v4l2_subdev *mipi_sd)
{
struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
return media_entity_pads_init(&state->mipi_sd.entity, CSIS_PADS_NUM,
state->pads);
}
static const struct v4l2_subdev_core_ops mipi_csis_core_ops = { static const struct v4l2_subdev_core_ops mipi_csis_core_ops = {
.log_status = mipi_csis_log_status, .log_status = mipi_csis_log_status,
}; };
...@@ -809,6 +820,10 @@ static const struct v4l2_subdev_ops mipi_csis_subdev_ops = { ...@@ -809,6 +820,10 @@ static const struct v4l2_subdev_ops mipi_csis_subdev_ops = {
.pad = &mipi_csis_pad_ops, .pad = &mipi_csis_pad_ops,
}; };
static const struct v4l2_subdev_internal_ops mipi_csis_internal_ops = {
.registered = mipi_csis_registered,
};
static int mipi_csis_parse_dt(struct platform_device *pdev, static int mipi_csis_parse_dt(struct platform_device *pdev,
struct csi_state *state) struct csi_state *state)
{ {
...@@ -869,6 +884,7 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, ...@@ -869,6 +884,7 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd,
mipi_sd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; mipi_sd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
mipi_sd->entity.ops = &mipi_csis_entity_ops; mipi_sd->entity.ops = &mipi_csis_entity_ops;
mipi_sd->internal_ops = &mipi_csis_internal_ops;
mipi_sd->dev = &pdev->dev; mipi_sd->dev = &pdev->dev;
...@@ -990,13 +1006,6 @@ static int mipi_csis_probe(struct platform_device *pdev) ...@@ -990,13 +1006,6 @@ static int mipi_csis_probe(struct platform_device *pdev)
if (ret < 0) if (ret < 0)
goto disable_clock; goto disable_clock;
state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
ret = media_entity_pads_init(&state->mipi_sd.entity, CSIS_PADS_NUM,
state->pads);
if (ret < 0)
goto unregister_subdev;
memcpy(state->events, mipi_csis_events, sizeof(state->events)); memcpy(state->events, mipi_csis_events, sizeof(state->events));
mipi_csis_debugfs_init(state); mipi_csis_debugfs_init(state);
...@@ -1016,7 +1025,6 @@ static int mipi_csis_probe(struct platform_device *pdev) ...@@ -1016,7 +1025,6 @@ static int mipi_csis_probe(struct platform_device *pdev)
unregister_all: unregister_all:
mipi_csis_debugfs_exit(state); mipi_csis_debugfs_exit(state);
media_entity_cleanup(&state->mipi_sd.entity); media_entity_cleanup(&state->mipi_sd.entity);
unregister_subdev:
v4l2_async_unregister_subdev(&state->mipi_sd); v4l2_async_unregister_subdev(&state->mipi_sd);
disable_clock: disable_clock:
mipi_csis_clk_disable(state); mipi_csis_clk_disable(state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment