License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifndef _LINUX_TTY_LDISC_H
|
|
|
|
#define _LINUX_TTY_LDISC_H
|
|
|
|
|
2021-07-23 13:31:42 +03:00
|
|
|
struct tty_struct;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/wait.h>
|
2018-06-05 17:53:34 +03:00
|
|
|
#include <linux/atomic.h>
|
2021-07-23 13:31:43 +03:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/lockdep.h>
|
2021-07-23 13:31:42 +03:00
|
|
|
#include <linux/seq_file.h>
|
2013-04-16 14:15:50 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* the semaphore definition
|
|
|
|
*/
|
|
|
|
struct ld_semaphore {
|
2018-06-05 17:53:34 +03:00
|
|
|
atomic_long_t count;
|
2013-04-16 14:15:50 +04:00
|
|
|
raw_spinlock_t wait_lock;
|
|
|
|
unsigned int wait_readers;
|
|
|
|
struct list_head read_wait;
|
|
|
|
struct list_head write_wait;
|
|
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
|
|
|
struct lockdep_map dep_map;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2021-09-14 12:11:21 +03:00
|
|
|
void __init_ldsem(struct ld_semaphore *sem, const char *name,
|
2013-04-16 14:15:50 +04:00
|
|
|
struct lock_class_key *key);
|
|
|
|
|
|
|
|
#define init_ldsem(sem) \
|
|
|
|
do { \
|
|
|
|
static struct lock_class_key __key; \
|
|
|
|
\
|
|
|
|
__init_ldsem((sem), #sem, &__key); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
2021-09-14 12:11:21 +03:00
|
|
|
int ldsem_down_read(struct ld_semaphore *sem, long timeout);
|
|
|
|
int ldsem_down_read_trylock(struct ld_semaphore *sem);
|
|
|
|
int ldsem_down_write(struct ld_semaphore *sem, long timeout);
|
|
|
|
int ldsem_down_write_trylock(struct ld_semaphore *sem);
|
|
|
|
void ldsem_up_read(struct ld_semaphore *sem);
|
|
|
|
void ldsem_up_write(struct ld_semaphore *sem);
|
2013-04-16 14:15:50 +04:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
2021-09-14 12:11:21 +03:00
|
|
|
int ldsem_down_read_nested(struct ld_semaphore *sem, int subclass,
|
|
|
|
long timeout);
|
|
|
|
int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
|
|
|
|
long timeout);
|
2013-04-16 14:15:50 +04:00
|
|
|
#else
|
|
|
|
# define ldsem_down_read_nested(sem, subclass, timeout) \
|
|
|
|
ldsem_down_read(sem, timeout)
|
|
|
|
# define ldsem_down_write_nested(sem, subclass, timeout) \
|
|
|
|
ldsem_down_write(sem, timeout)
|
|
|
|
#endif
|
|
|
|
|
2021-11-26 11:15:54 +03:00
|
|
|
/**
|
|
|
|
* struct tty_ldisc_ops - ldisc operations
|
|
|
|
*
|
|
|
|
* @name: name of this ldisc rendered in /proc/tty/ldiscs
|
|
|
|
* @num: ``N_*`` number (%N_TTY, %N_HDLC, ...) reserved to this ldisc
|
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @open: [TTY] ``int ()(struct tty_struct *tty)``
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
|
|
|
* This function is called when the line discipline is associated with the
|
2021-11-26 11:15:56 +03:00
|
|
|
* @tty. No other call into the line discipline for this tty will occur
|
|
|
|
* until it completes successfully. It should initialize any state needed
|
|
|
|
* by the ldisc, and set @tty->receive_room to the maximum amount of data
|
|
|
|
* the line discipline is willing to accept from the driver with a single
|
|
|
|
* call to @receive_buf(). Returning an error will prevent the ldisc from
|
|
|
|
* being attached.
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* Can sleep.
|
|
|
|
*
|
|
|
|
* @close: [TTY] ``void ()(struct tty_struct *tty)``
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
|
|
|
* This function is called when the line discipline is being shutdown,
|
|
|
|
* either because the @tty is being closed or because the @tty is being
|
2021-11-26 11:15:56 +03:00
|
|
|
* changed to use a new line discipline. At the point of execution no
|
|
|
|
* further users will enter the ldisc code for this tty.
|
|
|
|
*
|
|
|
|
* Can sleep.
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @flush_buffer: [TTY] ``void ()(struct tty_struct *tty)``
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
|
|
|
* This function instructs the line discipline to clear its buffers of any
|
|
|
|
* input characters it may have queued to be delivered to the user mode
|
2021-11-26 11:15:56 +03:00
|
|
|
* process. It may be called at any point between open and close.
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file,
|
2021-11-26 11:15:54 +03:00
|
|
|
* unsigned char *buf, size_t nr)``
|
|
|
|
*
|
|
|
|
* This function is called when the user requests to read from the @tty.
|
|
|
|
* The line discipline will return whatever characters it has buffered up
|
|
|
|
* for the user. If this function is not defined, the user will receive
|
2021-11-26 11:15:56 +03:00
|
|
|
* an %EIO error. Multiple read calls may occur in parallel and the ldisc
|
|
|
|
* must deal with serialization issues.
|
|
|
|
*
|
|
|
|
* Can sleep.
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @write: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file,
|
2021-11-26 11:15:54 +03:00
|
|
|
* const unsigned char *buf, size_t nr)``
|
|
|
|
*
|
|
|
|
* This function is called when the user requests to write to the @tty.
|
|
|
|
* The line discipline will deliver the characters to the low-level tty
|
|
|
|
* device for transmission, optionally performing some processing on the
|
|
|
|
* characters first. If this function is not defined, the user will
|
|
|
|
* receive an %EIO error.
|
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* Can sleep.
|
|
|
|
*
|
|
|
|
* @ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd,
|
2021-11-26 11:15:54 +03:00
|
|
|
* unsigned long arg)``
|
|
|
|
*
|
|
|
|
* This function is called when the user requests an ioctl which is not
|
|
|
|
* handled by the tty layer or the low-level tty driver. It is intended
|
|
|
|
* for ioctls which affect line discpline operation. Note that the search
|
|
|
|
* order for ioctls is (1) tty layer, (2) tty low-level driver, (3) line
|
|
|
|
* discpline. So a low-level driver can "grab" an ioctl request before
|
|
|
|
* the line discpline has a chance to see it.
|
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @compat_ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd,
|
2021-11-26 11:15:54 +03:00
|
|
|
* unsigned long arg)``
|
|
|
|
*
|
|
|
|
* Process ioctl calls from 32-bit process on 64-bit system.
|
|
|
|
*
|
|
|
|
* Note that only ioctls that are neither "pointer to compatible
|
|
|
|
* structure" nor tty-generic. Something private that takes an integer or
|
|
|
|
* a pointer to wordsize-sensitive structure belongs here, but most of
|
|
|
|
* ldiscs will happily leave it %NULL.
|
|
|
|
*
|
2022-08-16 14:57:36 +03:00
|
|
|
* @set_termios: [TTY] ``void ()(struct tty_struct *tty, const struct ktermios *old)``
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
|
|
|
* This function notifies the line discpline that a change has been made
|
|
|
|
* to the termios structure.
|
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @poll: [TTY] ``int ()(struct tty_struct *tty, struct file *file,
|
2021-11-26 11:15:54 +03:00
|
|
|
* struct poll_table_struct *wait)``
|
|
|
|
*
|
|
|
|
* This function is called when a user attempts to select/poll on a @tty
|
|
|
|
* device. It is solely the responsibility of the line discipline to
|
|
|
|
* handle poll requests.
|
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @hangup: [TTY] ``void ()(struct tty_struct *tty)``
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
|
|
|
* Called on a hangup. Tells the discipline that it should cease I/O to
|
2021-11-26 11:15:56 +03:00
|
|
|
* the tty driver. The driver should seek to perform this action quickly
|
|
|
|
* but should wait until any pending driver I/O is completed. No further
|
|
|
|
* calls into the ldisc code will occur.
|
|
|
|
*
|
|
|
|
* Can sleep.
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @receive_buf: [DRV] ``void ()(struct tty_struct *tty,
|
|
|
|
* const unsigned char *cp, const char *fp, int count)``
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
|
|
|
* This function is called by the low-level tty driver to send characters
|
|
|
|
* received by the hardware to the line discpline for processing. @cp is
|
|
|
|
* a pointer to the buffer of input character received by the device. @fp
|
|
|
|
* is a pointer to an array of flag bytes which indicate whether a
|
|
|
|
* character was received with a parity error, etc. @fp may be %NULL to
|
|
|
|
* indicate all data received is %TTY_NORMAL.
|
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @write_wakeup: [DRV] ``void ()(struct tty_struct *tty)``
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
|
|
|
* This function is called by the low-level tty driver to signal that line
|
|
|
|
* discpline should try to send more characters to the low-level driver
|
|
|
|
* for transmission. If the line discpline does not have any more data to
|
|
|
|
* send, it can just return. If the line discipline does have some data to
|
|
|
|
* send, please arise a tasklet or workqueue to do the real data transfer.
|
|
|
|
* Do not send data in this hook, it may lead to a deadlock.
|
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @dcd_change: [DRV] ``void ()(struct tty_struct *tty, unsigned int status)``
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
|
|
|
* Tells the discipline that the DCD pin has changed its status. Used
|
|
|
|
* exclusively by the %N_PPS (Pulse-Per-Second) line discipline.
|
|
|
|
*
|
2021-11-26 11:15:56 +03:00
|
|
|
* @receive_buf2: [DRV] ``int ()(struct tty_struct *tty,
|
|
|
|
* const unsigned char *cp, const char *fp, int count)``
|
2021-11-26 11:15:54 +03:00
|
|
|
*
|
|
|
|
* This function is called by the low-level tty driver to send characters
|
|
|
|
* received by the hardware to the line discpline for processing. @cp is a
|
|
|
|
* pointer to the buffer of input character received by the device. @fp
|
|
|
|
* is a pointer to an array of flag bytes which indicate whether a
|
|
|
|
* character was received with a parity error, etc. @fp may be %NULL to
|
|
|
|
* indicate all data received is %TTY_NORMAL. If assigned, prefer this
|
|
|
|
* function for automatic flow control.
|
|
|
|
*
|
tty: Implement lookahead to process XON/XOFF timely
When tty is not read from, XON/XOFF may get stuck into an
intermediate buffer. As those characters are there to do software
flow-control, it is not very useful. In the case where neither end
reads from ttys, the receiving ends might not be able receive the
XOFF characters and just keep sending more data to the opposite
direction. This problem is almost guaranteed to occur with DMA
which sends data in large chunks.
If TTY is slow to process characters, that is, eats less than given
amount in receive_buf, invoke lookahead for the rest of the chars
to process potential XON/XOFF characters.
We need to keep track of how many characters have been processed by the
lookahead to avoid processing the flow control char again on the normal
path. Bookkeeping occurs parallel on two layers (tty_buffer and n_tty)
to avoid passing the lookahead_count through the whole call chain.
When a flow-control char is processed, two things must occur:
a) it must not be treated as normal char
b) if not yet processed, flow-control actions need to be taken
The return value of n_tty_receive_char_flow_ctrl() tells caller a), and
b) is kept internal to n_tty_receive_char_flow_ctrl().
If characters were previous looked ahead, __receive_buf() makes two
calls to the appropriate n_tty_receive_buf_* function. First call is
made with lookahead_done=true for the characters that were subject to
lookahead earlier and then with lookahead=false for the new characters.
Either of the calls might be skipped when it has no characters to
handle.
Reported-by: Gilles Buloz <gilles.buloz@kontron.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220606153652.63554-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-06 18:36:51 +03:00
|
|
|
* @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty,
|
2022-06-14 10:50:54 +03:00
|
|
|
* const unsigned char *cp, const char *fp, int count)``
|
tty: Implement lookahead to process XON/XOFF timely
When tty is not read from, XON/XOFF may get stuck into an
intermediate buffer. As those characters are there to do software
flow-control, it is not very useful. In the case where neither end
reads from ttys, the receiving ends might not be able receive the
XOFF characters and just keep sending more data to the opposite
direction. This problem is almost guaranteed to occur with DMA
which sends data in large chunks.
If TTY is slow to process characters, that is, eats less than given
amount in receive_buf, invoke lookahead for the rest of the chars
to process potential XON/XOFF characters.
We need to keep track of how many characters have been processed by the
lookahead to avoid processing the flow control char again on the normal
path. Bookkeeping occurs parallel on two layers (tty_buffer and n_tty)
to avoid passing the lookahead_count through the whole call chain.
When a flow-control char is processed, two things must occur:
a) it must not be treated as normal char
b) if not yet processed, flow-control actions need to be taken
The return value of n_tty_receive_char_flow_ctrl() tells caller a), and
b) is kept internal to n_tty_receive_char_flow_ctrl().
If characters were previous looked ahead, __receive_buf() makes two
calls to the appropriate n_tty_receive_buf_* function. First call is
made with lookahead_done=true for the characters that were subject to
lookahead earlier and then with lookahead=false for the new characters.
Either of the calls might be skipped when it has no characters to
handle.
Reported-by: Gilles Buloz <gilles.buloz@kontron.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220606153652.63554-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-06 18:36:51 +03:00
|
|
|
*
|
|
|
|
* This function is called by the low-level tty driver for characters
|
|
|
|
* not eaten by ->receive_buf() or ->receive_buf2(). It is useful for
|
|
|
|
* processing high-priority characters such as software flow-control
|
|
|
|
* characters that could otherwise get stuck into the intermediate
|
|
|
|
* buffer until tty has room to receive them. Ldisc must be able to
|
|
|
|
* handle later a ->receive_buf() or ->receive_buf2() call for the
|
|
|
|
* same characters (e.g. by skipping the actions for high-priority
|
|
|
|
* characters already handled by ->lookahead_buf()).
|
|
|
|
*
|
2021-11-26 11:15:54 +03:00
|
|
|
* @owner: module containting this ldisc (for reference counting)
|
|
|
|
*
|
|
|
|
* This structure defines the interface between the tty line discipline
|
|
|
|
* implementation and the tty routines. The above routines can be defined.
|
|
|
|
* Unless noted otherwise, they are optional, and can be filled in with a %NULL
|
|
|
|
* pointer.
|
2021-11-26 11:15:56 +03:00
|
|
|
*
|
|
|
|
* Hooks marked [TTY] are invoked from the TTY core, the [DRV] ones from the
|
|
|
|
* tty_driver side.
|
2021-11-26 11:15:54 +03:00
|
|
|
*/
|
2008-07-17 00:53:12 +04:00
|
|
|
struct tty_ldisc_ops {
|
2005-04-17 02:20:36 +04:00
|
|
|
char *name;
|
|
|
|
int num;
|
2013-03-06 17:38:21 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* The following routines are called from above.
|
|
|
|
*/
|
2021-11-26 11:15:54 +03:00
|
|
|
int (*open)(struct tty_struct *tty);
|
|
|
|
void (*close)(struct tty_struct *tty);
|
2005-04-17 02:20:36 +04:00
|
|
|
void (*flush_buffer)(struct tty_struct *tty);
|
2013-03-06 17:38:21 +04:00
|
|
|
ssize_t (*read)(struct tty_struct *tty, struct file *file,
|
2021-01-19 00:31:30 +03:00
|
|
|
unsigned char *buf, size_t nr,
|
|
|
|
void **cookie, unsigned long offset);
|
2013-03-06 17:38:21 +04:00
|
|
|
ssize_t (*write)(struct tty_struct *tty, struct file *file,
|
|
|
|
const unsigned char *buf, size_t nr);
|
2021-11-22 12:45:29 +03:00
|
|
|
int (*ioctl)(struct tty_struct *tty, unsigned int cmd,
|
|
|
|
unsigned long arg);
|
|
|
|
int (*compat_ioctl)(struct tty_struct *tty, unsigned int cmd,
|
|
|
|
unsigned long arg);
|
2022-08-16 14:57:36 +03:00
|
|
|
void (*set_termios)(struct tty_struct *tty, const struct ktermios *old);
|
2021-11-26 11:15:54 +03:00
|
|
|
__poll_t (*poll)(struct tty_struct *tty, struct file *file,
|
|
|
|
struct poll_table_struct *wait);
|
2021-09-14 12:11:22 +03:00
|
|
|
void (*hangup)(struct tty_struct *tty);
|
2013-03-06 17:38:21 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* The following routines are called from below.
|
|
|
|
*/
|
2021-11-26 11:15:54 +03:00
|
|
|
void (*receive_buf)(struct tty_struct *tty, const unsigned char *cp,
|
2021-05-05 12:19:04 +03:00
|
|
|
const char *fp, int count);
|
2021-11-26 11:15:54 +03:00
|
|
|
void (*write_wakeup)(struct tty_struct *tty);
|
|
|
|
void (*dcd_change)(struct tty_struct *tty, unsigned int status);
|
|
|
|
int (*receive_buf2)(struct tty_struct *tty, const unsigned char *cp,
|
2021-05-05 12:19:04 +03:00
|
|
|
const char *fp, int count);
|
tty: Implement lookahead to process XON/XOFF timely
When tty is not read from, XON/XOFF may get stuck into an
intermediate buffer. As those characters are there to do software
flow-control, it is not very useful. In the case where neither end
reads from ttys, the receiving ends might not be able receive the
XOFF characters and just keep sending more data to the opposite
direction. This problem is almost guaranteed to occur with DMA
which sends data in large chunks.
If TTY is slow to process characters, that is, eats less than given
amount in receive_buf, invoke lookahead for the rest of the chars
to process potential XON/XOFF characters.
We need to keep track of how many characters have been processed by the
lookahead to avoid processing the flow control char again on the normal
path. Bookkeeping occurs parallel on two layers (tty_buffer and n_tty)
to avoid passing the lookahead_count through the whole call chain.
When a flow-control char is processed, two things must occur:
a) it must not be treated as normal char
b) if not yet processed, flow-control actions need to be taken
The return value of n_tty_receive_char_flow_ctrl() tells caller a), and
b) is kept internal to n_tty_receive_char_flow_ctrl().
If characters were previous looked ahead, __receive_buf() makes two
calls to the appropriate n_tty_receive_buf_* function. First call is
made with lookahead_done=true for the characters that were subject to
lookahead earlier and then with lookahead=false for the new characters.
Either of the calls might be skipped when it has no characters to
handle.
Reported-by: Gilles Buloz <gilles.buloz@kontron.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220606153652.63554-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-06 18:36:51 +03:00
|
|
|
void (*lookahead_buf)(struct tty_struct *tty, const unsigned char *cp,
|
|
|
|
const unsigned char *fp, unsigned int count);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct module *owner;
|
|
|
|
};
|
|
|
|
|
2008-07-17 00:53:12 +04:00
|
|
|
struct tty_ldisc {
|
|
|
|
struct tty_ldisc_ops *ops;
|
2013-06-15 15:04:48 +04:00
|
|
|
struct tty_struct *tty;
|
2008-07-17 00:53:12 +04:00
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#define MODULE_ALIAS_LDISC(ldisc) \
|
|
|
|
MODULE_ALIAS("tty-ldisc-" __stringify(ldisc))
|
|
|
|
|
2021-07-23 13:31:42 +03:00
|
|
|
extern const struct seq_operations tty_ldiscs_seq_ops;
|
|
|
|
|
|
|
|
struct tty_ldisc *tty_ldisc_ref(struct tty_struct *);
|
|
|
|
void tty_ldisc_deref(struct tty_ldisc *);
|
|
|
|
struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *);
|
|
|
|
|
|
|
|
void tty_ldisc_flush(struct tty_struct *tty);
|
|
|
|
|
|
|
|
int tty_register_ldisc(struct tty_ldisc_ops *new_ldisc);
|
|
|
|
void tty_unregister_ldisc(struct tty_ldisc_ops *ldisc);
|
|
|
|
int tty_set_ldisc(struct tty_struct *tty, int disc);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif /* _LINUX_TTY_LDISC_H */
|