Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3089762lqo; Tue, 21 May 2024 06:43:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWMF+sP8Jv3CLrNVRvLFHc73zD+qQ5IConaqsY88AFgDkMxto0L6ywXi++VxF6TDW4+uITRv3CO2vgszMup1di6HEG0Ffbe0ehhf76umg== X-Google-Smtp-Source: AGHT+IHNJ8lrArd7eIDnifOEZ3j7iWRijAuUoNh6spbi27TQw+kjPYQRFKsgTETmo8CGHFJwnX3B X-Received: by 2002:a05:6358:27a3:b0:18f:81e1:c4e5 with SMTP id e5c5f4694b2df-193bb3f8d2dmr2752516055d.5.1716298997599; Tue, 21 May 2024 06:43:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716298997; cv=pass; d=google.com; s=arc-20160816; b=YdUnIPjXyrG7JX4pxnHgHbOaj2EbWAaRqCEd3hFLODvguqrodgcO5T/RP98+AGkW0i yJAaNEpgPoJRKTQdJrElhDhbys/2YhYWYCPG2qTZx5LmVlThAh7JwBJ1N+6nzj8XdPVP 8HEkodbfbuUvvONvYdH3ndLFkjqC4r6nHu0zutzNj0szRXBvxmhjRm/iwF8K/scnJ4yw U4PusSwUcMVSJ/J8a0WbicgLOlh/+Ge6nKt9EeJHkvHr5az86QzH9QfNR9hsoFzhyNtu Cs1NUYUBenPJH5rYtlKmjTG+N3qHgqGVaQzUMpLhR5hY6C6nLnwysAjUMbbJRUya1xpb xwMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from; bh=WvrLP0He+9by7N2Nnvyai5HKp/yhuPAIkPzQsNcAyg8=; fh=s0cnZ+lm2CedJsF9l4kv8sLpP4J26MCyNCEmcRA10uI=; b=C/SEJud8vA6MTbmOZrbwtETnGIdJw99ahGjVf1j34Dwy8r3X7z+C3XOld2d4SB9XAn 8dhQ7CCWkJKqcrT4qt/ADL3IG8B1gYXm3ze+g2yInIgpX66minwH7BirDGudcvSNrSyD zacfinrb13xS5EfFrq7L6qnlAnkCavGLr6/1GvGoGObLYZZiCdw2EyCCIfJLXsZnf4A4 YUpYAYLdruHf3v292AuOlfc0HAyGoZLX4VzEm1KEJazHXa+rry7wb4npOfRW/iGL9mJL KGwmw1kQY3Wo1l183TLAB//oauATZnxeso184Ms7qwmNEY2X7cRszJ7G07HdJRHfgtme Oo2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=mansr.com); spf=pass (google.com: domain of linux-kernel+bounces-185029-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185029-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b1db56si2076287b3a.269.2024.05.21.06.43.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 06:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185029-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=mansr.com); spf=pass (google.com: domain of linux-kernel+bounces-185029-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185029-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2F687283EB2 for ; Tue, 21 May 2024 13:43:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 481FE7EF14; Tue, 21 May 2024 13:43:09 +0000 (UTC) Received: from unicorn.mansr.com (unicorn.mansr.com [81.2.72.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 490677F46B; Tue, 21 May 2024 13:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.2.72.234 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716298988; cv=none; b=tVMXjhKjIzIzarKsRVNaIW4luU/qaEKOaGgEuRSbVMg5t20akBTvibiMrmLIGg/FTV74WmjHap99eyvoZAdslP3D1FoPZpbmzWu/SwGc/jHkYxA8eNBfgK94qlxLqfPqtUOSYQ98S7JYJ8MeNbRxDFW9XFzgATFty3XQmzjLaks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716298988; c=relaxed/simple; bh=zjB8v+NoVOfwtkTTGvRVzO2+JLMrRbv6D0wkhQKyrv0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=TR2wMQ+K8g/IQNOkiSYHHM4Kb2qIOhWAXVi4eBowQVgsBTzHF4sjUUhGb0fMeV6fknrwmxVOzILQb3KoZ62svVFjWTPuF1PFHkYvIRvsk9EWXemaTgTFALAvyfosDgDTvPEsfCXNavTrZUIJDAm1JQOK06OWWWI/9YrbIhTgAYk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mansr.com; spf=pass smtp.mailfrom=mansr.com; arc=none smtp.client-ip=81.2.72.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mansr.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mansr.com Received: from raven.mansr.com (raven.mansr.com [IPv6:2001:8b0:ca0d:1::3]) by unicorn.mansr.com (Postfix) with ESMTPS id 5E1C915362; Tue, 21 May 2024 14:35:47 +0100 (BST) Received: by raven.mansr.com (Postfix, from userid 51770) id 4E7CB219E4D; Tue, 21 May 2024 14:35:47 +0100 (BST) From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: Frank Oltmanns Cc: Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Guido =?iso-8859-1?Q?G=FCnther?= , Purism Kernel Team , Ondrej Jirman , Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v4 1/5] clk: sunxi-ng: common: Support minimum and maximum rate In-Reply-To: <20240310-pinephone-pll-fixes-v4-1-46fc80c83637@oltmanns.dev> (Frank Oltmanns's message of "Sun, 10 Mar 2024 14:21:11 +0100") References: <20240310-pinephone-pll-fixes-v4-0-46fc80c83637@oltmanns.dev> <20240310-pinephone-pll-fixes-v4-1-46fc80c83637@oltmanns.dev> Date: Tue, 21 May 2024 14:35:47 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.3 (gnu/linux) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Frank Oltmanns writes: > The Allwinner SoC's typically have an upper and lower limit for their > clocks' rates. Up until now, support for that has been implemented > separately for each clock type. > > Implement that functionality in the sunxi-ng's common part making use of > the CCF rate liming capabilities, so that it is available for all clock > types. > > Suggested-by: Maxime Ripard > Signed-off-by: Frank Oltmanns > Cc: stable@vger.kernel.org > --- > drivers/clk/sunxi-ng/ccu_common.c | 19 +++++++++++++++++++ > drivers/clk/sunxi-ng/ccu_common.h | 3 +++ > 2 files changed, 22 insertions(+) This just landed in 6.6 stable, and it broke HDMI output on an A20 based device, the clocks ending up all wrong as seen in this diff of /sys/kernel/debug/clk/clk_summary: @@ -70,16 +71,14 @@ apb1-i2c0 0 0 0 24000000 = 0=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 pll-gpu 0 0 0 1200000000 = 0=20=20=20 - pll-video1 3 3 1 159000000 = 0=20=20=20 + pll-video1 2 2 1 159000000 = 0=20=20=20 hdmi 1 1 0 39750000 = 0=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 tcon0-ch1-sclk2 1 1 1 39750000 = 0=20=20=20 tcon0-ch1-sclk1 1 1 1 39750000 = 0=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 - pll-video1-2x 1 1 0 318000000 = 0=20=20=20 + pll-video1-2x 0 0 0 318000000 = 0=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 - hdmi-tmds 2 2 0 39750000 = 0=20=20=20 - hdmi-ddc 1 1 0 1987500 = 0=20=20=20 pll-periph-base 2 2 0 1200000000 = 0=20=20=20 mbus 1 1 0 300000000 = 0=20=20=20 pll-periph-sata 0 0 0 100000000 = 0=20=20=20 @@ -199,7 +198,7 @@ =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 ace 0 0 0 384000000 = 0=20=20=20 ve 0 0 0 384000000 = 0=20=20=20 - pll-video0 4 4 2 297000000 = 0=20=20=20 + pll-video0 5 5 2 297000000 = 0=20=20=20 hdmi1 0 0 0 297000000 = 0=20=20=20 tcon1-ch1-sclk2 0 0 0 297000000 = 0=20=20=20 tcon1-ch1-sclk1 0 0 0 297000000 = 0=20=20=20 @@ -222,8 +221,10 @@ =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 de-be0 1 1 1 297000000 = 0=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 - pll-video0-2x 0 0 0 594000000 = 0=20=20=20 + pll-video0-2x 1 1 0 594000000 = 0=20=20=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 + hdmi-tmds 2 2 0 594000000 = 0=20=20=20 + hdmi-ddc 1 1 0 29700000 = 0=20=20=20 pll-audio-base 0 0 0 1500000 = 0=20=20=20 pll-audio-8x 0 0 0 3000000 = 0=20=20=20 i2s2 0 0 0 3000000 = 0=20=20=20 Reverting this commit makes it work again. > diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu= _common.c > index 8babce55302f..ac0091b4ce24 100644 > --- a/drivers/clk/sunxi-ng/ccu_common.c > +++ b/drivers/clk/sunxi-ng/ccu_common.c > @@ -44,6 +44,16 @@ bool ccu_is_better_rate(struct ccu_common *common, > unsigned long current_rate, > unsigned long best_rate) > { > + unsigned long min_rate, max_rate; > + > + clk_hw_get_rate_range(&common->hw, &min_rate, &max_rate); > + > + if (current_rate > max_rate) > + return false; > + > + if (current_rate < min_rate) > + return false; > + > if (common->features & CCU_FEATURE_CLOSEST_RATE) > return abs(current_rate - target_rate) < abs(best_rate - target_rate); > > @@ -122,6 +132,7 @@ static int sunxi_ccu_probe(struct sunxi_ccu *ccu, str= uct device *dev, > > for (i =3D 0; i < desc->hw_clks->num ; i++) { > struct clk_hw *hw =3D desc->hw_clks->hws[i]; > + struct ccu_common *common =3D hw_to_ccu_common(hw); > const char *name; > > if (!hw) > @@ -136,6 +147,14 @@ static int sunxi_ccu_probe(struct sunxi_ccu *ccu, st= ruct device *dev, > pr_err("Couldn't register clock %d - %s\n", i, name); > goto err_clk_unreg; > } > + > + if (common->max_rate) > + clk_hw_set_rate_range(hw, common->min_rate, > + common->max_rate); > + else > + WARN(common->min_rate, > + "No max_rate, ignoring min_rate of clock %d - %s\n", > + i, name); > } > > ret =3D of_clk_add_hw_provider(node, of_clk_hw_onecell_get, > diff --git a/drivers/clk/sunxi-ng/ccu_common.h b/drivers/clk/sunxi-ng/ccu= _common.h > index 942a72c09437..329734f8cf42 100644 > --- a/drivers/clk/sunxi-ng/ccu_common.h > +++ b/drivers/clk/sunxi-ng/ccu_common.h > @@ -31,6 +31,9 @@ struct ccu_common { > u16 lock_reg; > u32 prediv; > > + unsigned long min_rate; > + unsigned long max_rate; > + > unsigned long features; > spinlock_t *lock; > struct clk_hw hw; > > --=20 > > 2.44.0 > --=20 M=E5ns Rullg=E5rd