Received: by 10.192.165.156 with SMTP id m28csp1101322imm; Wed, 11 Apr 2018 12:25:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx48P543iYDJI2AcQ/NpCKNf7OvF1yl/JRg9nwtx76h4rSJYfOQRFwob1Mfewz42uXahQcpjd X-Received: by 2002:a17:902:52ec:: with SMTP id a99-v6mr812495pli.371.1523474758517; Wed, 11 Apr 2018 12:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523474758; cv=none; d=google.com; s=arc-20160816; b=s+7AWpplj0Hzt/ETTDc7y0Fsmv/Cf8dJE9oFi1ngeHnDV923lrkFZiXu56EV1LS4lU H7gCTGcthub24ut2oQ5Dey+fcjPhbreyiLTbFn6pjmBWCxX/v0AU2geAOYvLhlkEMth9 BwHETeYdgCDSyq8ORiJkZOa49iPBzz7m1xXCRsKfeMC5nhKQoWwAoJr/FvQj+NHXf2Xt SwjaBxLg2rMXELEdf153T1wPkNGpBH7kU41EIQivGqKCzq5Omat69UL/4njMNqVQBnXG 9HbxW4AV5WsvuPCWH277wBDwNafgr+9VbBLZPma3B34DpbfA0YtK7LXhHoyk7N8isw02 amUQ== 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=2dxGFPh7M2Vb1Rxw1xeMJ3CxIZbDtbisAlTsUEghCnc=; b=ZSDzgB8xq0l3J+q4SH6tJn8r/LGwKYWfi1nK6euPc3oPKpSQQocykfcLTvYM53PThn rEIAOQ6yfi4Y9CMZdfurBiTA02jfpW5Ol44lgJMiYusWL7Mi9ORmGNpRsntMg3ofg7VT h0QGKtQyytcYveD0klKaUtmdH7vMLaRb0dRYOZLCA+0+U2G6Einp7Ud0wnEe9NfvF5TE k/15T+J9ffK9U7aaTV4k6w7YYMJkFwbs5BYFlWsgQjgWjOXmFsiuHsXBWAk6fVJzejC9 5eVNTn3fTJi/45CPgDOVCwu3YpIn5vVM0GDlsf3LuPIWh6haoNLRY96+CG+p4ctY4pVC vNJQ== 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 f3-v6si1721554plf.446.2018.04.11.12.25.21; Wed, 11 Apr 2018 12:25:58 -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 S934902AbeDKTTn (ORCPT + 99 others); Wed, 11 Apr 2018 15:19:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39950 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934870AbeDKTEi (ORCPT ); Wed, 11 Apr 2018 15:04:38 -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 24B5BC9F; Wed, 11 Apr 2018 19:04:37 +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.9 263/310] tty: n_gsm: Allow ADM response in addition to UA for control dlci Date: Wed, 11 Apr 2018 20:36:42 +0200 Message-Id: <20180411183633.976088548@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@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.9-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 @@ -1467,6 +1467,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) @@ -1480,8 +1484,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--; @@ -1499,8 +1510,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. */