haiku/headers/os/drivers
Adrien Destugues 0f6f5adb50 generic/tty: restore lock sharing between master and slave TTYs
The code in this module was derived from the one in driver/tty. However,
the driver uses a shared lock between the master and slave side of a
TTY, and this was changed to use two separate locks. The approach with
two locks does not work. It seems the change was unfinished and the
second TTY was never locked. But attempting to lock it will result in
lock inversion problems, unless we do complicated things (try to find
which of the two TTY is the master side, and lock that first, for
example). It is simpler to restore the shared lock as used in the
driver.

To set up the shared lock, I modified the tty_create function to take a
pointer to the master TTY when creating the slave. Maybe it makes more
sense to create both sides in the same call, create_tty_pair?

However, this does not work as easily as I wanted, because there is some
recursion going on: at least in one case, the tty_control function is
calling the driver's tty_service function, which in turns attempts to
call back into tty_control for the "other side" TTY. To handle this
case, replace the mutex with a recursive_lock.

Fixes #17091, where the root problem was access to
other_tty->select_pool without locking. This was also made unconvenient
to debug because select_pool objects are self-deleting, when the last
item in the pool is removed. As a result, the code accessing it without
log would suddenly find out that the data it was accessing had been
freed and erased.

This also makes the TTY code in driver/tty and generic/tty a bit more
similar than it was before, and brings us one step closer to merging the
two together. There are still two main differences and I don't know
enough about TTY to decide if they are important, and which version
should be kept:
- The driver has extra code for "background" read and write. I don't
  know what this is used for.
- The driver has a single "settings" instance shared by a master and
  slave TTY, while the module has two separate instances, but seems to
  copy one to the other. I'm not sure which approach is correct.

Change-Id: Ie2daddd027859ce32ba395af76b4f109f8b984b0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4604
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-10-21 14:49:15 +00:00
..
bus bus_managers/fdt: rewrite to support device manager node tree 2021-08-14 23:57:35 +00:00
pcmcia
tty generic/tty: restore lock sharing between master and slave TTYs 2021-10-21 14:49:15 +00:00
usb usb hid: implement horizontal scrollwheel 2020-02-06 00:10:10 +00:00
ACPI.h acpi: add ACPI_DEVICE_UID_ITEM 2020-04-20 14:56:59 +00:00
bios.h
bus_manager.h
config_manager.h
cpufreq.h
cpuidle.h
device_manager.h device_manager: add find_child_node 2020-04-10 11:25:39 +00:00
disk_device_manager.h
dpc.h
driver_settings.h libroot: remove delete_driver_settings 2021-05-31 06:51:45 +00:00
Drivers.h Fix trim-related issues 2021-07-16 18:35:34 +00:00
fs_cache.h block_cache: Change signature of *_etc() functions 2020-06-20 18:10:03 +00:00
fs_interface.h vfs: functions to change a vnode busy status and ID 2019-02-19 18:44:43 +00:00
interrupt_controller.h
io_requests.h
ISA.h ISA: fix ram_address() to use phys_addr_t for completeness 2017-11-21 21:44:02 +01:00
isapnp.h
KernelExport.h POSIX: add dprintf 2020-10-04 19:34:40 +00:00
locked_pool.h
midi_driver.h
mime_table.h
module.h
PCI_x86.h
PCI.h PCI: add subclasses for data acquisition 2020-03-23 15:38:52 +00:00
Select.h
USB2.h
USB3.h USB: Move usb_iso_packet_descriptor to a separate header. 2021-09-02 16:00:17 +00:00
USB_isochronous.h USB: Move usb_iso_packet_descriptor to a separate header. 2021-09-02 16:00:17 +00:00
USB_printer.h
USB_rle.h
USB_spec.h PVS V547: always false conditions 2019-07-17 01:48:25 +00:00
USB.h