Received: by 10.223.176.5 with SMTP id f5csp1002292wra; Fri, 2 Feb 2018 09:31:04 -0800 (PST) X-Google-Smtp-Source: AH8x226cY9GjhGBfeoSA8AW6rRrZzeiaHNpcibmFnXlpCyNxJqXV7MtLNPN4kQ95/gYAHym25O1g X-Received: by 2002:a17:902:a617:: with SMTP id u23-v6mr15622906plq.201.1517592664115; Fri, 02 Feb 2018 09:31:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592664; cv=none; d=google.com; s=arc-20160816; b=paMrSm8PMsiKYslPRTsx2Z0+53CmGHtXghenaB7IcrJj15/9Z4UDVw20i9mLmObNlw 8zgHP54NEG5X5iRklrrdBFRPseOHkAk5t670zQHTEFfh43KPf3ljNN5e/C/TLraZjPhM BWLg4Kppr1VGP5RleyuB+aWMiTN7pH0ZYoa/0INZy8fVmlEFVLppeXazyWYLotsreRTC dodl8IZ+5xrnQu/bYxamUmCU9FM3JpDMvSEvHOmvrJJ4GYIdP0LLBZYIKsQPpaolQyRX qgK9fgmvPaI6PzoMkXMiIs6k487t53evMoIBF5vJ0gzDsZLV92HcKQJf4ofQlulmMNaw bxUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Jc9y0gnUyTp7kNYhOxkjMpYmRmF2o0hR+bnSV71PG2s=; b=RaLxWlgRPSfhLeZna/iZLZPUrvBRTq9mfbENdZGLYL0rvKereYWhZG3lUBxQAK90Tv rCEzPZFNxv1OabhESyq5V1jJFjae0VdaUPOdg3afFBsV5yY1Ojn8kKsjpx6KGXAeT3HQ HsSLSBhw2n68PeD5DeWG0FiTWUDTmba6TW7ShIXtwtjGOA1euiFuGgtwi0SL/aa+SfDc BujFxGuZUnoar9JKoFTFijpoLQTx5wt0E9IKrjGexupyTMcOiKqfQvQ8Mgo1RzNi57Lq OHSX/zLrsqVnH4YFwgBdR2AvJA2N/zQM4y7u4Yv8CpqYC1zEJqnAwzGBGaTP0gwEKBjl RB9Q== 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 f6si1702745pgn.336.2018.02.02.09.30.49; Fri, 02 Feb 2018 09:31:04 -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 S1753705AbeBBR3h (ORCPT + 99 others); Fri, 2 Feb 2018 12:29:37 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41230 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753695AbeBBRR3 (ORCPT ); Fri, 2 Feb 2018 12:17:29 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6712AED5; Fri, 2 Feb 2018 17:17:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ed Blake , Heikki Krogerus , Lukas Wunner , Andy Shevchenko Subject: [PATCH 4.15 47/55] serial: 8250_dw: Revert "Improve clock rate setting" Date: Fri, 2 Feb 2018 17:59:05 +0100 Message-Id: <20180202140830.649634918@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140826.117602411@linuxfoundation.org> References: <20180202140826.117602411@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andy Shevchenko commit c14b65feac9ebed649d6fe79c6b6d64d21d0287d upstream. The commit de9e33bdfa22 ("serial: 8250_dw: Improve clock rate setting") obviously tries to cure symptoms, and not a root cause. The root cause is the non-flexible rate calculation inside the corresponding clock driver. What we need is to provide maximum UART divisor value to the clock driver to allow it do the job transparently to the caller. Since from the initial commit message I have got no clue which clock driver actually needs to be amended, I leave this exercise to the people who know better the case. Moreover, it seems [1] the fix introduced a regression. And possible even one more [2]. Taking above, revert the commit de9e33bdfa22 for now. [1]: https://www.spinics.net/lists/linux-serial/msg28872.html [2]: https://github.com/Dunedan/mbp-2016-linux/issues/29#issuecomment-357583782 Fixes: de9e33bdfa22 ("serial: 8250_dw: Improve clock rate setting") Cc: Ed Blake Cc: Heikki Krogerus Cc: Lukas Wunner Signed-off-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -252,31 +252,25 @@ static void dw8250_set_termios(struct ua struct ktermios *old) { unsigned int baud = tty_termios_baud_rate(termios); - unsigned int target_rate, min_rate, max_rate; struct dw8250_data *d = p->private_data; long rate; - int i, ret; + int ret; if (IS_ERR(d->clk) || !old) goto out; - /* Find a clk rate within +/-1.6% of an integer multiple of baudx16 */ - target_rate = baud * 16; - min_rate = target_rate - (target_rate >> 6); - max_rate = target_rate + (target_rate >> 6); - - for (i = 1; i <= UART_DIV_MAX; i++) { - rate = clk_round_rate(d->clk, i * target_rate); - if (rate >= i * min_rate && rate <= i * max_rate) - break; - } - if (i <= UART_DIV_MAX) { - clk_disable_unprepare(d->clk); + clk_disable_unprepare(d->clk); + rate = clk_round_rate(d->clk, baud * 16); + if (rate < 0) + ret = rate; + else if (rate == 0) + ret = -ENOENT; + else ret = clk_set_rate(d->clk, rate); - clk_prepare_enable(d->clk); - if (!ret) - p->uartclk = rate; - } + clk_prepare_enable(d->clk); + + if (!ret) + p->uartclk = rate; out: p->status &= ~UPSTAT_AUTOCTS;