Received: by 10.223.185.116 with SMTP id b49csp956836wrg; Sat, 3 Mar 2018 11:28:21 -0800 (PST) X-Google-Smtp-Source: AG47ELv/R3jUZYkQ3Qs+EUlrwl95qQp/RWZB6f17OoHUkaT+4xFYFuDdBY5+rTiNLv2BRrNzTtVC X-Received: by 2002:a17:902:5401:: with SMTP id d1-v6mr8816713pli.176.1520105301655; Sat, 03 Mar 2018 11:28:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520105301; cv=none; d=google.com; s=arc-20160816; b=WCceT/v+ka+Bg93ColC3x/pkCzC7R6e/XBZY+fkAb2zQlmvUZgvD9uVTo4qp1pjXTg LTdl8fO3Ru/RF/RL9zJdIXTJXXnn75uXHaO9YOKC8NC8iuwT1QIQxSx6Q9PmRszOLCeW iMuOCRhdx+Zhv4DpceSJ4kGLHiVw8Teo+OZVTcKATDaIYLQpqqARZp5zVvljoOMmlXT7 cLcEXnCH4wZXATchggFCcRpfdGt0N9P0QZJR3FmMqcrC16Z12cijEPckP4jND+4HjOpF IURqR3imaicaj0BDdWbOWzVH6lam2L6SbJpyFo5t/+oxko0/c+O/7uuvs8A4c6vCRbRx F4Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=/N/X5/QV54myHP9RaEZagCBv94nEkTtBpcOSOGEzPD0=; b=QVbVY6TiyyhJZKnD2ktj3fh6QCjGqHApUwdNxKMlz9BWNsBrETdF0KhgiakTeC9bZY TeFhoAYbLwUzUV8P/CjvnGiwyNjGv0Lxv+vUB8KAAmJz7dwqFiH7cyQ9JdUPSa7M/DBZ XYOSKJXbuEyByTXyYtXK1CYHxldlJcRdc6kRID0Q9n37fLJKoKdQrjalqlIrfRAdf4aG MoKWf/VTfNfBkRQyQxOwGMr517lPpzWFJji6bA0eSIc8yjhEP+Lbt5uomVVRL2m0sMN3 x4HPzTHmf/hUmNa46IkdQh9XIifDCsSw59qV5CLY2eSJwJC33vw/F9M/8oPVTxFEyHJI MmmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=bUNBHBi3; dkim=fail header.i=@chromium.org header.s=google header.b=ngIeBAgQ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u64si5896476pgc.295.2018.03.03.11.28.07; Sat, 03 Mar 2018 11:28: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; dkim=fail header.i=@google.com header.s=20161025 header.b=bUNBHBi3; dkim=fail header.i=@chromium.org header.s=google header.b=ngIeBAgQ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752336AbeCCT1P (ORCPT + 99 others); Sat, 3 Mar 2018 14:27:15 -0500 Received: from mail-yw0-f174.google.com ([209.85.161.174]:35258 "EHLO mail-yw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752307AbeCCT1N (ORCPT ); Sat, 3 Mar 2018 14:27:13 -0500 Received: by mail-yw0-f174.google.com with SMTP id d205so4418805ywe.2 for ; Sat, 03 Mar 2018 11:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=/N/X5/QV54myHP9RaEZagCBv94nEkTtBpcOSOGEzPD0=; b=bUNBHBi3py2s0fTQf9Cn4rFuDpPO1RIBeCjH8kcWOOAe/lbuWAn7xgzfU6cqQUQt/d UCVl4UA/YHiior99vAG0gdcB73TyQwiXtxykuk3yxHpaz1IeDamB/5Cs1zCHFKYSn4Uk 6lNkBR3skiQ9gvdjhmRFMDh2FJdpLelJa3tKKL9Etr/FO1gJcasn03UMouiNLRPb/lfY fbD+HTY2OnNiujvittGfc+Yj8Sdn0UVjxTXJ6JzA7udKwHhBDDVdzNKsAqTFuIu0Mtvv /VNNyMXMrzMf+BcSSQrQ4ZI+bUBe9w0iRgGFmfw9+Ox77nBnWRHfVbAf9xfii6VZ5pr6 J0zA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=/N/X5/QV54myHP9RaEZagCBv94nEkTtBpcOSOGEzPD0=; b=ngIeBAgQpkU6arRW1UXHJ3ISpKk/CvzI7j3qvxXd09AygIQ/VpsDQl2qsNo3tQC4Le U3D7bkMWi80IgfOEyyqc72evxJPpWjqzMGJuZqdhhIQwKwkKYCy8bZtT9+PFJKbvN1C2 rjd4eS2lpkVcQdRkUMCbV8X+LAqTE6ghm80+o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=/N/X5/QV54myHP9RaEZagCBv94nEkTtBpcOSOGEzPD0=; b=eukCcY0dHgMtulPlDMTASjBdabUBYIXwpvt2s1ZTj4o11uuKCG9XmeUFiVjlY/HqZ8 YFoKGbZ7X5fvrMtfsGxUCsBuLqVMsGN7tvlbZh91RxK8yRKhNEmWBnhCaxqWkGjBJNe9 xUioK8dFCwXSkV4PJL9eW5NzY3Ye91+YnWEee8yo5+8XEgETrcXji/6OzMHYlX3mbEZN ShQ04p8imQrTvs2CW8mchqFmbg431/s5sbiHYrfxf4InjVqIkdKgnCkp+SzF6e6q0gmj sfnY2HhLERT2aaTNYJDOdIMcKu3Fim3etCcdUhm9Sf7x1aw/xnDZq3mNk+jUIVOdzwSU q1hw== X-Gm-Message-State: APf1xPAt3qnkS/q15tZTK0pG5C2iU9pTxhFRNhQfxbDntCQDHKvA4yr/ L5e97NT+PAVB/ehY9zHQgmqXgExanHy4jUbD83l+3w== X-Received: by 10.129.92.85 with SMTP id q82mr6354001ywb.138.1520105232623; Sat, 03 Mar 2018 11:27:12 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a25:b219:0:0:0:0:0 with HTTP; Sat, 3 Mar 2018 11:27:11 -0800 (PST) In-Reply-To: References: <20180301184335.248378-1-djkurtz@chromium.org> From: Aaron Durbin Date: Sat, 3 Mar 2018 12:27:11 -0700 X-Google-Sender-Auth: ByVlha7TELgY4_v8mTbBE9m4UCk Message-ID: Subject: Re: [PATCH v2] earlycon: Allow specifying a uartclk in options To: Andy Shevchenko Cc: Daniel Kurtz , Aaron Durbin , Brian Norris , Jonathan Corbet , Greg Kroah-Hartman , Jiri Slaby , Ingo Molnar , Thomas Gleixner , Christoffer Dall , Paul McKenney , Marc Zyngier , Frederic Weisbecker , David Woodhouse , Tom Saeger , Mimi Zohar , "Levin, Alexander (Sasha Levin)" , Linux Documentation List , Linux Kernel Mailing List , "open list:SERIAL DRIVERS" 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 On Sat, Mar 3, 2018 at 8:56 AM, Andy Shevchenko wrote: > On Fri, Mar 2, 2018 at 8:35 PM, Daniel Kurtz wrote: >> On Thu, Mar 1, 2018 at 1:02 PM Andy Shevchenko >> wrote: >>> On Thu, Mar 1, 2018 at 9:22 PM, Daniel Kurtz wrote: >>> > On Thu, Mar 1, 2018 at 11:47 AM Andy Shevchenko < >> andy.shevchenko@gmail.com> >>> > wrote: > >> the UART bitclock >> is >>> > always "BASE_BAUD * 16" (1843200). While this may be true for many >> UARTs, >>> > it isn't true for AMD's CZ/ST which has a 8250_dw and uses a fixed 48 >> MHz >>> > clock. The main 8250_dw driver uses devm_clk_get to get the "baudclk" >> and >>> > uses its rate to initialize uartclk. For AMD CZ/ST, this "baudclk" is >>> > actually a set up in acpi_apd.c when there is an acpi match for >> "AMD0020", >>> > with a rate read from the .fixed_clk_rate param of the corresponding >>> > apd_device_desc. > >> As >>> > noted above, the information is actually already in the kernel and used >> by >>> > 8250_dw - I would happy be to hear recommendations for wiring this data >>> > into earlycon that doesn't require adding another command line arg. > > Brief look at the code shows that ->setup() call back is executed > after setting initial (which is hardcoded) clock. > > What you need is to either create another type of earlycon for your > device with accompanied ->setup() callback, or patch 8250_early.c. If I'm understand you correctly, you are suggesting new driver code that sets the clock accordingly within the port structure such that the baud rate calculation actually works based on the correct input clock? Why wouldn't we just extened the generic earlycon driver like the original patch to support providing the clock? Anything in the earlycon path that tries to set a baud rate will fail once the hard-coded input clock assumption doesn't hold true. Why not provide the ability to correct the assumption for platforms that need it? > >>> > I see that support was also added recently to earlycon to let it use >> ACPI >>> > SPCR to choose a console and configure its parameters... but AFAICT, >> this >>> > path also doesn't allow specifying the uart clock. > > It does specify baudrate. It means it's _firmware_ responsibility to > configure UART device properly. baudrate != input clock. The issue is that once the driver code attempts to set a baud rate w/o having the correct input clock then things break. > >>> Fix your firmware then. It should set console to 115200 like (almost) >>> everyone does. >>> Okay, configures a necessary IPs to feed UART with expected 1.8432M clock. >> >> The console is 115200 when it is enabled. However, the firmware does not >> always enable it by default. > > Another firmware bug. It's more complex than that. You seem to take the stance that the firmware should bring every IP block out of reset and/or clock and power gating. That then subsequently requires the kernel to enable all those soc drivers that put those devices in power or clock gated state to reach the maximum power savings. While that's certainly possible, it just leads to bloated kernels. That is orthogonal to the problem of setting baud rate w/o knowing the proper input clock frequency, though. If we do make the assumption the firmware sets up the uart, but the kernel earlycon has a different baud rate specified than what firmware set up then the baud rate calculation would be wrong as well since the input clock isn't known. As such one cannot use earlycon when: 1. firmware doesn't set up uart 2. firmware baud rate != earlycon specified baud rate. Providing the proper input clock for the device in question solves both 1 and 2. > >> The problem is that the UART IP block has a fixed 48 MHz input clock, but >> earlycon assumes this clock is always 1843200. > >> I looked a bit further, and I think this patch (or something similar) is >> still required to teach generic earlycon how to handle an explicit >> port->uartclk (ie, one that is not 1843200). >> The extended string can then be explicitly set on the kernel command line >> for this kind of hardware. > > No. > >> In addition, we can add another patch with a new quirk detector in >> drivers/acpi/spcr.c:acpi_parse_spcr() to handle this hardware. >> acpi_parse_spcr() can then use the extended option string to pass in the >> appropriate UART clock to setup_eralycon(). > > Definitely no. It's not defined in SPCR spec. > >> This would again allow a user to just use the simple command line parameter >> "earlycon" if the device's firmware has a correctly confiured ACPI SPCR >> table. > > NAK to the patch, see above alternatives. > > -- > With Best Regards, > Andy Shevchenko