From patchwork Mon Apr 7 13:12:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 14040478 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 68A8E253B5F for ; Mon, 7 Apr 2025 13:13:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031595; cv=none; b=Pq1zwCLa2J0zpBCrEBTs/bQCEJDSigmr4EpTgfAkRpEMi3AdTcGKQS8DA6Fcwh20zPxTtNuqbT4aR9VEvA4LDlYUCzBn9Ldcoi4Sg8xtE5Urr47ks25Gsoj5p3HS99U4MQaG0qUSTWrV7u+YzlmKFNIa/FSyBJUDot9eR/tMsQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031595; c=relaxed/simple; bh=7eX6vU70kWv6aUWi8R4b9wN+zN2bOhSNdyX7zLBgvhU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=cOxL9CNFYCfm37OC+8aTwPJ/IyHKGuSH1c8pO+6bsyPPvXFypPwRpo2sthG8U5eBOW9chXF/B8IGmv5X/X2leBr5+07KsXVpJbf5xWb/KIx+m6vUyg0CLYVdwV9hwExxJhYGCBy4dgdtVJtsxfNlHEw7iZkmkiHABaBJS1uoIyg= 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=CekVyWKt; arc=none smtp.client-ip=170.10.129.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="CekVyWKt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744031592; 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=a9lCnalV/KwjMC4bFuYLU7hw0fDsHdehp4fkHlEXRtM=; b=CekVyWKtuvvZVrWMgmkuP2OJBFh+qfeqKP9eAIUZqEV7XKobZXQHpa6M3gHOF2s7ccwaq7 LtJ3J4O/gaQptHH0XTVB0Hm27JPxHtAiv8phd0MlytOcbld0vbaM3I314oq49RcFVQia6m N67u1LzibzWbbh1lgxJGgdbGvO6VVXA= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-593-2_D6ZyghNb-RqwpEdIBy1g-1; Mon, 07 Apr 2025 09:13:11 -0400 X-MC-Unique: 2_D6ZyghNb-RqwpEdIBy1g-1 X-Mimecast-MFC-AGG-ID: 2_D6ZyghNb-RqwpEdIBy1g_1744031591 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6e8ed78717eso79254566d6.2 for ; Mon, 07 Apr 2025 06:13:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744031590; x=1744636390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a9lCnalV/KwjMC4bFuYLU7hw0fDsHdehp4fkHlEXRtM=; b=JG6nKMci0w836eyny/To7xACR/9f1oyiryapZa4ZnLAIeRvZY7cbyAfT511M5ICCwG yQHcEjgZvND/mqsWrhHei5wpnvHJNG1hrJRCbqtozYOHJ76qbst3XVCz3OqT9MnrmTkC 2M9y22jwN/3w8v77vgkTZPeinsZRwNWlpOid1/edVrYPzTDvuYeoy0cVmYJ1e/YBRfGh M4wSJHQ9RACWZHDEB1A1F5AWC5l0tV/2Sc5LKZvVtKZlxJ0rd4xelqwzydVmPxOzyeKr f2TGbbVzBU5Z7gDSjaeFIccDD8Fs5ZLPBxNZZCXy34nZDJL9Vf9WVpf0bpCKOB308uDx KQIQ== X-Gm-Message-State: AOJu0YxRVWyFz0hHoarAw4fATxyVnuQ8We2Jf7/njMAGXt3uyUIb773w /RTmbLpvSHJy/LqwO/VZzsW5DKR2TwoO4Q6W2JYm0JssdizDlSDTCBJ4EXSo+qFrt1N2TG5p50y fv0i8X7YAlmDi1QqdhnDqkJ4gowcViryumwByFGL/4l4sfWtvbvEqWdX1RQ== X-Gm-Gg: ASbGnctq8r3k82PRYmeitsFfSyxu2EgIWcMElfhKLJ81ts6/u79HFDjiNBOoSQtA4IL l6aiRFnzhhKnhlIrw3HgqzVqol1ZmCZWy7kY3yMPUD009hCXiHWMBt41EBmTAf/mdyjUokjudc+ lGbJgN/H/tAmVwTKn09Gi1dKOU9EtFbV1mhf0YktkL+tOosLzrwo5PogrFeTXSvurCTl24M/gvs KREfvGPxvowgr1hLmQKXVyP4Ck6tED7w6VuGSaFgzWIczlACuDhCQGuWR3NCxIyBfrEH9WI/XwW wMMrj6tlcbQkUVfcWhnQlb76zPIE0uCQw3Cf5MiqMA== X-Received: by 2002:ad4:5f4a:0:b0:6ef:3de:5ff7 with SMTP id 6a1803df08f44-6f00deb6471mr216309776d6.15.1744031590770; Mon, 07 Apr 2025 06:13:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJVA5cdvPfMT1cbbV0KBVMgtp43I7rMfUHFXHZZtE9t1ke1BHH9yVmlIS35qB8irghkIqLjQ== X-Received: by 2002:ad4:5f4a:0:b0:6ef:3de:5ff7 with SMTP id 6a1803df08f44-6f00deb6471mr216309396d6.15.1744031590508; Mon, 07 Apr 2025 06:13:10 -0700 (PDT) Received: from x1.. (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ef0f138e15sm57662556d6.82.2025.04.07.06.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 06:13:09 -0700 (PDT) From: Brian Masney To: sboyd@kernel.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, mripard@redhat.com Subject: [PATCH 1/8] clk: test: introduce a few specific rate constants for mock testing Date: Mon, 7 Apr 2025 09:12:51 -0400 Message-ID: <20250407131258.70638-2-bmasney@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250407131258.70638-1-bmasney@redhat.com> References: <20250407131258.70638-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Some of the mock tests care about the relationship between two different rates, and the specific numbers are important, such as for mocking a divider. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index f08feeaa3750..1b34d54ec9c6 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -24,6 +24,10 @@ static const struct clk_ops empty_clk_ops = { }; #define DUMMY_CLOCK_INIT_RATE (42 * 1000 * 1000) #define DUMMY_CLOCK_RATE_1 (142 * 1000 * 1000) #define DUMMY_CLOCK_RATE_2 (242 * 1000 * 1000) +#define DUMMY_CLOCK_RATE_6_MHZ (6 * 1000 * 1000) +#define DUMMY_CLOCK_RATE_16_MHZ (16 * 1000 * 1000) +#define DUMMY_CLOCK_RATE_24_MHZ (24 * 1000 * 1000) +#define DUMMY_CLOCK_RATE_48_MHZ (48 * 1000 * 1000) struct clk_dummy_context { struct clk_hw hw; From patchwork Mon Apr 7 13:12:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 14040479 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 DC9A1253B51 for ; Mon, 7 Apr 2025 13:13:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031598; cv=none; b=q88ek5ulFbe6c4xpOSycNF99J0GW4/rFgVY1VU5XHnDlbAr4dOWtvOoYggYxODkI64JJnPfNSOBPwPDC4bS8hwX1N4E1h6XHuP/AkwLM1xa98T/7wxKKxmHkNrBnhHpwbYBLxmvBeF2u2DHZSOxfZf2iSoZQ48N9/V4r8s6b1Ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031598; c=relaxed/simple; bh=wlO2M5Iffb0ZdGXwHjBV+tKDbXC9cX8F+bfsNcUAoXU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=d7qiMwo1VhmKvl4GbQgUbM/wk/K4ERoE5+Chml6Fu9tsSHEUlBbN6V3STKPhBbfYtSCijjKACigjZhyUfdVl4v5s3rIUEejoF971u1Lfz8knFC3Q0mB1E76WPcBGbDnt29OjxEofgTioDJzwNt5bIKNfauQF70Ttx3ZZC6g01TE= 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=MpsFgg/I; arc=none smtp.client-ip=170.10.129.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="MpsFgg/I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744031594; 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=SPeRRdg+oYji3tLFW/edfVgnk/6p+M7V8UpTleI7ZF0=; b=MpsFgg/I0Rq7YNtyefVH3atlJwdQ9gyWHsxVVK/2WOwLBSap88pi++3IzSGGFyQJSzyepB lfODMCOo4FKmWJtbwc5ofsLRcN3fEDu2aKYTNwfVg98GlJBtbgzzpOwz+4tynSU7YoCvND DSrj+qr6cF+klYWSmYakmF4cQN9sBOM= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-GQYgajz3OG6YHdpSGi3F3w-1; Mon, 07 Apr 2025 09:13:13 -0400 X-MC-Unique: GQYgajz3OG6YHdpSGi3F3w-1 X-Mimecast-MFC-AGG-ID: GQYgajz3OG6YHdpSGi3F3w_1744031593 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6e905e89798so59514796d6.3 for ; Mon, 07 Apr 2025 06:13:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744031593; x=1744636393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SPeRRdg+oYji3tLFW/edfVgnk/6p+M7V8UpTleI7ZF0=; b=vQUo/6SA+5tocRw5KKjQnq8Z+IIzbhXXHuhx8l06+7QIL74TfwySREdlj/AiLrsQca 2KRUdFubn7VNYqKjf6j5AmqJarg6heX2B0n0amwyz+L3ojQ1YZixRWAf9dn5H5CV93vH Fl3ThT7pJcLjMGYHutFME4sCjD80NsZww+myXEfe8V3tZHFh3S/PqIt9fz/6CyPBAiQg qmjFZEcoy00K0JZykwPY7sVyawJ8n3PoGOYREAUfitucMi1ZgAK/uU8i+5CNd93Z596I BaIKSix5YMqmqxD9jOXCKRl156mTX63u96HzmR5uuh1dGN7d1nwEM2U1qJUWh259qBu6 u7JA== X-Gm-Message-State: AOJu0YzBPN9UIPfrUnVcluzItMmulEfhmxWWY3PYPgIr+SBh9z+5rj1b fE9Gr3K52styrBVXnxzU/CUvmW0y7f5qH8CC5TWhckYO4BNR2XTs/iQCNbbbZM97SM0WuoK57Lm AadDnnMW5qvcgedqnVAUfKnHsEydBwmeSfTTvGYioyjUpxpCY2oxlfHXg5A== X-Gm-Gg: ASbGnctbHfCIg0i1CU9qV2/SWLC/hZlrgHvi9zbdxpC0z5q5lu15h8zJDLKlnRLqnja 7pmd+LDB4jd0oyR7wCjxRG7bc2wV3QgCzBpXHjHuDMKLMIa4ctKt9r9qpvq/wmTGya3fyQ7tDRi WVXOQmVqWL8NNlSA+QaVPcVZ93FqnVJcG3kcQoU7TtW//QbOIi7HElVnZraxqUZBehWli1qEYx2 c8oHVopMI0A0plMQeO3Y3Tw0SstC9fo8iP5WI/NY65NaUJtzYy2EazpURwfkPPuiJYXxdpwmafQ KSvl9e8YsH56S33e8VObGL0dlgVLc0KX7ZQ5ooGvlw== X-Received: by 2002:a05:6214:f27:b0:6ef:eb:a42 with SMTP id 6a1803df08f44-6f0b74f697fmr155461106d6.28.1744031592981; Mon, 07 Apr 2025 06:13:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnMH67qk17ML1Xxl6I5rVLhnarS2cRcaURH5/qJHB2dqvoAJCYELgv7syc1xm8QgsFtGxTTA== X-Received: by 2002:a05:6214:f27:b0:6ef:eb:a42 with SMTP id 6a1803df08f44-6f0b74f697fmr155460846d6.28.1744031592686; Mon, 07 Apr 2025 06:13:12 -0700 (PDT) Received: from x1.. (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ef0f138e15sm57662556d6.82.2025.04.07.06.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 06:13:11 -0700 (PDT) From: Brian Masney To: sboyd@kernel.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, mripard@redhat.com Subject: [PATCH 2/8] clk: test: introduce clk_dummy_div for a mock divider Date: Mon, 7 Apr 2025 09:12:52 -0400 Message-ID: <20250407131258.70638-3-bmasney@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250407131258.70638-1-bmasney@redhat.com> References: <20250407131258.70638-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain This is used to mock up a divider in the clk kunit tests. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 1b34d54ec9c6..4908fb9c0c46 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -140,6 +140,47 @@ static const struct clk_ops clk_dummy_single_parent_ops = { .get_parent = clk_dummy_single_get_parent, }; +// 4 ought to be enough for anybody +#define CLK_DUMMY_DIV_WIDTH 4 + +struct clk_dummy_div { + struct clk_hw hw; + unsigned int div; +}; + +static unsigned long clk_dummy_div_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct clk_dummy_div *div = container_of(hw, struct clk_dummy_div, hw); + + return divider_recalc_rate(hw, parent_rate, div->div, NULL, + CLK_DIVIDER_ROUND_CLOSEST, CLK_DUMMY_DIV_WIDTH); +} + +static long clk_dummy_div_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) +{ + return divider_round_rate(hw, rate, parent_rate, NULL, + CLK_DUMMY_DIV_WIDTH, CLK_DIVIDER_ROUND_CLOSEST); +} + +static int clk_dummy_div_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + struct clk_dummy_div *div = container_of(hw, struct clk_dummy_div, hw); + + div->div = divider_get_val(rate, parent_rate, NULL, CLK_DUMMY_DIV_WIDTH, + CLK_DIVIDER_ROUND_CLOSEST); + + return 0; +} + +static const struct clk_ops clk_dummy_div_ops = { + .recalc_rate = clk_dummy_div_recalc_rate, + .round_rate = clk_dummy_div_round_rate, + .set_rate = clk_dummy_div_set_rate, +}; + struct clk_multiple_parent_ctx { struct clk_dummy_context parents_ctx[2]; struct clk_hw hw; From patchwork Mon Apr 7 13:12:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 14040480 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 5EC2A254845 for ; Mon, 7 Apr 2025 13:13:21 +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=1744031603; cv=none; b=c0roh1JM5lT2Ln+NRqycYprIywnORX8fRMj9469mQGuFxABRdqkV/yD3jYkBKn3+/WM3CtCAbCN+Ohewth2X3nG5MOhn3Eg0dt5KJfNOemmVfD5DhmqJIrzGwaTXAuR4oea0mxmBvCQU8AzgnRiwT8fRV6gx6iFKyGNZUhYFHLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031603; c=relaxed/simple; bh=ZYipNs+crvm5U+agBHLVdGPNoOm0fvljgZMQ2NaTkBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=U2sJ5KzSW6YE36l1Cfu/r/ElikVDBTuQILhYAyiOgVCGyFKFpn+3YepGL5i8zONKvx4O1a7A5lK8bWPGtZ7I7jTCE/Bd05fEtm9M9XFmzXsbtS/l+DXjYxsv2rFAbvEzsa2uKTOpZBZpVj1Pr7SCoi/jhsyUIz2MppPL7c5CKiA= 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=Vlsf2gNd; 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="Vlsf2gNd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744031600; 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=kj6PU5kJaei74PopQFAd4HOXHT8Ovro9cVP0ls9g+Yo=; b=Vlsf2gNdavrG4T7WQCWxRxSIC7H0B/lnKCI0eJJCtwIovOw2bsjg27+uZ/5bdvtqKX6nKX +cSAFxYkS6YkgtZMHnncdbDCi/NGP66bqQXwGjKJ026bA0zVtx/OlrRUtNRAHFDakiPatb FAVhPtkuKvgpqzUo7wEwpG/dabinPIw= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-78-nd-6dxV0PfyJ2hIcKsdOXg-1; Mon, 07 Apr 2025 09:13:18 -0400 X-MC-Unique: nd-6dxV0PfyJ2hIcKsdOXg-1 X-Mimecast-MFC-AGG-ID: nd-6dxV0PfyJ2hIcKsdOXg_1744031597 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6f0c089909aso30579976d6.2 for ; Mon, 07 Apr 2025 06:13:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744031596; x=1744636396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kj6PU5kJaei74PopQFAd4HOXHT8Ovro9cVP0ls9g+Yo=; b=rZRVMhARw8HwlIa2calMv1ahlwFsHt80Iae9jSNPYfEb8pAyvTcxYyGRpA7Cihs9eD zpDr503NNkSDiJDqXfX0EZ1OqRopwKc1kykDeNfXephz7frh1t5sZhHqEYGgZrgQl9LL jDWt9cqZ/j62JsEu9Cr/d661dd1S08K8F1u6xX8SSU6rrpWDPeCwHdoNFjLo3x+zMmiW uXvwvH6W6Rme2a0cDuTMysUGkipFajdVBI9r0+eymK+7w7+dmwqB4BqxWhWJ18JNr4Es kt4vMiB4qF+4wRK0SiQ/UvrA2SX4ZSneZCFDaTUfdk5jrvCQsXPyVeXbYVUs4cC5tBL+ QYaw== X-Gm-Message-State: AOJu0YxYGociM+2NWAYvvDGDF1vvVBbynrS3n173RdkXLJXjAq+YiuL4 HUy61jU1d+kmpxK437CkdsdoIqP4H2GGyWXMQPnTgZXI3kc8O6F7aef47gzzFaPNm2gZsBFKQj9 dwBFTYIOt8oDKKKcvOT1TGOuI3ROGBkwaAYPYMQPzXdQc2ED/+qP1kP3jiZOitf90QQ== X-Gm-Gg: ASbGnctiP+GoQu2/+AWS8QR7SoTPmlSyJeD5eecWj9rr5kYBjPVJ7FX3Z/2hLmUgN0B oMNwjCGuvp+7LTqMPro3+faIwxswI5mejLmL/qXB7qs5o8u6ZE5YWT9nDKZmACvC86TxlCQtHA4 5PfoAFFlyqAauNiWTvmMpeBRvBVi9C4DdDaucT54qonaQmRn3qwV9uBw0aaRnCA+Dj4yd4XSPiY bt35UDfolMm81jZm5VsdmsGJofH5YalcLlXwb3GJ9Jc622ri5i7nY0q5wDOrCLzg/BNa0wfhxIp eC77eVL7HtbOSzbpz6DSmKRQyvw6z7yPuMarQFILHw== X-Received: by 2002:a05:6214:1d2d:b0:6e8:ef80:bcbc with SMTP id 6a1803df08f44-6f00debc511mr203626186d6.5.1744031595750; Mon, 07 Apr 2025 06:13:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGByCpQR2AniaNCjBHDOmGlDE2aS5mpzlnF4QdIIC1rtfrWYX0CPYIvd3RuYJyKvftUvu52LQ== X-Received: by 2002:a05:6214:1d2d:b0:6e8:ef80:bcbc with SMTP id 6a1803df08f44-6f00debc511mr203625856d6.5.1744031595407; Mon, 07 Apr 2025 06:13:15 -0700 (PDT) Received: from x1.. (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ef0f138e15sm57662556d6.82.2025.04.07.06.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 06:13:13 -0700 (PDT) From: Brian Masney To: sboyd@kernel.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, mripard@redhat.com Subject: [PATCH 3/8] clk: test: introduce test suite for sibling rate changes on a divider Date: Mon, 7 Apr 2025 09:12:53 -0400 Message-ID: <20250407131258.70638-4-bmasney@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250407131258.70638-1-bmasney@redhat.com> References: <20250407131258.70638-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Introduce a test suite that creates a parent with two divider-only children, and ensure that changing the rate of one child does not affect the rate of the sibling. Some of the tests are disabled until the relevant issue(s) are fixed in the clk core. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 135 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 4908fb9c0c46..7d4dd1a559db 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -653,6 +653,140 @@ clk_multiple_parents_mux_test_suite = { .test_cases = clk_multiple_parents_mux_test_cases, }; +struct clk_rate_change_sibling_div_div_context { + struct clk_dummy_context parent; + struct clk_dummy_div child1, child2; + struct clk *parent_clk, *child1_clk, *child2_clk; +}; + +static int clk_rate_change_sibling_div_div_test_init(struct kunit *test) +{ + struct clk_rate_change_sibling_div_div_context *ctx; + int ret; + + ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + test->priv = ctx; + + ctx->parent.hw.init = CLK_HW_INIT_NO_PARENT("parent", &clk_dummy_rate_ops, 0); + ctx->parent.rate = DUMMY_CLOCK_RATE_24_MHZ; + ret = clk_hw_register_kunit(test, NULL, &ctx->parent.hw); + if (ret) + return ret; + + ctx->child1.hw.init = CLK_HW_INIT_HW("child1", &ctx->parent.hw, + &clk_dummy_div_ops, + CLK_SET_RATE_PARENT); + ret = clk_hw_register_kunit(test, NULL, &ctx->child1.hw); + if (ret) + return ret; + + ctx->child2.hw.init = CLK_HW_INIT_HW("child2", &ctx->parent.hw, + &clk_dummy_div_ops, + CLK_SET_RATE_PARENT); + ret = clk_hw_register_kunit(test, NULL, &ctx->child2.hw); + if (ret) + return ret; + + ctx->parent_clk = clk_hw_get_clk(&ctx->parent.hw, NULL); + ctx->child1_clk = clk_hw_get_clk(&ctx->child1.hw, NULL); + ctx->child2_clk = clk_hw_get_clk(&ctx->child2.hw, NULL); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->parent_clk), DUMMY_CLOCK_RATE_24_MHZ); + + return 0; +} + +static void clk_rate_change_sibling_div_div_test_exit(struct kunit *test) +{ + struct clk_rate_change_sibling_div_div_context *ctx = test->priv; + + clk_put(ctx->parent_clk); + clk_put(ctx->child1_clk); + clk_put(ctx->child2_clk); +} + +/* + * Test that, for a parent with two divider-only children and one requests a + * rate compatible with the existing parent rate, the parent and sibling rates + * are not affected. + */ +static void clk_test_rate_change_sibling_div_div_1(struct kunit *test) +{ + struct clk_rate_change_sibling_div_div_context *ctx = test->priv; + int ret; + + ret = clk_set_rate(ctx->child1_clk, DUMMY_CLOCK_RATE_6_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->parent_clk), DUMMY_CLOCK_RATE_24_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), DUMMY_CLOCK_RATE_6_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), DUMMY_CLOCK_RATE_24_MHZ); +} + +/* + * Test that, for a parent with two divider-only children and one requests a + * rate incompatible with the existing parent rate, the sibling rate is not + * affected. + */ +static void clk_test_rate_change_sibling_div_div_2(struct kunit *test) +{ + struct clk_rate_change_sibling_div_div_context *ctx = test->priv; + int ret; + + kunit_skip(test, "This needs to be fixed in the core."); + + ret = clk_set_rate(ctx->child1_clk, DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_GE(test, clk_get_rate(ctx->parent_clk), DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), DUMMY_CLOCK_RATE_24_MHZ); +} + +/* + * Test that, for a parent with two divider-only children that request rates + * incompatible with the existing parent rate, both children end up with the + * requested rates. + */ +static void clk_test_rate_change_sibling_div_div_3(struct kunit *test) +{ + struct clk_rate_change_sibling_div_div_context *ctx = test->priv; + int ret; + + kunit_skip(test, "This needs to be fixed in the core."); + + ret = clk_set_rate(ctx->child1_clk, DUMMY_CLOCK_RATE_16_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + ret = clk_set_rate(ctx->child2_clk, DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_GE(test, clk_get_rate(ctx->parent_clk), DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), DUMMY_CLOCK_RATE_16_MHZ); +} + +static struct kunit_case clk_rate_change_sibling_div_div_cases[] = { + KUNIT_CASE(clk_test_rate_change_sibling_div_div_1), + KUNIT_CASE(clk_test_rate_change_sibling_div_div_2), + KUNIT_CASE(clk_test_rate_change_sibling_div_div_3), + {} +}; + +/* + * Test suite that creates a parent with two divider-only children, and + * ensures that changing the rate of one child does not affect the rate + * of the other child. + */ +static struct kunit_suite clk_rate_change_sibling_div_div_test_suite = { + .name = "clk-rate-change-sibling-div-div", + .init = clk_rate_change_sibling_div_div_test_init, + .exit = clk_rate_change_sibling_div_div_test_exit, + .test_cases = clk_rate_change_sibling_div_div_cases, +}; + static int clk_orphan_transparent_multiple_parent_mux_test_init(struct kunit *test) { @@ -3445,6 +3579,7 @@ kunit_test_suites( &clk_leaf_mux_set_rate_parent_test_suite, &clk_test_suite, &clk_multiple_parents_mux_test_suite, + &clk_rate_change_sibling_div_div_test_suite, &clk_mux_no_reparent_test_suite, &clk_mux_notifier_test_suite, &clk_orphan_transparent_multiple_parent_mux_test_suite, From patchwork Mon Apr 7 13:12:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 14040519 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 B5092254AFC for ; Mon, 7 Apr 2025 13:16:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031765; cv=none; b=RzrcNuLojYHYEGo432tDYZf8gJD6bs54AFPsn8aDndgVZLVLvWhydW1FEhqYDwWACi9NsqY2Tyy11NZSjZIvBUhcD1BDPgp/gmFoqibY/vHx0wJNXkVeveQDZIyiznu6kIikFh26kMHJHq5nEUJVl8HpeXR16bIMKVSQbOkSmiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031765; c=relaxed/simple; bh=Ga2K09VmKsNU+0mnEVhgO1+H24/PI+fT+YcdrRb2qEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=hYk5KUUFzRI9uQnHEl/AbQs9AlLlEbn2Vwx0+3CTPWUrlSLzqOQUPLQuGq3Q6MQ4wMShSzmrQNhni9a9IYoHtYYXqKHutDS1aQvrAzEEmtYFOMMl714EM/DZI3SKKvFFFMfP3xXWEZwCbjSrQuc2jCfm7Z6/TWtUltU5OzgHbr8= 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=UzmDZLp/; arc=none smtp.client-ip=170.10.129.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="UzmDZLp/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744031762; 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=vCiYE/HbpALtWNARoJxya1tjWc8KeYYpYFoVh2t216c=; b=UzmDZLp/2wGjxpzcsZDSylnzhFfu4i9HTqaFTAjzYOfkk3PsID5+C3hj39AQqlnorsQ6Qf /38Mf7K30IeHHrLGqcVUYfSRaVa5myOTzlDZ0vThnrIgI1uI/yGCcrOwhff0VvjxK5nHuH F4Baxw/t75nalRd3OrIhFuEE7HIyH3g= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-I3wsxK99OTqLdUBZGOD5Bg-1; Mon, 07 Apr 2025 09:13:19 -0400 X-MC-Unique: I3wsxK99OTqLdUBZGOD5Bg-1 X-Mimecast-MFC-AGG-ID: I3wsxK99OTqLdUBZGOD5Bg_1744031599 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7c548e16909so395127785a.2 for ; Mon, 07 Apr 2025 06:13:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744031598; x=1744636398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vCiYE/HbpALtWNARoJxya1tjWc8KeYYpYFoVh2t216c=; b=AtMQKl0q2gJTtQJVwNhiQitM4iNV31/RVNVMjWhVlfwRwnh/L3O/dqRbRHKOaHpe9T TFhCbnQ9RO3WinMeG7F+LtLdIwcpsYWy24AFPEUarB6SoJsR9joKr//WugTcqfN/dCRp GwayT6BsVgVKIw5Az99H/J3yM3kXhsf+g6NoOCi7yyS1lpzlL5omJBSUYWvy9AmLXyDW oyQVTXEuPNdAE8mWh3JRPl6Y5/wCHRVXC0yU2MpY/iCdJA++owTPRSUYM+AOF24gObmR yOi2H2KL3HGSI+L66BGi0N/fW5EUfN8uvQCrHiU8nW/RPRc9WLZ2KQdZyl0KVi5c+3LJ Cq8Q== X-Gm-Message-State: AOJu0YzFRBJqkW6dXNbf6pAKpZDWWldpz7qWVmQzzqHNPgKax247KDG4 EUPgbvwRnmJJdv9rnoadl/OLyyLM7ZVLAl6cG620Qgub/3db1YHHOqK5/1FYLZd1huSOrmPIpKD SKlq/VGHuWzo5VCwJg+/aO4DZe/bn8jAnR5REcsD2xOcQx7ohbCQ5Qh2u5smoHXhezA== X-Gm-Gg: ASbGncuezKrvr+RDe1omCeXhu/nZFeSOOIYfilihw6mM0vh+ieBHe0Lrs2CVHWdSpLr OSed8h/wgo7OpFb09akHRaCZajRN2YVLj3gw0baHnj7uutiJ+oyPsFnZChhY3lYj6Ojhu3o8RJ/ FobARlkUZRI9m/tLB/V8XXW0Sns9g0/W1ztfaTVsst9IDmN8eTs+Eh18FJIot1PaBU3j0vkgmE9 0WhgSQO1ZygO4TQaDloVqc+qPz8Uj45wipzAYQ29GJ0gK3uoX9am9AhJE5N3dntD+CbzJRc3jrj uzA7KWOB6yMSIMr0ndc+oZzQynyb4UtyCicDusu/wg== X-Received: by 2002:a05:6214:2a8c:b0:6e8:f568:22e8 with SMTP id 6a1803df08f44-6f0584e7218mr192571016d6.15.1744031597899; Mon, 07 Apr 2025 06:13:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFockwKyOARh1pqCe+ax8s85aAbuAeIui04lL9zrBZU1ZDa7xBuA5q5m9Vib49h98pfLr3qNw== X-Received: by 2002:a05:6214:2a8c:b0:6e8:f568:22e8 with SMTP id 6a1803df08f44-6f0584e7218mr192570576d6.15.1744031597548; Mon, 07 Apr 2025 06:13:17 -0700 (PDT) Received: from x1.. (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ef0f138e15sm57662556d6.82.2025.04.07.06.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 06:13:15 -0700 (PDT) From: Brian Masney To: sboyd@kernel.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, mripard@redhat.com Subject: [PATCH 4/8] clk: test: introduce clk_dummy_gate for a mock gate Date: Mon, 7 Apr 2025 09:12:54 -0400 Message-ID: <20250407131258.70638-5-bmasney@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250407131258.70638-1-bmasney@redhat.com> References: <20250407131258.70638-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain This is used to mock up a gate in the clk kunit tests. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 7d4dd1a559db..14ae88df5389 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -181,6 +181,40 @@ static const struct clk_ops clk_dummy_div_ops = { .set_rate = clk_dummy_div_set_rate, }; +struct clk_dummy_gate { + struct clk_hw hw; + bool enabled; +}; + +static int clk_dummy_gate_enable(struct clk_hw *hw) +{ + struct clk_dummy_gate *gate = container_of(hw, struct clk_dummy_gate, hw); + + gate->enabled = true; + + return 0; +} + +static void clk_dummy_gate_disable(struct clk_hw *hw) +{ + struct clk_dummy_gate *gate = container_of(hw, struct clk_dummy_gate, hw); + + gate->enabled = false; +} + +static int clk_dummy_gate_is_enabled(struct clk_hw *hw) +{ + struct clk_dummy_gate *gate = container_of(hw, struct clk_dummy_gate, hw); + + return gate->enabled; +} + +static const struct clk_ops clk_dummy_gate_ops = { + .enable = clk_dummy_gate_enable, + .disable = clk_dummy_gate_disable, + .is_enabled = clk_dummy_gate_is_enabled, +}; + struct clk_multiple_parent_ctx { struct clk_dummy_context parents_ctx[2]; struct clk_hw hw; From patchwork Mon Apr 7 13:12:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 14040481 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 B03A8252919 for ; Mon, 7 Apr 2025 13:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031606; cv=none; b=vEJJokpKHcC8aftVuvIdLnV9oQe+OTwbNfdSK4uBR/It5ZEK5xAMB23MGW5f5SsG+tzEPSz+wXXpWvM+BRhHw8rMgt7ja7xfd3+n+rKJaK/sOODTtfb9YyEriQQR7JSMm2QcRKvEbo1KP2DcHUYuU8sQbfnnB77nP/M5NosjNP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031606; c=relaxed/simple; bh=19xZqCbMrxhaSVg4THIIDnGeA1aclB846rauCeJXklE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=J3NG99ANJpaXDtv1VOtzwu+QSYjX7YoZZzzVOGkeWC7WQbS5ElCkbgpO/Cqe5xAio5Ly/mYaTRg2g5C51/fhe8jokdC8dTKPlqCW05ZCdZ/kth/fZ5BOrcDhOgibtXXWOaWPRHnasYaNo4KjYIBEiYn5O5/nScGKePnnEkYpAGE= 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=fCgCOYRh; arc=none smtp.client-ip=170.10.129.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="fCgCOYRh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744031602; 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=2LwcXXpdL89K8CifyOieLXHCWhlyVVIdRdeG/nxs+w4=; b=fCgCOYRh3xX86NZHgGI3fw8U4qEDaZri9HaToebAizE5UoT4PCnNjK1EyRPKxq9A58v4qu bHqeRS1b1YiwdHX8q1kOqG6PMT2IP0+kxeJlZ93o6L/qjGqnQ3toCJ3KR0YeNQItnunZxZ HVTAd6EFOSLzIQoUqWgAgaLMXMlCyBQ= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-UNBq48xIMZuzEebEAqsQnA-1; Mon, 07 Apr 2025 09:13:21 -0400 X-MC-Unique: UNBq48xIMZuzEebEAqsQnA-1 X-Mimecast-MFC-AGG-ID: UNBq48xIMZuzEebEAqsQnA_1744031601 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6eeffdba0e2so89316136d6.2 for ; Mon, 07 Apr 2025 06:13:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744031600; x=1744636400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2LwcXXpdL89K8CifyOieLXHCWhlyVVIdRdeG/nxs+w4=; b=obKz1ntXwffrt/l6R61n7MA13J0PrTPzGoUayVg0pXoVX0KW66VYQzLnF7/50ckW6k KC3yJoGnxOYhoTkWtQM1kxdMqf6XbHqjEsFIxbXZaKR8VqIDalFunCK8xXZTWFpuAj4J U0zvLDo05neITRUJnpG8Uy2MKwKSqPvcGNkZZH5kZyrIEVUNbGW/l/kItK0w2PYOrpbV mjReHgxbmD8HSQNyZOwIyrs02taw+adVYuMNs0lwzjeNB2UupfebfXHJlavu8aCYI7aG 9pujI1rdA/JemKE5rsGn9sYWclM4XatadBi3QIEfKYqxTG+39WgHsgOXwPKhq6UICahk M/6g== X-Gm-Message-State: AOJu0YzIuNo7FEo2hlnPEzqkZ9pQYWEfEVeAE1QL0d3QSzZqi1EF7tWs LkjUqerwj0Gu7+vpEtQcB6IoBxFfSbl5aT5aFhbrfBE14w9fQBkM9rw3ijK/5E3FzoWcMJxNGap n11qsc4gSuIgWJVtFDyaLdV/4+TsOAR2lh4iIA72hj5WK7pU0FKdj37oEkg== X-Gm-Gg: ASbGnct8hSz1SsmYwI7+6N7AHMcPT2r+CB4ByYX27UBTA1Gj4/LUYk650Sr1q4F4prm X7RC7ItAmwsj319Nb9iS8cEBUWJccpc9TplKR5kSUysWCfrvFkVoYx/4yFYtNMHv7TebxXw1XAE r8I/uttvrR7S+zVqTUzYNL4c3/3etWOluPf2g0qb4O3a4Tep9B5CG1wbfM+maC7JDl6kf7d6PFD pD0+jm5gQgGQDj9PhN0y6Kr/94EWreBKn9/JOocsLUHeSiTmi4UIHaTitkURUU/ZCRCA44mv37E YywE+g/x854VYNt7biIfb5lekHAecqpRp6V5a5wHGw== X-Received: by 2002:ad4:5ba1:0:b0:6ee:b77c:7dbe with SMTP id 6a1803df08f44-6f058433cecmr192715516d6.12.1744031600703; Mon, 07 Apr 2025 06:13:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbIcdTOZ9gWbu8ai03fhRZZ0ayJGUGd9p13kqveI+0V3okeGBC6eJdQ6jZSyZ9kK0gTCIo5w== X-Received: by 2002:ad4:5ba1:0:b0:6ee:b77c:7dbe with SMTP id 6a1803df08f44-6f058433cecmr192715266d6.12.1744031600409; Mon, 07 Apr 2025 06:13:20 -0700 (PDT) Received: from x1.. (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ef0f138e15sm57662556d6.82.2025.04.07.06.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 06:13:18 -0700 (PDT) From: Brian Masney To: sboyd@kernel.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, mripard@redhat.com Subject: [PATCH 5/8] clk: test: introduce test suite for sibling rate changes on a gate Date: Mon, 7 Apr 2025 09:12:55 -0400 Message-ID: <20250407131258.70638-6-bmasney@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250407131258.70638-1-bmasney@redhat.com> References: <20250407131258.70638-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Introduce a test suite that creates a parent with two children: a divider and a gate. Ensure that changing the rate of one child does not affect the rate of the gate. Some of the tests are disabled until the relevant issue(s) are fixed in the clk core. This is also implemented as a parameterized kunit test since additional test variations will be added. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 156 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 14ae88df5389..df5d4b25aa69 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -821,6 +821,161 @@ static struct kunit_suite clk_rate_change_sibling_div_div_test_suite = { .test_cases = clk_rate_change_sibling_div_div_cases, }; +struct clk_test_rate_change_sibling_clk_ctx { + struct clk *parent_clk, *child1_clk, *child2_clk; +}; + +static void +clk_test_rate_change_sibling_clk_ctx_put(struct clk_test_rate_change_sibling_clk_ctx *clk_ctx) +{ + clk_put(clk_ctx->parent_clk); + clk_put(clk_ctx->child1_clk); + clk_put(clk_ctx->child2_clk); +} + +struct clk_rate_change_sibling_div_gate_sibling_context { + struct clk_dummy_context parent; + struct clk_dummy_div child1; + struct clk_dummy_gate child2; + struct clk_test_rate_change_sibling_clk_ctx clk_ctx; +}; + +static struct clk_test_rate_change_sibling_clk_ctx * +clk_rate_change_sibling_div_gate_test_init(struct kunit *test) +{ + struct clk_rate_change_sibling_div_gate_sibling_context *ctx; + int ret; + + ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return ERR_PTR(-ENOMEM); + test->priv = ctx; + + ctx->parent.hw.init = CLK_HW_INIT_NO_PARENT("parent", &clk_dummy_rate_ops, 0); + ctx->parent.rate = DUMMY_CLOCK_RATE_24_MHZ; + ret = clk_hw_register_kunit(test, NULL, &ctx->parent.hw); + if (ret) + return ERR_PTR(ret); + + ctx->child1.hw.init = CLK_HW_INIT_HW("child1", &ctx->parent.hw, + &clk_dummy_div_ops, + CLK_SET_RATE_PARENT); + ret = clk_hw_register_kunit(test, NULL, &ctx->child1.hw); + if (ret) + return ERR_PTR(ret); + + ctx->child2.hw.init = CLK_HW_INIT_HW("child2", &ctx->parent.hw, + &clk_dummy_gate_ops, + CLK_SET_RATE_PARENT); + ret = clk_hw_register_kunit(test, NULL, &ctx->child2.hw); + if (ret) + return ERR_PTR(ret); + + ctx->clk_ctx.parent_clk = clk_hw_get_clk(&ctx->parent.hw, NULL); + ctx->clk_ctx.child1_clk = clk_hw_get_clk(&ctx->child1.hw, NULL); + ctx->clk_ctx.child2_clk = clk_hw_get_clk(&ctx->child2.hw, NULL); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->clk_ctx.parent_clk), + DUMMY_CLOCK_RATE_24_MHZ); + + return &ctx->clk_ctx; +} + +struct clk_test_rate_change_sibling_test_case { + const char *desc; + struct clk_test_rate_change_sibling_clk_ctx *(*init)(struct kunit *test); +}; + +static struct clk_test_rate_change_sibling_test_case clk_test_rate_change_sibling_test_cases[] = { + { + .desc = "div_gate", + .init = clk_rate_change_sibling_div_gate_test_init, + }, +}; + +KUNIT_ARRAY_PARAM_DESC(clk_test_rate_change_sibling_test_case, + clk_test_rate_change_sibling_test_cases, desc); + +/* + * Test that, for a parent with two children and one requests a rate change that + * requires a change to the parent rate, the sibling rates are not affected. + */ +static void clk_test_rate_change_sibling_1(struct kunit *test) +{ + struct clk_test_rate_change_sibling_test_case *testcase = + (struct clk_test_rate_change_sibling_test_case *) test->param_value; + struct clk_test_rate_change_sibling_clk_ctx *ctx; + int ret; + + kunit_skip(test, "This needs to be fixed in the core."); + + ctx = testcase->init(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), DUMMY_CLOCK_RATE_24_MHZ); + + ret = clk_set_rate(ctx->child1_clk, DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_GE(test, clk_get_rate(ctx->parent_clk), DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), DUMMY_CLOCK_RATE_24_MHZ); + + clk_test_rate_change_sibling_clk_ctx_put(ctx); +} + +/* + * Test that, for a parent with two children where one requests an exclusive + * rate and the other requests a rate change that requires a change to the + * parent rate, the sibling rates are not affected. + */ +static void clk_test_rate_change_sibling_2(struct kunit *test) +{ + struct clk_test_rate_change_sibling_test_case *testcase = + (struct clk_test_rate_change_sibling_test_case *)(test->param_value); + struct clk_test_rate_change_sibling_clk_ctx *ctx; + int ret; + + ctx = testcase->init(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); + + ret = clk_rate_exclusive_get(ctx->child2_clk); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), DUMMY_CLOCK_RATE_24_MHZ); + + ret = clk_set_rate(ctx->child1_clk, DUMMY_CLOCK_RATE_48_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_GE(test, clk_get_rate(ctx->parent_clk), DUMMY_CLOCK_RATE_24_MHZ); + /* child1 is rounded to the closest supported rate */ + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), DUMMY_CLOCK_RATE_24_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), DUMMY_CLOCK_RATE_24_MHZ); + + clk_rate_exclusive_put(ctx->child2_clk); + + clk_test_rate_change_sibling_clk_ctx_put(ctx); +} + + +static struct kunit_case clk_rate_change_sibling_cases[] = { + KUNIT_CASE_PARAM(clk_test_rate_change_sibling_1, + clk_test_rate_change_sibling_test_case_gen_params), + KUNIT_CASE_PARAM(clk_test_rate_change_sibling_2, + clk_test_rate_change_sibling_test_case_gen_params), + {} +}; + +/* + * Test suite that creates a parent with two children: a gate and a mux. + * Ensure that changing the rate of one child does affect the rate of the + * other child. + */ +static struct kunit_suite clk_rate_change_sibling_test_suite = { + .name = "clk-rate-change-sibling", + .test_cases = clk_rate_change_sibling_cases, +}; + static int clk_orphan_transparent_multiple_parent_mux_test_init(struct kunit *test) { @@ -3614,6 +3769,7 @@ kunit_test_suites( &clk_test_suite, &clk_multiple_parents_mux_test_suite, &clk_rate_change_sibling_div_div_test_suite, + &clk_rate_change_sibling_test_suite, &clk_mux_no_reparent_test_suite, &clk_mux_notifier_test_suite, &clk_orphan_transparent_multiple_parent_mux_test_suite, From patchwork Mon Apr 7 13:12:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 14040482 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 C2F3A253B53 for ; Mon, 7 Apr 2025 13:13:25 +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=1744031607; cv=none; b=i2NK77pfqQzv4jnCQwlNbanHmlSq28kOdgMsoMVySWKQhJ0z98IGLbjx1PVmYlmXvuby4BM+GJN9Q88GAXs4prh5+VwPCakDw2FPWonHRtjf3u/kw0IOkNAmcGQbN/RCDz9G8nxAbAT3iRjG4YuxyzHTa6tpqcIpvazguNRf58c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031607; c=relaxed/simple; bh=w+xCGDIdzVRV8Qx5LNSMut5UWIJvmE8bj12UF53NjSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=aaIaCHjt8+pmCDgrpPcdV8a/4KJ5KpcSyiHu9Dv94GIYvGIgfQxTc9GG5S4hIGP69Ca1yUOR8oKhDa64hZ6IUC3MTCQb9oHfXsP+cNnw8zrEUOt3cBGjrhnu5tbPpcQ7PQZmMKmoUl5Z7jFRfU4gvSHM+wv/6TSJKQ/JhaM6CM8= 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=i7scMAwQ; 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="i7scMAwQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744031604; 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=1BC2Jz5jp96nLB4+e1LcdwFK2nm1a7mDNlVuZGEZ0cg=; b=i7scMAwQckQIbar63/ZyAplHTqa4nClbPylPe2Sn1KuygBZeZ2zqmAILDugfidrFhJIH9q kCADzM3nP66G7Ryh+LNSviKWS0NQwreE+bhEoLaW8tn7GDFx7uu7dqp5mu6tjlBFcrG7aT pyiJzdwNHhlIumAuJcV13vEisrMLnMY= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-ibh1QrqRMmiFO0MkQNviCw-1; Mon, 07 Apr 2025 09:13:23 -0400 X-MC-Unique: ibh1QrqRMmiFO0MkQNviCw-1 X-Mimecast-MFC-AGG-ID: ibh1QrqRMmiFO0MkQNviCw_1744031603 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6e913e1cf4aso122764386d6.2 for ; Mon, 07 Apr 2025 06:13:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744031603; x=1744636403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1BC2Jz5jp96nLB4+e1LcdwFK2nm1a7mDNlVuZGEZ0cg=; b=BKSQ18LBf3Dus+qT/fOqKozWC0oY439np9xJT5DL5zIRzmyOx55cVO8dx1ppNAre5D Gw+CW6mysiSczrTQ1Gym/5DSOkOQO6WQlYbHddXJaJ7BGHbjNWdueOyt71QBnkK4l60+ sRswzbsu3i35+B+A0Rxqd8Xfyw/D8qv/6b+449mQUAg5U5IbIanQLVbKU/Z2s6PvhR/g Mf4HrHqb8BjLSOWEPvW7QQmm+Dgnt0lgh5PpBJwfkXKuatP3MQ6eJSS8pKNRaStUyLhJ 3kzLmiroOqnQb4TuksMlQ9p/aBFaqFBgMQfLZvbkINpKEObfuI5RBuMqSkxj5XfPMgln wUCg== X-Gm-Message-State: AOJu0Yzh5ee+GkEiIqWpUbfaRsFR20o6aV4YUyOEPtsDl61XEG18r1+O +FhxLVRSjkmIVy6t5b5joPq2xL2ZixSFuK1zg+qa3CvoEooe7/+JCZ5IXWLSo/xU3iyhDZeOPUz n9ZcgvrGgpbJrY+1OB2XiAv6O8w2PDcI8cbN0NK3eSLhUCql/zp1jgV/8Dg== X-Gm-Gg: ASbGncs1lO/sUNj+WV3J44t+ATPSAlQXCAGstnjrg3HE7Jkx8VsPlmPWGKyKDGxp1VW qmZ4hG8WcVNNTx1ZBGBMgHHha1B1RQot1eHFUFsZQhMjTM1X1mKIOcquPRJNDePfW2PqOEPzTuv l9EvpE/uM+n4uvKYaDMiPVTzxGEmRD7A8BV21ZIxA+pmupPl0X9CRUeW/ExNOsy0bu+mi0oHQCJ NzJhDLRHz9bid6P9NW0a97ydYiLhBxSn2gAFqWXUcnqOYkyUXJ626eNl6h30OurBjm8UtZCKKcZ fV2SMM2KURAVK9DiSyFiJEOdbX5CDucT2Tp7adGN8Q== X-Received: by 2002:a05:6214:4001:b0:6e8:97c0:76f8 with SMTP id 6a1803df08f44-6f01e731605mr183726566d6.27.1744031603169; Mon, 07 Apr 2025 06:13:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECigefhr/fQPDSyepNGdMzhuvgNE/MDsWMUGZvR1lvDTwiG0VImJiSlq4Fy1KlSBS40YJRJQ== X-Received: by 2002:a05:6214:4001:b0:6e8:97c0:76f8 with SMTP id 6a1803df08f44-6f01e731605mr183726066d6.27.1744031602596; Mon, 07 Apr 2025 06:13:22 -0700 (PDT) Received: from x1.. (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ef0f138e15sm57662556d6.82.2025.04.07.06.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 06:13:20 -0700 (PDT) From: Brian Masney To: sboyd@kernel.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, mripard@redhat.com Subject: [PATCH 6/8] clk: test: introduce helper to create a mock mux Date: Mon, 7 Apr 2025 09:12:56 -0400 Message-ID: <20250407131258.70638-7-bmasney@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250407131258.70638-1-bmasney@redhat.com> References: <20250407131258.70638-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Introduce a helper to create a mock mux to reduce code duplication. This also changes it so that the relevant clk_hws are registered with the kunit framework. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 141 +++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 89 deletions(-) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index df5d4b25aa69..d72ce0226dc7 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -538,45 +538,64 @@ static struct kunit_suite clk_uncached_test_suite = { .test_cases = clk_uncached_test_cases, }; -static int -clk_multiple_parents_mux_test_init(struct kunit *test) -{ - struct clk_multiple_parent_ctx *ctx; - const char *parents[2] = { "parent-0", "parent-1"}; +static int clk_init_multiple_parent_ctx(struct kunit *test, + struct clk_multiple_parent_ctx *ctx, + const char *parent0_name, + unsigned long parent0_rate, + const char *parent1_name, + unsigned long parent1_rate, + const char *mux_name, int mux_flags, + const struct clk_ops *mux_ops) +{ + const struct clk_hw *parents[2]; int ret; - ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); - if (!ctx) - return -ENOMEM; - test->priv = ctx; - - ctx->parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT("parent-0", + ctx->parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT(parent0_name, &clk_dummy_rate_ops, 0); - ctx->parents_ctx[0].rate = DUMMY_CLOCK_RATE_1; + ctx->parents_ctx[0].rate = parent0_rate; ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[0].hw); if (ret) return ret; - ctx->parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("parent-1", + ctx->parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT(parent1_name, &clk_dummy_rate_ops, 0); - ctx->parents_ctx[1].rate = DUMMY_CLOCK_RATE_2; + ctx->parents_ctx[1].rate = parent1_rate; ret = clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[1].hw); if (ret) return ret; - ctx->current_parent = 0; - ctx->hw.init = CLK_HW_INIT_PARENTS("test-mux", parents, - &clk_multiple_parents_mux_ops, - CLK_SET_RATE_PARENT); + parents[0] = &ctx->parents_ctx[0].hw; + parents[1] = &ctx->parents_ctx[1].hw; + ctx->hw.init = CLK_HW_INIT_PARENTS_HW(mux_name, parents, + mux_ops, mux_flags); ret = clk_hw_register_kunit(test, NULL, &ctx->hw); if (ret) return ret; + ctx->current_parent = 0; + return 0; } +static int +clk_multiple_parents_mux_test_init(struct kunit *test) +{ + struct clk_multiple_parent_ctx *ctx; + + ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + test->priv = ctx; + + return clk_init_multiple_parent_ctx(test, ctx, + "parent-0", DUMMY_CLOCK_RATE_1, + "parent-1", DUMMY_CLOCK_RATE_2, + "test-mux", CLK_SET_RATE_PARENT, + &clk_multiple_parents_mux_ops); +} + /* * Test that for a clock with multiple parents, clk_get_parent() * actually returns the current one. @@ -2532,7 +2551,6 @@ static int clk_leaf_mux_set_rate_parent_test_init(struct kunit *test) { struct clk_leaf_mux_ctx *ctx; - const char *top_parents[2] = { "parent-0", "parent-1" }; int ret; ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); @@ -2540,27 +2558,11 @@ clk_leaf_mux_set_rate_parent_test_init(struct kunit *test) return -ENOMEM; test->priv = ctx; - ctx->mux_ctx.parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT("parent-0", - &clk_dummy_rate_ops, - 0); - ctx->mux_ctx.parents_ctx[0].rate = DUMMY_CLOCK_RATE_1; - ret = clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[0].hw); - if (ret) - return ret; - - ctx->mux_ctx.parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("parent-1", - &clk_dummy_rate_ops, - 0); - ctx->mux_ctx.parents_ctx[1].rate = DUMMY_CLOCK_RATE_2; - ret = clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[1].hw); - if (ret) - return ret; - - ctx->mux_ctx.current_parent = 0; - ctx->mux_ctx.hw.init = CLK_HW_INIT_PARENTS("test-mux", top_parents, - &clk_multiple_parents_mux_ops, - 0); - ret = clk_hw_register(NULL, &ctx->mux_ctx.hw); + ret = clk_init_multiple_parent_ctx(test, &ctx->mux_ctx, + "parent-0", DUMMY_CLOCK_RATE_1, + "parent-1", DUMMY_CLOCK_RATE_2, + "test-mux", 0, + &clk_multiple_parents_mux_ops); if (ret) return ret; @@ -2748,7 +2750,6 @@ static int clk_mux_notifier_callback(struct notifier_block *nb, static int clk_mux_notifier_test_init(struct kunit *test) { struct clk_mux_notifier_ctx *ctx; - const char *top_parents[2] = { "parent-0", "parent-1" }; int ret; ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); @@ -2759,27 +2760,11 @@ static int clk_mux_notifier_test_init(struct kunit *test) init_waitqueue_head(&ctx->pre_rate_change.wq); init_waitqueue_head(&ctx->post_rate_change.wq); - ctx->mux_ctx.parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT("parent-0", - &clk_dummy_rate_ops, - 0); - ctx->mux_ctx.parents_ctx[0].rate = DUMMY_CLOCK_RATE_1; - ret = clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[0].hw); - if (ret) - return ret; - - ctx->mux_ctx.parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("parent-1", - &clk_dummy_rate_ops, - 0); - ctx->mux_ctx.parents_ctx[1].rate = DUMMY_CLOCK_RATE_2; - ret = clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[1].hw); - if (ret) - return ret; - - ctx->mux_ctx.current_parent = 0; - ctx->mux_ctx.hw.init = CLK_HW_INIT_PARENTS("test-mux", top_parents, - &clk_multiple_parents_mux_ops, - 0); - ret = clk_hw_register(NULL, &ctx->mux_ctx.hw); + ret = clk_init_multiple_parent_ctx(test, &ctx->mux_ctx, + "parent-0", DUMMY_CLOCK_RATE_1, + "parent-1", DUMMY_CLOCK_RATE_2, + "test-mux", 0, + &clk_multiple_parents_mux_ops); if (ret) return ret; @@ -2862,39 +2847,17 @@ static int clk_mux_no_reparent_test_init(struct kunit *test) { struct clk_multiple_parent_ctx *ctx; - const char *parents[2] = { "parent-0", "parent-1"}; - int ret; ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; test->priv = ctx; - ctx->parents_ctx[0].hw.init = CLK_HW_INIT_NO_PARENT("parent-0", - &clk_dummy_rate_ops, - 0); - ctx->parents_ctx[0].rate = DUMMY_CLOCK_RATE_1; - ret = clk_hw_register(NULL, &ctx->parents_ctx[0].hw); - if (ret) - return ret; - - ctx->parents_ctx[1].hw.init = CLK_HW_INIT_NO_PARENT("parent-1", - &clk_dummy_rate_ops, - 0); - ctx->parents_ctx[1].rate = DUMMY_CLOCK_RATE_2; - ret = clk_hw_register(NULL, &ctx->parents_ctx[1].hw); - if (ret) - return ret; - - ctx->current_parent = 0; - ctx->hw.init = CLK_HW_INIT_PARENTS("test-mux", parents, - &clk_multiple_parents_no_reparent_mux_ops, - 0); - ret = clk_hw_register(NULL, &ctx->hw); - if (ret) - return ret; - - return 0; + return clk_init_multiple_parent_ctx(test, ctx, + "parent-0", DUMMY_CLOCK_RATE_1, + "parent-1", DUMMY_CLOCK_RATE_2, + "test-mux", 0, + &clk_multiple_parents_no_reparent_mux_ops); } static void From patchwork Mon Apr 7 13:12:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 14040483 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 DAD92253F02 for ; Mon, 7 Apr 2025 13:13:27 +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=1744031609; cv=none; b=sLjJF5s2jurioCXSKYzndFkwt8msSdID9CoVgusvU8o4nrCMcva6vfmUuKG0p0lNfybJYfaL9q0thl+OO4XrTuIGOjVFFBKGLjY7CP4OoO+3FIsZ7TKulNHKIYyA/HsmJnn1rGBXGmJiQ5SmI9Y+EC0nOq3+xAqpUrY8w1f9Cfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031609; c=relaxed/simple; bh=cINZpHs1181ZZIfn0v+Bqs6Xi6sKYwzvG+kUmnvZOgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=ML6h3JZiwg3Q29EAhWQzPcicPoPYKgjLGUO1xmqkwsTmDO3tZ8l7sYI84sLQf5WEjxfr2dd1bOLvSwHbOXF9A3Q07dgpC4Gjcl3YRgTKGVmkNfUznmCsRVahVxzrOdXnVE9ui5CGFb7HJCIdQe2MU/AiUOK+hvvk3s6JnRwnJhc= 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=iHbc21Pk; 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="iHbc21Pk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744031606; 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=kMB86ctjcybiwuXbvZXBElgp1Cu7q2l6feChD2s1BJ0=; b=iHbc21Pk0ZtqoxtVbix1OlGYTCNTlyyrvymI6mfea2nUP3oCcfcfXB+EJZ1MlFgQ4gchbJ hGfVTPVUNBRYuxlG5d+MdqVPVnqYAOXh9LbQpzkFxkJBXgulOrtEFPUk1YAzwWGOA5nVAq cfwY9C1zsni1/Hm5Rcuz7+ZuIWedP4k= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-k2lJ3MOnM1exUfi20Cm_0Q-1; Mon, 07 Apr 2025 09:13:25 -0400 X-MC-Unique: k2lJ3MOnM1exUfi20Cm_0Q-1 X-Mimecast-MFC-AGG-ID: k2lJ3MOnM1exUfi20Cm_0Q_1744031605 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6eada773c0eso143896966d6.3 for ; Mon, 07 Apr 2025 06:13:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744031605; x=1744636405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kMB86ctjcybiwuXbvZXBElgp1Cu7q2l6feChD2s1BJ0=; b=wICSUcluHdl9E9qiBI/rXRfk2w1S6RdfMduKpYIlYKG6ezST5Z0dG9qkwzQZLxL1BR ud/98PCgMzopJOqlTscpVVgKTJRjcJXY8oEszHH4htqKqRONu3NJObpitdvpGjHO7+tG UGvsiyQPof9Zpz5mrUu4Zl3P0fzbXcPEZouO17X/9MVoSv24azXNPZz5j0bJ1R365zII LqKw4cA9JWyl5ly7scv+MqXJDl705VKv1GolIzRghJLKFQV7lDgQIWMxKUr4DecDNIJi dQihsyxn+Ky47rc1HzLT6qSx9tIUGKo1DP4zWNhKpeBybz1pHfvau0SmA3uZPJ77njTC VUtw== X-Gm-Message-State: AOJu0YxgIIiXMOL/Sbuwi7r8DIQ2LQBdvlucLMj9a4/FZpMcjS4Vuu1P yzUXaKUuzKXzO3J8ra03dYdtDkSw5bZd8moWXIZiACBWxBnVz3pxgRzOrAPGoBGMMhVB5GrT3Qv vqXYcSPYu4B/tXKVB3MYQgjd85/EmytnCd0v93esZ1rGX1FnLZ3fyBfSKQQ== X-Gm-Gg: ASbGncvfLuhS1O/fMjiGTq+qCp7Dy85ZRzsvr4MEVUDJgPskH/hkdnmGJ9znkGvXpZQ 0ODTJbV3moVplnu3PTrhQj0rsT2mxyWixiPfUvWsNdQbUp9pIBuDSWOKtINhjmkzV/mIRJhOLIL E7t6704UBqX6/KAUDrieC54V8tpFsSuc45dXcqu0P8KYiYRSBltLMkfZfIEOJgEp+8c/yTaSnTH YIhq/wNloLqfol0EYME53BybOvGpuH88B3apku/Y0yBJeLaqldPJYTipz9O/RT9bwzQrOpexASQ MgVwbL9Rf2D1My1oLPTGpzsNzlBmU4DYQTzTtNGbig== X-Received: by 2002:ad4:4ee2:0:b0:6d4:1ea3:981d with SMTP id 6a1803df08f44-6f01e79adabmr204618946d6.43.1744031605288; Mon, 07 Apr 2025 06:13:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqafTGStLaTMqYGR4+6zlBqYN2im0YRpTHE40qDR5UH6vvMiQFkULd23bOD87HuJxEejDCHw== X-Received: by 2002:ad4:4ee2:0:b0:6d4:1ea3:981d with SMTP id 6a1803df08f44-6f01e79adabmr204618516d6.43.1744031604938; Mon, 07 Apr 2025 06:13:24 -0700 (PDT) Received: from x1.. (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ef0f138e15sm57662556d6.82.2025.04.07.06.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 06:13:23 -0700 (PDT) From: Brian Masney To: sboyd@kernel.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, mripard@redhat.com Subject: [PATCH 7/8] clk: test: introduce test variation for sibling rate changes on a mux Date: Mon, 7 Apr 2025 09:12:57 -0400 Message-ID: <20250407131258.70638-8-bmasney@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250407131258.70638-1-bmasney@redhat.com> References: <20250407131258.70638-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Introduce a test variation that creates a parent with two children: a divider and a mux. Ensure that changing the rate of the divider does not affect the rate of the mux. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index d72ce0226dc7..97909caa71b2 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -900,6 +900,48 @@ clk_rate_change_sibling_div_gate_test_init(struct kunit *test) return &ctx->clk_ctx; } +struct clk_rate_change_sibling_div_mux_sibling_context { + struct clk_dummy_div child1; + struct clk_multiple_parent_ctx child2_mux; + struct clk_test_rate_change_sibling_clk_ctx clk_ctx; +}; + +static struct clk_test_rate_change_sibling_clk_ctx * +clk_rate_change_sibling_div_mux_test_init(struct kunit *test) +{ + struct clk_rate_change_sibling_div_mux_sibling_context *ctx; + int ret; + + ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return ERR_PTR(-ENOMEM); + test->priv = ctx; + + ret = clk_init_multiple_parent_ctx(test, &ctx->child2_mux, + "parent0", DUMMY_CLOCK_RATE_24_MHZ, + "parent1", DUMMY_CLOCK_RATE_48_MHZ, + "child2", CLK_SET_RATE_NO_REPARENT, + &clk_multiple_parents_mux_ops); + if (ret) + return ERR_PTR(ret); + + ctx->child1.hw.init = CLK_HW_INIT_HW("child1", + &ctx->child2_mux.parents_ctx[0].hw, + &clk_dummy_div_ops, + CLK_SET_RATE_PARENT); + ret = clk_hw_register_kunit(test, NULL, &ctx->child1.hw); + if (ret) + return ERR_PTR(ret); + + KUNIT_ASSERT_EQ(test, ret, 0); + + ctx->clk_ctx.parent_clk = clk_hw_get_clk(&ctx->child2_mux.parents_ctx[0].hw, NULL); + ctx->clk_ctx.child1_clk = clk_hw_get_clk(&ctx->child1.hw, NULL); + ctx->clk_ctx.child2_clk = clk_hw_get_clk(&ctx->child2_mux.hw, NULL); + + return &ctx->clk_ctx; +} + struct clk_test_rate_change_sibling_test_case { const char *desc; struct clk_test_rate_change_sibling_clk_ctx *(*init)(struct kunit *test); @@ -910,6 +952,10 @@ static struct clk_test_rate_change_sibling_test_case clk_test_rate_change_siblin .desc = "div_gate", .init = clk_rate_change_sibling_div_gate_test_init, }, + { + .desc = "div_mux", + .init = clk_rate_change_sibling_div_mux_test_init, + }, }; KUNIT_ARRAY_PARAM_DESC(clk_test_rate_change_sibling_test_case, From patchwork Mon Apr 7 13:12:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 14040484 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 8BB21254B0B for ; Mon, 7 Apr 2025 13:13:30 +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=1744031612; cv=none; b=KEUmL92GZTrYdUKbYy2DkbLDmJfpksDBP3ZLpz/rK3pqQ0vlH51tHg6luo1ITJ/RpAGBUxEgMw75LyVzlh+ChgOqOewMGfhN1kJdEmciWupHulRk9obAWI4IYeuoYCn3BbvA+VKAwKpznY81ncoIT+z7dMReGag5yuBCT1Lm7sQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744031612; c=relaxed/simple; bh=GN3voStKR5Oh+8mUZUpd029ZKjm8JBA4D8k5Q2aS0T8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=EKcLAA+TMY+y3VR2itU+tufY9jm3urdP/mwZfYl7/2jQq2HJUBvEH2OhisHz3i6qGqRVHReHCgInDi2Rrr1KSNR/NKDaDrlQWgjIGqMIya3VpZq/4mBJZ4ZrPabvHyxXRqNeK0MkyjrzIY2sISer5jk6yJtClPkDv51+c4KFBZw= 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=SrkPLpwP; 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="SrkPLpwP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744031609; 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=Bh5Q0sLZw7+M5FGlXd5xakStCO4/0BURaA8xUUHrIXY=; b=SrkPLpwPcuczwuETjXA/Q7FIH4rzvVRNlEMEBZ5KaiQNLfDHhWxp6DCXlgYMbrv5pJM8aj 5CnxRx5ig6GZrO3KwOtKELgOA2GTDrS/QafTMUIanz91HxLiIMyMxCl8vJRRfWcMJuP0zh hb3LfLJFZ92R2jc0YQctZSAxeoI7kbA= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-Cib4E21tOIOYSgKHKcJoLA-1; Mon, 07 Apr 2025 09:13:28 -0400 X-MC-Unique: Cib4E21tOIOYSgKHKcJoLA-1 X-Mimecast-MFC-AGG-ID: Cib4E21tOIOYSgKHKcJoLA_1744031608 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6e8f64eb467so35240246d6.3 for ; Mon, 07 Apr 2025 06:13:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744031608; x=1744636408; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bh5Q0sLZw7+M5FGlXd5xakStCO4/0BURaA8xUUHrIXY=; b=Qnp/MDUXButFS6WKmoPOy9NSr40lEIWHby3TrU9FAyCGHrPs1Q+htwz9pfHB9/lmSi zxPGM7D0Y6mRRkjFAkpMa3rynKMS4CqHsfiRWeuV58YlXqd88D1E94GPYdNn3O0DHEUd uj8pLEUY8LFjHSttGTtWPWivzfP4y2qUcVR+sH5mUn4cyo6IhKTtkTRBPG9V4YrO389W MuVSPx0KptZV8k09GKUBI2zqjN8c+8/yQcEy+IPRfuCB48mE7GfFo/BzzIbx2WFNW10m Y0Xff1x0xAAHwFRfC7oF6Osk0CEnFDRbJz4zacl9HZPob6rVpJGBi8Yc1NEu5hfN5jL+ tLpQ== X-Gm-Message-State: AOJu0YwXRMgLukVv7DAchqMpatqD//44sDhfMCp12M6iBjPpvOxMv5FT 2u/DWx5MRttOO8itHpPmdPQg4DDHuodxflxc9yBKZc5Bc8DWgincSWRRVkEVctiDbSqLdsZ8LyD 7MX9yiP1pnJKhspiAzJtPO2NOts7aCy8bxYVycKPNlFrwJPz5HXTkeuLfWA== X-Gm-Gg: ASbGnctX9MvkZ4VSZvkniNlzLcMt+qGJpw1aWbwcCSNotealXQAcFIvGAhTun0XPqTs nTAPA8DDn9VP0LpKuUhGMdq8wlEWcM2bzWkcN06h5K9JBti9MgiOPlvdo1cVri40ApqTe4GFWTq vhNNGeEb2UVktPINiSejjTw2Qy+3O1u9lbF5RTKG/wJ4EhntUpN5Zuz/Fu0HC1JFe7Q/h0n0s7p xLwvraPUqwhmosKBy6u3ewLx4UM25GjpMu8Aas9hfgBeT5NmFvELRVeFpR3Wylp7Cl7KsmVBHX6 SQEwQO4jzSR3FoeDkD+0ManWBX5GLweykr0uLkOwww== X-Received: by 2002:a05:6214:f6a:b0:6e8:fad6:7104 with SMTP id 6a1803df08f44-6f064b27e5dmr230252446d6.35.1744031608042; Mon, 07 Apr 2025 06:13:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3ciFpFjf+SwD8KF8vuNyhdHnxtlz8uDM6Kto6KyAm9+ypPxnut52K/L2hr2yRorO4oeMeag== X-Received: by 2002:a05:6214:f6a:b0:6e8:fad6:7104 with SMTP id 6a1803df08f44-6f064b27e5dmr230252186d6.35.1744031607774; Mon, 07 Apr 2025 06:13:27 -0700 (PDT) Received: from x1.. (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ef0f138e15sm57662556d6.82.2025.04.07.06.13.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 06:13:25 -0700 (PDT) From: Brian Masney To: sboyd@kernel.org, mturquette@baylibre.com Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, mripard@redhat.com Subject: [PATCH 8/8] clk: test: introduce test variation for sibling rate changes on a gate/mux Date: Mon, 7 Apr 2025 09:12:58 -0400 Message-ID: <20250407131258.70638-9-bmasney@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250407131258.70638-1-bmasney@redhat.com> References: <20250407131258.70638-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Introduce a test variation that creates a parent with two children: a gate and a mux. Ensure that changing the rate of the gate does not affect the rate of the mux. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 97909caa71b2..e6df1d2274b2 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -942,6 +942,48 @@ clk_rate_change_sibling_div_mux_test_init(struct kunit *test) return &ctx->clk_ctx; } +struct clk_rate_change_sibling_gate_mux_sibling_context { + struct clk_dummy_gate child1; + struct clk_multiple_parent_ctx child2_mux; + struct clk_test_rate_change_sibling_clk_ctx clk_ctx; +}; + +static struct clk_test_rate_change_sibling_clk_ctx * +clk_rate_change_sibling_gate_mux_test_init(struct kunit *test) +{ + struct clk_rate_change_sibling_gate_mux_sibling_context *ctx; + int ret; + + ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return ERR_PTR(-ENOMEM); + test->priv = ctx; + + ret = clk_init_multiple_parent_ctx(test, &ctx->child2_mux, + "parent0", DUMMY_CLOCK_RATE_24_MHZ, + "parent1", DUMMY_CLOCK_RATE_48_MHZ, + "child2", CLK_SET_RATE_NO_REPARENT, + &clk_multiple_parents_mux_ops); + if (ret) + return ERR_PTR(ret); + + ctx->child1.hw.init = CLK_HW_INIT_HW("child1", + &ctx->child2_mux.parents_ctx[0].hw, + &clk_dummy_gate_ops, + CLK_SET_RATE_PARENT); + ret = clk_hw_register_kunit(test, NULL, &ctx->child1.hw); + if (ret) + return ERR_PTR(ret); + + KUNIT_ASSERT_EQ(test, ret, 0); + + ctx->clk_ctx.parent_clk = clk_hw_get_clk(&ctx->child2_mux.parents_ctx[0].hw, NULL); + ctx->clk_ctx.child1_clk = clk_hw_get_clk(&ctx->child1.hw, NULL); + ctx->clk_ctx.child2_clk = clk_hw_get_clk(&ctx->child2_mux.hw, NULL); + + return &ctx->clk_ctx; +} + struct clk_test_rate_change_sibling_test_case { const char *desc; struct clk_test_rate_change_sibling_clk_ctx *(*init)(struct kunit *test); @@ -956,6 +998,10 @@ static struct clk_test_rate_change_sibling_test_case clk_test_rate_change_siblin .desc = "div_mux", .init = clk_rate_change_sibling_div_mux_test_init, }, + { + .desc = "gate_mux", + .init = clk_rate_change_sibling_gate_mux_test_init, + }, }; KUNIT_ARRAY_PARAM_DESC(clk_test_rate_change_sibling_test_case,