Lines Matching full:req

39 static void media_request_clean(struct media_request *req)  in media_request_clean()  argument
44 WARN_ON(req->state != MEDIA_REQUEST_STATE_CLEANING); in media_request_clean()
45 WARN_ON(req->updating_count); in media_request_clean()
46 WARN_ON(req->access_count); in media_request_clean()
48 list_for_each_entry_safe(obj, obj_safe, &req->objects, list) { in media_request_clean()
53 req->updating_count = 0; in media_request_clean()
54 req->access_count = 0; in media_request_clean()
55 WARN_ON(req->num_incomplete_objects); in media_request_clean()
56 req->num_incomplete_objects = 0; in media_request_clean()
57 wake_up_interruptible_all(&req->poll_wait); in media_request_clean()
62 struct media_request *req = in media_request_release() local
64 struct media_device *mdev = req->mdev; in media_request_release()
66 dev_dbg(mdev->dev, "request: release %s\n", req->debug_str); in media_request_release()
69 req->state = MEDIA_REQUEST_STATE_CLEANING; in media_request_release()
71 media_request_clean(req); in media_request_release()
74 mdev->ops->req_free(req); in media_request_release()
76 kfree(req); in media_request_release()
79 void media_request_put(struct media_request *req) in media_request_put() argument
81 kref_put(&req->kref, media_request_release); in media_request_put()
87 struct media_request *req = filp->private_data; in media_request_close() local
89 media_request_put(req); in media_request_close()
96 struct media_request *req = filp->private_data; in media_request_poll() local
103 poll_wait(filp, &req->poll_wait, wait); in media_request_poll()
104 spin_lock_irqsave(&req->lock, flags); in media_request_poll()
105 if (req->state == MEDIA_REQUEST_STATE_COMPLETE) { in media_request_poll()
109 if (req->state != MEDIA_REQUEST_STATE_QUEUED) { in media_request_poll()
115 spin_unlock_irqrestore(&req->lock, flags); in media_request_poll()
119 static long media_request_ioctl_queue(struct media_request *req) in media_request_ioctl_queue() argument
121 struct media_device *mdev = req->mdev; in media_request_ioctl_queue()
126 dev_dbg(mdev->dev, "request: queue %s\n", req->debug_str); in media_request_ioctl_queue()
136 media_request_get(req); in media_request_ioctl_queue()
138 spin_lock_irqsave(&req->lock, flags); in media_request_ioctl_queue()
139 if (req->state == MEDIA_REQUEST_STATE_IDLE) in media_request_ioctl_queue()
140 req->state = MEDIA_REQUEST_STATE_VALIDATING; in media_request_ioctl_queue()
141 state = req->state; in media_request_ioctl_queue()
142 spin_unlock_irqrestore(&req->lock, flags); in media_request_ioctl_queue()
146 req->debug_str, media_request_state_str(state)); in media_request_ioctl_queue()
147 media_request_put(req); in media_request_ioctl_queue()
152 ret = mdev->ops->req_validate(req); in media_request_ioctl_queue()
169 spin_lock_irqsave(&req->lock, flags); in media_request_ioctl_queue()
170 req->state = ret ? MEDIA_REQUEST_STATE_IDLE in media_request_ioctl_queue()
172 spin_unlock_irqrestore(&req->lock, flags); in media_request_ioctl_queue()
175 mdev->ops->req_queue(req); in media_request_ioctl_queue()
181 req->debug_str, ret); in media_request_ioctl_queue()
182 media_request_put(req); in media_request_ioctl_queue()
188 static long media_request_ioctl_reinit(struct media_request *req) in media_request_ioctl_reinit() argument
190 struct media_device *mdev = req->mdev; in media_request_ioctl_reinit()
193 spin_lock_irqsave(&req->lock, flags); in media_request_ioctl_reinit()
194 if (req->state != MEDIA_REQUEST_STATE_IDLE && in media_request_ioctl_reinit()
195 req->state != MEDIA_REQUEST_STATE_COMPLETE) { in media_request_ioctl_reinit()
198 req->debug_str); in media_request_ioctl_reinit()
199 spin_unlock_irqrestore(&req->lock, flags); in media_request_ioctl_reinit()
202 if (req->access_count) { in media_request_ioctl_reinit()
205 req->debug_str); in media_request_ioctl_reinit()
206 spin_unlock_irqrestore(&req->lock, flags); in media_request_ioctl_reinit()
209 req->state = MEDIA_REQUEST_STATE_CLEANING; in media_request_ioctl_reinit()
210 spin_unlock_irqrestore(&req->lock, flags); in media_request_ioctl_reinit()
212 media_request_clean(req); in media_request_ioctl_reinit()
214 spin_lock_irqsave(&req->lock, flags); in media_request_ioctl_reinit()
215 req->state = MEDIA_REQUEST_STATE_IDLE; in media_request_ioctl_reinit()
216 spin_unlock_irqrestore(&req->lock, flags); in media_request_ioctl_reinit()
224 struct media_request *req = filp->private_data; in media_request_ioctl() local
228 return media_request_ioctl_queue(req); in media_request_ioctl()
230 return media_request_ioctl_reinit(req); in media_request_ioctl()
250 struct media_request *req; in media_request_get_by_fd() local
262 req = fd_file(f)->private_data; in media_request_get_by_fd()
263 if (req->mdev != mdev) in media_request_get_by_fd()
274 media_request_get(req); in media_request_get_by_fd()
277 return req; in media_request_get_by_fd()
290 struct media_request *req; in media_request_alloc() local
300 req = mdev->ops->req_alloc(mdev); in media_request_alloc()
302 req = kzalloc(sizeof(*req), GFP_KERNEL); in media_request_alloc()
303 if (!req) in media_request_alloc()
318 filp->private_data = req; in media_request_alloc()
319 req->mdev = mdev; in media_request_alloc()
320 req->state = MEDIA_REQUEST_STATE_IDLE; in media_request_alloc()
321 req->num_incomplete_objects = 0; in media_request_alloc()
322 kref_init(&req->kref); in media_request_alloc()
323 INIT_LIST_HEAD(&req->objects); in media_request_alloc()
324 spin_lock_init(&req->lock); in media_request_alloc()
325 init_waitqueue_head(&req->poll_wait); in media_request_alloc()
326 req->updating_count = 0; in media_request_alloc()
327 req->access_count = 0; in media_request_alloc()
331 snprintf(req->debug_str, sizeof(req->debug_str), "%u:%d", in media_request_alloc()
333 dev_dbg(mdev->dev, "request: allocated %s\n", req->debug_str); in media_request_alloc()
344 mdev->ops->req_free(req); in media_request_alloc()
346 kfree(req); in media_request_alloc()
355 struct media_request *req = obj->req; in media_request_object_release() local
357 if (WARN_ON(req)) in media_request_object_release()
363 media_request_object_find(struct media_request *req, in media_request_object_find() argument
374 spin_lock_irqsave(&req->lock, flags); in media_request_object_find()
375 list_for_each_entry(obj, &req->objects, list) { in media_request_object_find()
382 spin_unlock_irqrestore(&req->lock, flags); in media_request_object_find()
396 obj->req = NULL; in media_request_object_init()
404 int media_request_object_bind(struct media_request *req, in media_request_object_bind() argument
415 spin_lock_irqsave(&req->lock, flags); in media_request_object_bind()
417 if (WARN_ON(req->state != MEDIA_REQUEST_STATE_UPDATING && in media_request_object_bind()
418 req->state != MEDIA_REQUEST_STATE_QUEUED)) in media_request_object_bind()
421 obj->req = req; in media_request_object_bind()
426 list_add_tail(&obj->list, &req->objects); in media_request_object_bind()
428 list_add(&obj->list, &req->objects); in media_request_object_bind()
429 req->num_incomplete_objects++; in media_request_object_bind()
433 spin_unlock_irqrestore(&req->lock, flags); in media_request_object_bind()
440 struct media_request *req = obj->req; in media_request_object_unbind() local
444 if (WARN_ON(!req)) in media_request_object_unbind()
447 spin_lock_irqsave(&req->lock, flags); in media_request_object_unbind()
449 obj->req = NULL; in media_request_object_unbind()
451 if (req->state == MEDIA_REQUEST_STATE_COMPLETE) in media_request_object_unbind()
454 if (WARN_ON(req->state == MEDIA_REQUEST_STATE_VALIDATING)) in media_request_object_unbind()
457 if (req->state == MEDIA_REQUEST_STATE_CLEANING) { in media_request_object_unbind()
459 req->num_incomplete_objects--; in media_request_object_unbind()
463 if (WARN_ON(!req->num_incomplete_objects)) in media_request_object_unbind()
466 req->num_incomplete_objects--; in media_request_object_unbind()
467 if (req->state == MEDIA_REQUEST_STATE_QUEUED && in media_request_object_unbind()
468 !req->num_incomplete_objects) { in media_request_object_unbind()
469 req->state = MEDIA_REQUEST_STATE_COMPLETE; in media_request_object_unbind()
471 wake_up_interruptible_all(&req->poll_wait); in media_request_object_unbind()
475 spin_unlock_irqrestore(&req->lock, flags); in media_request_object_unbind()
479 media_request_put(req); in media_request_object_unbind()
485 struct media_request *req = obj->req; in media_request_object_complete() local
489 spin_lock_irqsave(&req->lock, flags); in media_request_object_complete()
493 if (WARN_ON(!req->num_incomplete_objects) || in media_request_object_complete()
494 WARN_ON(req->state != MEDIA_REQUEST_STATE_QUEUED)) in media_request_object_complete()
497 if (!--req->num_incomplete_objects) { in media_request_object_complete()
498 req->state = MEDIA_REQUEST_STATE_COMPLETE; in media_request_object_complete()
499 wake_up_interruptible_all(&req->poll_wait); in media_request_object_complete()
503 spin_unlock_irqrestore(&req->lock, flags); in media_request_object_complete()
505 media_request_put(req); in media_request_object_complete()