Re: [PATCH v3] tty: tty_port: add workqueue to flip tty buffer

From: Tejun Heo
Date: Mon Nov 24 2025 - 11:02:31 EST


On Mon, Nov 24, 2025 at 01:17:51PM +0800, Xin Zhao wrote:
> > +/**
> > + * tty_flip_wq_init -- prepare workqueue for tty/pty flip buffer work
> > + * @port: tty_port of the device
> > + * @driver: tty_driver for this device
> > + * @index: index of the tty
> > + *
> > + * Not all tty_port will be initialized by tty_port_init where tty_flip_wq will
> > + * be set to system_unbound_wq as default. Allocate workqueue with WQ_SYSFS for
> > + * flip buffer, so that cpumask and nice can be changed dynamically.
> > + */
> > +void tty_flip_wq_init(struct tty_port *port, struct tty_driver *driver,
> > + unsigned int index)
> > +{
> > + char name[64];
> > +
> > + if (driver->type == TTY_DRIVER_TYPE_PTY) {
> > + port->buf.tty_flip_wq = pty_flip_wq;
> > + return;
> > + }
> > + tty_line_name(driver, index, name);
> > + if (!port->buf.tty_flip_wq
> > + || port->buf.tty_flip_wq == system_unbound_wq) {
> > + port->buf.tty_flip_wq = alloc_workqueue("%s-flip-wq",
> > + WQ_UNBOUND | WQ_SYSFS,
> > + 0, name);
> > + if (unlikely(!port->buf.tty_flip_wq))
> > + port->buf.tty_flip_wq = system_unbound_wq;
> > + }
> > +}

These look overly elaborate to me. Just fail init if workqueue allocation
fails? Also, is it necessary for each port to have separate port?

Thanks.

--
tejun