summaryrefslogtreecommitdiff
path: root/drivers/media/media-request.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2018-08-27 18:10:38 +0300
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-09-11 16:53:31 +0300
commit6736f4e948817ca8385bdc6feb5475cdf1eb1ec8 (patch)
tree073eb0d6ce248e12b7fa74ca9f3e3941b9e5bc6e /drivers/media/media-request.c
parente5079cf11373e4cc98be8b1072aece429eb2d4d2 (diff)
downloadlinux-6736f4e948817ca8385bdc6feb5475cdf1eb1ec8.tar.xz
media: media-request: add media_request_(un)lock_for_access
Add helper functions to prevent a completed request from being re-inited while it is being accessed. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/media-request.c')
-rw-r--r--drivers/media/media-request.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/media/media-request.c b/drivers/media/media-request.c
index 4cee67e6657e..414197645e09 100644
--- a/drivers/media/media-request.c
+++ b/drivers/media/media-request.c
@@ -43,6 +43,7 @@ static void media_request_clean(struct media_request *req)
/* Just a sanity check. No other code path is allowed to change this. */
WARN_ON(req->state != MEDIA_REQUEST_STATE_CLEANING);
WARN_ON(req->updating_count);
+ WARN_ON(req->access_count);
list_for_each_entry_safe(obj, obj_safe, &req->objects, list) {
media_request_object_unbind(obj);
@@ -50,6 +51,7 @@ static void media_request_clean(struct media_request *req)
}
req->updating_count = 0;
+ req->access_count = 0;
WARN_ON(req->num_incomplete_objects);
req->num_incomplete_objects = 0;
wake_up_interruptible_all(&req->poll_wait);
@@ -198,6 +200,13 @@ static long media_request_ioctl_reinit(struct media_request *req)
spin_unlock_irqrestore(&req->lock, flags);
return -EBUSY;
}
+ if (req->access_count) {
+ dev_dbg(mdev->dev,
+ "request: %s is being accessed, cannot reinit\n",
+ req->debug_str);
+ spin_unlock_irqrestore(&req->lock, flags);
+ return -EBUSY;
+ }
req->state = MEDIA_REQUEST_STATE_CLEANING;
spin_unlock_irqrestore(&req->lock, flags);
@@ -313,6 +322,7 @@ int media_request_alloc(struct media_device *mdev, int *alloc_fd)
spin_lock_init(&req->lock);
init_waitqueue_head(&req->poll_wait);
req->updating_count = 0;
+ req->access_count = 0;
*alloc_fd = fd;