Received: by 10.223.164.202 with SMTP id h10csp6276812wrb; Wed, 22 Nov 2017 01:59:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMY5WTTeQ47ymRcIghU4gx6NUWfD6FSTUMus8NyPMfRpLQxZwzFUC5WNEfZVLHIiUJbIk+H/ X-Received: by 10.84.128.36 with SMTP id 33mr21340554pla.329.1511344761931; Wed, 22 Nov 2017 01:59:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511344761; cv=none; d=google.com; s=arc-20160816; b=ANCrgc1xWVylzHRao9YGI+qBHeJTZWxeUQCN2xzXDZPauJR+S2+hI8VdbZKqEQk+Us IFn06WG8eKEFsWAj8hJzvKWInaB62rOZKM3mAh3ZQvnQJ8I328xIhHRr0/+kD7vZGurI WN4QO5U9Yv2jIKlDH+bAQFjOOg598y8a8Jte+JtTc2ZUL+990XQBiDoIwJ0j/Iwdv5oW +QCQPP8aZlvbfbyqlek6cFVCleH0Wt1wcGh7vr7Oz3FEueUmjSx1++/uTAn6qWvVsH2e dsbdDgk52iaCs1GsQgMpEmOYBGxquWRpnAGFGxE9AGFF4DxOjHDBUCgxRWuWJ2hLWalA 4+jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=G5goXXxOk6icscCvKRIL489TUNVJR7XtMIASYxlcf7o=; b=FDg3J+fD62RZstUmuTUXPqm8WVxHxXzPfJwSF2U2Msbtr+yRto01YUaP7xtrAZf4CV UDDLWA8MRUN0mN2dRvlUGjHgPF6kNJE9fz5vorfwBwWbFrJmP3DI93dMY3RjsJqeZCjZ hjCL+Ei29uugKfHegDewPuNCsOAz9n7YX3aGM3wc2alLTxXyFKJr6rdM/RVaoBX368PY YsVcUQbeapALveX34eLaWdR05Ra5MMkGpc/rSAKsqC+qy1hPrWgjRRsftIFJswea02Ee md3C4HLNZSIQcCgsJc6CioKGfa5rN/Z+fq10rXCdANgIiTgn6ilgd+W1zvfzC4FCX7pa dBQQ== ARC-Authentication-Results: i=1; mx.google.com; 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 1si13297768plk.258.2017.11.22.01.59.10; Wed, 22 Nov 2017 01:59:21 -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; 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 S1751946AbdKVJ6c (ORCPT + 76 others); Wed, 22 Nov 2017 04:58:32 -0500 Received: from 19pmail.ess.barracuda.com ([64.235.150.245]:51977 "EHLO 19pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751749AbdKVJ62 (ORCPT ); Wed, 22 Nov 2017 04:58:28 -0500 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx29.ess.sfj.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Wed, 22 Nov 2017 09:57:59 +0000 Received: from mredfearn-linux.mipstec.com (10.150.130.83) by MIPSMAIL01.mipstec.com (10.20.43.31) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 22 Nov 2017 01:57:51 -0800 From: Matt Redfearn To: Greg Kroah-Hartman , Ralf Baechle , James Hogan CC: Eugeniy Paltsev , , , Matt Redfearn , "stable # 4 . 14" , "Marc Gonzalez" , Jiri Slaby , , Douglas Anderson , Jeffy Chen Subject: [PATCH 1/2] serial: 8250_early: Only set divisor if valid clk & baud Date: Wed, 22 Nov 2017 09:57:28 +0000 Message-ID: <1511344649-27612-1-git-send-email-matt.redfearn@mips.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.150.130.83] X-BESS-ID: 1511344679-637139-12578-470676-3 X-BESS-VER: 2017.14-r1710272128 X-BESS-Apparent-Source-IP: 12.201.5.28 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.187188 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If either uartclk or baud are 0, avoid calculating and setting a divisor based on them since the output will almost certainly be garbage. This also allows platforms such as the MIPS generic kernel, which has no way to know a valid BASE_BASE for the board it is actually booted on at compile time, to set BASE_BAUD to 0 and avoid early_8250 setting a bad divisor. This fixes a regression caused by commit 31cb9a8575ca ("earlycon: initialise baud field of earlycon device structure"), which changed the behavior of of_setup_earlycon such that it sets a baud rate in the earlycon structure where previously it was left as 0. All boards supported by the MIPS generic kernel started outputting garbage from the boot console due to an incorrect divisor being set. Fixes: 31cb9a8575ca ("earlycon: initialise baud field of earlycon device structure") Cc: stable # 4.14 Signed-off-by: Matt Redfearn --- drivers/tty/serial/8250/8250_early.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index af72ec32e404..f135c1846477 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c @@ -125,12 +125,14 @@ static void __init init_port(struct earlycon_device *device) serial8250_early_out(port, UART_FCR, 0); /* no fifo */ serial8250_early_out(port, UART_MCR, 0x3); /* DTR + RTS */ - divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud); - c = serial8250_early_in(port, UART_LCR); - serial8250_early_out(port, UART_LCR, c | UART_LCR_DLAB); - serial8250_early_out(port, UART_DLL, divisor & 0xff); - serial8250_early_out(port, UART_DLM, (divisor >> 8) & 0xff); - serial8250_early_out(port, UART_LCR, c & ~UART_LCR_DLAB); + if (port->uartclk && device->baud) { + divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud); + c = serial8250_early_in(port, UART_LCR); + serial8250_early_out(port, UART_LCR, c | UART_LCR_DLAB); + serial8250_early_out(port, UART_DLL, divisor & 0xff); + serial8250_early_out(port, UART_DLM, (divisor >> 8) & 0xff); + serial8250_early_out(port, UART_LCR, c & ~UART_LCR_DLAB); + } } int __init early_serial8250_setup(struct earlycon_device *device, -- 2.7.4 From 1584591821983039263@xxx Mon Nov 20 13:28:42 +0000 2017 X-GM-THRID: 1584591821983039263 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread