]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tty: n_gsm: Fix control dlci ADM mode processing
authorIvaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Sat, 28 Dec 2024 15:01:00 +0000 (17:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Jan 2025 10:50:07 +0000 (11:50 +0100)
Currently, code retries n2 times to open control dlci in ABM mode before
switching to ADM mode, but only if DM has been received. This contradicts
to the comment that dlci is switched to control mode unconditionally if
DLCI_OPENING retries time out. Also, it does not make sense to continue
trying once DM has received.

Change the logic to switch to ADM mode upon DM received. That way control
channel state will change to DLCI_OPEN way faster. Fix the misleading
comment while at it.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20241228150100.100354-3-ivo.g.dimitrov.75@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_gsm.c

index b92480051e3dbb59f68307dd64f42b86d353b4bc..363afe11974f579b9dabdd137fef3011eb95eb10 100644 (file)
@@ -2224,7 +2224,7 @@ static int gsm_dlci_negotiate(struct gsm_dlci *dlci)
  *
  *     Some control dlci can stay in ADM mode with other dlci working just
  *     fine. In that case we can just keep the control dlci open after the
- *     DLCI_OPENING retries time out.
+ *     DLCI_OPENING receives DM.
  */
 
 static void gsm_dlci_t1(struct timer_list *t)
@@ -2243,7 +2243,12 @@ static void gsm_dlci_t1(struct timer_list *t)
                }
                break;
        case DLCI_OPENING:
-               if (dlci->retries) {
+               if (!dlci->addr && gsm->control == (DM | PF)) {
+                       if (debug & DBG_ERRORS)
+                               pr_info("DLCI 0 opening in ADM mode.\n");
+                       dlci->mode = DLCI_MODE_ADM;
+                       gsm_dlci_open(dlci);
+               } else if (dlci->retries) {
                        if (!dlci->addr || !gsm->dlci[0] ||
                            gsm->dlci[0]->state != DLCI_OPENING) {
                                dlci->retries--;
@@ -2251,11 +2256,6 @@ static void gsm_dlci_t1(struct timer_list *t)
                        }
 
                        mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
-               } else if (!dlci->addr && gsm->control == (DM | PF)) {
-                       if (debug & DBG_ERRORS)
-                               pr_info("DLCI 0 opening in ADM mode.\n");
-                       dlci->mode = DLCI_MODE_ADM;
-                       gsm_dlci_open(dlci);
                } else {
                        gsm->open_error++;
                        gsm_dlci_begin_close(dlci); /* prevent half open link */