media: ipu3-cio2: Serialise access to pad format
Pad format can be accessed from user space. Serialise access to it.
Fixes: c2a6a07afe
("media: intel-ipu3: cio2: add new MIPI-CSI2 driver")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: stable@vger.kernel.org # v4.16 and up
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Родитель
8160e86702
Коммит
55a6c6b2be
|
@ -1233,11 +1233,15 @@ static int cio2_subdev_get_fmt(struct v4l2_subdev *sd,
|
||||||
{
|
{
|
||||||
struct cio2_queue *q = container_of(sd, struct cio2_queue, subdev);
|
struct cio2_queue *q = container_of(sd, struct cio2_queue, subdev);
|
||||||
|
|
||||||
|
mutex_lock(&q->subdev_lock);
|
||||||
|
|
||||||
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
|
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
|
||||||
fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
|
fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
|
||||||
else
|
else
|
||||||
fmt->format = q->subdev_fmt;
|
fmt->format = q->subdev_fmt;
|
||||||
|
|
||||||
|
mutex_unlock(&q->subdev_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1261,6 +1265,8 @@ static int cio2_subdev_set_fmt(struct v4l2_subdev *sd,
|
||||||
if (fmt->pad == CIO2_PAD_SOURCE)
|
if (fmt->pad == CIO2_PAD_SOURCE)
|
||||||
return cio2_subdev_get_fmt(sd, cfg, fmt);
|
return cio2_subdev_get_fmt(sd, cfg, fmt);
|
||||||
|
|
||||||
|
mutex_lock(&q->subdev_lock);
|
||||||
|
|
||||||
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
|
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||||
*v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format;
|
*v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1271,6 +1277,8 @@ static int cio2_subdev_set_fmt(struct v4l2_subdev *sd,
|
||||||
fmt->format = q->subdev_fmt;
|
fmt->format = q->subdev_fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_unlock(&q->subdev_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1529,6 +1537,7 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q)
|
||||||
|
|
||||||
/* Initialize miscellaneous variables */
|
/* Initialize miscellaneous variables */
|
||||||
mutex_init(&q->lock);
|
mutex_init(&q->lock);
|
||||||
|
mutex_init(&q->subdev_lock);
|
||||||
|
|
||||||
/* Initialize formats to default values */
|
/* Initialize formats to default values */
|
||||||
fmt = &q->subdev_fmt;
|
fmt = &q->subdev_fmt;
|
||||||
|
@ -1645,6 +1654,7 @@ fail_vdev_media_entity:
|
||||||
fail_subdev_media_entity:
|
fail_subdev_media_entity:
|
||||||
cio2_fbpt_exit(q, &cio2->pci_dev->dev);
|
cio2_fbpt_exit(q, &cio2->pci_dev->dev);
|
||||||
fail_fbpt:
|
fail_fbpt:
|
||||||
|
mutex_destroy(&q->subdev_lock);
|
||||||
mutex_destroy(&q->lock);
|
mutex_destroy(&q->lock);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
@ -1657,6 +1667,7 @@ static void cio2_queue_exit(struct cio2_device *cio2, struct cio2_queue *q)
|
||||||
v4l2_device_unregister_subdev(&q->subdev);
|
v4l2_device_unregister_subdev(&q->subdev);
|
||||||
media_entity_cleanup(&q->subdev.entity);
|
media_entity_cleanup(&q->subdev.entity);
|
||||||
cio2_fbpt_exit(q, &cio2->pci_dev->dev);
|
cio2_fbpt_exit(q, &cio2->pci_dev->dev);
|
||||||
|
mutex_destroy(&q->subdev_lock);
|
||||||
mutex_destroy(&q->lock);
|
mutex_destroy(&q->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -335,6 +335,7 @@ struct cio2_queue {
|
||||||
|
|
||||||
/* Subdev, /dev/v4l-subdevX */
|
/* Subdev, /dev/v4l-subdevX */
|
||||||
struct v4l2_subdev subdev;
|
struct v4l2_subdev subdev;
|
||||||
|
struct mutex subdev_lock; /* Serialise acces to subdev_fmt field */
|
||||||
struct media_pad subdev_pads[CIO2_PADS];
|
struct media_pad subdev_pads[CIO2_PADS];
|
||||||
struct v4l2_mbus_framefmt subdev_fmt;
|
struct v4l2_mbus_framefmt subdev_fmt;
|
||||||
atomic_t frame_sequence;
|
atomic_t frame_sequence;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче