Received: by 10.192.165.148 with SMTP id m20csp4157563imm; Mon, 30 Apr 2018 12:52:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqhKBnBOhcFCENx2Z3RARRDH+G5hPaKQbX3nkUup8cZuZaZYch9rtDP5KOnyZdg2QJXHjYX X-Received: by 2002:a17:902:5709:: with SMTP id k9-v6mr13274670pli.165.1525117956788; Mon, 30 Apr 2018 12:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525117956; cv=none; d=google.com; s=arc-20160816; b=Xvr7KrjkqrcSZ36PYiicnDp8RRdVfqgM77q+AWWtRu/DbFukGc1xR17Yij8OIx2GnO X0SPmhh91ZcCtefcJhQrpU+LbbYcG0KE6/FKYTjSnjaCRC5rBZ37/Yhic6xIE60JwmQ8 KDre9HEADy2puitBmZ6AD/eXAMfpCWovs+2gqLbCi+WoaaaYj3LXGRUydmaCeyjXRMpc LeX5mNY5C+5jph+5fPsxO0h0OrO7kA9aCQ+OyJRTCY6fdv6VBWeI42I+hTPhYKcJYeIx st8nmZgZX5fGIKf+DoPNtYzFccvIelgMzk2u905Ht8WIWHA+rZ1Yj0/N8H9fEO3I5hCU SnAQ== 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:dmarc-filter :arc-authentication-results; bh=wamp1KwJq8UlRhrfZiaArOMQebtGZiq2TMg/V3Ycxso=; b=RW7Jl/h3ggRhHJUp1g+yd9YIiKSXSMbvGAHWHObL7uzszRN7bdEXSIEad/gu3rxAjO KY9fuA6kJQkU/sVrQsciBRae/tts3y/kwxMmiDECvuECR3fGXSvMNj9t5cHmgyih92P/ gKTHkZyZOtbdFwfKdokptiOLIqvTlUAt8neFVx0ZR0G6401nhP9a9Ydk8YUWbUPsxE/5 5SRzKhHmom46lQFeme3/OxSVbAEk2PW+3vykJLtc5LltV+d/BLcZxrrI12qMccx0vAU6 x1V1rc6vujXdP04cycQGvWkkJvYOePvJJJ52ugkkFTp7F2iVovrdtprudB4VYkuGtyLx hj7w== 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 g63si8113179pfd.93.2018.04.30.12.52.22; Mon, 30 Apr 2018 12:52:36 -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 S1756386AbeD3TuV (ORCPT + 99 others); Mon, 30 Apr 2018 15:50:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:35446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756195AbeD3T2I (ORCPT ); Mon, 30 Apr 2018 15:28:08 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DCA1C22DCC; Mon, 30 Apr 2018 19:28:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCA1C22DCC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org 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 , Dan Williams , Jiri Prchal , Jiri Slaby , Marcel Partap , Merlijn Wajer , Michael Nazzareno Trimarchi , Michael Scott , Pavel Machek , Peter Hurley , Russ Gorby , Sascha Hauer , Sebastian Reichel , Tony Lindgren Subject: [PATCH 4.16 032/113] tty: n_gsm: Fix long delays with control frame timeouts in ADM mode Date: Mon, 30 Apr 2018 12:24:03 -0700 Message-Id: <20180430184016.419612744@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tony Lindgren commit e9ec22547986dd32c5c70da78107ce35dbff1344 upstream. Commit ea3d8465ab9b ("tty: n_gsm: Allow ADM response in addition to UA for control dlci") added support for DLCI to stay in Asynchronous Disconnected Mode (ADM). But we still get long delays waiting for commands to other DLCI to complete: --> 5) C: SABM(P) Q> 0) C: UIH(F) Q> 0) C: UIH(F) Q> 0) C: UIH(F) ... This happens because gsm_control_send() sets cretries timer to T2 that is by default set to 34. This will cause resend for T2 times for the control frame. In ADM mode, we will never get a response so the control frame, so retries are just delaying all the commands. Let's fix the issue by setting DLCI_MODE_ADM flag after detecting the ADM mode for the control DLCI. Then we can use that in gsm_control_send() to set retries to 1. This means the control frame will be sent once allowing the other end at an opportunity to switch from ADM to ABM mode. Note that retries will be decremented in gsm_control_retransmit() so we don't want to set it to 0 here. Fixes: ea3d8465ab9b ("tty: n_gsm: Allow ADM response in addition to UA for control dlci") Cc: linux-serial@vger.kernel.org Cc: Alan Cox Cc: Dan Williams Cc: Jiri Prchal Cc: Jiri Slaby Cc: Marcel Partap Cc: Merlijn Wajer Cc: Michael Nazzareno Trimarchi Cc: Michael Scott Cc: Pavel Machek Cc: Peter Hurley Cc: Russ Gorby Cc: Sascha Hauer Cc: Sebastian Reichel Signed-off-by: Tony Lindgren Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_gsm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -121,6 +121,9 @@ struct gsm_dlci { struct mutex mutex; /* Link layer */ + int mode; +#define DLCI_MODE_ABM 0 /* Normal Asynchronous Balanced Mode */ +#define DLCI_MODE_ADM 1 /* Asynchronous Disconnected Mode */ spinlock_t lock; /* Protects the internal state */ struct timer_list t1; /* Retransmit timer for SABM and UA */ int retries; @@ -1364,7 +1367,13 @@ retry: ctrl->data = data; ctrl->len = clen; gsm->pending_cmd = ctrl; - gsm->cretries = gsm->n2; + + /* If DLCI0 is in ADM mode skip retries, it won't respond */ + if (gsm->dlci[0]->mode == DLCI_MODE_ADM) + gsm->cretries = 1; + else + gsm->cretries = gsm->n2; + mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100); gsm_control_transmit(gsm, ctrl); spin_unlock_irqrestore(&gsm->control_lock, flags); @@ -1472,6 +1481,7 @@ static void gsm_dlci_t1(struct timer_lis if (debug & 8) pr_info("DLCI %d opening in ADM mode.\n", dlci->addr); + dlci->mode = DLCI_MODE_ADM; gsm_dlci_open(dlci); } else { gsm_dlci_close(dlci);