Lines Matching refs:buf

57 	struct tty_bufhead *buf = &port->buf;  in tty_buffer_lock_exclusive()  local
59 atomic_inc(&buf->priority); in tty_buffer_lock_exclusive()
60 mutex_lock(&buf->lock); in tty_buffer_lock_exclusive()
66 struct tty_bufhead *buf = &port->buf; in tty_buffer_unlock_exclusive() local
69 restart = buf->head->commit != buf->head->read; in tty_buffer_unlock_exclusive()
71 atomic_dec(&buf->priority); in tty_buffer_unlock_exclusive()
72 mutex_unlock(&buf->lock); in tty_buffer_unlock_exclusive()
74 queue_work(system_unbound_wq, &buf->work); in tty_buffer_unlock_exclusive()
92 int space = port->buf.mem_limit - atomic_read(&port->buf.mem_used); in tty_buffer_space_avail()
117 struct tty_bufhead *buf = &port->buf; in tty_buffer_free_all() local
121 while ((p = buf->head) != NULL) { in tty_buffer_free_all()
122 buf->head = p->next; in tty_buffer_free_all()
126 llist = llist_del_all(&buf->free); in tty_buffer_free_all()
130 tty_buffer_reset(&buf->sentinel, 0); in tty_buffer_free_all()
131 buf->head = &buf->sentinel; in tty_buffer_free_all()
132 buf->tail = &buf->sentinel; in tty_buffer_free_all()
134 atomic_set(&buf->mem_used, 0); in tty_buffer_free_all()
158 free = llist_del_first(&port->buf.free); in tty_buffer_alloc()
167 if (atomic_read(&port->buf.mem_used) > port->buf.mem_limit) in tty_buffer_alloc()
175 atomic_add(size, &port->buf.mem_used); in tty_buffer_alloc()
190 struct tty_bufhead *buf = &port->buf; in tty_buffer_free() local
193 WARN_ON(atomic_sub_return(b->size, &buf->mem_used) < 0); in tty_buffer_free()
198 llist_add(&b->free, &buf->free); in tty_buffer_free()
216 struct tty_bufhead *buf = &port->buf; in tty_buffer_flush() local
219 atomic_inc(&buf->priority); in tty_buffer_flush()
221 mutex_lock(&buf->lock); in tty_buffer_flush()
222 while ((next = buf->head->next) != NULL) { in tty_buffer_flush()
223 tty_buffer_free(port, buf->head); in tty_buffer_flush()
224 buf->head = next; in tty_buffer_flush()
226 buf->head->read = buf->head->commit; in tty_buffer_flush()
231 atomic_dec(&buf->priority); in tty_buffer_flush()
232 mutex_unlock(&buf->lock); in tty_buffer_flush()
251 struct tty_bufhead *buf = &port->buf; in __tty_buffer_request_room() local
255 b = buf->tail; in __tty_buffer_request_room()
266 buf->tail = n; in __tty_buffer_request_room()
307 struct tty_buffer *tb = port->buf.tail; in tty_insert_flip_string_fixed_flag()
342 struct tty_buffer *tb = port->buf.tail; in tty_insert_flip_string_flags()
369 struct tty_bufhead *buf = &port->buf; in tty_schedule_flip() local
371 buf->tail->commit = buf->tail->used; in tty_schedule_flip()
372 schedule_work(&buf->work); in tty_schedule_flip()
394 struct tty_buffer *tb = port->buf.tail; in tty_prepare_flip_string()
441 struct tty_port *port = container_of(work, struct tty_port, buf.work); in flush_to_ldisc()
442 struct tty_bufhead *buf = &port->buf; in flush_to_ldisc() local
454 mutex_lock(&buf->lock); in flush_to_ldisc()
457 struct tty_buffer *head = buf->head; in flush_to_ldisc()
462 if (atomic_read(&buf->priority)) in flush_to_ldisc()
475 buf->head = next; in flush_to_ldisc()
485 mutex_unlock(&buf->lock); in flush_to_ldisc()
517 struct tty_bufhead *buf = &port->buf; in tty_buffer_init() local
519 mutex_init(&buf->lock); in tty_buffer_init()
520 tty_buffer_reset(&buf->sentinel, 0); in tty_buffer_init()
521 buf->head = &buf->sentinel; in tty_buffer_init()
522 buf->tail = &buf->sentinel; in tty_buffer_init()
523 init_llist_head(&buf->free); in tty_buffer_init()
524 atomic_set(&buf->mem_used, 0); in tty_buffer_init()
525 atomic_set(&buf->priority, 0); in tty_buffer_init()
526 INIT_WORK(&buf->work, flush_to_ldisc); in tty_buffer_init()
527 buf->mem_limit = TTYB_DEFAULT_MEM_LIMIT; in tty_buffer_init()
542 port->buf.mem_limit = limit; in tty_buffer_set_limit()
550 lockdep_set_subclass(&port->buf.lock, TTY_LOCK_SLAVE); in tty_buffer_set_lock_subclass()
555 flush_work(&port->buf.work); in tty_buffer_flush_work()