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

media: media-request: EPERM -> EACCES/EBUSY

If requests are not supported by the driver, then return EACCES, not
EPERM.

If you attempt to mix queueing buffers directly and using requests,
then EBUSY is returned instead of EPERM: once a specific queueing mode
has been chosen the queue is 'busy' if you attempt the other mode
(i.e. direct queueing vs via a request).

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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
15cd442e ffda0b4c

+32 -29
+4 -5
Documentation/media/uapi/mediactl/media-request-ioc-queue.rst
··· 49 49 the application to stop streaming to reset the hardware state. 50 50 51 51 It is not allowed to mix queuing requests with queuing buffers directly 52 - (without a request). ``EPERM`` will be returned if the first buffer was 52 + (without a request). ``EBUSY`` will be returned if the first buffer was 53 53 queued directly and you next try to queue a request, or vice versa. 54 54 55 55 A request must contain at least one buffer, otherwise this ioctl will ··· 63 63 :ref:`Generic Error Codes <gen-errors>` chapter. 64 64 65 65 EBUSY 66 - The request was already queued. 67 - EPERM 68 - The application queued the first buffer directly, but later attempted 69 - to use a request. It is not permitted to mix the two APIs. 66 + The request was already queued or the application queued the first 67 + buffer directly, but later attempted to use a request. It is not permitted 68 + to mix the two APIs. 70 69 ENOENT 71 70 The request did not contain any buffers. All requests are required 72 71 to have at least one buffer. This can also be returned if required
+2 -2
Documentation/media/uapi/mediactl/request-api.rst
··· 64 64 .. caution:: 65 65 For :ref:`memory-to-memory devices <codec>` you can use requests only for 66 66 output buffers, not for capture buffers. Attempting to add a capture buffer 67 - to a request will result in an ``EPERM`` error. 67 + to a request will result in an ``EACCES`` error. 68 68 69 69 If the request contains parameters for multiple entities, individual drivers may 70 70 synchronize so the requested pipeline's topology is applied before the buffers ··· 77 77 whichever method is used first locks this in place until 78 78 :ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>` is called or the device is 79 79 :ref:`closed <func-close>`. Attempts to directly queue a buffer when earlier 80 - a buffer was queued via a request or vice versa will result in an ``EPERM`` 80 + a buffer was queued via a request or vice versa will result in an ``EBUSY`` 81 81 error. 82 82 83 83 Controls can still be set without a request and are applied immediately,
+1 -1
Documentation/media/uapi/v4l/buffer.rst
··· 314 314 :ref:`ioctl VIDIOC_QBUF <VIDIOC_QBUF>` and ignored by other ioctls. 315 315 Applications should not set ``V4L2_BUF_FLAG_REQUEST_FD`` for any ioctls 316 316 other than :ref:`VIDIOC_QBUF <VIDIOC_QBUF>`. 317 - If the device does not support requests, then ``EPERM`` will be returned. 317 + If the device does not support requests, then ``EACCES`` will be returned. 318 318 If requests are supported but an invalid request file descriptor is 319 319 given, then ``EINVAL`` will be returned. 320 320
+4 -5
Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst
··· 100 100 then the controls are not applied immediately when calling 101 101 :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, but instead are applied by 102 102 the driver for the buffer associated with the same request. 103 - If the device does not support requests, then ``EPERM`` will be returned. 103 + If the device does not support requests, then ``EACCES`` will be returned. 104 104 If requests are supported but an invalid request file descriptor is given, 105 105 then ``EINVAL`` will be returned. 106 106 ··· 233 233 these controls have to be retrieved from a request or tried/set for 234 234 a request. In the latter case the ``request_fd`` field contains the 235 235 file descriptor of the request that should be used. If the device 236 - does not support requests, then ``EPERM`` will be returned. 236 + does not support requests, then ``EACCES`` will be returned. 237 237 238 238 .. note:: 239 239 ··· 299 299 - ``request_fd`` 300 300 - File descriptor of the request to be used by this operation. Only 301 301 valid if ``which`` is set to ``V4L2_CTRL_WHICH_REQUEST_VAL``. 302 - If the device does not support requests, then ``EPERM`` will be returned. 302 + If the device does not support requests, then ``EACCES`` will be returned. 303 303 If requests are supported but an invalid request file descriptor is 304 304 given, then ``EINVAL`` will be returned. 305 305 * - __u32 ··· 408 408 control, or to get a control from a request that has not yet been 409 409 completed. 410 410 411 - EPERM 412 - The ``which`` field was set to ``V4L2_CTRL_WHICH_REQUEST_VAL`` but the 411 + Or the ``which`` field was set to ``V4L2_CTRL_WHICH_REQUEST_VAL`` but the 413 412 device does not support requests.
+10 -8
Documentation/media/uapi/v4l/vidioc-qbuf.rst
··· 104 104 until the request itself is queued. Also, the driver will apply any 105 105 settings associated with the request for this buffer. This field will 106 106 be ignored unless the ``V4L2_BUF_FLAG_REQUEST_FD`` flag is set. 107 - If the device does not support requests, then ``EPERM`` will be returned. 107 + If the device does not support requests, then ``EACCES`` will be returned. 108 108 If requests are supported but an invalid request file descriptor is given, 109 109 then ``EINVAL`` will be returned. 110 110 111 111 .. caution:: 112 112 It is not allowed to mix queuing requests with queuing buffers directly. 113 - ``EPERM`` will be returned if the first buffer was queued directly and 113 + ``EBUSY`` will be returned if the first buffer was queued directly and 114 114 then the application tries to queue a request, or vice versa. 115 115 116 116 For :ref:`memory-to-memory devices <codec>` you can specify the 117 117 ``request_fd`` only for output buffers, not for capture buffers. Attempting 118 - to specify this for a capture buffer will result in an ``EPERM`` error. 118 + to specify this for a capture buffer will result in an ``EACCES`` error. 119 119 120 120 Applications call the ``VIDIOC_DQBUF`` ioctl to dequeue a filled 121 121 (capturing) or displayed (output) buffer from the driver's outgoing ··· 175 175 codecs if a buffer with the ``V4L2_BUF_FLAG_LAST`` was already 176 176 dequeued and no new buffers are expected to become available. 177 177 178 - EPERM 178 + EACCES 179 179 The ``V4L2_BUF_FLAG_REQUEST_FD`` flag was set but the device does not 180 - support requests. Or the first buffer was queued via a request, but 181 - the application now tries to queue it directly, or vice versa (it is 182 - not permitted to mix the two APIs). Or an attempt is made to queue a 183 - CAPTURE buffer to a request for a :ref:`memory-to-memory device <codec>`. 180 + support requests for the given buffer type. 181 + 182 + EBUSY 183 + The first buffer was queued via a request, but the application now tries 184 + to queue it directly, or vice versa (it is not permitted to mix the two 185 + APIs).
+1 -1
drivers/media/common/videobuf2/videobuf2-core.c
··· 1495 1495 (!req && vb->state != VB2_BUF_STATE_IN_REQUEST && 1496 1496 q->uses_requests)) { 1497 1497 dprintk(1, "queue in wrong mode (qbuf vs requests)\n"); 1498 - return -EPERM; 1498 + return -EBUSY; 1499 1499 } 1500 1500 1501 1501 if (req) {
+6 -3
drivers/media/common/videobuf2/videobuf2-v4l2.c
··· 381 381 if (!(b->flags & V4L2_BUF_FLAG_REQUEST_FD)) { 382 382 if (q->uses_requests) { 383 383 dprintk(1, "%s: queue uses requests\n", opname); 384 - return -EPERM; 384 + return -EBUSY; 385 385 } 386 386 return 0; 387 - } else if (q->uses_qbuf || !q->supports_requests) { 387 + } else if (!q->supports_requests) { 388 + dprintk(1, "%s: queue does not support requests\n", opname); 389 + return -EACCES; 390 + } else if (q->uses_qbuf) { 388 391 dprintk(1, "%s: queue does not use requests\n", opname); 389 - return -EPERM; 392 + return -EBUSY; 390 393 } 391 394 392 395 /*
+2 -2
drivers/media/media-request.c
··· 249 249 250 250 if (!mdev || !mdev->ops || 251 251 !mdev->ops->req_validate || !mdev->ops->req_queue) 252 - return ERR_PTR(-EPERM); 252 + return ERR_PTR(-EACCES); 253 253 254 254 filp = fget(request_fd); 255 255 if (!filp) ··· 405 405 int ret = -EBUSY; 406 406 407 407 if (WARN_ON(!ops->release)) 408 - return -EPERM; 408 + return -EACCES; 409 409 410 410 spin_lock_irqsave(&req->lock, flags); 411 411
+2 -2
include/media/media-request.h
··· 198 198 * Get the request represented by @request_fd that is owned 199 199 * by the media device. 200 200 * 201 - * Return a -EPERM error pointer if requests are not supported 201 + * Return a -EACCES error pointer if requests are not supported 202 202 * by this driver. Return -EINVAL if the request was not found. 203 203 * Return the pointer to the request if found: the caller will 204 204 * have to call @media_request_put when it finished using the ··· 231 231 static inline struct media_request * 232 232 media_request_get_by_fd(struct media_device *mdev, int request_fd) 233 233 { 234 - return ERR_PTR(-EPERM); 234 + return ERR_PTR(-EACCES); 235 235 } 236 236 237 237 #endif