Received: by 10.223.185.116 with SMTP id b49csp947804wrg; Sat, 3 Mar 2018 11:13:27 -0800 (PST) X-Google-Smtp-Source: AG47ELuTWkV306tvNuFlvi5jH23mXEadtfMMS9Rxac7Y4R1G6PLmR+YvtIir+NQbVzMs6/dY8nZ7 X-Received: by 2002:a17:902:8215:: with SMTP id x21-v6mr8802670pln.164.1520104407285; Sat, 03 Mar 2018 11:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520104407; cv=none; d=google.com; s=arc-20160816; b=RhoIR1wo+gl84Cyita/2PN3nWmUW72MWC2I35Q+Rn8TxNMuJz0eb1Hvm0lmie26hgE PBQ1CFXJzSnV6Fxf7DXy1x0CUMPVtLhZ+kwpLyB3fZc+/AoU+93Ud4np/Xj4TM5F408i 58q5Au567adpJFWwwwkSvlFWR18Ul4461O0h303GYt0vPap9n3Ei/Y3C3TwN/emfQ4lK egqvrYS8slV9SZ728CKnbFLctASnN6a22oDkja2AnxXcktCNlw+Rfrbz+nVDBBl2JwNF jBTYunpgWmnRUOOTDNThI1G/SirLyuVy7mY+Xb1QMAuAxXN5UwPyb1HUx5a1LJX6g6XT SR5g== 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=4GmKgIhxV+Sm7y37wyP00s8Hqi10//V4jKDhUrAxOeg=; b=ZdTPNP6lGwlGBo87tJwkQK6WGe/lkKjcDEWhWeyNRtEdXmXSAdfDCO4NNhAUQZ5uEh kHWAUU5jBaNdM2WRuI2/2nCSxHP9H39BCspOF+p/CIyrSJmt1e2wAT26d7z0kcBytt6y XGCzlr41c/4DO/1ej8Dna8rOAS6iJVqY9cZ4o+dLkOTCEHNqZ4+0VjS4ePa68T9ESHDz dAXAjruQxnbfV/FhmjkStfm49DRy/3Ex254YEX5uVPupzCt4aKKldkspcTFdsAZiJo03 LBnSqhzKSgAbRUJtE+/GC14k1s4+19HWEhcvAT8z3yS11gxY36bJd39cL4+0CN9LkT4O inAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=T2t3z+Bd; dkim=fail header.i=@chromium.org header.s=google header.b=XShZJ/ts; 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 k14si5888059pgt.32.2018.03.03.11.13.12; Sat, 03 Mar 2018 11:13:27 -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=T2t3z+Bd; dkim=fail header.i=@chromium.org header.s=google header.b=XShZJ/ts; 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 S932112AbeCCTMZ (ORCPT + 99 others); Sat, 3 Mar 2018 14:12:25 -0500 Received: from mail-yb0-f196.google.com ([209.85.213.196]:45602 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752145AbeCCTMX (ORCPT ); Sat, 3 Mar 2018 14:12:23 -0500 Received: by mail-yb0-f196.google.com with SMTP id e89-v6so4484331ybi.12 for ; Sat, 03 Mar 2018 11:12:23 -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=4GmKgIhxV+Sm7y37wyP00s8Hqi10//V4jKDhUrAxOeg=; b=T2t3z+BdWIekWEFfW+1Xx5KYSQaZ5Yney9wsuNAG0caWPrvQhoTjwwqD23RyruIN0Y 1RoZ9Q+XwJ7cWgKuN25BpWG4HhFYrn8abtVpjtIb48LkTtcpScxWfxcJNlM5OkPUp3BZ 7BvmOpyAvumL11ro5bmZjEe6i7qcS7GNGbxx/e5Imj86OFX9ORogyzTpYoYCnFAS5PHU ON3bdtujtypapwY7W3mJXMTOARCkZHK3ufVRVFw99KPsxUFgxuCmwvMrib+MlQ7maAjn LZCvFGbd5kAxZVM6T8m1tdjSwzWMzjc5+TX5X0Hg6PzLEIf7K3H1mtXexcWcpYPqIgQ2 iN8Q== 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=4GmKgIhxV+Sm7y37wyP00s8Hqi10//V4jKDhUrAxOeg=; b=XShZJ/ts1UwFgr7BSjCzerfFYT12/NhQVtjxImyvlq/xi27hZ21jsOvsGEXFvJ1DmN iriSsz0b722zRqFPYvOxGK4Af35CfLF/VhmHIBuJa8n4vZtoHeG40jeTuCzyZuUU4Fp2 3aG+pFKaDsJFipMiCRXtmIb1j0ytRh20rxUfY= 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=4GmKgIhxV+Sm7y37wyP00s8Hqi10//V4jKDhUrAxOeg=; b=b2dCPoVNoNyI9KQnBFmULZtoeW9jinIeMnYV6ohoDdWhcvjntP+HUrBQyVriyWS/Tv x0SxXV6Z95HQPwYnGD7tXqU8NSuX0K6HY1U5RsT3UvBJdh35vOYn8pJMbpeRmVqbCU92 /W2t3zkfNyPzj+kG9nuR//WfKmf7oEJw8oksiGGCpA0eiTizABa6/67POoYptnnbep6N YFkjOtjjVkZUAFUfWKnQVU3BIUTG6Mm3shGb7pP1y96/09uvpMVXFNnLdyBmKboA8n+9 T1WYsANFoiiljnkSUJ46VzuHBOMz0S4TbdJGby/L1cqO5A58Rm5gyOPYZ44Sb0bs1gvW +RsQ== X-Gm-Message-State: AElRT7GHbxgKtjUcj6r6M1RyeloqaVapF9DvBkPN6ls3g7LIPwWDpbrq iV7PIcdniAc/mncFpBbuNAF15axbT5N8HwMMfsZuHA== X-Received: by 2002:a25:bd42:: with SMTP id p2-v6mr6205077ybm.214.1520104342325; Sat, 03 Mar 2018 11:12:22 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a25:b219:0:0:0:0:0 with HTTP; Sat, 3 Mar 2018 11:12:21 -0800 (PST) In-Reply-To: References: <20180301184335.248378-1-djkurtz@chromium.org> From: Aaron Durbin Date: Sat, 3 Mar 2018 12:12:21 -0700 X-Google-Sender-Auth: _r9b5AfMxxhb9TKp7BHG7gw0QJU Message-ID: Subject: Re: [PATCH v2] earlycon: Allow specifying a uartclk in options To: Andy Shevchenko Cc: Aaron Durbin , Daniel Kurtz , Brian Norris , Jonathan Corbet , Greg Kroah-Hartman , Jiri Slaby , Ingo Molnar , Thomas Gleixner , Christoffer Dall , "Paul E. 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:38 AM, Andy Shevchenko wrote: > On Thu, Mar 1, 2018 at 11:24 PM, Aaron Durbin 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 >>>> wrote: >>> >>>> "earlycon simply does not utilize the information". >>>> >>>> earlycon parses iotype, mapbase and baud (from options). However, it is >>>> hard-coded to assume that the clock used to generate 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. >>>> >>>> This patch attempts to add a way to inform earlycon about this clock. 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. >>> >>> And it should not require that for sure! >> >> But it does require that. There's an input clock to the uart ip block. >> That is a design constraint by the hardware and is required to make >> baud calculation work. > > I mean it should not be user's headache to provide this information to > the system. > >> It's not a firmware problem. > > If it's ACPI, then it's definitely firmware issue, since SPCR provides > a baudrate. > earlycon is another implemetnation of driver binding/settings that is done before the rest of the kernel driver stack. SPCR provides baudrate, but that's only one piece to the puzzle. You need to know the UART input clock which you admit is hard coded in the current driver. It's not possible to configure the divisor in the UART without knowing the external clock. That's a real dependency that can't be worked around. The moment the code attempts to configure the baud it has to know the input clock -- otherwise the calculation is inherently wrong. Or are you suggesting to lie about the baud such that the the math works out even though the values are not real? >> Its the driver's problem in that it >> assumes an input clock to the uart block that does not reflect >> reality. > > So, driver can't get this info from device tree or what? There is no device tree on x86. And ACPI driver binding is not fully initialized when earlycon is being processed. Yes, this can be solved by getting up the entire ACPI stack, but then that's not really 'early' in the kernel's initialization sequence. > >>> Okay, configures a necessary IPs to feed UART with expected 1.8432M clock. >> >> That's only possible if there is a clock divider on the front end of >> the uart block. For this hardware that's not the case. I actually did >> this very thing on intel chromebook devices, but it was only possible >> because there was a hardware divider that could be tuned to reach the >> assumed clock that the code currently assumes. > > OK. > > -- > With Best Regards, > Andy Shevchenko