Lines Matching refs:buf
55 struct tty_bufhead *buf = &port->buf; in tty_buffer_lock_exclusive() local
57 atomic_inc(&buf->priority); in tty_buffer_lock_exclusive()
58 mutex_lock(&buf->lock); in tty_buffer_lock_exclusive()
72 struct tty_bufhead *buf = &port->buf; in tty_buffer_unlock_exclusive() local
73 bool restart = buf->head->commit != buf->head->read; in tty_buffer_unlock_exclusive()
75 atomic_dec(&buf->priority); in tty_buffer_unlock_exclusive()
76 mutex_unlock(&buf->lock); in tty_buffer_unlock_exclusive()
79 queue_work(system_unbound_wq, &buf->work); in tty_buffer_unlock_exclusive()
96 int space = port->buf.mem_limit - atomic_read(&port->buf.mem_used); in tty_buffer_space_avail()
122 struct tty_bufhead *buf = &port->buf; in tty_buffer_free_all() local
128 while ((p = buf->head) != NULL) { in tty_buffer_free_all()
129 buf->head = p->next; in tty_buffer_free_all()
134 llist = llist_del_all(&buf->free); in tty_buffer_free_all()
138 tty_buffer_reset(&buf->sentinel, 0); in tty_buffer_free_all()
139 buf->head = &buf->sentinel; in tty_buffer_free_all()
140 buf->tail = &buf->sentinel; in tty_buffer_free_all()
142 still_used = atomic_xchg(&buf->mem_used, 0); in tty_buffer_free_all()
168 free = llist_del_first(&port->buf.free); in tty_buffer_alloc()
178 if (atomic_read(&port->buf.mem_used) > port->buf.mem_limit) in tty_buffer_alloc()
186 atomic_add(size, &port->buf.mem_used); in tty_buffer_alloc()
200 struct tty_bufhead *buf = &port->buf; in tty_buffer_free() local
203 WARN_ON(atomic_sub_return(b->size, &buf->mem_used) < 0); in tty_buffer_free()
208 llist_add(&b->free, &buf->free); in tty_buffer_free()
224 struct tty_bufhead *buf = &port->buf; in tty_buffer_flush() local
227 atomic_inc(&buf->priority); in tty_buffer_flush()
229 mutex_lock(&buf->lock); in tty_buffer_flush()
233 while ((next = smp_load_acquire(&buf->head->next)) != NULL) { in tty_buffer_flush()
234 tty_buffer_free(port, buf->head); in tty_buffer_flush()
235 buf->head = next; in tty_buffer_flush()
237 buf->head->read = buf->head->commit; in tty_buffer_flush()
238 buf->head->lookahead = buf->head->read; in tty_buffer_flush()
243 atomic_dec(&buf->priority); in tty_buffer_flush()
244 mutex_unlock(&buf->lock); in tty_buffer_flush()
264 struct tty_bufhead *buf = &port->buf; in __tty_buffer_request_room() local
265 struct tty_buffer *n, *b = buf->tail; in __tty_buffer_request_room()
278 buf->tail = n; in __tty_buffer_request_room()
310 struct tty_buffer *tb = port->buf.tail; in __tty_insert_flip_string_flags()
359 struct tty_buffer *tb = port->buf.tail; in tty_prepare_flip_string()
464 struct tty_port *port = container_of(work, struct tty_port, buf.work); in flush_to_ldisc()
465 struct tty_bufhead *buf = &port->buf; in flush_to_ldisc() local
467 mutex_lock(&buf->lock); in flush_to_ldisc()
470 struct tty_buffer *head = buf->head; in flush_to_ldisc()
475 if (atomic_read(&buf->priority)) in flush_to_ldisc()
490 buf->head = next; in flush_to_ldisc()
505 mutex_unlock(&buf->lock); in flush_to_ldisc()
530 struct tty_bufhead *buf = &port->buf; in tty_flip_buffer_push() local
532 tty_flip_buffer_commit(buf->tail); in tty_flip_buffer_push()
533 queue_work(system_unbound_wq, &buf->work); in tty_flip_buffer_push()
554 struct tty_bufhead *buf = &port->buf; in tty_insert_flip_string_and_push_buffer() local
560 tty_flip_buffer_commit(buf->tail); in tty_insert_flip_string_and_push_buffer()
563 queue_work(system_unbound_wq, &buf->work); in tty_insert_flip_string_and_push_buffer()
577 struct tty_bufhead *buf = &port->buf; in tty_buffer_init() local
579 mutex_init(&buf->lock); in tty_buffer_init()
580 tty_buffer_reset(&buf->sentinel, 0); in tty_buffer_init()
581 buf->head = &buf->sentinel; in tty_buffer_init()
582 buf->tail = &buf->sentinel; in tty_buffer_init()
583 init_llist_head(&buf->free); in tty_buffer_init()
584 atomic_set(&buf->mem_used, 0); in tty_buffer_init()
585 atomic_set(&buf->priority, 0); in tty_buffer_init()
586 INIT_WORK(&buf->work, flush_to_ldisc); in tty_buffer_init()
587 buf->mem_limit = TTYB_DEFAULT_MEM_LIMIT; in tty_buffer_init()
603 port->buf.mem_limit = limit; in tty_buffer_set_limit()
611 lockdep_set_subclass(&port->buf.lock, TTY_LOCK_SLAVE); in tty_buffer_set_lock_subclass()
616 return queue_work(system_unbound_wq, &port->buf.work); in tty_buffer_restart_work()
621 return cancel_work_sync(&port->buf.work); in tty_buffer_cancel_work()
626 flush_work(&port->buf.work); in tty_buffer_flush_work()