From patchwork Fri Oct 22 07:22:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Ma X-Patchwork-Id: 1544823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=dY1Ayi0B; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HbG5V3sqSz9sXN for ; Fri, 22 Oct 2021 18:22:37 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mdoso-00009i-KT; Fri, 22 Oct 2021 07:22:30 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mdosn-000098-Ch for kernel-team@lists.ubuntu.com; Fri, 22 Oct 2021 07:22:29 +0000 Received: from localhost.localdomain (unknown [222.129.35.96]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 039863F23B for ; Fri, 22 Oct 2021 07:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1634887349; bh=H+aKgtxpKuARNHVeGMXl5L3fKkM4CPcfrF/ss/CrwgY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dY1Ayi0B74I3hJyx2t26ZUr3e0M+nQ00lHhTjg3BuL6XYJmEzKMTZW15cwTXXez4O ++mTX+lfg/EUsbpE/D98odKySmcGc0TxUKgIWVIYXObso6RxMcVWg1JZzgKTtwOsfo KqYOXyB5N5qX5164CpenGGdTuZ/vtVT4+I8zvgY5dMMofnbTMDH4G5wGt4RmB1jut9 Iqm+D5ddXbWNJ1iwNjarppulJ0wU0mJBGKDgMY1MLo+5QT9WU15r2jn1laxwyF3vUm OkzrB9drNmb0fOjglEAHRKp+XFCYqQyX5FUuFl+afzAizXHlJkxYMRjYE2s3TLKLx3 BfsZeLfrAihxg== From: Aaron Ma To: kernel-team@lists.ubuntu.com Subject: [F][PATCH 2/2] USB: serial: pl2303: fix line-speed handling on newer chips Date: Fri, 22 Oct 2021 15:22:17 +0800 Message-Id: <20211022072217.468706-3-aaron.ma@canonical.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211022072217.468706-1-aaron.ma@canonical.com> References: <20211022072217.468706-1-aaron.ma@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Johan Hovold BugLink: https://bugs.launchpad.net/bugs/1948377 The latest chip family (HXN) apparently does not support setting the line speed using divisors and instead needs to use the direct encoding scheme for all rates. This specifically enables 50, 110, 134, 200 bps and other rates not supported by the original chip type. Fixes: ebd09f1cd417 ("USB: serial: pl2303: add support for PL2303HXN") Cc: stable@vger.kernel.org # 5.5 Cc: Charles Yeh Signed-off-by: Johan Hovold (cherry picked from commit 979d9cbe75b922ab1695b8ad5576115774f72e62) Signed-off-by: Aaron Ma --- drivers/usb/serial/pl2303.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 25b4333e9f85..67d2249cae22 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -184,6 +184,7 @@ struct pl2303_type_data { speed_t max_baud_rate; unsigned long quirks; unsigned int no_autoxonxoff:1; + unsigned int no_divisors:1; }; struct pl2303_serial_private { @@ -210,6 +211,7 @@ static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = { }, [TYPE_HXN] = { .max_baud_rate = 12000000, + .no_divisors = true, }, }; @@ -572,8 +574,12 @@ static void pl2303_encode_baud_rate(struct tty_struct *tty, baud = min_t(speed_t, baud, spriv->type->max_baud_rate); /* * Use direct method for supported baud rates, otherwise use divisors. + * Newer chip types do not support divisor encoding. */ - baud_sup = pl2303_get_supported_baud_rate(baud); + if (spriv->type->no_divisors) + baud_sup = baud; + else + baud_sup = pl2303_get_supported_baud_rate(baud); if (baud == baud_sup) baud = pl2303_encode_baud_rate_direct(buf, baud);