From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4E90606A31C for ; Mon, 30 Nov 2026 10:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=sPlMZzV4; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.a=rsa-sha256 header.s=google header.b=HqT/yjvF DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=+3uWT38aeoHVM+xt85Q30eIIge8Pf71B2KjH75jrvsQ=; b=sPlMZzV4vzYgCIv3qyS8cvVros Yro/pWW1FKkSV1d1NT+PTrHWDL2038Rz3d+SyirBjrpOvOff6TfqBiqRyHv0oWbtoMSFXpuBWIk5t PfPbBheNFzk5cywe2FA1CQmy053h10zXwscaujTdRkjf2PR1VdyYP8BUbAD5M9nM882XaJubZNP7R AcWSxP0rVqqtmF9GrOHxgJ+mwE7p7KGzGLLwU17w8smNZKoFEfB0ImUkAvo7QFp/48tnXtWJfaL+G vpn+cKnLa2TFJSBHJTn8Z2Yei7BC70GXtvZpY73M3fMJb46QUPQudn6yc72AEobxFlF8UZPMbCLN5 plFczyNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXyyR-00000004Cj7-3WRZ; Mon, 30 Nov 2026 10:51:07 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXyyO-00000004ChG-2crT for linux-amlogic@lists.infradead.org; Mon, 30 Nov 2026 10:51:07 +0000 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-6bab377105dso9428472a12.1 for ; Mon, 30 Nov 2026 02:51:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1796035863; x=1796640663; darn=lists.infradead.org; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5dnZJ9XWuR4I/QQHBrmwZspDanfZVvJVYIbyIjI3FRE=; b=HqT/yjvFCx3rp9VTfQEegQicIsByt5lRZ+zoTyYa3XCh2hs2NqqNapqtsy3hPX4Z0M d38MYm2XWcJ5NhUTH6fWKba+Wur9yhDYM2yzpXCGhl/P3W9P4SlwNiOp4nCUh6QxtG0C EhnPlFqKlxqrUJsq2oUWAqR9O7p/4MQZ5DSIRBUwEWqWU/4Gj+9JYTTm00Z2jiVHM6If hn5Jz6QkgmSCQf6Rn+TOFCEBCNXHlKENGXLPat/1a9B0HavH1tAMbx1JojRbjxRyXgSW CUNK+ONhbFsf35L3JLPKCcTEDXhfk0IUbVjJGzOhEDhyv25uPxIuSDXbKD9GKM1gRSgs 6kUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796035863; x=1796640663; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=5dnZJ9XWuR4I/QQHBrmwZspDanfZVvJVYIbyIjI3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JO4z4rNzD2I4ZU9uoZs3qsWqJsrCM65RyUG3lGk+2e+I/7vH5XGEcBtRQ5NAb/g JrDZpDdKmAQEs/B5PIeP0DeRupGzJVRysGDmKLEzYUUiHSpbKpU3vx1O17t5ct35e3z/gbTv7Wz 0pMrIqRhMiuZ/mexDCMSngUkIMI8zfasbt0P2HKBNJS08LHh X-Received: by 2002:a17:907:3c92:b0:c50:51e1:c141 with SMTP id a640c23a62f3a-c513a4aea6fmr2718248466b.2.1796035862686; Mon, 30 Nov 2026 02:51:02 -0800 (PST) Received: from localhost (82-67-6-57.subs.proxad.net. [82.67.6.57]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513b01e242sm1110794166b.82.2026.11.30.02.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 02:51:02 -0800 (PST) From: Jerome Brunet To: Jian Hu Cc: Neil Armstrong , Stephen Boyd , Brian Masney , Kevin Hilman , Martin Blumenstingl , Jerome Brunet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH RFC RFT v2 2/3] clk: divider: add CLK_DIVIDER_INVALID_ZERO flag In-Reply-To: <179390104085.2573818.16461908615505096359.b4-review@b4> References: <20261029-meson_refactor_n-v2-0-ff4ac74e527b@amlogic.com> <20261029-meson_refactor_n-v2-2-ff4ac74e527b@amlogic.com> <179390104085.2573818.16461908615505096359.b4-review@b4> Date: Mon, 30 Nov 2026 11:51:01 +0100 Message-ID: <1jjylusicq.fsf@starbuckisacylon.baylibre.com> X-Archived-By: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_025104_699192_51206DA7 X-CRM114-Status: GOOD ( 22.63 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On jeu. 05 nov. 2026 at 18:50, Jerome Brunet wrote: >> When a divider register reads zero, divider_recalc_rate() currently >> emits a warning (unless CLK_DIVIDER_ALLOW_ZERO is set) and returns >> the parent rate. >> >> This behaviour assumes a zero divisor acts as a pass-through, which >> does not apply to all hardware. Some dividers, for example PLL >> pre-dividers on Amlogic SoCs, come out of reset with a zero value >> that does not produce a usable clock. Returning the parent rate >> hides this fault behind an incorrect, plausible value. >> >> CLK_DIVIDER_ALLOW_ZERO only suppresses the warning while still >> reporting the parent rate, so it cannot represent this hardware >> behaviour. >> >> Add CLK_DIVIDER_INVALID_ZERO for dividers where a zero divisor value >> is invalid. When this flag is set, recalc_rate() returns 0, making >> the faulty state visible to the clock framework rather than hiding it >> as a pass-through. >> >> Signed-off-by: Jian Hu >> --- >> drivers/clk/clk-divider.c | 3 +++ >> include/linux/clk-provider.h | 6 ++++++ >> 2 files changed, 9 insertions(+) >> >> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c >> index f68216c65d3d..6c1523d22477 100644 >> --- a/drivers/clk/clk-divider.c >> +++ b/drivers/clk/clk-divider.c >> @@ -143,6 +143,9 @@ unsigned long divider_recalc_rate(struct clk_hw *hw, unsigned long parent_rate, >> >> div = _get_div(table, val, flags, width); >> if (!div) { >> + if (flags & CLK_DIVIDER_INVALID_ZERO) >> + return 0; > > While I think CLK_DIVIDER_INVALID_ZERO really makes sense for a writeable divider > only, to gracefully handle a reset value at zero that we would later correct, > we should still handle all paths correctly. This include a RO divider and its > determine rate path. I'll try to send something for this soon. Hi Jian, After looking at it, I think you should keep divider_recalc_rate() as sent here. For the RO divider, return -EINVAL in divider_ro_determine_rate() after _get_div() since it is now a possible expected value. The documentation could read like this: CLK_DIVIDER_INVALID_ZERO - A decoded divisor of zero indicates no usable output. recalc_rate() returns 0 instead of the parent rate. > >> + >> WARN(!(flags & CLK_DIVIDER_ALLOW_ZERO), >> "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n", >> clk_hw_get_name(hw)); >> diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h >> index dc8e161f9c2c..fe2dbbba49e3 100644 >> --- a/include/linux/clk-provider.h >> +++ b/include/linux/clk-provider.h >> @@ -744,6 +744,11 @@ struct clk_div_table { >> * big endian. >> * CLK_DIVIDER_EVEN_INTEGERS - clock divisor is 2, 4, 6, 8, 10, etc. >> * Formula is 2 * (value read from hardware + 1). >> + * CLK_DIVIDER_INVALID_ZERO - a zero value read from the register is not a >> + * divide by one / bypass but an invalid setting which does not produce >> + * a usable clock. recalc_rate() returns 0 so that the broken state is >> + * reported to the framework instead of the parent rate, without >> + * triggering the CLK_DIVIDER_ALLOW_ZERO warning. > > > CLK_DIVIDER_INVALID_ZERO - a zero divisor is an invalid setting with no > usable output. recalc_rate() returns 0 instead of the parent rate. > Takes precedence over CLK_DIVIDER_ALLOW_ZERO. > > -- > Jerome > -- Jerome _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic