Commit 4a495b97 authored by Ivaylo Dimitrov's avatar Ivaylo Dimitrov Committed by Greg Kroah-Hartman
Browse files

tty: n_gsm: Fix control dlci ADM mode processing



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: default avatarIvaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20241228150100.100354-3-ivo.g.dimitrov.75@gmail.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e2e4025b
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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 */