FAILED: patch "[PATCH] tty: n_gsm: fix software flow control handling" failed to apply to 4.14-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From f4f7d63287217ba25e5c80f5faae5e4f7118790e Mon Sep 17 00:00:00 2001
From: Daniel Starke <[email protected]>
Date: Fri, 22 Apr 2022 00:10:25 -0700
Subject: [PATCH] tty: n_gsm: fix software flow control handling
n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
the newer 27.010 here. Chapter 5.4.8.1 states that XON/XOFF characters
shall be used instead of Fcon/Fcoff command in advanced option mode to
handle flow control. Chapter 5.4.8.2 describes how XON/XOFF characters
shall be handled. Basic option mode only used Fcon/Fcoff commands and no
XON/XOFF characters. These are treated as data bytes here.
The current implementation uses the gsm_mux field 'constipated' to handle
flow control from the remote peer and the gsm_dlci field 'constipated' to
handle flow control from each DLCI. The later is unrelated to this patch.
The gsm_mux field is correctly set for Fcon/Fcoff commands ingsm_control_message(). However, the same is not true for XON/XOFF
characters in gsm1_receive().
Disable software flow control handling in the tty to allow explicit
handling by n_gsm.
Add the missing handling in advanced option mode for gsm_mux ingsm1_receive() to comply with the standard.
This patch depends on the following commit:
Commit 8838b2af23ca ("tty: n_gsm: fix SW flow control encoding/handling")
drivers/tty/n_gsm.c +16 -0
@@ -232,6 +232,7 @@ struct gsm_mux {int initiator;/* Did we initiate connection */ bool dead;/* Has the mux been shut down */ struct gsm_dlci *dlci[NUM_DLCI ]; +int old_c_iflag;/* termios c_iflag value before attach */ bool constipated;/* Asked by remote to shut up */ spinlock_t tx_lock;
@@ -2022,6 +2023,16 @@ static void gsm0_receive(struct gsm_mux *gsm, unsigned char c)static void gsm1_receive (struct gsm_mux *gsm,unsigned char c) { +/* handle XON/XOFF */ +if ((c &ISO_IEC_646_MASK ) ==XON ) { + gsm->constipated = true; +return ; + }else if ((c &ISO_IEC_646_MASK ) ==XOFF ) { + gsm->constipated = false; +/* Kick the link in case it is idling */ +gsm_data_kick (gsm,NULL ); +return ; + }if (c ==GSM1_SOF ) {/* EOF is only valid in frame if we have got to the data state */ if (gsm->state ==GSM_DATA ) {
@@ -2449,6 +2460,9 @@ static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)int ret, i; gsm->tty =tty_kref_get (tty); +/* Turn off tty XON/XOFF handling to handle it explicitly. */ + gsm->old_c_iflag = tty->termios.c_iflag; + tty->termios.c_iflag &= (IXON |IXOFF ); ret =gsm_activate_mux (gsm);if (ret !=0 )tty_kref_put (gsm->tty);
@@ -2489,6 +2503,8 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)WARN_ON (tty != gsm->tty);for (i =1 ; i <NUM_DLCI ; i++)tty_unregister_device (gsm_tty_driver, base + i); +/* Restore tty XON/XOFF handling. */ + gsm->tty->termios.c_iflag = gsm->old_c_iflag;tty_kref_put (gsm->tty); gsm->tty =NULL ; }