Skip to content

Commit 0a15f43

Browse files
committed
Revert "tty: tty_port: add workqueue to flip TTY buffer"
This reverts commit d000422. It is reported by many to cause boot failures, so must be reverted. Cc: Xin Zhao <jackzxcui1989@163.com> Cc: Jiri Slaby <jirislaby@kernel.org> Link: https://lore.kernel.org/r/d1942304-ee30-478d-90fb-279519f3ae81@samsung.com Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> Reported-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d000422 commit 0a15f43

7 files changed

Lines changed: 9 additions & 78 deletions

File tree

drivers/tty/pty.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,6 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty,
403403
o_tty->link = tty;
404404
tty_port_init(ports[0]);
405405
tty_port_init(ports[1]);
406-
tty_port_link_wq(ports[0], system_dfl_wq);
407-
tty_port_link_wq(ports[1], system_dfl_wq);
408406
tty_buffer_set_limit(ports[0], 8192);
409407
tty_buffer_set_limit(ports[1], 8192);
410408
o_tty->port = ports[0];
@@ -534,16 +532,14 @@ static void __init legacy_pty_init(void)
534532
pty_driver = tty_alloc_driver(legacy_count,
535533
TTY_DRIVER_RESET_TERMIOS |
536534
TTY_DRIVER_REAL_RAW |
537-
TTY_DRIVER_DYNAMIC_ALLOC |
538-
TTY_DRIVER_CUSTOM_WORKQUEUE);
535+
TTY_DRIVER_DYNAMIC_ALLOC);
539536
if (IS_ERR(pty_driver))
540537
panic("Couldn't allocate pty driver");
541538

542539
pty_slave_driver = tty_alloc_driver(legacy_count,
543540
TTY_DRIVER_RESET_TERMIOS |
544541
TTY_DRIVER_REAL_RAW |
545-
TTY_DRIVER_DYNAMIC_ALLOC |
546-
TTY_DRIVER_CUSTOM_WORKQUEUE);
542+
TTY_DRIVER_DYNAMIC_ALLOC);
547543
if (IS_ERR(pty_slave_driver))
548544
panic("Couldn't allocate pty slave driver");
549545

@@ -853,17 +849,15 @@ static void __init unix98_pty_init(void)
853849
TTY_DRIVER_REAL_RAW |
854850
TTY_DRIVER_DYNAMIC_DEV |
855851
TTY_DRIVER_DEVPTS_MEM |
856-
TTY_DRIVER_DYNAMIC_ALLOC |
857-
TTY_DRIVER_CUSTOM_WORKQUEUE);
852+
TTY_DRIVER_DYNAMIC_ALLOC);
858853
if (IS_ERR(ptm_driver))
859854
panic("Couldn't allocate Unix98 ptm driver");
860855
pts_driver = tty_alloc_driver(NR_UNIX98_PTY_MAX,
861856
TTY_DRIVER_RESET_TERMIOS |
862857
TTY_DRIVER_REAL_RAW |
863858
TTY_DRIVER_DYNAMIC_DEV |
864859
TTY_DRIVER_DEVPTS_MEM |
865-
TTY_DRIVER_DYNAMIC_ALLOC |
866-
TTY_DRIVER_CUSTOM_WORKQUEUE);
860+
TTY_DRIVER_DYNAMIC_ALLOC);
867861
if (IS_ERR(pts_driver))
868862
panic("Couldn't allocate Unix98 pts driver");
869863

drivers/tty/tty_buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void tty_buffer_unlock_exclusive(struct tty_port *port)
7676
mutex_unlock(&buf->lock);
7777

7878
if (restart)
79-
queue_work(buf->flip_wq, &buf->work);
79+
queue_work(system_dfl_wq, &buf->work);
8080
}
8181
EXPORT_SYMBOL_GPL(tty_buffer_unlock_exclusive);
8282

@@ -530,7 +530,7 @@ void tty_flip_buffer_push(struct tty_port *port)
530530
struct tty_bufhead *buf = &port->buf;
531531

532532
tty_flip_buffer_commit(buf->tail);
533-
queue_work(buf->flip_wq, &buf->work);
533+
queue_work(system_dfl_wq, &buf->work);
534534
}
535535
EXPORT_SYMBOL(tty_flip_buffer_push);
536536

@@ -560,7 +560,7 @@ int tty_insert_flip_string_and_push_buffer(struct tty_port *port,
560560
tty_flip_buffer_commit(buf->tail);
561561
spin_unlock_irqrestore(&port->lock, flags);
562562

563-
queue_work(buf->flip_wq, &buf->work);
563+
queue_work(system_dfl_wq, &buf->work);
564564

565565
return size;
566566
}
@@ -613,7 +613,7 @@ void tty_buffer_set_lock_subclass(struct tty_port *port)
613613

614614
bool tty_buffer_restart_work(struct tty_port *port)
615615
{
616-
return queue_work(port->buf.flip_wq, &port->buf.work);
616+
return queue_work(system_dfl_wq, &port->buf.work);
617617
}
618618

619619
bool tty_buffer_cancel_work(struct tty_port *port)

drivers/tty/tty_io.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,23 +3446,10 @@ int tty_register_driver(struct tty_driver *driver)
34463446
if (error < 0)
34473447
goto err;
34483448

3449-
if (!(driver->flags & TTY_DRIVER_CUSTOM_WORKQUEUE)) {
3450-
driver->flip_wq = alloc_workqueue("%s-flip-wq", WQ_UNBOUND | WQ_SYSFS,
3451-
0, driver->name);
3452-
if (!driver->flip_wq) {
3453-
error = -ENOMEM;
3454-
goto err_unreg_char;
3455-
}
3456-
for (i = 0; i < driver->num; i++) {
3457-
if (driver->ports[i])
3458-
tty_port_link_driver_wq(driver->ports[i], driver);
3459-
}
3460-
}
3461-
34623449
if (driver->flags & TTY_DRIVER_DYNAMIC_ALLOC) {
34633450
error = tty_cdev_add(driver, dev, 0, driver->num);
34643451
if (error)
3465-
goto err_destroy_wq;
3452+
goto err_unreg_char;
34663453
}
34673454

34683455
scoped_guard(mutex, &tty_mutex)
@@ -3488,10 +3475,6 @@ int tty_register_driver(struct tty_driver *driver)
34883475
scoped_guard(mutex, &tty_mutex)
34893476
list_del(&driver->tty_drivers);
34903477

3491-
err_destroy_wq:
3492-
if (!(driver->flags & TTY_DRIVER_CUSTOM_WORKQUEUE))
3493-
destroy_workqueue(driver->flip_wq);
3494-
34953478
err_unreg_char:
34963479
unregister_chrdev_region(dev, driver->num);
34973480
err:
@@ -3511,8 +3494,6 @@ void tty_unregister_driver(struct tty_driver *driver)
35113494
driver->num);
35123495
scoped_guard(mutex, &tty_mutex)
35133496
list_del(&driver->tty_drivers);
3514-
if (!(driver->flags & TTY_DRIVER_CUSTOM_WORKQUEUE))
3515-
destroy_workqueue(driver->flip_wq);
35163497
}
35173498
EXPORT_SYMBOL(tty_unregister_driver);
35183499

drivers/tty/tty_port.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,6 @@ void tty_port_init(struct tty_port *port)
9999
}
100100
EXPORT_SYMBOL(tty_port_init);
101101

102-
/**
103-
* tty_port_link_wq - link tty_port and flip workqueue
104-
* @port: tty_port of the device
105-
* @flip_wq: workqueue to queue flip buffer work on
106-
*
107-
* When %TTY_DRIVER_CUSTOM_WORKQUEUE is used, every tty_port shall be linked to
108-
* a workqueue manually by this function, otherwise tty_flip_buffer_push() will
109-
* see %NULL flip_wq pointer on queue_work.
110-
* When %TTY_DRIVER_CUSTOM_WORKQUEUE is NOT used, the function can be used to
111-
* link a certain port to a specific workqueue, instead of using the workqueue
112-
* allocated in tty_register_driver().
113-
*
114-
* Note that TTY port API will NOT destroy the workqueue.
115-
*/
116-
void tty_port_link_wq(struct tty_port *port, struct workqueue_struct *flip_wq)
117-
{
118-
port->buf.flip_wq = flip_wq;
119-
}
120-
EXPORT_SYMBOL_GPL(tty_port_link_wq);
121-
122102
/**
123103
* tty_port_link_device - link tty and tty_port
124104
* @port: tty_port of the device
@@ -177,7 +157,6 @@ struct device *tty_port_register_device_attr(struct tty_port *port,
177157
const struct attribute_group **attr_grp)
178158
{
179159
tty_port_link_device(port, driver, index);
180-
tty_port_link_driver_wq(port, driver);
181160
return tty_register_device_attr(driver, index, device, drvdata,
182161
attr_grp);
183162
}
@@ -204,7 +183,6 @@ struct device *tty_port_register_device_attr_serdev(struct tty_port *port,
204183
struct device *dev;
205184

206185
tty_port_link_device(port, driver, index);
207-
tty_port_link_driver_wq(port, driver);
208186

209187
dev = serdev_tty_port_register(port, host, parent, driver, index);
210188
if (PTR_ERR(dev) != -ENODEV) {
@@ -725,7 +703,6 @@ int tty_port_install(struct tty_port *port, struct tty_driver *driver,
725703
struct tty_struct *tty)
726704
{
727705
tty->port = port;
728-
tty_port_link_driver_wq(port, driver);
729706
return tty_standard_install(driver, tty);
730707
}
731708
EXPORT_SYMBOL_GPL(tty_port_install);

include/linux/tty_buffer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ static inline u8 *flag_buf_ptr(struct tty_buffer *b, unsigned int ofs)
3434

3535
struct tty_bufhead {
3636
struct tty_buffer *head; /* Queue head */
37-
struct workqueue_struct *flip_wq;
3837
struct work_struct work;
3938
struct mutex lock;
4039
atomic_t priority;

include/linux/tty_driver.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ struct serial_struct;
6969
* Do not create numbered ``/dev`` nodes. For example, create
7070
* ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a
7171
* driver for a single tty device is being allocated.
72-
*
73-
* @TTY_DRIVER_CUSTOM_WORKQUEUE:
74-
* Do not create workqueue when tty_register_driver(). When set, flip
75-
* buffer workqueue shall be set by tty_port_link_wq() for every port.
7672
*/
7773
enum tty_driver_flag {
7874
TTY_DRIVER_INSTALLED = BIT(0),
@@ -83,7 +79,6 @@ enum tty_driver_flag {
8379
TTY_DRIVER_HARDWARE_BREAK = BIT(5),
8480
TTY_DRIVER_DYNAMIC_ALLOC = BIT(6),
8581
TTY_DRIVER_UNNUMBERED_NODE = BIT(7),
86-
TTY_DRIVER_CUSTOM_WORKQUEUE = BIT(8),
8782
};
8883

8984
enum tty_driver_type {
@@ -511,7 +506,6 @@ struct tty_operations {
511506
* @flags: tty driver flags (%TTY_DRIVER_)
512507
* @proc_entry: proc fs entry, used internally
513508
* @other: driver of the linked tty; only used for the PTY driver
514-
* @flip_wq: workqueue to queue flip buffer work on
515509
* @ttys: array of active &struct tty_struct, set by tty_standard_install()
516510
* @ports: array of &struct tty_port; can be set during initialization by
517511
* tty_port_link_device() and similar
@@ -545,7 +539,6 @@ struct tty_driver {
545539
unsigned long flags;
546540
struct proc_dir_entry *proc_entry;
547541
struct tty_driver *other;
548-
struct workqueue_struct *flip_wq;
549542

550543
/*
551544
* Pointer to the tty data structures

include/linux/tty_port.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ struct tty_port {
138138
kernel */
139139

140140
void tty_port_init(struct tty_port *port);
141-
void tty_port_link_wq(struct tty_port *port, struct workqueue_struct *flip_wq);
142141
void tty_port_link_device(struct tty_port *port, struct tty_driver *driver,
143142
unsigned index);
144143
struct device *tty_port_register_device(struct tty_port *port,
@@ -166,18 +165,6 @@ static inline struct tty_port *tty_port_get(struct tty_port *port)
166165
return NULL;
167166
}
168167

169-
/*
170-
* Never overwrite the workqueue set by tty_port_link_wq().
171-
* No effect when %TTY_DRIVER_CUSTOM_WORKQUEUE is set, as driver->flip_wq is
172-
* %NULL.
173-
*/
174-
static inline void tty_port_link_driver_wq(struct tty_port *port,
175-
struct tty_driver *driver)
176-
{
177-
if (!port->buf.flip_wq)
178-
port->buf.flip_wq = driver->flip_wq;
179-
}
180-
181168
/* If the cts flow control is enabled, return true. */
182169
static inline bool tty_port_cts_enabled(const struct tty_port *port)
183170
{

0 commit comments

Comments
 (0)