From patchwork Mon Apr 12 09:38:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12197463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E021BC43470 for ; Mon, 12 Apr 2021 09:46:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF8EC6120B for ; Mon, 12 Apr 2021 09:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242111AbhDLJqC (ORCPT ); Mon, 12 Apr 2021 05:46:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:55822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239136AbhDLJjB (ORCPT ); Mon, 12 Apr 2021 05:39:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 39C1E6124A; Mon, 12 Apr 2021 09:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618220314; bh=QDJTgFMDEzH6DCtgRlJKFTIuSBVCHxr3ft9FZhxyCi8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ksO6PHELWPjo9hpVVRkHo3k02/yR6PObodqvYUkJQGR6P8dsWfdBtPoLKSWCDgg9P aJ6nU2mTGG9YVniKrKUuqRvPQi/oaNeMeSBra+0e/+NTIBR3uSHsqBoWyy7SDjnkg4 6pJDRVDZbofyghD+JgqMBJCNAfAdRSz9x2Om5Cj8b9OGE9upVgZcemyJSmsCwLzO6T JosMUEYPrY3saNTLRf5kSZb+mo2KC1cX7zjw8GKiERG43+LexJlu2bsSNZzM8yvIdz sQBxyEKhacMVtETbm9FXiMmLl5D4rSdPWg1zn/vBiBXSmI8m1zAiYeGWoUEFQJSa/5 lzbU7L5nrC0aA== Received: from johan by xi with local (Exim 4.93.0.4) (envelope-from ) id 1lVt1Y-0000Ci-B9; Mon, 12 Apr 2021 11:38:28 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] USB: serial: f81232: drop time-based drain delay Date: Mon, 12 Apr 2021 11:38:12 +0200 Message-Id: <20210412093815.736-2-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210412093815.736-1-johan@kernel.org> References: <20210412093815.736-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The f81232 driver now waits for the transmit FIFO to drain during close so there is no need to keep the time-based drain delay, which would add up to two seconds on every close for low line speeds. Fixes: 98405f81036d ("USB: serial: f81232: add tx_empty function") Signed-off-by: Johan Hovold --- drivers/usb/serial/f81232.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index b4b847dce4bc..a7a7af8d05bf 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -948,7 +948,6 @@ static int f81232_port_probe(struct usb_serial_port *port) usb_set_serial_port_data(port, priv); - port->port.drain_delay = 256; priv->port = port; return 0; From patchwork Mon Apr 12 09:38:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12197459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 468CAC433B4 for ; Mon, 12 Apr 2021 09:45:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B0FE61247 for ; Mon, 12 Apr 2021 09:45:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240664AbhDLJpl (ORCPT ); Mon, 12 Apr 2021 05:45:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:55820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238880AbhDLJjB (ORCPT ); Mon, 12 Apr 2021 05:39:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 37BCF61249; Mon, 12 Apr 2021 09:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618220314; bh=t9qOhZ9FiANoiUN/D2w9FYQpykHnyvkO6VLNd1kcNIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PQl7zFERbr4YPhig/YkCw5KTqMJtSP0h1rInTvaAR84TTkMLUukYVaItTHyOMoZeK hk9vXcxyU4LC3HaMYxadVi9I/PXIaEdMlvjttyDVddiFGPnEbnAL5ZmESVOf0CFI// YHNn3mpSMjbJ5E10sRoPZME7IW0BnbqSSDUYdkcLCbHGw3O/6qPCUnRSyJ4XN9Ahtm RLZRYhlFAUAla+YYwJJALqgNlccOglrZAkNwQnDCSjWsf7whzSBq7CjOKe5t7FHYQm 8MJNIkdblGc/+XJvw31HFEt40XMMziLlYmRZgiobLe0pdYsf2WedGAC+4CFV54KgPU QUDnrVtgfxXdQ== Received: from johan by xi with local (Exim 4.93.0.4) (envelope-from ) id 1lVt1Y-0000Ck-E3; Mon, 12 Apr 2021 11:38:28 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] USB: serial: io_ti: document reason for drain delay Date: Mon, 12 Apr 2021 11:38:13 +0200 Message-Id: <20210412093815.736-3-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210412093815.736-1-johan@kernel.org> References: <20210412093815.736-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Document that the device line-status register doesn't tell when the transmitter shift register has emptied and that this is why the one-character drain delay is needed. Signed-off-by: Johan Hovold --- drivers/usb/serial/io_ti.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 75325c2b295e..17720670e06c 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2590,6 +2590,10 @@ static int edge_port_probe(struct usb_serial_port *port) if (ret) goto err; + /* + * The LSR does not tell when the transmitter shift register has + * emptied so add a one-character drain delay. + */ port->port.drain_delay = 1; return 0; From patchwork Mon Apr 12 09:38:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12197467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17F8AC43462 for ; Mon, 12 Apr 2021 09:46:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2AF461261 for ; Mon, 12 Apr 2021 09:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241723AbhDLJqE (ORCPT ); Mon, 12 Apr 2021 05:46:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:55932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239291AbhDLJjF (ORCPT ); Mon, 12 Apr 2021 05:39:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3BF626124C; Mon, 12 Apr 2021 09:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618220314; bh=yaWMoh1oN0d0dzUD64dBH6HNKA51GCQDv/Tyy4bCSB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BVU4TruWKRttYfsqbLq2Wh3TVWOkKwy/Lp88ouY0B+B0PPgOepR4920sHMMHwx+xk msqlb/ExSwzcmhAq58a8JQizuYfseChN8mZyHiqdC7Bgyns8887WIWiKf1ewqOXBBa 24OchhzKrcubCAc+9lJ7kwQEqFOHN2HvNrNRTWnfoKyQT4s65cboevfoCQr/DYWjLv HFHFuBI5r4m3yijmI/0yNh2uQRpcb0mGi2e3AFFtHaeysKRJB4wLCiuWcMp2JU+dHq afjzx1AqkNG4XhZ+RHE/eHAXwCSjJYlN+BB6FjSxM7MS1SnPRV5uJemNT/0hDCi4oI Cqq+zY4DKRukg== Received: from johan by xi with local (Exim 4.93.0.4) (envelope-from ) id 1lVt1Y-0000Co-Gv; Mon, 12 Apr 2021 11:38:28 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] USB: serial: ti_usb_3410_5052: reduce drain delay to one char Date: Mon, 12 Apr 2021 11:38:14 +0200 Message-Id: <20210412093815.736-4-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210412093815.736-1-johan@kernel.org> References: <20210412093815.736-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The three-character drain delay was added by commit f1175daa5312 ("USB: ti_usb_3410_5052: kill custom closing_wait") when removing the custom closing-wait implementation, which used a fixed 20 ms poll period and drain delay. This was likely a bit too conservative as a one-character timeout (e.g. 33 ms at 300 bps) should be enough to compensate for the lack of a transmitter empty bit in the TUSB5052 line-status register. Signed-off-by: Johan Hovold --- drivers/usb/serial/ti_usb_3410_5052.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 03839289d6c0..8ed64115987f 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -610,7 +610,11 @@ static int ti_port_probe(struct usb_serial_port *port) usb_set_serial_port_data(port, tport); - port->port.drain_delay = 3; + /* + * The TUSB5052 LSR does not tell when the transmitter shift register + * has emptied so add a one-character drain delay. + */ + port->port.drain_delay = 1; return 0; } From patchwork Mon Apr 12 09:38:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12197465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 992A4C43461 for ; Mon, 12 Apr 2021 09:46:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 684BE61247 for ; Mon, 12 Apr 2021 09:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242104AbhDLJp6 (ORCPT ); Mon, 12 Apr 2021 05:45:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:55816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241373AbhDLJjB (ORCPT ); Mon, 12 Apr 2021 05:39:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35CC761247; Mon, 12 Apr 2021 09:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618220314; bh=bqEtBdOkvB/DNRA6H4F+NMJ2qqkMlorwIcznImbrFYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fnBUps08cY4sxYvkhOiMh0HQ+gZKylUsOD4F56PdgXp1BScQfaZ50rP4pzbdjkh42 RjOQd/o1+R03TqemMeFTM5igu+B1R5aBMH3F/dKRD4DUeshBkJMT/dBPd4Zzi99i1R wMSrnCUmkgisZ4CUZuK4tJLqG02X2onJh6pUBbLik2ppj4qCmGS9dN4tX/jxkaXtvp 6kUaBfrLIiG/CLDu7gb9tMDPq1kPYq+/0wd/yYAPiCTygVIdmw5Ty099O+xhNUzrfT /t3DwQiOuOSeGR+WD3/M8CJ7TC8tTyiP3ghSJD1URSjFtJgs2kUxYb3SUUXXGT26bo MG2RKeKpVG/dw== Received: from johan by xi with local (Exim 4.93.0.4) (envelope-from ) id 1lVt1Y-0000Cr-Jo; Mon, 12 Apr 2021 11:38:28 +0200 From: Johan Hovold To: Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] USB: serial: ti_usb_3410_5052: drop drain delay for 3410 Date: Mon, 12 Apr 2021 11:38:15 +0200 Message-Id: <20210412093815.736-5-johan@kernel.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210412093815.736-1-johan@kernel.org> References: <20210412093815.736-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Unlike the TUSB5052, the TUSB3410 has an LSR TEMT bit to tell if both the transmitter data and shift registers are empty. Make sure to check also the shift register on TUSB3410 when waiting for the transmit buffer to drain during close and drop the time-based one-char delay which is otherwise needed (e.g. 90 ms at 110 bps). Signed-off-by: Johan Hovold --- drivers/usb/serial/ti_usb_3410_5052.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 8ed64115987f..d9bffb2de8bf 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -121,6 +121,7 @@ #define TI_LSR_ERROR 0x0F #define TI_LSR_RX_FULL 0x10 #define TI_LSR_TX_EMPTY 0x20 +#define TI_LSR_TX_EMPTY_BOTH 0x40 /* Line control */ #define TI_LCR_BREAK 0x40 @@ -614,7 +615,8 @@ static int ti_port_probe(struct usb_serial_port *port) * The TUSB5052 LSR does not tell when the transmitter shift register * has emptied so add a one-character drain delay. */ - port->port.drain_delay = 1; + if (!tport->tp_tdev->td_is_3410) + port->port.drain_delay = 1; return 0; } @@ -851,11 +853,20 @@ static int ti_chars_in_buffer(struct tty_struct *tty) static bool ti_tx_empty(struct usb_serial_port *port) { struct ti_port *tport = usb_get_serial_port_data(port); + u8 lsr, mask; int ret; - u8 lsr; + + /* + * TUSB5052 does not have the TEMT bit to tell if the shift register + * is empty. + */ + if (tport->tp_tdev->td_is_3410) + mask = TI_LSR_TX_EMPTY_BOTH; + else + mask = TI_LSR_TX_EMPTY; ret = ti_get_lsr(tport, &lsr); - if (!ret && !(lsr & TI_LSR_TX_EMPTY)) + if (!ret && !(lsr & mask)) return false; return true;