Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp554818rdb; Thu, 5 Oct 2023 14:03:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHf9APcLr5gOsZWR1cUC1krl6Lz09C7APAVxfeI/wRNwjQ2h8sUr4wCXvR6Od6/IM4kfFN7 X-Received: by 2002:a05:6a21:33a8:b0:16b:8bcf:9e27 with SMTP id yy40-20020a056a2133a800b0016b8bcf9e27mr119699pzb.20.1696539828140; Thu, 05 Oct 2023 14:03:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696539828; cv=none; d=google.com; s=arc-20160816; b=yweRlrX3syL2pQ0VlYYeY1wsWsos/mEWKCCqQWhNi4qUGCiej/P9K2GmgyAP7zPL+a yr0gOlo+fHyvq5A2ugODwCwfZnM1hY4Y7gCAw6Qs0pSr33RuwcsGtk2yw77TXJD7qGKv ESyat3y3PJTfp9aE/GaUqCzxGod4iPZppVYj9Q+CDl2MRMQE9lleSm5TsZGdEfWsQ8XA 8eYDP9IQAg5wzRR6JcQulrM/HejERbKzUzWq283pQP8YSFLHN4atv62n3IUcll3XEVv3 MFqHHR1xxEks/XwA8y9CsqR7bZcjEU8/Qq0xiS4bdlqyxQVCMLKH1hF7vypnjiRQKdhp /mXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:date:to:cc:from:subject:references :in-reply-to:content-transfer-encoding:mime-version:message-id :dkim-signature; bh=Q84nE+9z5yxfua7ciTPujDxEaU/RjpXOZxvXUS6jxmc=; fh=y7A7ZJEVJj856JgyYb4f69mcv3ysIa+4XuA4M8p0tu8=; b=Kx+UipyRQDZITPEmbGNdbhjnMeK0VVmKlku6E23iuwjJGvba8k+3QVaKZa6/ADACvy W7rR2oA9rg6EFSNab8exsfUIkb902WKuKxG4PehnFZTHbeuUJVo76TzvYt6fHWFtYrNh pQJlllTzV+ErjY7Vq/Fz8BmKM4Yv8AiRW/bbbfhDZ+47KgReaaa04xTdqFWOS7VZziMD mp/lx4OAqQu8BRnP45YBEH6gj9n1qtvEtYg4LetzUdh2H1OCkAZ/+MsGe17uFJr9efrf b6ahOOaHVbi5IRE4LbY/LH9WvEABRC9RiVr58Jv2jjvhWCEPgN2/W2H5e/5MA6q83XoL 0dpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M2xhVj2N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id d18-20020a056a0010d200b00691018e3f4dsi25662pfu.201.2023.10.05.14.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 14:03:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M2xhVj2N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0AEF6887B74E; Thu, 5 Oct 2023 14:03:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231747AbjJEVD0 (ORCPT + 99 others); Thu, 5 Oct 2023 17:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbjJEVDY (ORCPT ); Thu, 5 Oct 2023 17:03:24 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 969B7E7; Thu, 5 Oct 2023 14:03:22 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23CEAC433C9; Thu, 5 Oct 2023 21:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696539802; bh=d7Ppl8D44fkRETlgz0A2LIGOQ/MHiCD4kZFvw+UJxEI=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=M2xhVj2NonefTX0Fr2avsBvsmxS7B89O6UJNdP2pIB5LjkaPbfnjzCJwyEsslERhM yNnGxvCUIV+3fpzisohQ6YHTX5bvLmjUhXqJMV4amk3mG3Jaz8VZGo83NFkZLBMiee IuiMN5qWJwLh9nGx7TWYB39GiTSQ5aZQzlihI/62ChWupkrVw6j0ZGQNcMrv2mnIlj OgrqfQ9VE21tB56LV8zRv9D1pvxca806WCnkYJJwmPgAB3qQ4yNxyWcf1f8TNXAhHx KVekNW4njiUejlzV+XvWGy10g7K/2udnYHgYRWR56BMvRcDe4lfNZON3ZamQkksfpp /WqUg+XFSqihQ== Message-ID: <77d94f6a6a4b45f8ad711f52ca6ba86c.sboyd@kernel.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20231005203202.08b5d1cf@mitra> References: <20231005095927.12398-1-b.spranger@linutronix.de> <20231005095927.12398-2-b.spranger@linutronix.de> <20231005203202.08b5d1cf@mitra> Subject: Re: [PATCH 1/1] clk: socfpga: gate: Fix of by factor 2 for serial console From: Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Michael Turquette , Dinh Nguyen To: Benedikt Spranger , Maxime Ripard Date: Thu, 05 Oct 2023 14:03:19 -0700 User-Agent: alot/0.10 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 14:03:46 -0700 (PDT) Quoting Benedikt Spranger (2023-10-05 11:32:23) > On Thu, 5 Oct 2023 13:34:01 +0200 > Maxime Ripard wrote: >=20 > > Hi, > >=20 > > On Thu, Oct 05, 2023 at 11:59:27AM +0200, Benedikt Spranger wrote: > > > Commit 9607beb917df ("clk: socfpga: gate: Add a determine_rate > > > hook") introduce a specific determine_rate hook. As a result the > > > calculated clock for the serial IP is off by factor 2 after that > > > i.e. if the system configures a baudrate of 115200 it is set > > > physicaly to 57600. =20 > >=20 > > Where is that factor 2 coming from? > In drivers/tty/serial/8250/8250_dw.c p->uartclk is set twice as high, > as it should be:=20 >=20 > dw8250_set_termios() is called and rate is evaluated to 20000000 in the > bad and 10000000 in the good case. As a result p->uartclk is set to > 20000000 in the bad case. >=20 > > > Change the determine_rate hook to the reparent variant > > > __clk_mux_determine_rate() to fix the issue. =20 > >=20 > > It's also not clear to me why that would fix anything. This patch > > should only make the old behaviour explicit, could you expand a bit > > on what happens? > Booting the kernel with console=3DttyS0,115200 result in a corrupted > character output. Setting the serial terminal application to 57600 > make the serial console working. >=20 > I dug deeper and added some debug output (see patch below): What's your analysis? Does this patch also fix it? ---8<--- diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c index 8dd601bd8538..b3400d2d8128 100644 --- a/drivers/clk/socfpga/clk-gate.c +++ b/drivers/clk/socfpga/clk-gate.c @@ -173,6 +173,7 @@ void __init socfpga_gate_init(struct device_node *node) if (init.num_parents < 2) { ops->get_parent =3D NULL; ops->set_parent =3D NULL; + ops->determine_rate =3D NULL; } =20 init.parent_names =3D parent_name;