Received: by 10.192.165.156 with SMTP id m28csp44435imm; Tue, 10 Apr 2018 16:03:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ImRVE68qylqITmYd7Cy8qj4llsM4M7iLjhGMxdELAuSku4ceDPdNEIbtM8hGB7yFlowsQ X-Received: by 2002:a17:902:f44:: with SMTP id 62-v6mr2389001ply.318.1523401384513; Tue, 10 Apr 2018 16:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523401384; cv=none; d=google.com; s=arc-20160816; b=L3VEZN3q1HXVfiv9oONZiGsWJfOWmAAe60IQtp15zY3NKkXiVKPQ25pES3GC4E3xve kNJheQKyAbcBY4KwGRGm3rAcB7WIkWqzWzBXGITJ6sgHffJFHqi0T1DMecnsB+gXihNC 89ltzu7LS2BR/JNizQiEMOiSx2dWEa7BKGNA/M+wJEIxtWPxMH8eqyd1jmdIrzesOXi6 iCXFs7z0KRut3m0fk3kr62fsmqsBXsWWDqzqFP25KEAdGqn1HcyOAkZNamNW2ZljepSI 5xRnMVBodcj3MGcJR9LVqU+mcOXRsngbYpQ+s0uk0zRMHg67kwg0D3jvUxervncvMsQN nDBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Bdul1nSufYuwvJJpIkIUECjsZtOINnvC9/cVvVdxiZo=; b=q8S0M/VlX2iVXIeJ2ILyljiMX77fP/LHRCCCtfzvJHNZ6x/omACshhucFMKnUhJg/k rwC/mqK8zhrOa3u+7OdzrmtbQzqTpyJzw/hSiog1MsX74tD+rx0AmQjIhaqHy+WTJK9E jfBnh/OhvOe0I6FT6EJl5Zx3bZ83rOP23FBZ6HzxKOCUVfgt1xKTvFRTG4uXWIICmPB6 x7LqUHk3QL2IC9Hzl8EjJYKH3kS1A7TjA2RVtJz/rwvzM6PHYgtuddZLxPGRSFCglsmp /cEERyV5uo+duO99LBhWw1rPtUqj5MSKYvIpRbrsASZGXzTC7426zDP8Yz3hkCZBOPgb 1uow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f130si2398773pgc.304.2018.04.10.16.02.27; Tue, 10 Apr 2018 16:03:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756414AbeDJW5R (ORCPT + 99 others); Tue, 10 Apr 2018 18:57:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43210 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755652AbeDJWgm (ORCPT ); Tue, 10 Apr 2018 18:36:42 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 60EEAE03; Tue, 10 Apr 2018 22:36:26 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linux-serial@vger.kernel.org, Alan Cox , Jiri Prchal , Jiri Slaby , Marcel Partap , Michael Scott , Peter Hurley , Russ Gorby , Sascha Hauer , Sebastian Reichel , Tony Lindgren , Sasha Levin Subject: [PATCH 4.14 064/138] tty: n_gsm: Allow ADM response in addition to UA for control dlci Date: Wed, 11 Apr 2018 00:24:14 +0200 Message-Id: <20180410212909.543916081@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tony Lindgren [ Upstream commit ea3d8465ab9b3e01be329ac5195970a84bef76c5 ] Some devices have the control dlci stay in ADM mode instead of the UA mode. This can seen at least on droid 4 when trying to open the ts 27.010 mux port. Enabling n_gsm debug mode shows the control dlci always respond with DM to SABM instead of UA: # modprobe n_gsm debug=0xff # ldattach -d GSM0710 /dev/ttyS0 & gsmld_output: 00000000: f9 03 3f 01 1c f9 --> 0) C: SABM(P) gsmld_receive: 00000000: f9 03 1f 01 36 f9 <-- 0) C: DM(P) ... $ minicom -D /dev/gsmtty1 minicom: cannot open /dev/gsmtty1: No error information $ strace minicom -D /dev/gsmtty1 ... open("/dev/gsmtty1", O_RDWR|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = -1 EL2HLT Note that this is different issue from other n_gsm -EL2HLT issues such as timeouts when the control dlci does not respond at all. The ADM mode seems to be a quite common according to "RF Wireless World" article "GSM Issue-UE sends SABM and gets a DM response instead of UA response": This issue is most commonly observed in GSM networks where in UE sends SABM and expects network to send UA response but it ends up receiving DM response from the network. SABM stands for Set asynchronous balanced mode, UA stands for Unnumbered Acknowledge and DA stands for Disconnected Mode. An RLP entity can be in one of two modes: - Asynchronous Balanced Mode (ABM) - Asynchronous Disconnected Mode (ADM) Currently Linux kernel closes the control dlci after several retries in gsm_dlci_t1() on DM. This causes n_gsm /dev/gsmtty ports to produce error code -EL2HLT when trying to open them as the closing of control dlci has already set gsm->dead. Let's fix the issue by allowing control dlci stay in ADM mode after the retries so the /dev/gsmtty ports can be opened and used. It seems that it might take several attempts to get any response from the control dlci, so it's best to allow ADM mode only after the SABM retries are done. Note that for droid 4 additional patches are needed to mux the ttyS0 pins and to toggle RTS gpio_149 to wake up the mdm6600 modem are also needed to use n_gsm. And the mdm6600 modem needs to be powered on. Cc: linux-serial@vger.kernel.org Cc: Alan Cox Cc: Jiri Prchal Cc: Jiri Slaby Cc: Marcel Partap Cc: Michael Scott Cc: Peter Hurley Cc: Russ Gorby Cc: Sascha Hauer Cc: Sebastian Reichel Signed-off-by: Tony Lindgren Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_gsm.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1463,6 +1463,10 @@ static void gsm_dlci_open(struct gsm_dlc * in which case an opening port goes back to closed and a closing port * is simply put into closed state (any further frames from the other * end will get a DM response) + * + * 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. */ static void gsm_dlci_t1(unsigned long data) @@ -1476,8 +1480,15 @@ static void gsm_dlci_t1(unsigned long da if (dlci->retries) { gsm_command(dlci->gsm, dlci->addr, SABM|PF); mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100); - } else + } else if (!dlci->addr && gsm->control == (DM | PF)) { + if (debug & 8) + pr_info("DLCI %d opening in ADM mode.\n", + dlci->addr); + gsm_dlci_open(dlci); + } else { gsm_dlci_close(dlci); + } + break; case DLCI_CLOSING: dlci->retries--; @@ -1495,8 +1506,8 @@ static void gsm_dlci_t1(unsigned long da * @dlci: DLCI to open * * Commence opening a DLCI from the Linux side. We issue SABM messages - * to the modem which should then reply with a UA, at which point we - * will move into open state. Opening is done asynchronously with retry + * to the modem which should then reply with a UA or ADM, at which point + * we will move into open state. Opening is done asynchronously with retry * running off timers and the responses. */