Lines Matching refs:pipe
218 static int goldfish_pipe_cmd_locked(struct goldfish_pipe *pipe, in goldfish_pipe_cmd_locked() argument
221 pipe->command_buffer->cmd = cmd; in goldfish_pipe_cmd_locked()
223 pipe->command_buffer->status = PIPE_ERROR_INVAL; in goldfish_pipe_cmd_locked()
224 writel(pipe->id, pipe->dev->base + PIPE_REG_CMD); in goldfish_pipe_cmd_locked()
225 return pipe->command_buffer->status; in goldfish_pipe_cmd_locked()
228 static int goldfish_pipe_cmd(struct goldfish_pipe *pipe, enum PipeCmdCode cmd) in goldfish_pipe_cmd() argument
232 if (mutex_lock_interruptible(&pipe->lock)) in goldfish_pipe_cmd()
234 status = goldfish_pipe_cmd_locked(pipe, cmd); in goldfish_pipe_cmd()
235 mutex_unlock(&pipe->lock); in goldfish_pipe_cmd()
325 static int transfer_max_buffers(struct goldfish_pipe *pipe, in transfer_max_buffers() argument
339 if (mutex_lock_interruptible(&pipe->lock)) in transfer_max_buffers()
344 pipe->pages, &iter_last_page_size); in transfer_max_buffers()
346 mutex_unlock(&pipe->lock); in transfer_max_buffers()
350 populate_rw_params(pipe->pages, pages_count, address, address_end, in transfer_max_buffers()
352 pipe->command_buffer); in transfer_max_buffers()
355 *status = goldfish_pipe_cmd_locked(pipe, in transfer_max_buffers()
358 *consumed_size = pipe->command_buffer->rw_params.consumed_size; in transfer_max_buffers()
360 unpin_user_pages_dirty_lock(pipe->pages, pages_count, in transfer_max_buffers()
363 mutex_unlock(&pipe->lock); in transfer_max_buffers()
367 static int wait_for_host_signal(struct goldfish_pipe *pipe, int is_write) in wait_for_host_signal() argument
371 set_bit(wake_bit, &pipe->flags); in wait_for_host_signal()
374 goldfish_pipe_cmd(pipe, in wait_for_host_signal()
377 while (test_bit(wake_bit, &pipe->flags)) { in wait_for_host_signal()
378 if (wait_event_interruptible(pipe->wake_queue, in wait_for_host_signal()
379 !test_bit(wake_bit, &pipe->flags))) in wait_for_host_signal()
382 if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags)) in wait_for_host_signal()
394 struct goldfish_pipe *pipe = filp->private_data; in goldfish_pipe_read_write() local
400 if (unlikely(test_bit(BIT_CLOSED_ON_HOST, &pipe->flags))) in goldfish_pipe_read_write()
418 ret = transfer_max_buffers(pipe, address, address_end, is_write, in goldfish_pipe_read_write()
446 dev_err_ratelimited(pipe->dev->pdev_dev, in goldfish_pipe_read_write()
462 status = wait_for_host_signal(pipe, is_write); in goldfish_pipe_read_write()
492 struct goldfish_pipe *pipe = filp->private_data; in goldfish_pipe_poll() local
496 poll_wait(filp, &pipe->wake_queue, wait); in goldfish_pipe_poll()
498 status = goldfish_pipe_cmd(pipe, PIPE_CMD_POLL); in goldfish_pipe_poll()
508 if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags)) in goldfish_pipe_poll()
517 struct goldfish_pipe *pipe; in signalled_pipes_add_locked() local
522 pipe = dev->pipes[id]; in signalled_pipes_add_locked()
523 if (!pipe) in signalled_pipes_add_locked()
525 pipe->signalled_flags |= flags; in signalled_pipes_add_locked()
527 if (pipe->prev_signalled || pipe->next_signalled || in signalled_pipes_add_locked()
528 dev->first_signalled_pipe == pipe) in signalled_pipes_add_locked()
530 pipe->next_signalled = dev->first_signalled_pipe; in signalled_pipes_add_locked()
532 dev->first_signalled_pipe->prev_signalled = pipe; in signalled_pipes_add_locked()
533 dev->first_signalled_pipe = pipe; in signalled_pipes_add_locked()
537 struct goldfish_pipe *pipe) in signalled_pipes_remove_locked() argument
539 if (pipe->prev_signalled) in signalled_pipes_remove_locked()
540 pipe->prev_signalled->next_signalled = pipe->next_signalled; in signalled_pipes_remove_locked()
541 if (pipe->next_signalled) in signalled_pipes_remove_locked()
542 pipe->next_signalled->prev_signalled = pipe->prev_signalled; in signalled_pipes_remove_locked()
543 if (pipe == dev->first_signalled_pipe) in signalled_pipes_remove_locked()
544 dev->first_signalled_pipe = pipe->next_signalled; in signalled_pipes_remove_locked()
545 pipe->prev_signalled = NULL; in signalled_pipes_remove_locked()
546 pipe->next_signalled = NULL; in signalled_pipes_remove_locked()
552 struct goldfish_pipe *pipe; in signalled_pipes_pop_front() local
557 pipe = dev->first_signalled_pipe; in signalled_pipes_pop_front()
558 if (pipe) { in signalled_pipes_pop_front()
559 *wakes = pipe->signalled_flags; in signalled_pipes_pop_front()
560 pipe->signalled_flags = 0; in signalled_pipes_pop_front()
567 dev->first_signalled_pipe = pipe->next_signalled; in signalled_pipes_pop_front()
570 pipe->next_signalled = NULL; in signalled_pipes_pop_front()
574 return pipe; in signalled_pipes_pop_front()
581 struct goldfish_pipe *pipe; in goldfish_interrupt_task() local
584 while ((pipe = signalled_pipes_pop_front(dev, &wakes)) != NULL) { in goldfish_interrupt_task()
586 pipe->flags = 1 << BIT_CLOSED_ON_HOST; in goldfish_interrupt_task()
589 clear_bit(BIT_WAKE_ON_READ, &pipe->flags); in goldfish_interrupt_task()
591 clear_bit(BIT_WAKE_ON_WRITE, &pipe->flags); in goldfish_interrupt_task()
597 wake_up_interruptible(&pipe->wake_queue); in goldfish_interrupt_task()
703 struct goldfish_pipe *pipe = kzalloc(sizeof(*pipe), GFP_KERNEL); in goldfish_pipe_open() local
705 if (!pipe) in goldfish_pipe_open()
708 pipe->dev = dev; in goldfish_pipe_open()
709 mutex_init(&pipe->lock); in goldfish_pipe_open()
710 init_waitqueue_head(&pipe->wake_queue); in goldfish_pipe_open()
717 pipe->command_buffer = in goldfish_pipe_open()
719 if (!pipe->command_buffer) { in goldfish_pipe_open()
732 dev->pipes[id] = pipe; in goldfish_pipe_open()
733 pipe->id = id; in goldfish_pipe_open()
734 pipe->command_buffer->id = id; in goldfish_pipe_open()
740 (u64)(unsigned long)__pa(pipe->command_buffer); in goldfish_pipe_open()
741 status = goldfish_pipe_cmd_locked(pipe, PIPE_CMD_OPEN); in goldfish_pipe_open()
746 file->private_data = pipe; in goldfish_pipe_open()
754 free_page((unsigned long)pipe->command_buffer); in goldfish_pipe_open()
756 kfree(pipe); in goldfish_pipe_open()
763 struct goldfish_pipe *pipe = filp->private_data; in goldfish_pipe_release() local
764 struct goldfish_pipe_dev *dev = pipe->dev; in goldfish_pipe_release()
767 goldfish_pipe_cmd(pipe, PIPE_CMD_CLOSE); in goldfish_pipe_release()
770 dev->pipes[pipe->id] = NULL; in goldfish_pipe_release()
771 signalled_pipes_remove_locked(dev, pipe); in goldfish_pipe_release()
775 free_page((unsigned long)pipe->command_buffer); in goldfish_pipe_release()
776 kfree(pipe); in goldfish_pipe_release()