From nobody Thu Apr 2 15:39:01 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 BF3713803E3 for ; Fri, 27 Mar 2026 19:32:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774639966; cv=none; b=Q5/+0xQRSd7QajN7uxPxcIRK9VSWWWuhHg0lEaUl+H0ld9FLrYDA4GdQO1cvTt3RenKJigDBcnb1XUCvgxM6Uz8hvWo4kOq3Op0RO0ZL/eOHP4vJnkDSA7NIvYNXOHlDaC+vJd5cJAfkYXCpKQboLtp15VfZGbiP+2660ecVSZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774639966; c=relaxed/simple; bh=RGguDxs0mpixqcCPoxM/eD7hdhypb/MfsPjPm5+1CyE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NKkRn+QwVkD4zoBmHSB7Wb3NIXQGk13Q/5N2uObZ4D2LC/GMExDZqReGMxd5xJcEoZwBI66g7x93tZNiPuACjrvG8ofVPn1LOwaVuCM6HtnUtTH4RNWcCDLyBrkmea8MPOSdXGcZt88OSdbvdU8qATUuBnXQzUIRzfojAQv5yg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Pv/ZOz5K; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=kBklNiQ5; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Pv/ZOz5K"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="kBklNiQ5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774639955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5VTZSuhR1jCaLjcqylqIXA7GgBv7DZmHs0Ejxquvhuk=; b=Pv/ZOz5KSp4j/nzrzie5CWRayssOSQ3evOYqeWk6XTnlLao3haYJRhcJWPuxgZbTx+qK71 +XTbHKoAllpkEfpTU29td/s86d75eKeH6cmF1acxuLMBl6Az6o1jAGxKneG/f9KV+9o2vC Y1EsIK0Cg3S5bDn2Bk43aKlrJZQ0Rk8= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-58-y27-X9HcOPePeJFYrtoyaA-1; Fri, 27 Mar 2026 15:32:33 -0400 X-MC-Unique: y27-X9HcOPePeJFYrtoyaA-1 X-Mimecast-MFC-AGG-ID: y27-X9HcOPePeJFYrtoyaA_1774639953 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-5094741c1c1so58173731cf.1 for ; Fri, 27 Mar 2026 12:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1774639953; x=1775244753; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5VTZSuhR1jCaLjcqylqIXA7GgBv7DZmHs0Ejxquvhuk=; b=kBklNiQ5dPpC6UAzKm//CWB5oV/NEkjTQdnW76IMZieC1bdzjt9ZCIl72rRx7PU23X Tlf9qZTaaD+rEHkgXqWmI2Xw1SMEzclqYlavTsxLvUHlzqpricLV568PGqrHl5pJz0EV SXCKOqtLDCluc6rc+kGIN42wJyKtTBQrzT6AvvcG3EqtzBqQ7xlV6Jqz6RMJfpvpvvTh TAt4ZlWlOgIbqmdWt67gFMFdyvtuvDig8OlF0QJjGM/AAdcvgdW36IKx47PkVYSc1oC1 rpjfbrvkWfGSMsA1COENsoXuJdreDIkb8bjioH02C+/aIRmVCDAhvn6ZdnB7zb40hjz1 gHEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774639953; x=1775244753; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=5VTZSuhR1jCaLjcqylqIXA7GgBv7DZmHs0Ejxquvhuk=; b=kgDOjviQ98hmxIUTMZABTYC/q4J/bIlMLYZr/Whq2tHqzcg8qGzaTBbaPW9JiT2e6L 2Et8dkxPrQTYzTsTmXUNNUigI00aw7uH9JI467++CpWRQ8I+1vI+uOuyFBceVLHjKoKY WkX+FpdYKrj7fM+7zkXnVFQx5pQT4Pw4+iRqmqaYuL+Qyxc51qZU9mPqN/5efyy12kIt RobrNLDd6AJB8AEQFXdrSQJN3N71pd4xb10OdggNLSWJ0F9ItE/pgjYIpkaeGkFUTlD2 JhMgH/pOcO9TskTLeqpXXUS3E2FKvrUPfovG+18k1y0UEbLcNurz4MXst6N9khh8zKBE QkyA== X-Forwarded-Encrypted: i=1; AJvYcCXuwSHO7c5z39169QkHOPODbCHC7ySf3ULtsGf6tC/jpWusTdN0dLn0qwakAhQLUpQzB9ehRYDhxYxi0zc=@vger.kernel.org X-Gm-Message-State: AOJu0Yyygkdzt1UPSRB7bf1utjDP2nsofiZ4GgQsfB1aOyvckSac9LRB MvcYMVoJXVtDolRlYmscfSXIl1uhMO0GuPNtR5sFwrraNSn/yACQ+0ns91rlPpX91TMV8rp2fHj r9iWE6nCvvtCwToiLXJ2gV4hKIGtLDKK1Rh4Rkm5HES4XVptTkw2y1JgpT5yJJf1UjA== X-Gm-Gg: ATEYQzwX2jtMTdUXACqxyVeQZUyWTo20rGa0EbUu+4lugGTg5ODZqVp0qsLLToqlFne gYLRpRh0GpsTpuWfLnZBU91i0IQs8KoEVn/X6dMxb1fMQpLeUcUmXqChI4C9RIQbb3XYa8Gneah 9+yKyzJyOg8+7QMsM2paaQJj5MjNjLq66rvz4aJD/Yyyu+6VPiWfh9SIKpdId/tBPDK4fQeiyMm 90CbYTUAPDoifJ29O32H8qNH7oi8cqiT/goF6o8ECByRtNPJiwMkMZ294jhce57UFqmOeEzJG2O wizsm5Gukx6EMfkyVxNxldXFot6uhlU48ccI1eHav0ree6pCThAMORDntsS5xzqHnVL9GGM+gF/ 6xEJppjVxd+MJNnyRrYFGX6TW0M4F91NX2anRvJAm8gHRkfTInHuuMxnpjbIs X-Received: by 2002:ac8:58cc:0:b0:50b:3a6d:db4b with SMTP id d75a77b69052e-50ba39a8fb9mr56434541cf.55.1774639953097; Fri, 27 Mar 2026 12:32:33 -0700 (PDT) X-Received: by 2002:ac8:58cc:0:b0:50b:3a6d:db4b with SMTP id d75a77b69052e-50ba39a8fb9mr56434071cf.55.1774639952639; Fri, 27 Mar 2026 12:32:32 -0700 (PDT) Received: from [192.168.1.3] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50bb2c678e9sm2037551cf.6.2026.03.27.12.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2026 12:32:31 -0700 (PDT) From: Brian Masney Date: Fri, 27 Mar 2026 15:32:02 -0400 Subject: [PATCH v8 7/8] clk: divider: test: introduce additional test case showing v2 rate change + LCM parent 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260327-clk-scaling-v8-7-86cd0aba3c5f@redhat.com> References: <20260327-clk-scaling-v8-0-86cd0aba3c5f@redhat.com> In-Reply-To: <20260327-clk-scaling-v8-0-86cd0aba3c5f@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Alberto Ruiz , Brendan Higgins , David Gow , Rae Moar Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4963; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=RGguDxs0mpixqcCPoxM/eD7hdhypb/MfsPjPm5+1CyE=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDKP3XZ8V+pxWX/lDFF1hWf/tpc23uz1VNu63E5XsDX5q G/qozqxjlIWBjEuBlkxRZYluUYFEamrbO/d0WSBmcPKBDKEgYtTACbyzJXhf+lN57V2UoveTTyT 73b3THNNQw7nPpYZzYGJR96XH1/lIM3wi2nPg3L55yLvtxtMbnu2K6TugxvPy+KwSp6spktKUU/ 7mAE= X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 Add a test case that uses the clk divider with the v2 rate negotiation logic, plus the Lowest Common Multiple (LCM) to calculate the optimal parent rate. The test ensures that the parent clk rate is set to a rate that's acceptable to both children, and the sibling clock is not affected. The test in this commit use the following simplified clk tree with the initial state: parent 24 MHz / \ child1 child2 24 MHz 24 MHz child1 and child2 both divider-only clocks that have CLK_SET_RATE_PARENT set, and the parent is capable of achieving any rate. child1 requests 32 MHz, and the tree ends up with the correct state: parent 96 MHz / \ child1 child2 32 MHz 24 MHz Link: https://lore.kernel.org/linux-clk/aUSWU7UymULCXOeF@redhat.com/ Link: https://lpc.events/event/19/contributions/2152/ Signed-off-by: Brian Masney --- drivers/clk/clk-divider_test.c | 54 ++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 54 insertions(+) diff --git a/drivers/clk/clk-divider_test.c b/drivers/clk/clk-divider_test.c index f1ba15f3646ae501c940b82f0522eeee7831492a..b55c822dfff018452f0a3acd4ad= 7ccec6f1259d4 100644 --- a/drivers/clk/clk-divider_test.c +++ b/drivers/clk/clk-divider_test.c @@ -115,6 +115,18 @@ clk_rate_change_divider_test_lcm_ops_v1_params[] =3D { KUNIT_ARRAY_PARAM_DESC(clk_rate_change_divider_test_lcm_ops_v1, clk_rate_change_divider_test_lcm_ops_v1_params, desc) =20 +static const struct clk_rate_change_divider_test_param +clk_rate_change_divider_test_regular_ops_v2_params[] =3D { + { + .desc =3D "regular_ops_v2", + .ops =3D &clk_dummy_div_ops, + .extra_child_flags =3D CLK_V2_RATE_NEGOTIATION, + }, +}; + +KUNIT_ARRAY_PARAM_DESC(clk_rate_change_divider_test_regular_ops_v2, + clk_rate_change_divider_test_regular_ops_v2_params, desc) + static int clk_rate_change_divider_test_init(struct kunit *test) { const struct clk_rate_change_divider_test_param *param =3D test->param_va= lue; @@ -183,6 +195,11 @@ static void clk_test_rate_change_divider_1(struct kuni= t *test) KUNIT_EXPECT_EQ(test, ctx->child2.div, 1); } =20 +static inline bool __clk_has_v2_negotiation(struct clk *clk) +{ + return clk_hw_get_flags(__clk_get_hw(clk)) & CLK_V2_RATE_NEGOTIATION; +} + /* * Test that, for a parent with two divider-only children with CLK_SET_RAT= E_PARENT * set and one requests a rate incompatible with the existing parent rate,= the @@ -252,6 +269,39 @@ static void clk_test_rate_change_divider_3_v1(struct k= unit *test) KUNIT_EXPECT_EQ(test, ctx->child2.div, 1); } =20 +/* + * Test that, for a parent with two divider-only children with CLK_SET_RAT= E_PARENT + * set and one requests a rate incompatible with the existing parent rate,= the + * sibling rate is not affected, and maintains it's rate when the v2 rate + * negotiation logic is used. + */ +static void clk_test_rate_change_divider_4_v2(struct kunit *test) +{ + struct clk_rate_change_divider_context *ctx =3D test->priv; + int ret; + + KUNIT_ASSERT_EQ(test, clk_get_rate(ctx->parent_clk), 24 * HZ_PER_MHZ); + KUNIT_ASSERT_EQ(test, clk_get_rate(ctx->child1_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child1.div, 1); + KUNIT_ASSERT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child2.div, 1); + KUNIT_ASSERT_TRUE(test, __clk_has_v2_negotiation(ctx->child1_clk)); + KUNIT_ASSERT_TRUE(test, __clk_has_v2_negotiation(ctx->child2_clk)); + + ret =3D clk_set_rate(ctx->child1_clk, 32 * HZ_PER_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + /* + * With LCM-based parent + v2 rate changes, the parent should be at + * 96 MHz (LCM of 32 and 24), child1 at 32 MHz, and child2 at 24 MHz. + */ + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->parent_clk), 96 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), 32 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child1.div, 3); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child2.div, 4); +} + static struct kunit_case clk_rate_change_divider_cases[] =3D { KUNIT_CASE_PARAM(clk_test_rate_change_divider_1, clk_rate_change_divider_test_regular_ops_gen_params), @@ -259,6 +309,10 @@ static struct kunit_case clk_rate_change_divider_cases= [] =3D { clk_rate_change_divider_test_regular_ops_gen_params), KUNIT_CASE_PARAM(clk_test_rate_change_divider_3_v1, clk_rate_change_divider_test_lcm_ops_v1_gen_params), + KUNIT_CASE_PARAM(clk_test_rate_change_divider_1, + clk_rate_change_divider_test_regular_ops_v2_gen_params), + KUNIT_CASE_PARAM(clk_test_rate_change_divider_4_v2, + clk_rate_change_divider_test_regular_ops_v2_gen_params), {} }; =20 --=20 2.53.0