Received: by 10.213.65.68 with SMTP id h4csp1855970imn; Mon, 19 Mar 2018 15:21:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELtUiVViGKpp5jzATL9l9SNbQ9Q6d8qfn/lcT4bbT6IilYJhKqFxl90Y+elcm/IAHEPtmgTZ X-Received: by 2002:a17:902:c24:: with SMTP id 33-v6mr14277816pls.88.1521498103944; Mon, 19 Mar 2018 15:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521498103; cv=none; d=google.com; s=arc-20160816; b=x0FdlK+LqmPJBnVngTEp3vxG1KDOmx9NJczMnBTmxS4421YiCCOoU8tLOAmVqr5jpE rHBD2TZaKAZ5A7nDXsP4ccLvP42LpzQB58DZlJWTCz1A4XTV2KGr2UXrCnQQoYWEC7R2 ZsM3/mNlIveFfI+IkzlYFR8a29gR9+/K6Ww5oI41n7cGWcGosMhKJ4p3PNMvqk8FW1rO Ot7IzuMXXNAD0cWINtM4xliaG1gIquivqAW+oJ4PBYPnvB/kyPO/gftPUkFF/WS0RUwb f39en2MUNWNQNgp9TynvSSN6Zaja2u9W3VnRMxTpglJBwB/VIsCFAmAYLJ7heBT4dOag kXVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=md8xR6Xjrud+vkAnK7EeFwsEEt5pjn5nEz4kEJsS1xI=; b=K+/lWwHg87TwpCcBMWJPkPyKyXscnfg1v4frc7/NU0vCkcFhYqLhk4f/wbawaeQyS+ dYn6HAEoq3ZXsVvbrEqtgPYUYu+nA5UkQO90l7QM0w4d/wBtfNuRKdv6cko89wN8fAfR Oa14HV2OxUSceUV96eMycib/mo7uzoiMCdrvVXbPsmjDH44oEUepUdYc9RtEQniCFFC1 +qnXsWoY9LxCTtgivLbbfVDnYuVRpwUZEgJaf06JB/FWwzI0mBZX6gtfo/LphWKEgU4x K+pipySu7jsiIuLCIcIKfoifGXpvOQpVEyJCA4mHRyQLnkft2exBDveDFi/PAlQm4h3O c5CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=JMh6WHTy; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si140094pgu.531.2018.03.19.15.21.29; Mon, 19 Mar 2018 15:21:43 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=JMh6WHTy; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934012AbeCSWSt (ORCPT + 99 others); Mon, 19 Mar 2018 18:18:49 -0400 Received: from mail-sn1nam01on0129.outbound.protection.outlook.com ([104.47.32.129]:20557 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933224AbeCSPtm (ORCPT ); Mon, 19 Mar 2018 11:49:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=md8xR6Xjrud+vkAnK7EeFwsEEt5pjn5nEz4kEJsS1xI=; b=JMh6WHTyZKM4KPenSq/Yd+HtjCuMaDDOSsnFD2MY7TYOsH5XgwbnPTSl6+rTGKNzrwiigVosSxsGq2u+IZDX7ID+YC10Ks14z4wF0oZXtdYgtfwyJy1hzZXVQjBZtXaD7B0PuG0Q26fmGc422Drw3hd2lOgJNCQzlv3HByS9RwM= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0981.namprd21.prod.outlook.com (52.132.133.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.0; Mon, 19 Mar 2018 15:49:37 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:49:37 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Tony Lindgren , "linux-serial@vger.kernel.org" , Alan Cox , Jiri Prchal , Jiri Slaby , Marcel Partap , Michael Scott , Peter Hurley , Russ Gorby , Sascha Hauer , Sebastian Reichel , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 092/124] tty: n_gsm: Allow ADM response in addition to UA for control dlci Thread-Topic: [PATCH AUTOSEL for 4.15 092/124] tty: n_gsm: Allow ADM response in addition to UA for control dlci Thread-Index: AQHTv5nBnE4l0G5PtkeIfoWHRPuZ8Q== Date: Mon, 19 Mar 2018 15:48:42 +0000 Message-ID: <20180319154645.11350-92-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0981;7:ixkPz17lUG6Omi7QLCOidB1HrCgAMEyXjcwvwIUCtBz2w0xcdg6rQ96m6UqYzeO4YPea5f8s7FrOlSU2HZv41c+jes9hzflXX6VRm/W0vsMh9GzXxbUYvSA/1JfpLQ7iZqOa1WsFyNdFTRck9Rzj37Khrtgv38PTdBP0Ooq3xxFQiT2qJ9a7pjCwIL2tQPLSlJd0GWFvwK6+CDk37JujvPRGSWMH3Bf+s2tM8afIHBBkT8zbrVjIdOoe4kioiAK2;20:1hPnVH+6tduACU4Ybw5qfA9EHJjNbTgBZmN1sj7mfjJJE17ySZlRDV5YA3YvKWsu7i04oeZbaX7FXs7/M5+UoAscxxVpy2pkvD3/CzBAvKkMI6E5II+gDjeLo2ltg3ABIIRwRykqCk/jNQMVcP9CsJekqFi1bJuMet2TZ+FUSV4= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: c694db1d-f669-42ce-7e02-08d58db104cd x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0981; x-ms-traffictypediagnostic: DM5PR2101MB0981: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055)(248736688235697)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501300)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0981;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0981; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(376002)(366004)(39860400002)(39380400002)(189003)(199004)(66066001)(6486002)(26005)(110136005)(5660300001)(54906003)(3280700002)(6512007)(68736007)(102836004)(6436002)(107886003)(10290500003)(53936002)(7416002)(186003)(59450400001)(72206003)(14454004)(36756003)(6666003)(2950100002)(316002)(6506007)(22452003)(478600001)(10090500001)(106356001)(105586002)(99286004)(7736002)(3660700001)(86362001)(76176011)(305945005)(86612001)(2501003)(97736004)(5250100002)(4326008)(3846002)(6116002)(1076002)(8936002)(25786009)(81156014)(81166006)(8676002)(2900100001)(2906002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0981;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Jt3z3xZp8CwNcR+rv+/5EbeV9jfe4XCTXDfj80CvPiOv/b8BcusWIQ5SkVWzYsVqKKA95/mu0RSa16rS2dhpBtNRwg3JhluWfFLo88IeHxGbRz/AG00YZM2q904ztLBUCQLXSmUMOcvGbcrR44HBUiopYjzpabcn/cnMjTTKHvIeUz4uB+gwyy0tVmNKQPDyXoxyyE9ra9CijnOdQMRbIJrrrDFeh/ofzuK+UWd7Jk6ckGox8kvqFGWwTLSVNORkQoxbWgiagcPlApkicQ8VIt9T/9kgI8VwIFHkyeSgDty0eI9xqYiMAFjlIrgtFk1LHSgq6v/0cdKKcDjoAJ1rmQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: c694db1d-f669-42ce-7e02-08d58db104cd X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:48:43.0308 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0981 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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=3D0xff # 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) =3D -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 --- drivers/tty/n_gsm.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 5131bdc9e765..db33fc50bfaa 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1451,6 +1451,10 @@ static void gsm_dlci_open(struct gsm_dlci *dlci) * 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. */ =20 static void gsm_dlci_t1(struct timer_list *t) @@ -1464,8 +1468,15 @@ static void gsm_dlci_t1(struct timer_list *t) 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 =3D=3D (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_list *t) * @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. */ =20 --=20 2.14.1