From patchwork Fri Sep 21 17:52:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1492741 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 7B0EE3FCFC for ; Fri, 21 Sep 2012 17:53:51 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TF7Oc-0006N9-L5; Fri, 21 Sep 2012 17:52:10 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TF7OY-0006MI-WD for linux-arm-kernel@lists.infradead.org; Fri, 21 Sep 2012 17:52:07 +0000 Received: by wibhn17 with SMTP id hn17so1717276wib.0 for ; Fri, 21 Sep 2012 10:52:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=O5L4c0yFvQ9V+hPaTAGwWpVwl4FjGcf+qA5awmrOhlg=; b=biOgvQ8QB2rXZ7C4KH8NPjTKQD3IaqShAi3lEJ5eyQIF9HSzonybItLoJVOxw+hHjW hDp1+jecxaAFA++DKFpSNrBSv3l+2GDWmpr5hXRafUU+bM+7/PB18c8WA2i4e/JANNou Lq/hvBCi0InmrJMaYyycppGbQK9XUNWDH8rAe9ZOHXRDi8Q/XX9uGvbl+nhhcykkUN91 cmarOtv5ZDSvVOAmBHUM1caKg2vIJDf/5IrbV8xurrcDUdTIUmh84sDe10WXg/bppthh 0a1TD83QDZfTdlcIBrXeQkOA/uYeQc8Dj7hbwNcaBfaDXk5CGvHKPJF+R4crtEOq5LzP ZsOw== MIME-Version: 1.0 Received: by 10.180.100.37 with SMTP id ev5mr5893214wib.5.1348249924849; Fri, 21 Sep 2012 10:52:04 -0700 (PDT) Received: by 10.223.156.203 with HTTP; Fri, 21 Sep 2012 10:52:04 -0700 (PDT) In-Reply-To: <20120921162543.1ed18775@pyramind.ukuu.org.uk> References: <1348134368-25663-1-git-send-email-linus.walleij@stericsson.com> <20120920190034.GB15609@n2100.arm.linux.org.uk> <20120921162543.1ed18775@pyramind.ukuu.org.uk> Date: Fri, 21 Sep 2012 19:52:04 +0200 Message-ID: Subject: Re: [PATCH 3/3] serial: pl011: allow very high baudrates From: Linus Walleij To: Alan Cox X-Gm-Message-State: ALoCoQnklMkDbCADk265LvvFmj8tZhsC5N7QcfSQ+UvotPg52ESsalo+0h0P7fgQKjVTi4U90GLJ X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.177 listed in list.dnswl.org] -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 On Fri, Sep 21, 2012 at 5:25 PM, Alan Cox wrote: > Untested but I suspect the following may help Nope it doesn't, it's not this part that goes wrong, it's the call to tty_termios_encode_baud_rate() that is the problem, not how it gets called. It's that function that fuzzes and "snaps" the baudrate to some rough-fit speed and screws things up for me. But I looked a bit at the patch as such. It doesn't compile, but when I fix it like this: > - if (baud >= min && baud <= max) > + if (baud >= min && baud <= max) { > + tty_termios_encode_baud_rate(tty, baud, baud); s/tty/termios/ Then it compiles, but regresses. What's going wrong is that the termios encoding of zero does not happen anymore, for baudrate 0, i.e whereas we used to encode 0 into termios and then return 9600 this encodes 9600 and returns 9600. So if I handle baudrate 9600 specially instead like this it works: * The spd_hi, spd_vhi, spd_shi, spd_warp kludge... @@ -362,26 +363,27 @@ 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; + /* Encode zeroes to preserve semantics */ + tty_termios_encode_baud_rate(termios, 0, 0); + return 9600; } - if (baud >= min && baud <= max) + if (baud >= min && baud <= max) { + tty_termios_encode_baud_rate(termios, 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; } @@ -392,11 +394,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 */ (FWIW Signed-off-by: Linus Walleij for the twoliner) But as mentioned I get the same errors... Yours, Linus Walleij diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 7d9fbb8..a2442fb 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -351,8 +351,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); /*