From patchwork Fri Sep 21 15:25:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Cox X-Patchwork-Id: 1492011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id CC2F53FE65 for ; Fri, 21 Sep 2012 15:23:17 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TF52T-0000dw-JS; Fri, 21 Sep 2012 15:21:09 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TF52R-0000dr-54 for linux-arm-kernel@merlin.infradead.org; Fri, 21 Sep 2012 15:21:07 +0000 Received: from lxorguk.ukuu.org.uk ([81.2.110.251]) by casper.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TF52O-00020P-IZ for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2012 15:21:05 +0000 Received: from pyramind.ukuu.org.uk (earthlight.etchedpixels.co.uk [81.2.110.250]) by lxorguk.ukuu.org.uk (8.14.5/8.14.1) with ESMTP id q8LFrJ0N021631; Fri, 21 Sep 2012 16:53:24 +0100 Received: from pyramind.ukuu.org.uk (localhost [127.0.0.1]) by pyramind.ukuu.org.uk (8.14.5/8.14.5) with ESMTP id q8LFPhLC022495; Fri, 21 Sep 2012 16:25:43 +0100 Date: Fri, 21 Sep 2012 16:25:43 +0100 From: Alan Cox To: Linus Walleij Subject: Re: [PATCH 3/3] serial: pl011: allow very high baudrates Message-ID: <20120921162543.1ed18775@pyramind.ukuu.org.uk> In-Reply-To: References: <1348134368-25663-1-git-send-email-linus.walleij@stericsson.com> <20120920190034.GB15609@n2100.arm.linux.org.uk> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.8; x86_64-redhat-linux-gnu) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEWysKsSBQMIAwIZCwj///8wIhxoRDXH9QHCAAABeUlEQVQ4jaXTvW7DIBAAYCQTzz2hdq+rdg494ZmBeE5KYHZjm/d/hJ6NfzBJpp5kRb5PHJwvMPMk2L9As5Y9AmYRBL+HAyJKeOU5aHRhsAAvORQ+UEgAvgddj/lwAXndw2laEDqA4x6KEBhjYRCg9tBFCOuJFxg2OKegbWjbsRTk8PPhKPD7HcRxB7cqhgBRp9Dcqs+B8v4CQvFdqeot3Kov6hBUn0AJitrzY+sgUuiA8i0r7+B3AfqKcN6t8M6HtqQ+AOoELCikgQSbgabKaJW3kn5lBs47JSGDhhLKDUh1UMipwwinMYPTBuIBjEclSaGZUk9hDlTb5sUTYN2SFFQuPe4Gox1X0FZOufjgBiV1Vls7b+GvK3SU4wfmcGo9rPPQzgIabfj4TYQo15k3bTHX9RIw/kniir5YbtJF4jkFG+dsDK1IgE413zAthU/vR2HVMmFUPIHTvF6jWCpFaGw/A3qWgnbxpSm9MSmY5b3pM1gvNc/gQfwBsGwF0VCtxZgAAAAASUVORK5CYII= Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120921_162104_759757_0F22B31F X-CRM114-Status: GOOD ( 15.36 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.3.2 on casper.infradead.org summary: Content analysis details: (-2.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Russell King - ARM Linux , Linus Walleij , Greg Kroah-Hartman , Christophe Arnal , Guillaume Jaunet , Par-Gunnar Hjalmdahl , Anmar Oueja , Matthias Locher , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, "Rajanikanth H.V" , Alan Cox X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Untested but I suspect the following may help commit 44590a8cc4ee6e40737b843d1d9593345ef3bf04 Author: Alan Cox Date: Fri Sep 21 16:36:36 2012 +0100 serial: avoid iteratively re-encoding the termios If we do that then we will corrupt the termios data in some situations and thus not nicely encode the baud rates as we should. Signed-off-by: Alan Cox diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 78036c5..73a169e 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -348,8 +348,9 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, else if (flags == UPF_SPD_WARP) altbaud = 460800; + baud = tty_termios_baud_rate(termios); + for (try = 0; try < 2; try++) { - baud = tty_termios_baud_rate(termios); /* * The spd_hi, spd_vhi, spd_shi, spd_warp kludge... @@ -359,26 +360,25 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, baud = altbaud; /* - * Special case: B0 rate. + * Special case: B0 rate. Note: this breaks if the + * device cannot support 9600 baud */ if (baud == 0) { hung_up = 1; baud = 9600; } - if (baud >= min && baud <= max) + if (baud >= min && baud <= max) { + tty_termios_encode_baud_rate(tty, baud, baud); return baud; + } /* * Oops, the quotient was zero. Try again with * the old baud rate if possible. */ - termios->c_cflag &= ~CBAUD; if (old) { baud = tty_termios_baud_rate(old); - if (!hung_up) - tty_termios_encode_baud_rate(termios, - baud, baud); old = NULL; continue; } @@ -389,11 +389,9 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, */ if (!hung_up) { if (baud <= min) - tty_termios_encode_baud_rate(termios, - min + 1, min + 1); + baud = min + 1; else - tty_termios_encode_baud_rate(termios, - max - 1, max - 1); + baud = max - 1; } } /* Should never happen */