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()
225 while ((next = smp_load_acquire(&buf->head->next)) != NULL) { in tty_buffer_flush()
226 tty_buffer_free(port, buf->head); in tty_buffer_flush()
227 buf->head = next; in tty_buffer_flush()
229 buf->head->read = buf->head->commit; in tty_buffer_flush()
234 atomic_dec(&buf->priority); in tty_buffer_flush()
235 mutex_unlock(&buf->lock); in tty_buffer_flush()
254 struct tty_bufhead *buf = &port->buf; in __tty_buffer_request_room() local
258 b = buf->tail; in __tty_buffer_request_room()
270 buf->tail = n; in __tty_buffer_request_room()
313 struct tty_buffer *tb = port->buf.tail; in tty_insert_flip_string_fixed_flag()
348 struct tty_buffer *tb = port->buf.tail; in tty_insert_flip_string_flags()
375 struct tty_bufhead *buf = &port->buf; in tty_schedule_flip() local
380 smp_store_release(&buf->tail->commit, buf->tail->used); in tty_schedule_flip()
381 queue_work(system_unbound_wq, &buf->work); in tty_schedule_flip()
403 struct tty_buffer *tb = port->buf.tail; in tty_prepare_flip_string()
449 struct tty_port *port = container_of(work, struct tty_port, buf.work); in flush_to_ldisc()
450 struct tty_bufhead *buf = &port->buf; in flush_to_ldisc() local
462 mutex_lock(&buf->lock); in flush_to_ldisc()
465 struct tty_buffer *head = buf->head; in flush_to_ldisc()
470 if (atomic_read(&buf->priority)) in flush_to_ldisc()
485 buf->head = next; in flush_to_ldisc()
496 mutex_unlock(&buf->lock); in flush_to_ldisc()
528 struct tty_bufhead *buf = &port->buf; in tty_buffer_init() local
530 mutex_init(&buf->lock); in tty_buffer_init()
531 tty_buffer_reset(&buf->sentinel, 0); in tty_buffer_init()
532 buf->head = &buf->sentinel; in tty_buffer_init()
533 buf->tail = &buf->sentinel; in tty_buffer_init()
534 init_llist_head(&buf->free); in tty_buffer_init()
535 atomic_set(&buf->mem_used, 0); in tty_buffer_init()
536 atomic_set(&buf->priority, 0); in tty_buffer_init()
537 INIT_WORK(&buf->work, flush_to_ldisc); in tty_buffer_init()
538 buf->mem_limit = TTYB_DEFAULT_MEM_LIMIT; in tty_buffer_init()
553 port->buf.mem_limit = limit; in tty_buffer_set_limit()
561 lockdep_set_subclass(&port->buf.lock, TTY_LOCK_SLAVE); in tty_buffer_set_lock_subclass()
566 return queue_work(system_unbound_wq, &port->buf.work); in tty_buffer_restart_work()
571 return cancel_work_sync(&port->buf.work); in tty_buffer_cancel_work()
576 flush_work(&port->buf.work); in tty_buffer_flush_work()