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

From: Xin Zhao
Date: Wed Dec 10 2025 - 07:27:53 EST


Dear Jiri,

On Wed, 10 Dec 2025 09:24:30 +0100 Jiri Slaby <jirislaby@xxxxxxxxxx> wrote:

> I think Greg would mind missing "Change in v6" here :).
>
> > Change in v5:

Sorry, I will add the descriptions of v6 and v7 in v7.

> > +static struct workqueue_struct *pty_flip_wq;
>
> Can't pty simply "link" to system_unbound_wq instead of allocating a
> custom one:

It's a great idea! I'll revise it.

> > > + * When %TTY_DRIVER_CUSTOM_WORKQUEUE is used, you must link every tty port to
> >
> > Passive voice, please:
> > every tty port shall be linked to a workqueue manually by this function
>
>
> > +/**
> > + * tty_port_link_wq - link tty_port and flip workqueue
> > + * @port: tty_port of the device
> > + * @flip_wq: workqueue to queue flip buffer work on
> > + *
> > + * When %TTY_DRIVER_CUSTOM_WORKQUEUE is used, you must link every tty port to
>
> Passive voice, please:
> every tty port shall be linked to a workqueue manually by this function
>
> > + * workqueue manually by this function, otherwise tty_flip_buffer_push() will
> > + * see NULL flip_wq pointer when queue_work.
>
> %NULL flip_wq pointer on queue_work().
>
> > + * When %TTY_DRIVER_CUSTOM_WORKQUEUE is NOT used, you can also use the function
>
> this function can be used
>
> > + * to link a certain port to a specific workqueue, instead of using the
> > + * workqueue allocated in tty_register_driver().
> > + *
> > + * Note tty port api will not destroy the workqueue in the TTY port API.
>
> You sometimes write "tty port", other times "TTY port" -- unify to
> whatever surrounding code does.

Okay, here is the revised section:

/**
* tty_port_link_wq - link tty_port and flip workqueue
* @port: tty_port of the device
* @flip_wq: workqueue to queue flip buffer work on
*
* When %TTY_DRIVER_CUSTOM_WORKQUEUE is used, every tty_port shall be linked to
* a workqueue manually by this function, otherwise tty_flip_buffer_push() will
* see %NULL flip_wq pointer on queue_work.
* When %TTY_DRIVER_CUSTOM_WORKQUEUE is NOT used, the function can be used to
* link a certain port to a specific workqueue, instead of using the workqueue
* allocated in tty_register_driver().
*
* Note that TTY port API will NOT destroy the workqueue.
*/

> > + * @TTY_DRIVER_CUSTOM_WORKQUEUE:
> > + * Do not create workqueue when tty_register_driver(). In the case, you must
> > + * set flip buffer workqueue by tty_port_link_wq() every port.
>
> Do not create a workqueue in tty_register_driver(). When set, flip
> buffer workqueue shall be set by tty_port_link_wq() for every port.

Okay, here is the revised section:

* @TTY_DRIVER_CUSTOM_WORKQUEUE:
* Do not create workqueue when tty_register_driver(). When set, flip
* buffer workqueue shall be set by tty_port_link_wq() for every port.
*/

> > +/*
> > + * Never overwrite the workqueue set by tty_port_link_wq().
> > + * No effect when %TTY_DRIVER_CUSTOM_WORKQUEUE, as driver->flip_wq is NULL.
>
> when %TTY_DRIVER_CUSTOM_WORKQUEUE is set
>
> %NULL

Okay, here is the revised section:

/*
* Never overwrite the workqueue set by tty_port_link_wq().
* No effect when %TTY_DRIVER_CUSTOM_WORKQUEUE is set, as driver->flip_wq is
* %NULL.
*/


--
Xin Zhao