Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3526452imu; Mon, 7 Jan 2019 05:06:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN4+5uc1aaLX8F0ZKNZHvFgZ7pXemuyUyafPnlDr/csnUPvhWTyMe6nsPC+/hAfJRzzdJW2j X-Received: by 2002:a63:5d20:: with SMTP id r32mr10962758pgb.329.1546866403676; Mon, 07 Jan 2019 05:06:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546866403; cv=none; d=google.com; s=arc-20160816; b=ybbdNIw+RIc8AANTN5V1/AavqspQzibGzFqeAttPKaI69c6HX5Vvavd3Iybwsi4u9C NtLeCCM1wBRCmFzs8SW+sORtX86vCx+JRmAZEGzlTLpJAcUScqhm8RkplgmBDdkNIJnp SqcGfu//thzI6VhofSVpQgDfTBmYPb+aK7jQQDN2CF2CoQWTSYo4dN4mq81OaCLjSotW ljSJBEFZmRYYmuyEJGfy2mcxlAYwY80hf0FGZy5/m9Ir7vz9ug1gVNbjHNEJgbCaP1w+ mHZh4PIUiQOm5b0biPq5M6n2tF/eSzmL6+q/fxG9l3QH5uwjtGxr7NTXllYOlEzJuoKQ sDGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0FxDX+5AnHyuwCaYV+a87sySTeVEY8+pF2EUchtttMU=; b=G+S2s3MDILtG1YrUkVP2uOEjM1g2YR0l9RJLZUa6RLof7DEJQjyxY3YgJcY4sSdsZd Hfoa5f3QgmxGL3e8FBHpUGDIXapCkCVqTiY2tpLPP3BIUpVZMbQ0G3wPaTV4cv5ywQVT EmdHmGnPsNu/YFYdx2TxUAUFd+QSp+cq0tCbbOfMocy0KZywKDO59luEdWXiZWbBe8cI KHhWSn9QTAxbsalRchjC16QNdclZHPacGe7njElym72Fp2JtXa+sG9lNbJEyB/wIXohY zroey7qGNK0nuBVFGZzDVpfQ1uEPyo7ezIGZWTz+Y6m9aRwQLFi22lELzuQySPF6+7tX wdlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=11Yt7YlY; 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 3si30851395plq.138.2019.01.07.05.06.28; Mon, 07 Jan 2019 05:06:43 -0800 (PST) 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=@kernel.org header.s=default header.b=11Yt7YlY; 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 S1730973AbfAGNDS (ORCPT + 99 others); Mon, 7 Jan 2019 08:03:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:50752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730522AbfAGNDQ (ORCPT ); Mon, 7 Jan 2019 08:03:16 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 DD54F206BB; Mon, 7 Jan 2019 13:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866195; bh=TVDN2ykqWGbFWIl08st6vrWQDk/46mPtASMS9yGhdtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=11Yt7YlYOO9Vu/LBYLQLUVRUy7b2vcvZjpckexs3qQjRbO9Us62l2kpsMne/P0RC6 fVnM0rS085T+wP6jKoA/EFPL5Mq3GKYPwg3/vCQgHvtPNqlr+8ezFadUytEuOB5MUG Dqxj+YOHU6huk82GUUHJY3QoLFjTz2gYzdA9LbQw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Macpaul Lin , Johan Hovold , Oliver Neukum Subject: [PATCH 4.14 076/101] cdc-acm: fix abnormal DATA RX issue for Mediatek Preloader. Date: Mon, 7 Jan 2019 13:33:04 +0100 Message-Id: <20190107105337.131531897@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.372621917@linuxfoundation.org> References: <20190107105330.372621917@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Macpaul Lin commit eafb27fa5283599ce6c5492ea18cf636a28222bb upstream. Mediatek Preloader is a proprietary embedded boot loader for loading Little Kernel and Linux into device DRAM. This boot loader also handle firmware update. Mediatek Preloader will be enumerated as a virtual COM port when the device is connected to Windows or Linux OS via CDC-ACM class driver. When the USB enumeration has been done, Mediatek Preloader will send out handshake command "READY" to PC actively instead of waiting command from the download tool. Since Linux 4.12, the commit "tty: reset termios state on device registration" (93857edd9829e144acb6c7e72d593f6e01aead66) causes Mediatek Preloader receiving some abnoraml command like "READYXX" as it sent. This will be recognized as an incorrect response. The behavior change also causes the download handshake fail. This change only affects subsequent connects if the reconnected device happens to get the same minor number. By disabling the ECHO termios flag could avoid this problem. However, it cannot be done by user space configuration when download tool open /dev/ttyACM0. This is because the device running Mediatek Preloader will send handshake command "READY" immediately once the CDC-ACM driver is ready. This patch wants to fix above problem by introducing "DISABLE_ECHO" property in driver_info. When Mediatek Preloader is connected, the CDC-ACM driver could disable ECHO flag in termios to avoid the problem. Signed-off-by: Macpaul Lin Cc: stable@vger.kernel.org Reviewed-by: Johan Hovold Acked-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/cdc-acm.c | 10 ++++++++++ drivers/usb/class/cdc-acm.h | 1 + 2 files changed, 11 insertions(+) --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -593,6 +593,13 @@ static int acm_tty_install(struct tty_dr if (retval) goto error_init_termios; + /* + * Suppress initial echoing for some devices which might send data + * immediately after acm driver has been installed. + */ + if (acm->quirks & DISABLE_ECHO) + tty->termios.c_lflag &= ~ECHO; + tty->driver_data = acm; return 0; @@ -1685,6 +1692,9 @@ static const struct usb_device_id acm_id { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */ .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ }, + { USB_DEVICE(0x0e8d, 0x2000), /* MediaTek Inc Preloader */ + .driver_info = DISABLE_ECHO, /* DISABLE ECHO in termios flag */ + }, { USB_DEVICE(0x0e8d, 0x3329), /* MediaTek Inc GPS */ .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ }, --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h @@ -140,3 +140,4 @@ struct acm { #define QUIRK_CONTROL_LINE_STATE BIT(6) #define CLEAR_HALT_CONDITIONS BIT(7) #define SEND_ZERO_PACKET BIT(8) +#define DISABLE_ECHO BIT(9)