Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4525942rwb; Tue, 6 Sep 2022 08:42:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR4oN8RNt92jIPlW6JKMaoBxsZNM/V967i5W/k3LleRkTHf2kUIU1y4tRZRoTxqpokAMFvoR X-Received: by 2002:a05:6a00:1410:b0:528:5a5a:d846 with SMTP id l16-20020a056a00141000b005285a5ad846mr56664770pfu.9.1662478929308; Tue, 06 Sep 2022 08:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662478929; cv=none; d=google.com; s=arc-20160816; b=l+oUn8VoyPKJSWqXEa0heo0+Jn5YJJBCLuhLtWXGE4J7lKrYlkHsWZn2C30T8eVNcj /uJpCqxiEmM74Jg/Lzktvh4QDO93Ut520hk5wl4/nxLOGFS85pxxGVXnpinNS3UnNfyu E7Zdb+o+icXJ6UD0fWMJBoYAgi84eei/3V5ojGuVmYMd0nULt3JkStxQemGq88OWwYzB Di4ZgsiDi1iBA4Zth/trKyEh2DXqwRW6D7yzBS+P/Ldh0rYtCDuWjPL3XAqpllENSB8m rLZGk42IuQkTEEUAIeah6QpCo5ktBnK1Q5IW5nchMJuIXAEtPttxRglLNB6QNaIVp3vW WWQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+ePwMkqaDH0ThHHKTjRlRGa+UeAu0rY8CMbCAnY6QIs=; b=Lk+lTMwtZkAMOQXRqTcVpiGOi85N41mBfS9Y+3EXJ93ILgO+Fxctw/NOK9Chomq5Lf NbTtuURCXvimWMud7avRTa6aW7KcuWcpm8Qx+wFUz3p5ODMsvTD58mmGbT2NgG9It/FA BoN6cpwF/nS1AG3uCJh5u0mTN/EsE5JWO2o30hJ1EubrN/ZV+zkrmDfz/0nof/5XCXg3 IGsvTjIo321Ge/pqeMs3mu/BfRHqofs1RWAnqBLtdmmri+0Q/+NlwyJ7WmiJSIg7KB7T POMsWE3Zx1KigDlaKbWhQSTwrIlHI7N1gY6d0/EsbWRssEvKSIcAmEapUilX+OKYJqrL c9jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Kyqv3ddO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a170902ecc400b00172ec19cb96si14675109plh.436.2022.09.06.08.41.57; Tue, 06 Sep 2022 08:42:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Kyqv3ddO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240174AbiIFN4n (ORCPT + 99 others); Tue, 6 Sep 2022 09:56:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239895AbiIFNyQ (ORCPT ); Tue, 6 Sep 2022 09:54:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E7B580B7F; Tue, 6 Sep 2022 06:41:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 42B9E61539; Tue, 6 Sep 2022 13:41:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F39DC433D7; Tue, 6 Sep 2022 13:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471668; bh=2kANwVg4Rl6NnGBq0LzTxlY7t3U55WnFxJwykv2/8uQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kyqv3ddOMZVySw5y3d7F16FsSS8QSUx2SfMvNYOjHY1ZghUZu4UvgL9DPBMJfaE6Q fxvTdPQGR12Sg5tdxIizAouA8IfTyw59/IhsUAtozq+zHC3GP/Lq1Ruv+k7qV0X1wQ mlkiu0n2/2sRQlphY8RcvrPCXvD1E5dvcJcFzjU4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Woithe , Johan Hovold Subject: [PATCH 5.15 106/107] USB: serial: ch341: fix lost character on LCR updates Date: Tue, 6 Sep 2022 15:31:27 +0200 Message-Id: <20220906132826.361860150@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132821.713989422@linuxfoundation.org> References: <20220906132821.713989422@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit 8e83622ae7ca481c76c8fd9579877f6abae64ca2 upstream. Disable LCR updates for pre-0x30 devices which use a different (unknown) protocol for line control and where the current register write causes the next received character to be lost. Note that updating LCR using the INIT command has no effect on these devices either. Reported-by: Jonathan Woithe Tested-by: Jonathan Woithe Link: https://lore.kernel.org/r/Ys1iPTfiZRWj2gXs@marvin.atrad.com.au Fixes: 4e46c410e050 ("USB: serial: ch341: reinitialize chip on reconfiguration") Fixes: 55fa15b5987d ("USB: serial: ch341: fix baud rate and line-control handling") Cc: stable@vger.kernel.org # 4.10 Signed-off-by: Johan Hovold [ johan: adjust context to 5.15 ] Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ch341.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -97,7 +97,10 @@ struct ch341_private { u8 mcr; u8 msr; u8 lcr; + unsigned long quirks; + u8 version; + unsigned long break_end; }; @@ -271,6 +274,9 @@ static int ch341_set_baudrate_lcr(struct * (stop bits, parity and word length). Version 0x30 and above use * CH341_REG_LCR only and CH341_REG_LCR2 is always set to zero. */ + if (priv->version < 0x30) + return 0; + r = ch341_control_out(dev, CH341_REQ_WRITE_REG, CH341_REG_LCR2 << 8 | CH341_REG_LCR, lcr); if (r) @@ -323,7 +329,9 @@ static int ch341_configure(struct usb_de r = ch341_control_in(dev, CH341_REQ_READ_VERSION, 0, 0, buffer, size); if (r < 0) goto out; - dev_dbg(&dev->dev, "Chip version: 0x%02x\n", buffer[0]); + + priv->version = buffer[0]; + dev_dbg(&dev->dev, "Chip version: 0x%02x\n", priv->version); r = ch341_control_out(dev, CH341_REQ_SERIAL_INIT, 0, 0); if (r < 0)