summaryrefslogtreecommitdiff
path: root/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2022-04-12 12:42:46 +0300
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-04-24 10:21:45 +0300
commited647ea668fb27cd21408d5cb7cc7d4c30417332 (patch)
tree9b6dde41a38e471f42d0acb005ec67723083743c /drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
parent3cc7a4bbc3817ed79fc66122eb7cfbbc9b2ed17d (diff)
downloadlinux-ed647ea668fb27cd21408d5cb7cc7d4c30417332.tar.xz
media: subdev: add subdev state locking
The V4L2 subdevs have managed without centralized locking for the state (previously pad_config), as the try-state is supposedly safe (although I believe two TRY ioctls for the same fd would race), and the active-state, and its locking, is managed by the drivers internally. We now have active-state in a centralized position, and need locking. Strictly speaking the locking is only needed for new drivers that use the new state, as the current drivers continue behaving as they used to. However, active-state locking is complicated by the fact that currently the real active-state of a subdev is split into multiple parts: the new v4l2_subdev_state, subdev control state, and subdev's internal state. In the future all these three states should be combined into one state (the v4l2_subdev_state), and then a single lock for the state should be sufficient. But to solve the current split-state situation we need to share locks between the three states. This is accomplished by using the same lock management as the control handler does: we use a pointer to a mutex, allowing the driver to override the default mutex. Thus the driver can do e.g.: sd->state_lock = sd->ctrl_handler->lock; before calling v4l2_subdev_init_finalize(), resulting in sharing the same lock between the states and the controls. The locking model for active-state is such that any subdev op that gets the state as a parameter expects the state to be already locked by the caller, and expects the caller to release the lock. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c')
-rw-r--r--drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
index 87c76d439b12..2e2aa9d746ee 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
@@ -255,6 +255,7 @@ static int rvin_try_format(struct rvin_dev *vin, u32 which,
{
struct v4l2_subdev *sd = vin_to_source(vin);
struct v4l2_subdev_state *sd_state;
+ static struct lock_class_key key;
struct v4l2_subdev_format format = {
.which = which,
.pad = vin->parallel.source_pad,
@@ -267,7 +268,7 @@ static int rvin_try_format(struct rvin_dev *vin, u32 which,
* FIXME: Drop this call, drivers are not supposed to use
* __v4l2_subdev_state_alloc().
*/
- sd_state = __v4l2_subdev_state_alloc(sd);
+ sd_state = __v4l2_subdev_state_alloc(sd, "rvin:state->lock", &key);
if (IS_ERR(sd_state))
return PTR_ERR(sd_state);