Received: by 10.192.165.156 with SMTP id m28csp23492imm; Tue, 10 Apr 2018 15:35:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Y9N5q2thB6ZFGzvXcsDNyox5IKnw6x5Coou+Pk9Q9YRhB+LE9YP2xn7+KBO/NsmDOqLkp X-Received: by 10.98.163.153 with SMTP id q25mr1835509pfl.189.1523399729114; Tue, 10 Apr 2018 15:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523399729; cv=none; d=google.com; s=arc-20160816; b=UNI+SxpTJL5mv9PHae683JxOyibF850U8FWy4GF9kqD8wbO2Q/9CRojexM+dan4D/H B8pgr4+NdnLiYfmVKQ+D5OqrvtcIULXcbrpt47qW0e1isHZiVFJJTRLU4aO/YXKAWS1e J24BRY2Fnv7zlZD+k+YKYlheJmmRv0LgX35RreOaZrwrXwuXHkiY+xDR5ItOLZU0yVKx TjLqSyqoJXUaGKhmFIc7wMR1W6pgO7aNSPucga1zRKuYN2HYs6HY62UmYu+NXmmiiEBb tBZrXwmqCQyZSQnk/KTloAk3D94aatyKTLynxYV4GSghzB5VQ7hA5ij3r/8DfiDBxR3W WlMA== 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=+RmNmUrfIyLwvXyl0DCyxefr93/MlGGGQmgUQVnYrDE=; b=hLVOkXlHPscQZJVmXC9Utyn41J30HMvXMEWcnSL+y9Zrxlqelr7+zVeLnrVPf5uLBu 8hzrmSIlU9VkMqoAPV48IiyYVZR8sNb7QhNg65JhQK8cpj30BOjhxGrLCKupigO16pBq LWBytLlWcwqD2QKRJ2sGzc7Ad7kg9WSYrlLR91DX4nA3LbmESQx0Oeiba3+H4ZHc9sbH 8x5jrlMGgseC2udZrhtoKmZ/StZDgi0TpM4l34L3QZW/NDRcPLpCxrMEPY8VK8b9ucQV FSq7i2IA2j3I/sNLT4Xve8/qGskq1N8QJQp/am8tQVDBdty8tTQT9lNnX1Ez3pbuoQAW P/FQ== 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 f5si2371049pgv.668.2018.04.10.15.34.52; Tue, 10 Apr 2018 15:35:29 -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 S1754328AbeDJW3c (ORCPT + 99 others); Tue, 10 Apr 2018 18:29:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39576 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754308AbeDJW32 (ORCPT ); Tue, 10 Apr 2018 18:29:28 -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 A4219D59; Tue, 10 Apr 2018 22:29:27 +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.15 082/168] tty: n_gsm: Allow ADM response in addition to UA for control dlci Date: Wed, 11 Apr 2018 00:23:44 +0200 Message-Id: <20180410212803.765778717@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@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.15-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 @@ -1451,6 +1451,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(struct timer_list *t) @@ -1464,8 +1468,15 @@ static void gsm_dlci_t1(struct timer_lis 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--; @@ -1483,8 +1494,8 @@ static void gsm_dlci_t1(struct timer_lis * @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. */