From nobody Thu Oct 2 02:05:50 2025 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 7CAA013B5AE for ; Tue, 23 Sep 2025 14:39:55 +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=1758638397; cv=none; b=CA4izYEFrfgkByzXvP0Ph+0mkhNdKRk3Z1ZMeDX5ARvc9t8x2vcco6A26mAqFHLsYqoS/2V/3GE1HzVw0Zt7vV7dV+3FHP/GY7DKfPv5M6fuiR5AXL/Joitqr7mJ0ypptet/G5DkMQkWuUI742YUoRNNQ0J9zS/YPU5FjmhVVmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638397; c=relaxed/simple; bh=ifOqpq6EI5oUKKyRISwbxG5xRCmiQg5s1ikEzZQUYQ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EOp13TLD8mA58AgXTgzdBVHWcRkHz7AEVejWOCnAWkX7xlr/oFaw0JVZluzjgzFsHa0NhJa/ey4cyq3poSTAxacwhQ5gbmG1YY2HjoOw5NXViCI5edwsWX3884cFC3haFN5iPIo7WxigBPCkOnvcm4HN2Bt6kc110/96Oza9O8w= 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=fMrZy223; 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="fMrZy223" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638394; 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=pSSrqefXj8F1pFE7kwL8lKNSLHc0UQvp/2g3qfW9jDk=; b=fMrZy2232IukmdHqpK6jAa0jncEUUctbBlD+MUrJbfx3Z7SCF/ueBMcI0dc/Dm8Nwl4nwC B3YdTFezd+R+V8CtIGON/XgNJ+vJiNgGKYnBMvvDwTaLw1BcZ0T4sNu+DUYQTrhnB+zNok JuGMk6orsCmgsAsm1a2hsaTChxNZzsk= 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-75-_7Z9GmUGM0aCdJEA3AK4Ww-1; Tue, 23 Sep 2025 10:39:53 -0400 X-MC-Unique: _7Z9GmUGM0aCdJEA3AK4Ww-1 X-Mimecast-MFC-AGG-ID: _7Z9GmUGM0aCdJEA3AK4Ww_1758638392 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-846f089463eso560098185a.1 for ; Tue, 23 Sep 2025 07:39:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638392; x=1759243192; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pSSrqefXj8F1pFE7kwL8lKNSLHc0UQvp/2g3qfW9jDk=; b=g/VqxOPLMOQ9/WrDkUhMlIzRnKa04jbtgp7V2diHzV7P84CPKQnVKaKBtDHWoPa085 A9A6zEg/FmqH45PsGRdca0ZpFi06xONra3SfJuH7Cq3PnG51RgN3IQreotsQ0RYVJvyh vDciJan0cDf541eSGZk78MbR7a0ixFJ8Co/JQffPJpif4KtlMrnSatr/5xd0dOePqCqD ikTztI+DrGZS7ks+h8N7fNopVhEKPJmwQP6A00TplBeWi1OG/eMb669kRsSd7hi2pQ92 thgQHuZ938BqRbpIlS+vW62lmrMBuMKe2+TY8Rr3qZoWREGRndDoPJuel5to4EJZl1bu 2xWw== X-Forwarded-Encrypted: i=1; AJvYcCWJqF+JRYBPSpcE6Q6gVjWQFh+XpqJYwibpHOlvKpWLcSJMbrHV58EOS2TbqLtzSQHpF0QLeYZ5BSrOnFc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4iDYRSQpWg1Ip6K0WJdXfDqkDv7IqqWo4Jz05I5vEjAnf3/df WF0nsHWaenj++UyQlxDxxZsiI4UTufHM5+w2a+nUDWO+x6C8T/0dmS3qRiBrztpXWLdrVtAKQhx YqdRW6ETSqFL99jGhZh6EOSJU+tfHY8Is9Z+req5gnzFqil+t66cRJuvhwSIxn77ihA== X-Gm-Gg: ASbGncuX7qC9veL5hk+S1n0/9JQebIFM+hE5OL/rNOnm2noLSIwlYcLqUtdY+HSXRJv jaRoFAXCjmJiJZs8cQsPydWpHRxyErI7j9c6nZQCQGH0a5gSSUvDagWBSNR6ZdMEBTyrd5iXuKp J5nJ0dc3/j3hGiR52D93nClLspQm1DnqW3iZ1VsjjBZU8BErp6yltV3bfX/Eh6Qx/YHncateonW HkDxIdpkXZ2fTU6o3wmMebk6z5yj2JYi55hQgTPwLDqXWJkgTzHYGAWbOOe/m/wEF5hRSyr5DiE fYGT7fTzwOhwqBqkP3KzeifDu0MGp/s+lA84HJJaybMvtN8Q8zrww/ZFCi4oDJlljLoHepv1km9 QZIM4941abSNpz5lTslE6ZxJ5FmzUN4Icn6zTG6c= X-Received: by 2002:a05:620a:bd4:b0:84d:5320:287d with SMTP id af79cd13be357-8516fb9021amr294261385a.34.1758638392274; Tue, 23 Sep 2025 07:39:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKBUZpAD3XPLNDp4LkeiD173qMrCb+kitUiyWzyeQr+nw9KW/OanK+ID3iaqXtbBXsBu95YQ== X-Received: by 2002:a05:620a:bd4:b0:84d:5320:287d with SMTP id af79cd13be357-8516fb9021amr294256985a.34.1758638391633; Tue, 23 Sep 2025 07:39:51 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:39:51 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:20 -0400 Subject: [PATCH RFC v4 01/12] clk: add kernel docs for struct clk_core 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: <20250923-clk-tests-docs-v4-1-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4554; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=ifOqpq6EI5oUKKyRISwbxG5xRCmiQg5s1ikEzZQUYQ0=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubdRLzFhYrFgxd9+rLaksV/NSTSxflO5nTtuR8Kr0y X6vdw/lO0pZGMS4GGTFFFmW5BoVRKSusr13R5MFZg4rE8gQBi5OAZiIVR/DP62oW8vcIjxeCbEE Vjy8V5daO3HbGsEHUn5GP7geMpXlfGf4p71hXdWcU3feNPyaHqX5Z9Onpy9vxdz8L7TI5bdM6Jw 5E3gA X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 Document all of the members of struct clk_core. Reviewed-by: Maxime Ripard Signed-off-by: Brian Masney --- drivers/clk/clk.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 58 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b821b2cdb155331c85fafbd2fac8ab3703a08e4d..018dd5a32ecbf166718da3eda85= 1f51fdfdd2088 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -57,6 +57,64 @@ struct clk_parent_map { int index; }; =20 +/** + * struct clk_core - This structure represents the internal state of a clk + * within the kernel's clock tree. Drivers do not interact with this struc= ture + * directly. The clk_core is manipulated by the framework to manage clock + * operations, parent/child relationships, rate, and other properties. + * + * @name: Unique name of the clk for identification. + * @ops: Pointer to hardware-specific operations for this cl= k. + * @hw: Pointer for traversing from a struct clk to its + * corresponding hardware-specific structure. + * @owner: Kernel module owning this clk (for reference counti= ng). + * @dev: Device associated with this clk (optional) + * @rpm_node: Node for runtime power management list management. + * @of_node: Device tree node associated with this clk (if appli= cable) + * @parent: Pointer to the current parent in the clock tree. + * @parents: Array of possible parents (for muxes/selectable par= ents). + * @num_parents: Number of possible parents + * @new_parent_index: Index of the new parent during parent change. This = is + * also used when a clk's rate is changed. + * @rate: Current clock rate (Hz). This is effectively a cach= ed + * value of what the hardware has been programmed with= . It's + * initialized by reading the value at boot time, and = will + * be updated every time an operation affects the rate. + * Clocks with the CLK_GET_RATE_NOCACHE flag should no= t use + * this value, as its rate is expected to change behin= d the + * kernel's back (because the firmware might change it= , for + * example). Also, if the clock is orphan, it's set to= 0 + * and updated when (and if) its parent is later loade= d, so + * its content is only ever valid if clk_core->orphan = is + * false. + * @req_rate: The last rate requested by a call to clk_set_rate. = It's + * initialized to clk_core->rate. It's also updated to + * clk_core->rate every time the clock is reparented, = and + * when we're doing the orphan -> !orphan transition. + * @new_rate: New rate to be set during a rate change operation. + * @new_parent: Pointer to new parent during parent change. This is= also + * used when a clk's rate is changed. + * @new_child: Pointer to new child during reparenting. This is al= so + * used when a clk's rate is changed. + * @flags: Clock property and capability flags. + * @orphan: True if this clk is currently orphaned. + * @rpm_enabled: True if runtime power management is enabled for thi= s clk. + * @enable_count: Reference count of enables. + * @prepare_count: Reference count of prepares. + * @protect_count: Protection reference count against disable. + * @min_rate: Minimum supported clock rate (Hz). + * @max_rate: Maximum supported clock rate (Hz). + * @accuracy: Accuracy of the clock rate (parts per billion). + * @phase: Current phase (degrees). + * @duty: Current duty cycle configuration (percent). + * @children: All of the children of this clk. + * @child_node: Node for linking as a child in the parent's list. + * @clks: All of the clk consumers registered. + * @notifier_count: Number of notifiers registered for this clk. + * @dentry: DebugFS entry for this clk. + * @debug_node: DebugFS node for this clk. + * @ref: Reference count for structure lifetime management. + */ struct clk_core { const char *name; const struct clk_ops *ops; --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 2A70B231C91 for ; Tue, 23 Sep 2025 14:40:01 +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=1758638403; cv=none; b=jORP8oJc0EB9e6ppvcVvg5RML4QBr/F9iu5/kIicZdCdWq6JU0wpDpdKVShTCY7MSyD3uyEXPutMEB+mIPXM75xIF3XE+EqcszMsET11JeXzGHBHT/xczZIWuxduSz2QMuTd/9MCVUPP9yWA5lZ+lPFMORHxmkCft6yYsCzjmI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638403; c=relaxed/simple; bh=cfNqvBT+4t4p82Xzh3cs6GlN0grJes6Be3PtGF5MnJM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UbQBKK8/ylwfQaDTq1XGaQqj53w7D5J9IKLH4KJd+5s/MfkxngyiHamZW49xS7pwpQAipcsqbGf3mDe7ZC7c+nTUrgQgJLReNsHIZVpR65SaftKD5Gr9VrrtuifMWx2w+uqtvCJpENZcK1JhZcjed3q3OKmFgJnO80584Gxs5ks= 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=Wc3DnqXD; 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="Wc3DnqXD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638400; 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=ZOLL9fGO5xV3TbAIppZMqjfRBpE7K4vhEZj54a7DmcU=; b=Wc3DnqXDD93HnryJWl7DAAbmBdbUIpt0wk0pCwiC4esHZfv73BGFpx0kOPmQf1JdKp/wGK 9c0O4ZCtDttwQ9QW8UtSvWWgmkf8YSabcgDycWfzAHySdph0TUmEOB1+bcJdot+eC4j8lN GzzvyextXZbPKtGW6iaH9ldYP6NStyU= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-FGIlhKFFMYSWCdVxASisOA-1; Tue, 23 Sep 2025 10:39:56 -0400 X-MC-Unique: FGIlhKFFMYSWCdVxASisOA-1 X-Mimecast-MFC-AGG-ID: FGIlhKFFMYSWCdVxASisOA_1758638396 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-8492067f921so335883585a.1 for ; Tue, 23 Sep 2025 07:39:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638396; x=1759243196; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZOLL9fGO5xV3TbAIppZMqjfRBpE7K4vhEZj54a7DmcU=; b=JpFUt+waYyeQNwZe3Fi+8YrSctrtm0ON6O7SSVv1b1ycw+qlY0WdxZOSGaFPvfiAvO nJc/laWL42hKKfNvtayl3bbvO63Us+M26vbANDuiLUAhFcsQ1rGYfqbtP/Beu06EGWqE bDCmZVJAFo7iMHgfoNzRIbi2vBBN2Ey2P/5queB/baGnrW+VJTQrY4pOvzQ03SX2fdqG BCdCbNw51ZNN8VgCxADreDkgfOf9tI/IQkTn7jY/GQOO63Qm2KXsHv2U+27M6bxxzd3G /Zhgwl/WJpX/vu9DAiWtrrefB8tlmqqi4LNJniU29eTCPtIVeYyIs2pNNjtsgpAluDzA DseQ== X-Forwarded-Encrypted: i=1; AJvYcCV6/GXh/i2B0D8nIybrMV3V7gd5usvyc9usaLUK7hkDajSu0HWt93tDqcLCB1DzuKcYxJbsSdyCJ1NfigM=@vger.kernel.org X-Gm-Message-State: AOJu0YzFheLJ8Kwzl1ciKhkxm7WwoC4lQA3hjeZLrLKnLzApR+T/oruC Gg3Ml1JpV3E+owUEZTtVkn6hbOFcm8OlFnOt1bNnymPv0pxtGErErqcGyNH5VVI0jCgroyKJMQE tWfezYrVQJ9alG8Pf+3WoMXUu6XxDdZZL7i4j3n+t6G/UICcqoXMzdzXaTUTtJguoWA== X-Gm-Gg: ASbGncskJhU8zFbZxkzyYXKqslxCD1Zdd1eC/f4xVMKRpcAEJIE7HS3L7eNigULQQpy Vd6RLFIWNqZ3kmcR+3azTlYjEbxTlr/uWeM+Trh3yKDubCRegFY6I83qgKZoV661wNqWrhPWU6x KFVAPeO2rUXSVtAtIMKXwpTD62xfmG1ZEpnUA8KCPewdDVo5v1Ycn2wGCmUdOlzv4gni4n2tJow whMZU0nm7wPEyjfYilc0Di9lYtXMHyt1bJw1eXF/iQQb//i3BmuTDuYasWORbwfQYkYVKQOrU27 NiqvHfSRKMc7U8b3sD/ZQk/dQKmgpDjXDx6RRku9keeX7gIMGmvySy+qQrixivwnQMV2SYQw236 F1HnvkUr7U89eTaUUW5ZPPMWMr9qTKmnjldpEnSg= X-Received: by 2002:a05:620a:6cc4:b0:810:731f:32ff with SMTP id af79cd13be357-85173701be0mr359452285a.50.1758638395857; Tue, 23 Sep 2025 07:39:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9XR7K20CVO+2Sa3lgEN3xj1f6+KE/9jAZOYv1Eg7JSuBt2rHxjTNSu+IgMsqfCnyBEcwOqw== X-Received: by 2002:a05:620a:6cc4:b0:810:731f:32ff with SMTP id af79cd13be357-85173701be0mr359445285a.50.1758638395207; Tue, 23 Sep 2025 07:39:55 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:39:54 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:21 -0400 Subject: [PATCH RFC v4 02/12] clk: test: convert constants to use HZ_PER_MHZ 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: <20250923-clk-tests-docs-v4-2-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1065; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=cfNqvBT+4t4p82Xzh3cs6GlN0grJes6Be3PtGF5MnJM=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubdRXn7B+t4L05d5y9vOdYadeiyq828T9W+dX28Fkk evNvGHyHaUsDGJcDLJiiixLco0KIlJX2d67o8kCM4eVCWQIAxenAEzEWJWRYQK76J1DzGbvDqb2 ls2cnGOVbNyZu2Jze/oyDvEHOh2BHxgZzn1Zf3nDqW0t8s/CZmxey9F4UTdN9J/Sm2Tvno0tf2I CmQE= X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 Convert the DUMMY_CLOCK_* constants over to use HZ_PER_MHZ. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index a268d7b5d4cb28ec1f029f828c31107f8e130556..372dd289a7ba148a0725ea06433= 42ccda7196216 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -7,6 +7,7 @@ #include #include #include +#include =20 /* Needed for clk_hw_get_clk() */ #include "clk.h" @@ -21,9 +22,9 @@ =20 static const struct clk_ops empty_clk_ops =3D { }; =20 -#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_INIT_RATE (42 * HZ_PER_MHZ) +#define DUMMY_CLOCK_RATE_1 (142 * HZ_PER_MHZ) +#define DUMMY_CLOCK_RATE_2 (242 * HZ_PER_MHZ) =20 struct clk_dummy_context { struct clk_hw hw; --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 A75BC26A0DD for ; Tue, 23 Sep 2025 14:40:02 +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=1758638404; cv=none; b=khLL1gxRwXm5EHYwFnWvEW27X7EBRLbPlsZyHZkuFAzrc7sj8L4UUISl3ard0l+m240kkbZKqDUlXcM5khVcyxITHBRzNfIQ47uP2pac6AxwKf8ViqS/ZefWZu9oypW62RgYmUHo7yx8jscAo8c4zE5Ee+sLSaNSdxBgF8OjC6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638404; c=relaxed/simple; bh=cKxFZ1V9JkbMvlvajDHPLZ47CwL2tRpgNY6Q+YW/aF8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hBD6yTGx1qAVXHGfpLzwm4LlFOfAgo542uOqfxd+6YxfyAAj/uDpAqPt91Mzuhj9q9zGz3wIzc4Ip8yDJxS0LdiynawXCg0s2RoQ5x7MrPuWpiSvRU/VbbzeUYho3ec0OLGzrjFK18R38nSxK69EfhBGyeenmqYoR1Ehj5tYdYk= 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=RjAuTydV; 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="RjAuTydV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638401; 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=zbj/S0aRmzh4H+OIrc3SDD0aZUBHX/EMobfhnl53kHo=; b=RjAuTydVuvdRY22wetfAMweZwabsVoq7lPbayqsLe4itQsYagQTDnlI+pIP+6KgD+SFMmJ yokiZPY3jx5HNceJ1gu04y0PxulnDuFG54IRZSMB34sRbeeLZOv27tWocTaR/K7TrxPQlV mfNKHVauVdwo1M3aFgYhIjhpDn62ioM= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-RW6Nd_f8NviBqVBCzNrNGw-1; Tue, 23 Sep 2025 10:39:59 -0400 X-MC-Unique: RW6Nd_f8NviBqVBCzNrNGw-1 X-Mimecast-MFC-AGG-ID: RW6Nd_f8NviBqVBCzNrNGw_1758638399 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-8502939d0f6so250917985a.1 for ; Tue, 23 Sep 2025 07:39:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638399; x=1759243199; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zbj/S0aRmzh4H+OIrc3SDD0aZUBHX/EMobfhnl53kHo=; b=PQwdJb8O1tAHgXl+yJReDPcrnPtLGo8CQcSuGjM1Ido9wju9vHuPJhRgBEVP7xuC7Z YFErQq9HjuAGvwPnC+ZXh1kemtKHN9xjcx65+86kPmqcocrVRHR4b/FdpkP6l95lFh7/ FwDoDjQ23kI1m+Ae9/LBli0iKrcGULKfgos3OkJAFfipJdkL1X+km33VBTpvDtwPhcYm DvbtWZ2RbEYhmp4siv0Vy1zqkh1NOcFt4Att4gC9j5PYWe5B0Iabk+Rpj1UHeEu1zTaJ uWBW1T9rlCk0fQVPPwr5fKV/NW/T/To8crLd6j+vCIDCCVkxlPI012tGEYdwJmAjSrW9 lJ2A== X-Forwarded-Encrypted: i=1; AJvYcCXSI0TQ0avpJNTP8/omvHmsTThMPVCjGzYFXlT7S1FcHJ45HM5G0i4I776TfU5VUm5h+oBcofcEZruWnUg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4V4k+vf8F8qwaE7vQTlT7EplDH1wA2gIxjA9SIt3FxKJRKUyH JXyQEFploEIj2epvL0cGGJQZsmsU7QNF8DDfKM9P8PDQrWuP/+8FfwjTABvlZwzjSQpRhcpI2mu XdBeVp3hI1QOUY96fsZTWMMATT6DraWtGJ1fbsAlh8A1qPPjbOHAI2TmRlzmY1SAooA== X-Gm-Gg: ASbGncuYYApuMBvaJbWdmjPAuth0UIUJs7S2o7yrIPO9+FELkF1z1MvqYoi6PdTD6ra sNt2ABpjMaYlG3CYmLCLWnykOQ55IUZjNyBPVpPCED2PIwf8OAXu4pqe0zFV6km0Zl9PxXu1Mqw nMcBZqW65FA/a2JaMXGLL36TzPhX7xsI5X8FOEx7I0yROtn0tQ4RF4N7LQtboJjTbwPQybfDTAz n+OsE2EbS7kTmmI1SjK8IqEQkUUZbZwwZTVmBmvw8XLTkFs6U7tLXY2oTIPfBKGB26M4Pc0Alma bY50dfHHkBFgfFRMJykO3DbH1ZnbcGcMYjqx6k2xF1wxWjzPnRW+xkZGyhBAsIWdqw6v1IUrtau N05QODRmSxPwjegpTClR7ISAX7OKUYCIMW8E5ySo= X-Received: by 2002:a05:620a:29c4:b0:82b:7a80:e48a with SMTP id af79cd13be357-851b634daedmr251399685a.24.1758638398626; Tue, 23 Sep 2025 07:39:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkgaHgsa3dAnSghMgykCefgHSWKnQmgpmqmcnFrZsNTEAFjdJhOXkXgMBQKiKbRdGNJDtlSQ== X-Received: by 2002:a05:620a:29c4:b0:82b:7a80:e48a with SMTP id af79cd13be357-851b634daedmr251395985a.24.1758638398130; Tue, 23 Sep 2025 07:39:58 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:39:57 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:22 -0400 Subject: [PATCH RFC v4 03/12] clk: test: introduce clk_dummy_div for a mock divider 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: <20250923-clk-tests-docs-v4-3-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2072; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=cKxFZ1V9JkbMvlvajDHPLZ47CwL2tRpgNY6Q+YW/aF8=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubdSfu+BVmmykusC/m7o5639rzjv8RT2I0TLZPu7aB 4tcE7PlHaUsDGJcDLJiiixLco0KIlJX2d67o8kCM4eVCWQIAxenAEykg4Xhv09Y6ua9e74b7dv9 spTVMuTANluXe6ZNC2ZOmupvWntPUp2R4U3vYoHW2Suv6lqpGSfOFSr/qKqyqftUWfvSEiY/qZT lXAA= X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 This is used to mock up a divider in the clk kunit tests. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 372dd289a7ba148a0725ea0643342ccda7196216..e1f72fcede1df1d486744b17172= 8231ec8fa8836 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -137,6 +137,50 @@ static const struct clk_ops clk_dummy_single_parent_op= s =3D { .get_parent =3D clk_dummy_single_get_parent, }; =20 +// 4 ought to be enough for anybody +#define CLK_DUMMY_DIV_WIDTH 4 +#define CLK_DUMMY_DIV_FLAGS (CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ROUND_CLO= SEST) + +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 =3D container_of(hw, struct clk_dummy_div, hw); + + return divider_recalc_rate(hw, parent_rate, div->div, NULL, + CLK_DUMMY_DIV_FLAGS, CLK_DUMMY_DIV_WIDTH); +} + +static int clk_dummy_div_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && req->best_parent_rat= e < req->rate) + return -EINVAL; + + return divider_determine_rate(hw, req, NULL, CLK_DUMMY_DIV_WIDTH, CLK_DUM= MY_DIV_FLAGS); +} + +static int clk_dummy_div_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + struct clk_dummy_div *div =3D container_of(hw, struct clk_dummy_div, hw); + + div->div =3D divider_get_val(rate, parent_rate, NULL, CLK_DUMMY_DIV_WIDTH, + CLK_DUMMY_DIV_FLAGS); + + return 0; +} + +static const struct clk_ops clk_dummy_div_ops =3D { + .recalc_rate =3D clk_dummy_div_recalc_rate, + .determine_rate =3D clk_dummy_div_determine_rate, + .set_rate =3D clk_dummy_div_set_rate, +}; + struct clk_multiple_parent_ctx { struct clk_dummy_context parents_ctx[2]; struct clk_hw hw; --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 72BB127B4FA for ; Tue, 23 Sep 2025 14:40:05 +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=1758638407; cv=none; b=atkYwfxgX7vtT+hqSdTbplwxYpuxem+CNkThRkDYJog0cvu9vn2qRC21OxLXAEgmWbtG3EPOFrs/BoVt3FKlU8eu7x6fnApUG/XDkG043LHVngCyBdk0Xsk6sJ4/BysV4JkuxGmpvtkGQLtA9funOmddKaaLiPMSXKqKr0hcBaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638407; c=relaxed/simple; bh=1TO024p3M9e4CvKoFHluPPeetN75UqlgmhPAZLsIONQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hQzaRKj8uewSQD9gbogIvytOFBGfOVZTZQbCJuYrpfwct7P+jsyicQu30KzO9M7+gS4uwqH9eWoupd5fTKOTM8IYf/4H7Al4zABfXhSu81lGgk5GSRCnXZwNBoZdQzlPcQiBgv2vLTdKZlh8uxD76tovpQ2m4STgl3VpoLGAKGc= 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=grmB9FDp; 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="grmB9FDp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638404; 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=mKuLuPjkfTwmJjUEB4orAAqLaFZFpgNaOtW4WuFuAAc=; b=grmB9FDpxG+c3qp2ItqCjdyi1tFkiKKB4fV7bfg6s1/UuCZQKj4RoIBI29Tei2wM3LkMwq xDd7NppajhGNX7pIUlcoSWq1Y0S0ZoYK00+m1wx4aerY0zc3pjkX550dD1zZl4yepVPfET brfDcoVn30NlPu/LWMP1vEgX7eaf3ZI= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-310-yr1ODyUjM0WCEypBZ1TYyQ-1; Tue, 23 Sep 2025 10:40:02 -0400 X-MC-Unique: yr1ODyUjM0WCEypBZ1TYyQ-1 X-Mimecast-MFC-AGG-ID: yr1ODyUjM0WCEypBZ1TYyQ_1758638402 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-81b8e3e29edso961805985a.0 for ; Tue, 23 Sep 2025 07:40:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638402; x=1759243202; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mKuLuPjkfTwmJjUEB4orAAqLaFZFpgNaOtW4WuFuAAc=; b=BarVbsxGPutgIOQDFV7FglDvEg4X4gKJUJ1FhR2qKqC4cZXihs6f/ytSv+Ved1ZZLk uZBKwjgWX2ayx2BpSkKJa71qWTt1olAcssfsUsUIUaVZ6JjbsawVI31xQJ7AEEbiaIMI 1YoJEdc3Olm0DIOXOSd5H50WWk9lWkecbLo6SYgd5Ah2ujaZZgH0Mz+ihA4pQDA1Y7vO myyPDbs1oMdoCWl4ejEKBFkZ1PEu+63vmt7MwuKYMQLJdqDRK2XtGu3JJ+gmT1WoatPY 3lh0sGLnQIFF4r6RxE8Bfadwo+noYc7eRNLZW2/FdU2eej0Q7ZN5nzVXcURbKKSkFQMM 9ygA== X-Forwarded-Encrypted: i=1; AJvYcCW0qYDXeEXXKLZCMK4KwkI2MbtZQEPZ77H35w5RJ+l4IG/Xp1vGXtCSqwj14KtgLvEi+Oq8ESKg4l7+6V8=@vger.kernel.org X-Gm-Message-State: AOJu0Yxj0KVogKA/Tw6Vd8LdkbJXNPTEcNW6wF2DPupSIc4KvZK/x3Ww 3X0wa3+BUrHc3SAXOGBAPKkrGfVjdJ8Jy+MuZ0in3xc2TMs4WZi9x4vE5stujeEM81HgIWS+act OKRUFnbUcmB54TdtO7Q8ZKhImOYi1bkLcDPZHTl5njY2cRa6dy2/UO9eFv4+cnE7fUw== X-Gm-Gg: ASbGnct0q271Taz8JxIoNGF0YFJspuyefOwc5uRZS/D7WQOn8G/71kGnkxcMU26pgdb nYYGbVy54RrLgIC3C/TH0CBo+u7gFZCtLyLxyjf+JYgKx1tkPuNcS+VPzP6rax/7h7bFV4nW5Qx 1efWiOzVqwR65YT6NpyxwTTVPJ8I7CEG2Mr2b1Osinxs2da2Rm7RoKtyidgb3edc2pitVvbBJvN jgOGSudrgkpylz3CcAMBuafSwZ2m1xPsMpJTMcfPiMOD/sENV9mBRxzsvW1F4p0DNiDkU/rjLvr /D2FkBkUAmXGR3mEVsvHL7LVcZRxXi/sAeS9XhVD8zbGSOHKwiHPEjNUsmgcUep/0oDSZlC3ZdX uCGeQNHMtK4Ogf0VU6uEZVF4GYP9BQkg7hlCHEFQ= X-Received: by 2002:a05:620a:4004:b0:850:329f:f1ef with SMTP id af79cd13be357-85174c1e3fcmr346705985a.55.1758638401752; Tue, 23 Sep 2025 07:40:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+7OLSb7GBt5STwn4FgC6PtZci/VRxi6hdnrqJXbPq3mGFGcag7VbemPhwQuktFX6Ssqn1+w== X-Received: by 2002:a05:620a:4004:b0:850:329f:f1ef with SMTP id af79cd13be357-85174c1e3fcmr346700185a.55.1758638401033; Tue, 23 Sep 2025 07:40:01 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:40:00 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:23 -0400 Subject: [PATCH RFC v4 04/12] clk: test: introduce test suite for sibling rate changes on a divider 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: <20250923-clk-tests-docs-v4-4-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6518; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=1TO024p3M9e4CvKoFHluPPeetN75UqlgmhPAZLsIONQ=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubdQ/dWOW5qUp9/e7znpgzhEdGiDSpuwt3io1+43rZ ukCfXXljlIWBjEuBlkxRZYluUYFEamrbO/d0WSBmcPKBDKEgYtTACZy2oLhf3nL/+XnJrfnR1oe COLb/srg9Lz20pVab/6lbinUmvK7so3hf/WX7cZH/fZnXwu02i516Oj10rBZLz/3Bi4+KrX1+Ia bezkB X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 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 underlying issue is fixed in the clk core. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 145 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 145 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index e1f72fcede1df1d486744b171728231ec8fa8836..1aca266f9922beb7d81124c07d2= 1b2a3d700dc5c 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -653,6 +653,150 @@ clk_multiple_parents_mux_test_suite =3D { .test_cases =3D clk_multiple_parents_mux_test_cases, }; =20 +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 =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + test->priv =3D ctx; + + ctx->parent.hw.init =3D CLK_HW_INIT_NO_PARENT("parent", &clk_dummy_rate_o= ps, 0); + ctx->parent.rate =3D 24 * HZ_PER_MHZ; + ret =3D clk_hw_register_kunit(test, NULL, &ctx->parent.hw); + if (ret) + return ret; + + ctx->child1.hw.init =3D CLK_HW_INIT_HW("child1", &ctx->parent.hw, &clk_du= mmy_div_ops, + CLK_SET_RATE_PARENT); + ctx->child1.div =3D 1; + ret =3D clk_hw_register_kunit(test, NULL, &ctx->child1.hw); + if (ret) + return ret; + + ctx->child2.hw.init =3D CLK_HW_INIT_HW("child2", &ctx->parent.hw, &clk_du= mmy_div_ops, + CLK_SET_RATE_PARENT); + ctx->child2.div =3D 1; + ret =3D clk_hw_register_kunit(test, NULL, &ctx->child2.hw); + if (ret) + return ret; + + ctx->parent_clk =3D clk_hw_get_clk(&ctx->parent.hw, NULL); + ctx->child1_clk =3D clk_hw_get_clk(&ctx->child1.hw, NULL); + ctx->child2_clk =3D clk_hw_get_clk(&ctx->child2.hw, NULL); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->parent_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_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 =3D 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 with CLK_SET_RAT= E_PARENT set + * and one requests a rate compatible with the existing parent rate, the p= arent 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 =3D test->priv; + int ret; + + ret =3D clk_set_rate(ctx->child1_clk, 6 * HZ_PER_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->parent_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), 6 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child1.div, 4); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child2.div, 1); +} + +/* + * 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. The requested child rate picks a parent r= ate + * that's compatible with both children. + */ +static void clk_test_rate_change_sibling_div_div_2(struct kunit *test) +{ + struct clk_rate_change_sibling_div_div_context *ctx =3D test->priv; + int ret; + + kunit_skip(test, "This needs to be fixed in the core."); + + ret =3D clk_set_rate(ctx->child1_clk, 48 * HZ_PER_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->parent_clk), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child1.div, 1); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child2.div, 2); +} + +/* + * 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. The requested child rates require a paren= t rate + * that neither child would initially pick. + */ +static void clk_test_rate_change_sibling_div_div_3(struct kunit *test) +{ + struct clk_rate_change_sibling_div_div_context *ctx =3D test->priv; + int ret; + + kunit_skip(test, "This needs to be fixed in the core."); + + ret =3D clk_set_rate(ctx->child1_clk, 32 * HZ_PER_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + ret =3D clk_set_rate(ctx->child2_clk, 48 * HZ_PER_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + 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), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child2.div, 2); +} + +static struct kunit_case clk_rate_change_sibling_div_div_cases[] =3D { + 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 =3D { + .name =3D "clk-rate-change-sibling-div-div", + .init =3D clk_rate_change_sibling_div_div_test_init, + .exit =3D clk_rate_change_sibling_div_div_test_exit, + .test_cases =3D clk_rate_change_sibling_div_div_cases, +}; + static int clk_orphan_transparent_multiple_parent_mux_test_init(struct kunit *test) { @@ -3593,6 +3737,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, --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 45EC42E2286 for ; Tue, 23 Sep 2025 14:40:07 +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=1758638410; cv=none; b=WwpFgAHJSgu3CwnS4NDCY9r68hcyrPjym8T69Yv80HIn5K4lHhaDvOjjyp9z7BbWJAUntg8hJkStXL/dOqEJVsEZPGKxCZMUBbZ/rgSHXuQNVYqh+cl1qW3o2ey+vf+HZmSIiB/Y5dI22dPNdR0yDyy1aOY85SuF5lE34VuAAGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638410; c=relaxed/simple; bh=pFcsx99BIvhSJs9EZjHposR2YHdvSFZidHEyknZiq+Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AkUjT5YiRbwKqhSCXglPq2q64W2ehq6wE9So3IuAM3r0S+4g8ecSBU5hzAVA0ha2pogIQLYYysJbV9ecSCriOGZFBvo23BmNUEXf5iosq8Tcklp5CXfNMRMZrWPqZtiLZ1eH79UZDlvDn9NT5DDTtOVI+9vIIBfnGwyyfZ/eKpw= 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=EaF63Ecm; 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="EaF63Ecm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638407; 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=A9GRgIWzFYj7dDBWP7AZSAac6SnS5DXh5UVkU8dbhRY=; b=EaF63Ecm5mcWFDOvt5aUyaXBWWFXxTnFm3J5G597UKlNy64JWIf75XUzt/E1EFEb7v2zFk R08cWChZ3RJxtMw7FDGcGphBkK/Ui0IoLUexaTyRpiJnLFBWaRleBl56L4wGzOMpGBNeqj 8Um9jlsW/IL1voxF1BGo1NUQ1nWZAm8= 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-400-MCuku5MaO5Wgb78sdDMXXA-1; Tue, 23 Sep 2025 10:40:04 -0400 X-MC-Unique: MCuku5MaO5Wgb78sdDMXXA-1 X-Mimecast-MFC-AGG-ID: MCuku5MaO5Wgb78sdDMXXA_1758638404 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-816a52d9a6bso690548385a.1 for ; Tue, 23 Sep 2025 07:40:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638404; x=1759243204; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A9GRgIWzFYj7dDBWP7AZSAac6SnS5DXh5UVkU8dbhRY=; b=mPWASOG8f9t9S86ZAoCEr95SQafYCCbAoN8G/t0klDzKR5QoIc8zmlQTlueMAMAYVV MyxWmbBaRTEFaY22xiacicEthCGljFKV8BRViS+4oa7dXwUHJZSonzg0TRHG1i03x+eZ R8nnhn73tj4C9ej79Hr4LkVEry9/ww4Aef3LNxX8PJRxQ7eaj7UbbKTrLhQt5xGJdsoP CNht0zGTtHU1/1BVECebujwND/B3ZheN14v12ivkAdQ8COrSY8PzSBgC6PXHVypZQ2m9 mOuoPU0JEGRallaAw/Wt/pIAiE7B77Evu3roaJ26qUHVLwp1O0PzxGJCTNNAdtBL/Qdj pwCw== X-Forwarded-Encrypted: i=1; AJvYcCWHZKXWqYnDJxBzWNXLoSA+QMpeeuK4wPWApQxqkSDkMCvlM3+JOy6uIOlu6SP+eKnPh91dWZqmBEGEhyQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxmQ7JII2G5jmnqJ03uquZslV1w/9bUMP88BCnYced3D49oRoEW 9Xkw18B97IKT2C1wJhcOyV9K9GQaiGC2qlSAvXLWvLTZ2h0BrQS8kskmW43DoL+8O5YBAFFdJtX 4dwXSwXNHCCY40ICUjjgbZ9iJOnnBFHuhXQtHb505YbqJRuDhRjZ8KztFiLsH8WtBAA== X-Gm-Gg: ASbGncsNLeGYcahy0W++rmIoipYxxOwy0wFo9AKUen0DWxZ9i9fEeHNlK38kudVuVc7 QY0PbSxfBq9bm0iuQsUbb0DqwbiWsJ6TkpiXMuKTCBEevjgmH3Oq1DehnQXahi4R3NjsoW3CLzC lsxbanqzBEtsqC7N9I28x4hvXfefm2T+W1qr+RrIqnkwLpj0i1yI/VRw1y+1+G837PduqEy5e+6 XqNRVJh4+/MObmlpLbZrWLasRTi0gENaYyucJiM0cPomKpHAdQPGv/dyMMlFa8/X4eShXl4Mu6u imstmmK4QNOZLVldffi+e+4pHO0EpYPwA4CO5Geayxo5M410AW1xfUDlpW5RTSHySPe/YIpELhX hMlUi7IYZm1YWatYLgvDEjtuAj8G/d12cQokfccU= X-Received: by 2002:a05:620a:2893:b0:849:a372:24dd with SMTP id af79cd13be357-851724be79cmr315043085a.58.1758638404294; Tue, 23 Sep 2025 07:40:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGB1IVa4PYBoaIhw9LnlRHxc9bCRkENFx/qDelC+j1q0D87GHSENwmL4JOuTI63o0roDkoNIA== X-Received: by 2002:a05:620a:2893:b0:849:a372:24dd with SMTP id af79cd13be357-851724be79cmr315038985a.58.1758638403658; Tue, 23 Sep 2025 07:40:03 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:40:02 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:24 -0400 Subject: [PATCH RFC v4 05/12] clk: test: introduce clk_dummy_gate for a mock gate 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: <20250923-clk-tests-docs-v4-5-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1504; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=pFcsx99BIvhSJs9EZjHposR2YHdvSFZidHEyknZiq+Y=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubdRX8HNayV7rWPh6F3dtv+xR1zDb26FZK3vvbOiy5 ouTnGjRUcrCIMbFICumyLIk16ggInWV7b07miwwc1iZQIYwcHEKwEQ0vzIyTIn91u717/Zus7S2 9FulzUv5fcQYC75fvT1beMV/32UFGYwMT80s0+27gvmuVftwXFXeGnz7dO2XbI8p/hqTtpfO31T PAAA= X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 This is used to mock up a gate in the clk kunit tests. Reviewed-by: Maxime Ripard 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 1aca266f9922beb7d81124c07d21b2a3d700dc5c..e798ee0591b5db6a7728eda20dc= ab167245a9834 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 =3D { .set_rate =3D clk_dummy_div_set_rate, }; =20 +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 =3D container_of(hw, struct clk_dummy_gate, h= w); + + gate->enabled =3D true; + + return 0; +} + +static void clk_dummy_gate_disable(struct clk_hw *hw) +{ + struct clk_dummy_gate *gate =3D container_of(hw, struct clk_dummy_gate, h= w); + + gate->enabled =3D false; +} + +static int clk_dummy_gate_is_enabled(struct clk_hw *hw) +{ + struct clk_dummy_gate *gate =3D container_of(hw, struct clk_dummy_gate, h= w); + + return gate->enabled; +} + +static const struct clk_ops clk_dummy_gate_ops =3D { + .enable =3D clk_dummy_gate_enable, + .disable =3D clk_dummy_gate_disable, + .is_enabled =3D clk_dummy_gate_is_enabled, +}; + struct clk_multiple_parent_ctx { struct clk_dummy_context parents_ctx[2]; struct clk_hw hw; --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 145BC2E6105 for ; Tue, 23 Sep 2025 14:40:12 +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=1758638414; cv=none; b=aECarb9CyV4D0H5yqtcSrFA21+/QXZhJCA8brzYncY3VlxAUtooooJsvj3SYvxg9uiduck8uBlhvsOGMdcsAHYAGVFkR9Ys1kR9dYI4+yEmut96Qo4h9SGHDtBnDVsMaGRMI6FtW4QKU1GQl2Yb6MkctY+QhhjfkgZu0I9IpQcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638414; c=relaxed/simple; bh=zpyuXvyiYD9eeqhZlOVx8F+Pl/6qjadEKFFcmOgiDiU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HohRs6UDFNQhdicTc7lYNTLKOfzTSYg2HZl/jUOdJrqvrtkQ4b7yxQe86uy924cqGrBBlMa0o+f0BMi7SetgAeCG0XAL/y3XyB/k9Nrl3JoQX1TNJNbWmt8yb17+BczC3KBH25f7oISUcxvvzZA6odQoF61FsRHQcOVFioqXtpQ= 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=aupC7KDK; 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="aupC7KDK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638412; 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=EYAaIRlhQfgUHW4R/ndesV2wqa5bdYWvu/q6ojx4leM=; b=aupC7KDKU5lzQctkaLh6fcDqaFCky4yjzMmn5xdaJTzWtm3RK4ofzkxjVCO17clCDhthFt O1dmaAFnfYzHrbBgdAcs1brFiTCwZcbazcTKeSGV058JT0l4aL1w5jCseQIUgglGhyuL3x vlJHPjEGoVS3FVta70lVYwBPzjkAlio= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-393-yHXhHeUxOSuUfdvUUZrXvA-1; Tue, 23 Sep 2025 10:40:07 -0400 X-MC-Unique: yHXhHeUxOSuUfdvUUZrXvA-1 X-Mimecast-MFC-AGG-ID: yHXhHeUxOSuUfdvUUZrXvA_1758638407 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-828bd08624aso1152344185a.1 for ; Tue, 23 Sep 2025 07:40:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638407; x=1759243207; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EYAaIRlhQfgUHW4R/ndesV2wqa5bdYWvu/q6ojx4leM=; b=bgZDxDZVwwBUKZj6P07qKsulEyYr/jfkksnZRGnF+ZaHnhAzRpc9+heU0ZVVCwkaLz Kh+9mCjX392zjONPnREygLffAQCeRU6PF+np6E8UJrz09lzlJjhFPIvM1cwl/UP9RFfH n6RK1fgN/OL1zFWpePwidXieYNnphphkwN2Pp6ondHDVFZIdVHDvPeuqG6h7CEwm47hm a2B2oz7WbwzQ5kCWoF0Hj/Y4a+kAaWDpQJHEBs5/CxPZEiqIIEBeggh9HHikj7vXsi8w FRk3LjOb6G51n2Y4rZlMKSIjl8CCkIGeGyyHwnOJ682gYOlypZ2YMYZdWu6Rz/CIXhQe 2uTw== X-Forwarded-Encrypted: i=1; AJvYcCXN6lDprqe5O0Ur0nDw7Ch+FFo4oStAj+oGDn3mUXrFFdIafGQG9/t89eiIYag/dtLMhlWyLAe0WvYL8K4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2r2rYwhy75DooJokBcZdUK0ohwLajPA8kSTTQyqdjTmOq2+j1 DXeCau762hTrReKSiK1R7QrolEAoKjxHCrL3PvQ8xEBkt62nab5KjI6TBeAweG4jSBWQ+esE/5W 8H/c0qLKq6nqC6rKF438FlvbFNkPnufzPxZGvmlFql68VcLV5MExC8xOg1DN7MlM66w== X-Gm-Gg: ASbGncvwJZxoZZnLqouJjpKSIGmCv112VyCyCbaj797UBFSQi8DhqOsun/kwhX3gRD/ 5AldABTgk1TkG5mPf5UGuBfgkxlBpM3B/Jw3FOPq1BUerxqZ5YCQqZfOxtywAEmyrwskpbkey5Q cXJj8QmqOmUU6NobTDGBF8GFs52xyuHt1m/ZrFM6V5B06AwLLKFyhBYGQ2LQH+ZcN9u0VGAeujO d8CWLtpsq0yMpTH5POmUQvw6b4EcozDNqWgKoV5UxwgaG/Cu4kBHsLi3CX8pfFJo//uEQx73leB wMS5I+5KMSAJ4rHBZq12SCYyoMo8pa3b2OcUvityL85nKzl/5xvzjni4UqaelwclDbVp9NGirel vsOP1mNgsHM0q1SAGOH/uwjhqBkkaGbvTzTPTpfs= X-Received: by 2002:a05:620a:414b:b0:84d:b0e0:4183 with SMTP id af79cd13be357-8516a919802mr345616585a.23.1758638406872; Tue, 23 Sep 2025 07:40:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdjlcch00PashDlzbuTTmPoVSqMAIOcWAUI4Pr/QX+fLOPi2xGS7zPFlAxGgH4hNbH3DSn5A== X-Received: by 2002:a05:620a:414b:b0:84d:b0e0:4183 with SMTP id af79cd13be357-8516a919802mr345612485a.23.1758638406285; Tue, 23 Sep 2025 07:40:06 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:40:05 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:25 -0400 Subject: [PATCH RFC v4 06/12] clk: test: introduce test suite for sibling rate changes on a gate 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: <20250923-clk-tests-docs-v4-6-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6733; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=zpyuXvyiYD9eeqhZlOVx8F+Pl/6qjadEKFFcmOgiDiU=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubdSv7e01MH5uv3z93sjYY2E7mXaeku561bHeSyOgx cbYfoZnRykLgxgXg6yYIsuSXKOCiNRVtvfuaLLAzGFlAhnCwMUpABOJP8LwP/LOtXvqsaeYte4z 8niv/6JesMvukd93mbu28XINq8+8q2Zk2HRdPCgi4XXDNIbK+R9d5Rwrstz2bTZw2rxZvKBBaQE DLwA= X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 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 | 155 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 155 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index e798ee0591b5db6a7728eda20dcab167245a9834..5fb908a8c764f3c3d2c744022bd= 61e6307c890c2 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -831,6 +831,160 @@ static struct kunit_suite clk_rate_change_sibling_div= _div_test_suite =3D { .test_cases =3D clk_rate_change_sibling_div_div_cases, }; =20 +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_sibli= ng_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 =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return ERR_PTR(-ENOMEM); + test->priv =3D ctx; + + ctx->parent.hw.init =3D CLK_HW_INIT_NO_PARENT("parent", &clk_dummy_rate_o= ps, 0); + ctx->parent.rate =3D 24 * HZ_PER_MHZ; + ret =3D clk_hw_register_kunit(test, NULL, &ctx->parent.hw); + if (ret) + return ERR_PTR(ret); + + ctx->child1.hw.init =3D CLK_HW_INIT_HW("child1", &ctx->parent.hw, &clk_du= mmy_div_ops, + CLK_SET_RATE_PARENT); + ctx->child1.div =3D 1; + ret =3D clk_hw_register_kunit(test, NULL, &ctx->child1.hw); + if (ret) + return ERR_PTR(ret); + + ctx->child2.hw.init =3D CLK_HW_INIT_HW("child2", &ctx->parent.hw, &clk_du= mmy_gate_ops, + CLK_SET_RATE_PARENT); + ret =3D clk_hw_register_kunit(test, NULL, &ctx->child2.hw); + if (ret) + return ERR_PTR(ret); + + ctx->clk_ctx.parent_clk =3D clk_hw_get_clk(&ctx->parent.hw, NULL); + ctx->clk_ctx.child1_clk =3D clk_hw_get_clk(&ctx->child1.hw, NULL); + ctx->clk_ctx.child2_clk =3D clk_hw_get_clk(&ctx->child2.hw, NULL); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->clk_ctx.parent_clk), 24 * HZ_PER_= 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[] =3D { + { + .desc =3D "div_gate", + .init =3D 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 with CLK_SET_RATE_PARENT set = and + * one requests a rate change that requires a change to the parent rate, t= he + * 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 =3D + (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 =3D testcase->init(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_MHZ); + + ret =3D clk_set_rate(ctx->child1_clk, 48 * HZ_PER_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_GE(test, clk_get_rate(ctx->parent_clk), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_MHZ); + + clk_test_rate_change_sibling_clk_ctx_put(ctx); +} + +/* + * Test that, for a parent with two children with CLK_SET_RATE_PARENT set = 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 affecte= d. + */ +static void clk_test_rate_change_sibling_2(struct kunit *test) +{ + struct clk_test_rate_change_sibling_test_case *testcase =3D + (struct clk_test_rate_change_sibling_test_case *)(test->param_value); + struct clk_test_rate_change_sibling_clk_ctx *ctx; + int ret; + + ctx =3D testcase->init(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); + + ret =3D clk_rate_exclusive_get(ctx->child2_clk); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_MHZ); + + ret =3D clk_set_rate(ctx->child1_clk, 48 * HZ_PER_MHZ); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_GE(test, clk_get_rate(ctx->parent_clk), 24 * HZ_PER_MHZ); + /* child1 is rounded to the closest supported rate */ + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_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[] =3D { + 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, where the children = can + * be combinations of a divider, 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 =3D { + .name =3D "clk-rate-change-sibling", + .test_cases =3D clk_rate_change_sibling_cases, +}; + static int clk_orphan_transparent_multiple_parent_mux_test_init(struct kunit *test) { @@ -3772,6 +3926,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, --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 8AC592E62B9 for ; Tue, 23 Sep 2025 14:40:14 +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=1758638416; cv=none; b=PZDB/PaOafz/TzhyIfrF8R5CszAFdMImmqn1uM74jKb1HvY5Uutf4JWx2FXOFda5N1BAziJx6u2ULkUv4AljthO0O7VsaD1nMqSdPTGJE2GHnGgHgHGVkcGDw/W7osU1UtZNh5KcQ4ErfaFR33NufOdYaPWoEY/Lq78E7tV3ZFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638416; c=relaxed/simple; bh=yAsWE58IkjsKCLEl/DPZcoJASm8AUAsFuoIvwC4HaqM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W/OkXYYFx8/3kpj+sa+AoESe2d2PbHWHCgfD6FSdh8VKyUgvkK7IMb2m5H+3stkFgg7kDsOL9IZG7oqashY8GuTzny+uUrvEqoMUzbWbUQnE+2U5KFWF9Qs5coTM9+PnkiCGki4zWFy0fExtRbwUXWTGIMO6S0m9ZzPWvPILnJ8= 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=Md0Gpj5S; 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="Md0Gpj5S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638413; 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=IGMWuqBzhBNfmX/zEHWn5ay04MO78lPZtspT3NW2/jI=; b=Md0Gpj5Si90pN0A+1nM1ObicJBfWSgwOWMECHHGRiyDVsCze4FIctON6INHN7vWJjPOxPV qL1hNVjVkDcGiH5N/QAMYy3phiGjJoHCB9Pox7I5tNOgoLO55RPDxcSKp8LgXTa3FsVowB Ycn2f5AQApJcbrFPca06iNlqs37pO9c= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-205-K7TsR2CxM7OHnoDkGFQNrg-1; Tue, 23 Sep 2025 10:40:11 -0400 X-MC-Unique: K7TsR2CxM7OHnoDkGFQNrg-1 X-Mimecast-MFC-AGG-ID: K7TsR2CxM7OHnoDkGFQNrg_1758638411 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-817ecd47971so1270192985a.0 for ; Tue, 23 Sep 2025 07:40:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638410; x=1759243210; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IGMWuqBzhBNfmX/zEHWn5ay04MO78lPZtspT3NW2/jI=; b=sv540VX+HtJ649XwVPq62koU3ztzGm7dhhlbkYkXHWnDbkdYec7AZD81/Ro1nj5ljp IMxzDglC3J/HPsdDro50Jqxjb97ZWkOVW9meF5ZBTGkXKFGkGkFE+jFjQbv+uve/2OsX ngw0v304tYC41c5Vq9nDufEobnj71imgfyE+By/GbCILWRXYIvr70exK+V1Yolh9jzZd QpFKNceEM/ErrchacCBZnXhoByXewq2x7Td9vdn127GwnIubpzMKVL8l+yGdOr9QB2eo LwfwT3m8lHSGNqNKMCc2UpFQrgniFrL3u8QHLbvhVCyMX6mj9YHrQRXQqMk99WqhEn0+ 7s8g== X-Forwarded-Encrypted: i=1; AJvYcCWCnMZNt1M/Tyvo66sSH4m/jm1b3cdTE1QL0PIJBylbt1qBf2YIfgpctG+zCT+rtd9hxQEDGM0ISGT0vsU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/8osAnNJuB8lUHEjGTXnWbp+i1VRI5GE1VY+B1aFfXhwBwbdn Zap3bYC5TYmd1nVV64W3tcpeAQ+I5A16TqC1zTgNaA6if8lWcuqqZiV/NQo+ZVBrJQMlFODu3L1 RQroGeRBpJr2OTQvIuLGipvPObw6VXAs+LrNolLLIcO5BY3hc9SiPaNyvBBFgRSJ/Ggfw2koqBQ == X-Gm-Gg: ASbGncvkX3PFZ6qGbav/Ult7eM15C1L5Ks691V48v1nGADdFw4Q0Paejv/cwEpP31wb 9h3mhRSeW7Hlr1R/TiAVPk5Akbg+8xj9EihY0StV466R/4Z5pywOIdsnyHi8Dw0ytWkspY1theM Uvam6RY/8CvAH9620kM9OcXBx+my0OGK76WLcDdq+AAbqQy3u54s34Y7lHU6vHIqMX6M+8URKW/ 5o8cafLC30QqiA+/nmEhayQYQXYT7xnD6vO7rcjjjqug+oKQ1DZjbijH2U5dgiXgnaMQ77iy7J5 p0diZXX6rLwxZvKol0roHq+64kXr5ZRewjCWrxK++7hKyQdA73C4xptRmNXJhchSzfotCVbyzVD 59mLqlVirGV9yyvXj03uj3esb9duE6BajinfK6gQ= X-Received: by 2002:a05:620a:5dd0:b0:854:d17b:27dd with SMTP id af79cd13be357-854d17b2bf4mr77507285a.40.1758638410151; Tue, 23 Sep 2025 07:40:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+fyJ54UA/mPzWWxl9qvSXtQD04gMoGv1VTxXaLInAlQY+mfo1Pg0oNEkRJMY6/YiNVKGOcQ== X-Received: by 2002:a05:620a:5dd0:b0:854:d17b:27dd with SMTP id af79cd13be357-854d17b2bf4mr77503185a.40.1758638409310; Tue, 23 Sep 2025 07:40:09 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:40:08 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:26 -0400 Subject: [PATCH RFC v4 07/12] clk: test: introduce helper to create a mock mux 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: <20250923-clk-tests-docs-v4-7-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7421; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=yAsWE58IkjsKCLEl/DPZcoJASm8AUAsFuoIvwC4HaqM=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubTR4saX+p8yLXOFiU15Rs5qbF6/+EnYvczhh1jal1 LhduH5SRykLgxgXg6yYIsuSXKOCiNRVtvfuaLLAzGFlAhnCwMUpABNZcZPhf/XLULP4maF7J2ox dUY3lEatcUuyDLxzeoH21KtBveu0Yhn+cH7cyuoremXm4sk6k3ftCeIwu84ksOpqgyPP8s9H91i 6MgIA X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 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 5fb908a8c764f3c3d2c744022bd61e6307c890c2..a330de8bd8dc2cdda558d364a3c= 6d87a26791c8d 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 =3D= { .test_cases =3D clk_uncached_test_cases, }; =20 -static int -clk_multiple_parents_mux_test_init(struct kunit *test) -{ - struct clk_multiple_parent_ctx *ctx; - const char *parents[2] =3D { "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; =20 - ctx =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); - if (!ctx) - return -ENOMEM; - test->priv =3D ctx; - - ctx->parents_ctx[0].hw.init =3D CLK_HW_INIT_NO_PARENT("parent-0", + ctx->parents_ctx[0].hw.init =3D CLK_HW_INIT_NO_PARENT(parent0_name, &clk_dummy_rate_ops, 0); - ctx->parents_ctx[0].rate =3D DUMMY_CLOCK_RATE_1; + ctx->parents_ctx[0].rate =3D parent0_rate; ret =3D clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[0].hw); if (ret) return ret; =20 - ctx->parents_ctx[1].hw.init =3D CLK_HW_INIT_NO_PARENT("parent-1", + ctx->parents_ctx[1].hw.init =3D CLK_HW_INIT_NO_PARENT(parent1_name, &clk_dummy_rate_ops, 0); - ctx->parents_ctx[1].rate =3D DUMMY_CLOCK_RATE_2; + ctx->parents_ctx[1].rate =3D parent1_rate; ret =3D clk_hw_register_kunit(test, NULL, &ctx->parents_ctx[1].hw); if (ret) return ret; =20 - ctx->current_parent =3D 0; - ctx->hw.init =3D CLK_HW_INIT_PARENTS("test-mux", parents, - &clk_multiple_parents_mux_ops, - CLK_SET_RATE_PARENT); + parents[0] =3D &ctx->parents_ctx[0].hw; + parents[1] =3D &ctx->parents_ctx[1].hw; + ctx->hw.init =3D CLK_HW_INIT_PARENTS_HW(mux_name, parents, + mux_ops, mux_flags); ret =3D clk_hw_register_kunit(test, NULL, &ctx->hw); if (ret) return ret; =20 + ctx->current_parent =3D 0; + return 0; } =20 +static int +clk_multiple_parents_mux_test_init(struct kunit *test) +{ + struct clk_multiple_parent_ctx *ctx; + + ctx =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + test->priv =3D 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. @@ -2541,7 +2560,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] =3D { "parent-0", "parent-1" }; int ret; =20 ctx =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); @@ -2549,27 +2567,11 @@ clk_leaf_mux_set_rate_parent_test_init(struct kunit= *test) return -ENOMEM; test->priv =3D ctx; =20 - ctx->mux_ctx.parents_ctx[0].hw.init =3D CLK_HW_INIT_NO_PARENT("parent-0", - &clk_dummy_rate_ops, - 0); - ctx->mux_ctx.parents_ctx[0].rate =3D DUMMY_CLOCK_RATE_1; - ret =3D clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[0].hw); - if (ret) - return ret; - - ctx->mux_ctx.parents_ctx[1].hw.init =3D CLK_HW_INIT_NO_PARENT("parent-1", - &clk_dummy_rate_ops, - 0); - ctx->mux_ctx.parents_ctx[1].rate =3D DUMMY_CLOCK_RATE_2; - ret =3D clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[1].hw); - if (ret) - return ret; - - ctx->mux_ctx.current_parent =3D 0; - ctx->mux_ctx.hw.init =3D CLK_HW_INIT_PARENTS("test-mux", top_parents, - &clk_multiple_parents_mux_ops, - 0); - ret =3D clk_hw_register(NULL, &ctx->mux_ctx.hw); + ret =3D 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; =20 @@ -2757,7 +2759,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] =3D { "parent-0", "parent-1" }; int ret; =20 ctx =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); @@ -2768,27 +2769,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); =20 - ctx->mux_ctx.parents_ctx[0].hw.init =3D CLK_HW_INIT_NO_PARENT("parent-0", - &clk_dummy_rate_ops, - 0); - ctx->mux_ctx.parents_ctx[0].rate =3D DUMMY_CLOCK_RATE_1; - ret =3D clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[0].hw); - if (ret) - return ret; - - ctx->mux_ctx.parents_ctx[1].hw.init =3D CLK_HW_INIT_NO_PARENT("parent-1", - &clk_dummy_rate_ops, - 0); - ctx->mux_ctx.parents_ctx[1].rate =3D DUMMY_CLOCK_RATE_2; - ret =3D clk_hw_register(NULL, &ctx->mux_ctx.parents_ctx[1].hw); - if (ret) - return ret; - - ctx->mux_ctx.current_parent =3D 0; - ctx->mux_ctx.hw.init =3D CLK_HW_INIT_PARENTS("test-mux", top_parents, - &clk_multiple_parents_mux_ops, - 0); - ret =3D clk_hw_register(NULL, &ctx->mux_ctx.hw); + ret =3D 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; =20 @@ -2871,39 +2856,17 @@ static int clk_mux_no_reparent_test_init(struct kunit *test) { struct clk_multiple_parent_ctx *ctx; - const char *parents[2] =3D { "parent-0", "parent-1"}; - int ret; =20 ctx =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; test->priv =3D ctx; =20 - ctx->parents_ctx[0].hw.init =3D CLK_HW_INIT_NO_PARENT("parent-0", - &clk_dummy_rate_ops, - 0); - ctx->parents_ctx[0].rate =3D DUMMY_CLOCK_RATE_1; - ret =3D clk_hw_register(NULL, &ctx->parents_ctx[0].hw); - if (ret) - return ret; - - ctx->parents_ctx[1].hw.init =3D CLK_HW_INIT_NO_PARENT("parent-1", - &clk_dummy_rate_ops, - 0); - ctx->parents_ctx[1].rate =3D DUMMY_CLOCK_RATE_2; - ret =3D clk_hw_register(NULL, &ctx->parents_ctx[1].hw); - if (ret) - return ret; - - ctx->current_parent =3D 0; - ctx->hw.init =3D CLK_HW_INIT_PARENTS("test-mux", parents, - &clk_multiple_parents_no_reparent_mux_ops, - 0); - ret =3D 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); } =20 static void --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 665362EA146 for ; Tue, 23 Sep 2025 14:40:21 +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=1758638423; cv=none; b=N0rOGq9NxygxtOSoRdOQ1bJ2BocOJ1M4cz4XEkUHC8wjfEURz6K82IHo+gCFyhZwCIWXZBcEYrQlVTTQwY76JJgChfwk7fdPA/aXzb3kRmszDe5L8biHQQfIWBx917qJ68F6M8sVZ9qezejXh6p9sEIMF8ZoFIj0yAXHDEClRDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638423; c=relaxed/simple; bh=Q4FysjLwmisDNtR/Tyh/L+zp4+LEXH1XuUq81ZlHyiA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HfSauY03wL5Yny5TCAxiebwLEFlb3ajJGyYWvxlKX6KLto6h6Oxf9FJmr3JUTanAUDVd8DUudZOt6rWbt2wjGq24fnhdbzFPvPYkaNbKRlHb0M5aP8P6ny0UKsNCobhKqWkA9ldgXKsTkV8jXmboA6U3eHlfrqYGwIQBjIpwQuw= 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=DcwmbxpX; 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="DcwmbxpX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638420; 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=TRIZZjnscf0CTJC2caJhMyNbvqlOTaws6rzDBpb96D8=; b=DcwmbxpXqK6stZOuymhQoob5tvB8wAw1QZ4Z/AswvyOYZ/VgoLzGs2P4PrFFiRwQK28mFl DK9oERLqRRQYGuGbN5o+OCQpK/X1H7hjv0dmd+/4sfJ0CkOzi2D1nLYLxovJsBZ2USVpb2 JHbsYK8dssSBIuwyIfe7XIQ7CJwTNBg= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-Vs6uc_ZGMCKrJ3IJRh9F3g-1; Tue, 23 Sep 2025 10:40:14 -0400 X-MC-Unique: Vs6uc_ZGMCKrJ3IJRh9F3g-1 X-Mimecast-MFC-AGG-ID: Vs6uc_ZGMCKrJ3IJRh9F3g_1758638413 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-829080582b4so1080649285a.0 for ; Tue, 23 Sep 2025 07:40:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638413; x=1759243213; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TRIZZjnscf0CTJC2caJhMyNbvqlOTaws6rzDBpb96D8=; b=HLCp1ak02V7SrOSpZ1NH7VqJRLYrjpeZlmySS5HV912eynjHKGsalnTlEd0IfyKmRY ogEtYd8GAZgIR/Rwo8t/+m75lRUkLGI6AhK7+efGgv7AZtBLcnJ4pHSCOAzyfYcWAqOy BZsw8AuJRnmLH3zRDhV6fBtUgkm/q9hS0WGREzI50TXgAaBbmYJVkyLhw+80QIeEih/5 8YvBa/dRzh05L/fe2fQmR/dz7/MnltbnrSKRgfBmhjZfOQjdJzHCdXMfwxWA+5dpVq5s qCktol6EMghGGnHD+9r1YAM/D/AB5cJHWBG2tRt8M0AXFvopVhxmGDnmhDcr9mF7mjCP D06A== X-Forwarded-Encrypted: i=1; AJvYcCUX/9r5YMBkkhcmrr28v3/CzNCBBeGjZggQFpYivMb1gNhj2HBwhv8yuz93S+5w5xszBi1V76G0AsczKIg=@vger.kernel.org X-Gm-Message-State: AOJu0YwlG6BxXXukUDyiNnIM4e4L+sTkawF6+QgTH7djfyzJ+ikVkVk2 eTFnC/gEMrpnaB+A+fol3Cq2ek58xV8HU1lEBiq/vooGexYUNkEHYUXkZjnHcbhOmW+6KmGmxkD FZ7YzZztz0FaVZQ1ZeGkufja1cWbev/36PwlmE0aryeXsbrSNxuL8sIlaWQyrf0BeYw== X-Gm-Gg: ASbGncvB0BE1oEWNmiK2nW3M8bjO1JYx8Uv2bHupKHVgkoezBX4KPYdTKN8ow988ZsW GmjPZPQiSfbP9FkNly6CeK/pDm0Pm0JAFwKYz/9hUKtyqK7xF6qtiZOSjenbHzehyR4GKd59fbd 3AzoWgAwcSpb95HlRkxNs6fbBn7yp23DLMtAFQOUM/786mk9IIJYybNHFj01dUJW6TXgGWHCwgA UMQXQS3OKNK9hpNift3VPMhk3mRHfm0GIKpqxrgSZPiT7FrjpZ0/ISmgbaQmY3vEqVLH7QzHqYF Zx5SzVmIs0LDmWMYEQ5+GfmbTB6K1I7s6YQXvlUm0NIa/FQdtOfultqs4KfZZqDHN60yAai1T5P tqQD3apIfKECczMCXjy2R8LLYu7m35AtY12wnkXk= X-Received: by 2002:a05:620a:3953:b0:7ea:463:e2f9 with SMTP id af79cd13be357-8516eb4611bmr323652985a.20.1758638413182; Tue, 23 Sep 2025 07:40:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPaSgwgYu2jWSLtWkKuFwUUeiviIqk4f81BpVimVxbiuKlOcm9lYGy6m0TtX9XsNim1ZZ0Jg== X-Received: by 2002:a05:620a:3953:b0:7ea:463:e2f9 with SMTP id af79cd13be357-8516eb4611bmr323648585a.20.1758638412624; Tue, 23 Sep 2025 07:40:12 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:40:11 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:27 -0400 Subject: [PATCH RFC v4 08/12] clk: test: introduce test variation for sibling rate changes on a mux 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: <20250923-clk-tests-docs-v4-8-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2549; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=Q4FysjLwmisDNtR/Tyh/L+zp4+LEXH1XuUq81ZlHyiA=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubTR4svCbnaRe5RUGyR8OPzdxRmdP4VxQ18a24lZaf I5+06zDHaUsDGJcDLJiiixLco0KIlJX2d67o8kCM4eVCWQIAxenAEwkrZuRYfO2iu/hbyb0XTlo tejBw8MuZVF/Y3tYTum8PHeu3+nsMnOGf7YnXzAUm1WWCu+dyqlh9OvDzOCb3j/uZrguz7jm/7f +HCsA X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 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 | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index a330de8bd8dc2cdda558d364a3c6d87a26791c8d..0344f3f62251728e15af277ea0d= 143dc1f40fd94 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -908,6 +908,47 @@ clk_rate_change_sibling_div_gate_test_init(struct kuni= t *test) return &ctx->clk_ctx; } =20 +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 =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return ERR_PTR(-ENOMEM); + test->priv =3D ctx; + + ret =3D clk_init_multiple_parent_ctx(test, &ctx->child2_mux, + "parent0", 24 * HZ_PER_MHZ, + "parent1", 48 * HZ_PER_MHZ, + "child2", CLK_SET_RATE_NO_REPARENT, + &clk_multiple_parents_mux_ops); + if (ret) + return ERR_PTR(ret); + + ctx->child1.hw.init =3D CLK_HW_INIT_HW("child1", &ctx->child2_mux.parents= _ctx[0].hw, + &clk_dummy_div_ops, CLK_SET_RATE_PARENT); + ctx->child1.div =3D 1; + ret =3D 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 =3D clk_hw_get_clk(&ctx->child2_mux.parents_ctx[0= ].hw, NULL); + ctx->clk_ctx.child1_clk =3D clk_hw_get_clk(&ctx->child1.hw, NULL); + ctx->clk_ctx.child2_clk =3D 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); @@ -918,6 +959,10 @@ static struct clk_test_rate_change_sibling_test_case c= lk_test_rate_change_siblin .desc =3D "div_gate", .init =3D clk_rate_change_sibling_div_gate_test_init, }, + { + .desc =3D "div_mux", + .init =3D clk_rate_change_sibling_div_mux_test_init, + }, }; =20 KUNIT_ARRAY_PARAM_DESC(clk_test_rate_change_sibling_test_case, --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 785612472A6 for ; Tue, 23 Sep 2025 14:40:19 +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=1758638421; cv=none; b=Fu1TwYqhUf7lZsO722mypVLcPaeHma26+nWCruy3tdOc/1ltaWhLJ9AW0/RKqFmbT9a+xelmLKU/l2hT68F7RF1mY0s+/c+MNvHvmcwk2y4tj7uMLU1lfZ/wAWorkJEMJ2N9tgD7VOs3w1BjlWqtLCmeUp7M5Cg4c9QiwrQF+PM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638421; c=relaxed/simple; bh=CBq4gpUSfkFVa42LifJPSpuY6RfDWwyJToNVFFTmN1s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IQABGYll+K6DksP4HKIK+6G4yqnEcthmznZOzMqsEafK2oSAujme0+KWMYt++kV4q1O3cGDpuMtetxr1dtUbfo/YdvEx0NYwdlCS7HXAFM2FSjKN6K36VT2ECuh0SUqv6pT01OEkJewqNQbpi9hzakeMPV3int81gWXAkYEMuIE= 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=Or/x68Gt; 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="Or/x68Gt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638418; 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=x/qs4aNKvqEO+6lTRrN0KMMX6ekNLCCx7OU6VhGwFBo=; b=Or/x68GtVkpFcZeUK3l8qxBVPGxkfENjFbGcYSDdtwO7/YOsTbTnKNJGxXerjXz8LKz+Ka drok0BbLB5XOH4GQe3aWNYZkE7h5E2siyabtKSeICD+Ld8KDEp6Y574Wd7MIPv+LfcbHWg Twsh75Oej7wli1nxjmLIW11S09oxxCM= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-407-gGVgi_BePFCrwOdf0hwR4w-1; Tue, 23 Sep 2025 10:40:17 -0400 X-MC-Unique: gGVgi_BePFCrwOdf0hwR4w-1 X-Mimecast-MFC-AGG-ID: gGVgi_BePFCrwOdf0hwR4w_1758638416 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-82e5940eef8so1256195785a.1 for ; Tue, 23 Sep 2025 07:40:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638416; x=1759243216; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x/qs4aNKvqEO+6lTRrN0KMMX6ekNLCCx7OU6VhGwFBo=; b=C8jIvGmBypRQto65b8VLmX6eWqXCj8iqP6bT4mdWG+JYOc8Ki4pLx03LpADhEhvgh4 oVUvErBTG0rRSB/pXGDoDqsN8i/Vg6grJ0JRG5Q7FFGi/D7DyDHCpxry/ewC5TktzLiv oXYkjKJGcvyiACuXWCD1xrxJlahVDU721GWkW1jwKYY6CM/Zs1nsB6FuLUylzT7/JCWR DFvpo/KVje/wKpWGBalyRR8y6wOJo/qL5QUbBHeTyQzkzm0tRNp3dN712mMM0g35eF0g SOFihSes+tzhXZQBo4rwxu3RMUVdhYX/V4Ir6TzeaC4BBQIXjaqNqHW1XGPGJkx2xLGM Kw/g== X-Forwarded-Encrypted: i=1; AJvYcCXIDy6BXtsaBu33hNQqTy05k+5InXYqV6xMcRz2ShN47E/+WRxF1igrCj1WnmWODjipNASBetRlT9Mn7+8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3aZFWo2mdHnYR4ETnFk3zA1e+ja2Rt4+vD2ukAeocXpCfBIQ6 mcrWjIvNgqn6SNDRmowEVhzQxkvFus/S7QgWoHckmZUvwHUFMG9N5RipxXsBu5j4L8vkQRVKT7w GP0arfUewKif1l9uQ49JRmvjvCp6BJEL/uona+u7c2SDXrNKhxgfdoHq+Ppn7HlCh/A== X-Gm-Gg: ASbGnculUjmkfYPsBZEm2/KA3k6C+PEBSO8x4fzOOd2SnTC6bgwneBQBbiu0mhNiYJF rHzKHjVPfCUUvKfBeukNr+BA3fYAEaq5moAL0uTbDnRFsnpUJER6PadpKJasIfUyEeZuLlgGOdE GQEKNqHGopwLoxXskrloEv9o0E50nsQMFBD+IxyxNppOD4RtzbRTNJPoU/hHT1Ea+S613PU0bdB LOCdhn8+smQb4TvDdDWbyXd0FMRuq8ON2MSX8dfSUNkgnAZ9v5RZqzflnJbESD91TdZTnbKtc9T 9cO9887kqKqqM8fJwhnqz2o4sBpoJVFvTT4krLmi3YfKH77/HkPUQzZyABxdEf6BjE3Hsqkc0Zi 6ghTpdYUrZRhbKbtbNMnyfAdxeEK+M4zMwnxwo+Q= X-Received: by 2002:a05:620a:7006:b0:82e:ce61:f840 with SMTP id af79cd13be357-85177762e54mr266599885a.84.1758638415987; Tue, 23 Sep 2025 07:40:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkjrs9K+x4Mp+DvIuL0w/NCd2l+jLO7z2+XRg4C4o1bR3l4p1tNVqZ+0EwMNqqqZJaF/rzkQ== X-Received: by 2002:a05:620a:7006:b0:82e:ce61:f840 with SMTP id af79cd13be357-85177762e54mr266595085a.84.1758638415376; Tue, 23 Sep 2025 07:40:15 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:40:14 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:28 -0400 Subject: [PATCH RFC v4 09/12] clk: test: introduce test variation for sibling rate changes on a gate/mux 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: <20250923-clk-tests-docs-v4-9-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2523; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=CBq4gpUSfkFVa42LifJPSpuY6RfDWwyJToNVFFTmN1s=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubTRQMn2475bDjy/SG6e89L8/e8PjLZ6GU+LsQ+ckb NYvnbh0ZkcpC4MYF4OsmCLLklyjgojUVbb37miywMxhZQIZwsDFKQAT+ZTFyDBX2/hd7Cu292bb SsrF2cw2+h78ud5RIWZP8kZO/Y2/Dgoy/GK6OHVfkeDHO2o2Aqlnrlzlead1ULZYRPhTle2CANu PbZwA X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 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 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 0344f3f62251728e15af277ea0d143dc1f40fd94..32defaf1972c28224108c32aef1= e74796aae8bc0 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -949,6 +949,46 @@ clk_rate_change_sibling_div_mux_test_init(struct kunit= *test) return &ctx->clk_ctx; } =20 +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 =3D kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return ERR_PTR(-ENOMEM); + test->priv =3D ctx; + + ret =3D clk_init_multiple_parent_ctx(test, &ctx->child2_mux, + "parent0", 24 * HZ_PER_MHZ, + "parent1", 48 * HZ_PER_MHZ, + "child2", CLK_SET_RATE_NO_REPARENT, + &clk_multiple_parents_mux_ops); + if (ret) + return ERR_PTR(ret); + + ctx->child1.hw.init =3D CLK_HW_INIT_HW("child1", &ctx->child2_mux.parents= _ctx[0].hw, + &clk_dummy_gate_ops, CLK_SET_RATE_PARENT); + ret =3D 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 =3D clk_hw_get_clk(&ctx->child2_mux.parents_ctx[0= ].hw, NULL); + ctx->clk_ctx.child1_clk =3D clk_hw_get_clk(&ctx->child1.hw, NULL); + ctx->clk_ctx.child2_clk =3D 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); @@ -963,6 +1003,10 @@ static struct clk_test_rate_change_sibling_test_case = clk_test_rate_change_siblin .desc =3D "div_mux", .init =3D clk_rate_change_sibling_div_mux_test_init, }, + { + .desc =3D "gate_mux", + .init =3D clk_rate_change_sibling_gate_mux_test_init, + }, }; =20 KUNIT_ARRAY_PARAM_DESC(clk_test_rate_change_sibling_test_case, --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 E60EC2F0C78 for ; Tue, 23 Sep 2025 14:40: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=1758638426; cv=none; b=SjVRScnf+Su/nbKEWFChhI0nhyVY//kfsNGLf/DgPeHbDAXdEoWU2IzuolZ0/decIxK1GEmcFu87DZ28G1bpXDZvYi38fdF5UApYBAyQyKfVX+rEZMi+CHYR8hFb4iASf9Yq/eUzRg+HJX+lHi+dVeXhkAZgWwk6OseDPg7UhCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638426; c=relaxed/simple; bh=H1GPptBRUoh2w27cPKC4anGOn4jSZDc2JlW+WJNT3Wg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tmKHLs5G8H6ew09MFYz1rPbNpWg84tHbwQM3uYYo8ypyDPbp6jKDOJHF8QCVxBrZP9ZmfGiYOogtJVzAYPpYxpESnMDiKa8IA34SrVHidLr6IIACmmqtYS+zfxNdZaOiL9e3B78iyhTgWxADuvyTH/McMMwBJ9CwXBvZRE1JDkU= 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=KN0qI5VY; 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="KN0qI5VY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638424; 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=0PYeewd8MlKC92Ky0ymLghLD05PEieLt3ORobkOYxO0=; b=KN0qI5VY7XPN3iALhqc4nTb7ohliHIBuGdi6a+pxdyK5ZhAWaYEaboNYwrKcBEVvRIBDmA bR4SMxRhhOAl3GaSuZZ3itwQWYCJHKfrSBivlzDoTz33HM7snuyphrfvXsNbgySvsyKTdi f4MMzG2hWrzUDgeMMXs4Q2vwjCfEWB4= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-mSfHp44NPaWUCRUjj_BNyQ-1; Tue, 23 Sep 2025 10:40:19 -0400 X-MC-Unique: mSfHp44NPaWUCRUjj_BNyQ-1 X-Mimecast-MFC-AGG-ID: mSfHp44NPaWUCRUjj_BNyQ_1758638419 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-82968fe9e8cso1527234285a.0 for ; Tue, 23 Sep 2025 07:40:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638419; x=1759243219; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0PYeewd8MlKC92Ky0ymLghLD05PEieLt3ORobkOYxO0=; b=CFf/34BwPwyNlhASUHsRcI/gboWgwcaoGvcmbqnb/0Wlmyx2o7Ylyx2dR88RDxi/NV DGYihPh2wClsq+aj6qyMRAuk8ttCW174DcByshjtnT4QG2g7adc10SmGPlGaU5si6dh/ 2UZ5hyWJfWCB58Ox5qNzG0NeAHHroT8zJfWFjKMTuibF2GCbkRO8eVaG4frFYYgwytDy l6AXyGDs56FS/8K+5Af/yu56SNaIbQaUUCROPfcofkP0Pf0ZPVIlidxqK54YTfjKZuRf RkCqB+Ddl1RLL1IXaLdTLkFkhIVicV1dbgmJzybmfQnOkekkdDLe3BnJROseTxC4oYvy MCKQ== X-Forwarded-Encrypted: i=1; AJvYcCUUy+cV/xvoi6TsAwM6Ww9BunTIhtL94TOmWCGXLpt4YJkW0L024OY/bO8pmtEubQr1uc9mT5VlIO+/0uw=@vger.kernel.org X-Gm-Message-State: AOJu0Yyx6VQF1nyRQ+ugmFYMYPNqgdZj0NsDrz2HmrgkqixLj4OcOYkS eTWLfh6qaGab45zR65e/7CH4cK5+AVpBqsyTWeseLi6Id1hlc3lz/n3aPxxFyObLmseY4ipvFXu KQZTGb+dHJfK1sc6XnJ/IcUevkYQQ8whEB0fzLgY6Y3pqeuR3GQ7BLOUAQSIrOQgPZw== X-Gm-Gg: ASbGncuN0wh/y2fy/r0FFTWLkL+76Brxp3eXSG5vJ8Wyt+t/cSCAUaJwmRnvGvBQKcS 4rwEJpBDBZXAlMre9fR96Ynkkc+olxpXVbiUynhsf10JvLvULF7ZPV1nl/H9zkyxgRj1HQqywUp M+ro3+z7l2cSX1cDD5SzuajMsK7isowA+Dyw8nWKHaUCjADHUrPeW9VdoyenYISS96xcqoTtyqn 8kcCLgHL75p1YusvzjOaGHDtSSakW8UgP2bwDw1y0vnC6LRDPOB9Z77B7J2e/NrPsrncIFzEs0B G9tdk6GF3FHAZLy0YoEDB9+AqSFsfQ1V/L5ugGt+OKnpLGYl7a0fP2eym4E7RJBTqf8l5rTRccK Be89xr7D3I1KCFTqwAEdkVqr0TZV2i2gjRqmrmZo= X-Received: by 2002:a05:620a:198d:b0:850:77f0:3f47 with SMTP id af79cd13be357-85169115b30mr347183685a.6.1758638418778; Tue, 23 Sep 2025 07:40:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbgVS6UuxqwfuMj3mpvBhdDbNqqkvaMjz/xybyYpq+FR7zcqyCung0SHqwOTKpF22MmT0GVA== X-Received: by 2002:a05:620a:198d:b0:850:77f0:3f47 with SMTP id af79cd13be357-85169115b30mr347179385a.6.1758638418218; Tue, 23 Sep 2025 07:40:18 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:40:17 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:29 -0400 Subject: [PATCH RFC v4 10/12] clk: add support for v2 rate negotiation 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: <20250923-clk-tests-docs-v4-10-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=14850; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=H1GPptBRUoh2w27cPKC4anGOn4jSZDc2JlW+WJNT3Wg=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubTToeDv57+Q7fYVR3TerGdTWiBtJBcxc7dSVmDkn8 kTxsfvPOkpZGMS4GGTFFFmW5BoVRKSusr13R5MFZg4rE8gQBi5OAZiIGycjw6dHpxp+nrBY8eF0 iqFroEZCj5TmPQsWH70lRbM4M/4Wr2X4p11ssX6pwtaG/72/ehZHv+O2+VkxS9Xk7wfBQ0HrEmz PcAMA X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 The Common Clock Framework is expected to keep a clock=E2=80=99s rate stable after setting a new rate with: clk_set_rate(clk, NEW_RATE); Clock consumers do not know about the clock hierarchy, sibling clocks, or the type of clocks involved. However, several longstanding issues affect how rate changes propagate through the clock tree when CLK_SET_RATE_PARENT is involved, and the parent's clock rate is changed: - A clock in some cases can unknowingly change a sibling clock's rate. More details about this particular case are documented at the Link tag below. - No negotiation is done with the sibling clocks, so an inappropriate or less than ideal parent rate can be selected. An unknown subset of existing boards are unknowingly dependent on the existing behavior, so it's risky to change the way the rate negotiation logic is done in the clk core. Add support for v1 and v2 rate negotiation logic to the clk core. When a child determines that a parent rate change needs to occur when the v2 logic is used, the parent negotiates with all nodes in that part of the clk subtree and picks the first rate that's acceptable to all nodes. The v2 logic is used when the negotiate_rates clk op is defined on the parent, or current clk code. Otherwise, the existing v1 logic will be used. Additionally, the clk_v2_rate_negotiation kernel parameter is introduced to help with debugging when you suspect your board is unknowingly dependent the legacy behavior. Link: https://lore.kernel.org/linux-clk/20250528-clk-wip-v2-v2-2-0d2c2f2204= 42@redhat.com/ Signed-off-by: Brian Masney --- Documentation/admin-guide/kernel-parameters.txt | 15 +++ Documentation/driver-api/clk.rst | 3 + drivers/clk/clk.c | 143 ++++++++++++++++++++= +--- include/linux/clk-provider.h | 7 ++ include/linux/clk.h | 20 ++++ 5 files changed, 174 insertions(+), 14 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 747a55abf4946bb9efe320f0f62fdcd1560b0a71..3b8534811792165d0468616c8cb= b3b78f3591472 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -695,6 +695,21 @@ platform with proper driver support. For more information, see Documentation/driver-api/clk.rst. =20 + clk_v2_rate_negotiation + [CLK] + Use the v2 common clk rate negotiation logic. In some + cases when a child needs to change the rate of it's + parent clk, the rate of a sibling clk can be + unexpectedly changed with the v1 rate negotiation logic, + and some platforms are unknowingly dependent on this + behavior. + + This defaults to 1 where the v2 interface is used when + supported by the clk providers. If it is 0, then the v1 + interface will be used. This is useful for debugging when + you suspect your board is unknowingly dependent the + legacy behavior. + clock=3D [BUGS=3DX86-32, HW] gettimeofday clocksource override. [Deprecated] Forces specified clocksource (if available) to be used diff --git a/Documentation/driver-api/clk.rst b/Documentation/driver-api/cl= k.rst index 93bab5336dfda06069eea700d2830089bf3bce03..c46ee62ba5bd1bf0c66ca282c58= 2963b9ea55580 100644 --- a/Documentation/driver-api/clk.rst +++ b/Documentation/driver-api/clk.rst @@ -75,6 +75,9 @@ the operations defined in clk-provider.h:: void (*disable)(struct clk_hw *hw); int (*is_enabled)(struct clk_hw *hw); void (*disable_unused)(struct clk_hw *hw); + bool (*negotiate_rates)(struct clk_hw *hw, + struct clk_rate_request *req, + bool (*check_rate)(struct clk_core *, unsigned long)); unsigned long (*recalc_rate)(struct clk_hw *hw, unsigned long parent_rate); long (*round_rate)(struct clk_hw *hw, diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 018dd5a32ecbf166718da3eda851f51fdfdd2088..0cab15f0d7c3d45ff38c1d9971f= 29d95ac402d41 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -6,6 +6,7 @@ * Standard functionality for the common clock API. See Documentation/dri= ver-api/clk.rst */ =20 +#include #include #include #include @@ -92,6 +93,8 @@ struct clk_parent_map { * clk_core->rate every time the clock is reparented, = and * when we're doing the orphan -> !orphan transition. * @new_rate: New rate to be set during a rate change operation. + * @validate_rate: Temporary rate that's used when various clk nodes a= re + * negotiating a rate with the v2 rate negotiation log= ic. * @new_parent: Pointer to new parent during parent change. This is= also * used when a clk's rate is changed. * @new_child: Pointer to new child during reparenting. This is al= so @@ -130,6 +133,7 @@ struct clk_core { unsigned long rate; unsigned long req_rate; unsigned long new_rate; + unsigned long validate_rate; struct clk_core *new_parent; struct clk_core *new_child; unsigned long flags; @@ -411,6 +415,44 @@ static bool clk_core_is_enabled(struct clk_core *core) =20 /*** helper functions ***/ =20 +static bool clk_v2_rate_negotiation =3D 1; +static int __init clk_v2_rate_negotiation_setup(char *str) +{ + unsigned long enabled; + + if (!kstrtoul(str, 0, &enabled)) + clk_v2_rate_negotiation =3D enabled ? 1 : 0; + + return 1; +} +__setup("clk_v2_rate_negotiation", clk_v2_rate_negotiation_setup); + +static int clk_core_use_v2_rate_negotiation(struct clk_core *core) +{ + bool has_v2_ops =3D core->ops->negotiate_rates || + (core->parent && core->parent->ops->negotiate_rates); + + return has_v2_ops && clk_v2_rate_negotiation; +} + +void clk_enable_v1_rate_negotiation(void) +{ + clk_v2_rate_negotiation =3D false; +} +EXPORT_SYMBOL_IF_KUNIT(clk_enable_v1_rate_negotiation); + +void clk_enable_v2_rate_negotiation(void) +{ + clk_v2_rate_negotiation =3D true; +} +EXPORT_SYMBOL_IF_KUNIT(clk_enable_v2_rate_negotiation); + +int clk_use_v2_rate_negotiation(struct clk *clk) +{ + return clk_core_use_v2_rate_negotiation(clk->core); +} +EXPORT_SYMBOL_IF_KUNIT(clk_use_v2_rate_negotiation); + const char *__clk_get_name(const struct clk *clk) { return !clk ? NULL : clk->core->name; @@ -2321,7 +2363,8 @@ static int __clk_speculate_rates(struct clk_core *cor= e, } =20 static void clk_calc_subtree(struct clk_core *core, unsigned long new_rate, - struct clk_core *new_parent, u8 p_index) + struct clk_core *new_parent, u8 p_index, + struct clk_core *initiating_clk) { struct clk_core *child; =20 @@ -2334,8 +2377,66 @@ static void clk_calc_subtree(struct clk_core *core, = unsigned long new_rate, new_parent->new_child =3D core; =20 hlist_for_each_entry(child, &core->children, child_node) { - child->new_rate =3D clk_recalc(child, new_rate); - clk_calc_subtree(child, child->new_rate, NULL, 0); + if (child =3D=3D initiating_clk || !clk_core_use_v2_rate_negotiation(chi= ld)) + child->new_rate =3D clk_recalc(child, new_rate); + else + child->new_rate =3D child->rate; + + clk_calc_subtree(child, child->new_rate, NULL, 0, initiating_clk); + } +} + +static bool clk_check_rate(struct clk_core *core, unsigned long validate_r= ate) +{ + struct clk_rate_request req; + struct clk_hw *orig_parent; + struct clk_core *child; + int ret, old_flags; + + hlist_for_each_entry(child, &core->children, child_node) { + clk_core_init_rate_req(child, &req, child->new_rate); + req.best_parent_rate =3D validate_rate; + orig_parent =3D req.best_parent_hw; + + /* + * Round the existing child rate based on the new proposed + * parent rate. Don't allow the parent rate to be changed. + */ + old_flags =3D child->flags; + child->flags &=3D ~CLK_SET_RATE_PARENT; + ret =3D clk_core_determine_round_nolock(child, &req); + child->flags =3D old_flags; + + if (ret < 0) + return false; + + if (WARN_ON_ONCE(req.best_parent_rate !=3D validate_rate)) + return false; + + // FIXME - muxes not supported at the moment + if (req.best_parent_hw !=3D orig_parent) + return false; + + if (req.rate < child->new_rate || req.rate > child->new_rate) + return false; + + // Check the child's children (if present) + if (!clk_check_rate(child, req.rate)) + return false; + } + + core->validate_rate =3D validate_rate; + + return true; +} + +static void clk_accept_rate_negotiations(struct clk_core *core) +{ + struct clk_core *child; + + core->new_rate =3D core->validate_rate; + hlist_for_each_entry(child, &core->children, child_node) { + clk_accept_rate_negotiations(child); } } =20 @@ -2344,11 +2445,13 @@ static void clk_calc_subtree(struct clk_core *core,= unsigned long new_rate, * changed. */ static struct clk_core *clk_calc_new_rates(struct clk_core *core, - unsigned long rate) + unsigned long rate, + struct clk_core *initiating_clk) { struct clk_core *top =3D core; struct clk_core *old_parent, *parent; unsigned long best_parent_rate =3D 0; + bool fine_tune_rates =3D false; unsigned long new_rate; unsigned long min_rate; unsigned long max_rate; @@ -2392,7 +2495,7 @@ static struct clk_core *clk_calc_new_rates(struct clk= _core *core, return NULL; } else { /* pass-through clock with adjustable parent */ - top =3D clk_calc_new_rates(parent, rate); + top =3D clk_calc_new_rates(parent, rate, initiating_clk); new_rate =3D parent->new_rate; goto out; } @@ -2416,11 +2519,23 @@ static struct clk_core *clk_calc_new_rates(struct c= lk_core *core, } =20 if ((core->flags & CLK_SET_RATE_PARENT) && parent && - best_parent_rate !=3D parent->rate) - top =3D clk_calc_new_rates(parent, best_parent_rate); + best_parent_rate !=3D parent->rate) { + top =3D clk_calc_new_rates(parent, best_parent_rate, initiating_clk); + fine_tune_rates =3D true; + } =20 out: - clk_calc_subtree(core, new_rate, parent, p_index); + clk_calc_subtree(core, new_rate, parent, p_index, initiating_clk); + + if (fine_tune_rates && clk_core_use_v2_rate_negotiation(top)) { + struct clk_rate_request req; + + clk_core_init_rate_req(top, &req, top->new_rate); + if (!top->ops->negotiate_rates(top->hw, &req, clk_check_rate)) + return NULL; + + clk_accept_rate_negotiations(top); + } =20 return top; } @@ -2468,7 +2583,7 @@ static struct clk_core *clk_propagate_rate_change(str= uct clk_core *core, * walk down a subtree and set the new rates notifying the rate * change on the way */ -static void clk_change_rate(struct clk_core *core) +static void clk_change_rate(struct clk_core *core, struct clk_core *initia= ting_clk) { struct clk_core *child; struct hlist_node *tmp; @@ -2537,7 +2652,7 @@ static void clk_change_rate(struct clk_core *core) __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate); =20 if (core->flags & CLK_RECALC_NEW_RATES) - (void)clk_calc_new_rates(core, core->new_rate); + (void)clk_calc_new_rates(core, core->new_rate, initiating_clk); =20 /* * Use safe iteration, as change_rate can actually swap parents @@ -2547,12 +2662,12 @@ static void clk_change_rate(struct clk_core *core) /* Skip children who will be reparented to another clock */ if (child->new_parent && child->new_parent !=3D core) continue; - clk_change_rate(child); + clk_change_rate(child, initiating_clk); } =20 /* handle the new child who might not be in core->children yet */ if (core->new_child) - clk_change_rate(core->new_child); + clk_change_rate(core->new_child, initiating_clk); =20 clk_pm_runtime_put(core); } @@ -2608,7 +2723,7 @@ static int clk_core_set_rate_nolock(struct clk_core *= core, return -EBUSY; =20 /* calculate new rates and get the topmost changed clock */ - top =3D clk_calc_new_rates(core, req_rate); + top =3D clk_calc_new_rates(core, req_rate, core); if (!top) return -EINVAL; =20 @@ -2627,7 +2742,7 @@ static int clk_core_set_rate_nolock(struct clk_core *= core, } =20 /* change the rates */ - clk_change_rate(top); + clk_change_rate(top, core); =20 core->req_rate =3D req_rate; err: diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 630705a47129453c241f1b1755f2c2f2a7ed8f77..9041b17ba99ef16a01e9f4d749e= 2e4b601a94b93 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -129,6 +129,10 @@ struct clk_duty { * @restore_context: Restore the context of the clock after a restoration * of power. * + * @negotiate_rates: When a child clk requests a new rate that requires a = rate + * change from the parent, this negotiates a new parent rate that's + * acceptable to all of the children. + * * @recalc_rate: Recalculate the rate of this clock, by querying hardware.= The * parent rate is an input parameter. It is up to the caller to * ensure that the prepare_mutex is held across this call. If the @@ -242,6 +246,9 @@ struct clk_ops { void (*disable_unused)(struct clk_hw *hw); int (*save_context)(struct clk_hw *hw); void (*restore_context)(struct clk_hw *hw); + bool (*negotiate_rates)(struct clk_hw *hw, + struct clk_rate_request *req, + bool (*check_rate)(struct clk_core *, unsigned long)); unsigned long (*recalc_rate)(struct clk_hw *hw, unsigned long parent_rate); long (*round_rate)(struct clk_hw *hw, unsigned long rate, diff --git a/include/linux/clk.h b/include/linux/clk.h index b607482ca77e987b9344c38f25ebb5c8d35c1d39..e58f6c91aceaa329b4af90d3924= ee63d47ecd68c 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -91,6 +91,26 @@ struct clk_bulk_data { =20 #ifdef CONFIG_COMMON_CLK =20 +void clk_enable_v1_rate_negotiation(void); + +void clk_enable_v2_rate_negotiation(void); + +/** + * clk_use_v2_rate_negotiation - Use the v2 common clk rate negotiation lo= gic. + * In some cases when a child needs to change the rate of it's parent clk,= the + * rate of a sibling clk can be unexpectedly changed by the v1 negotiation + * logic. Some platforms are unknowingly dependent on this behavior. + * + * This function is only exported for the kunit tests, and this is not to = be + * used outside of the clk core. + * + * @clk: clock to check + * + * Returns 1 if the v2 negotiation logic is used, or 0 if the v1 negotiati= on + * logic is used. + */ +int clk_use_v2_rate_negotiation(struct clk *clk); + /** * clk_notifier_register - register a clock rate-change notifier callback * @clk: clock whose rate we are interested in --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 4CE8C30DD37 for ; Tue, 23 Sep 2025 14:40: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=1758638429; cv=none; b=Wz4rPFrnbgWKKrHpWnoSgc3bAvG5ddKnrPJunBIU9b5yyjPxO3hd3sofkqWd6mMf0qgX05b+QR9CxtYDgyMJ50fJiT3VHTuDSuiPcDcfJpbpQzG6GeG2hPCMRBe+fi+THFWJEQhx3rl4HbtHjSAnNgY+jfC+cVoXaDef1ah3pKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638429; c=relaxed/simple; bh=TiAVMMX0BhZ88QrzXHt9pRkEcv8jwTCO6wBg4capGYg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t1xT2/PFG/Di1B8DmToIY6tZTx3Gk0qBsymJV8zjTfrIwipMGXaSCNePH3y1+SiN4AIoiof6L7m28p21ydf3VwTibkolAMBYNcthgUIcj0S0xglQaiYxvkBcnyQz9N3RqWEVgVyNckRA0BEXxD5SWohX7/45GfLeSFEVAyxqJqw= 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=NgA1bzqA; 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="NgA1bzqA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638426; 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=ttJMiiiNX3mRY18NUefNDmQ3WxdD+1OalFtqeM6LpeI=; b=NgA1bzqAkvXl/4P8HRLCRyKhU7vOM0FMLWTbIAIf7RBBbe+RiGcl1607wV8hzm2/43/VxT EdwKLBvY7zjzxHJxQSApfxHHyXiv7RuSV5CLKWPZJ5+T9Z8QinrBz2iFOr98D9pjqQOOsx A8wcKrwSAzKhzW3O8qGmxiTL7dNmqos= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-352-7X5kzP9OOX6NKgOeY-PSsg-1; Tue, 23 Sep 2025 10:40:23 -0400 X-MC-Unique: 7X5kzP9OOX6NKgOeY-PSsg-1 X-Mimecast-MFC-AGG-ID: 7X5kzP9OOX6NKgOeY-PSsg_1758638422 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-8502939d0f6so251014485a.1 for ; Tue, 23 Sep 2025 07:40:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638422; x=1759243222; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ttJMiiiNX3mRY18NUefNDmQ3WxdD+1OalFtqeM6LpeI=; b=Ly0q6yWEDyn3aEeF9wp0kduuesRHCSKuGF6o0OcWSJ4gNHlOTSodIYjyjBLwImQuuN FpReyu1LLi1c0ab4UPlcItwybrTyckcx5139wEbCoPwMi7WKwcclaGqTHR4yLvMcE7mr golyZnDKFgXvtaUJCEki8h/ZZC1TFJDckDjA/PKAXPm5tDPNczKjPZII/Bw3qX0mshAB HGdHHJb9zA9mrJ4xNfMLDC2JoUQSl4P3hpVt7plOf76goUEoqYhxGCEhJy6LUnn9Xo9J Dbknz1186zBJKnp395rgKwrf9OEPCvWhwheifNT/WCtqRiSyJG5T6fvUJzDB/xNIjAdJ 9Wzg== X-Forwarded-Encrypted: i=1; AJvYcCUMj3+A6oP0BnzHEQssGkJauVmdnhjdLDknBlEb4P0uJWnKp/pxyEx9wcl32ZH8iiqMOaJBMiZIWTVX2p4=@vger.kernel.org X-Gm-Message-State: AOJu0YwfrbPpASJKN5sXMOjAaQ1RbidNJVe0A15D5fBr0qrVTdZI59Xf qPP6AQY283+I5IP4C+qtYw6Jqv/lyhwS6XMKosgGW1OGAa08HwPvKxB/8GMWHj+SpVc8Uyy+BGv lNKX9jrfxkvm0kB9D+tMKsYgANTESCl470d/9FOsX0L2njeFpiI4ly6jOvbSgll4QVQ== X-Gm-Gg: ASbGncu9JrC/Z/QjEZUienkMGnFT47HtlTl9YBEs8ZhK4KKNBlo9saP70AAMCT8lJqt zjMHN9BTbkGAXuq//QyvPlopQ/Fhoz+eeE4ltx2JiMMlZ3Uawy+o87g9EObYP0HprUKLhp8T2GB WhCU8wjZdhA9RfBGgAPZNiZBu+AVJfE/0CUMIhhg1ldafpTYMNZhIs7X9L93ud69ppR2MRbMmAd Mx89Kl5YsNE/Nc2X24QccGP9dTxxFJ59H7EICo8xI1Sb0UzSOx0JH6uFuF1lX78KBNLZMZD+tfk Mutnw0YVfDymNiFK0iICmxtjLR202vFWgezKFTOCwQ0iwJ7Oh7NPA48U+JSc7m0uBqan7Wqgo3r ZZEUr8AtJ+l9Chg1AOnMS4o3OO5pLrGQR7dV9m6c= X-Received: by 2002:a05:620a:3905:b0:84f:fa6f:8dae with SMTP id af79cd13be357-851b786ab49mr314755485a.30.1758638421511; Tue, 23 Sep 2025 07:40:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUK/M1zsnzUN9MP0pcbn4lT/oOtPlFmMyQzwG6v93P6G8aw82V54M2ccRD4QNt3HkJwTzLZQ== X-Received: by 2002:a05:620a:3905:b0:84f:fa6f:8dae with SMTP id af79cd13be357-851b786ab49mr314751885a.30.1758638421010; Tue, 23 Sep 2025 07:40:21 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:40:20 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:30 -0400 Subject: [PATCH RFC v4 11/12] clk: test: introduce negotiate_rates() op for clk_dummy and clk_dummy_div 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: <20250923-clk-tests-docs-v4-11-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2578; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=TiAVMMX0BhZ88QrzXHt9pRkEcv8jwTCO6wBg4capGYg=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubTS4dPWjtbXpB9tlnQwnJMKmrP7TWLkzU2FljPjRP +9Psz2531HKwiDGxSArpsiyJNeoICJ1le29O5osMHNYmUCGMHBxCsBE5ugx/M/qvHHrxuJr7Bse f3+m9FUgwG/XuecNl06o2Bw5xSv1aUYSI8M7hUCrhjl3p7Dq/F/LJPDL3myq7j8N3oql3yMUBCL fzGcBAA== X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 This is needed for the v2 rate negotiation code where the parent works with all of it's children to find the best suitable rate. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 32defaf1972c28224108c32aef1e74796aae8bc0..7c4d1a50a7dd0bfb66e021ba314= a9a9709813d97 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -29,6 +29,7 @@ static const struct clk_ops empty_clk_ops =3D { }; struct clk_dummy_context { struct clk_hw hw; unsigned long rate; + unsigned long negotiate_step_size; }; =20 static unsigned long clk_dummy_recalc_rate(struct clk_hw *hw, @@ -97,10 +98,31 @@ static u8 clk_dummy_single_get_parent(struct clk_hw *hw) return 0; } =20 +static bool clk_dummy_negotiate_rates(struct clk_hw *hw, + struct clk_rate_request *req, + bool (*check_rate)(struct clk_core *, unsigned long)) +{ + struct clk_dummy_context *ctx =3D + container_of(hw, struct clk_dummy_context, hw); + + if (WARN_ON_ONCE(!ctx->negotiate_step_size)) + return false; + + for (unsigned long rate =3D req->min_rate; + rate <=3D req->max_rate; + rate +=3D ctx->negotiate_step_size) { + if (check_rate(req->core, rate)) + return true; + } + + return false; +} + static const struct clk_ops clk_dummy_rate_ops =3D { .recalc_rate =3D clk_dummy_recalc_rate, .determine_rate =3D clk_dummy_determine_rate, .set_rate =3D clk_dummy_set_rate, + .negotiate_rates =3D clk_dummy_negotiate_rates, }; =20 static const struct clk_ops clk_dummy_maximize_rate_ops =3D { @@ -175,10 +197,28 @@ static int clk_dummy_div_set_rate(struct clk_hw *hw, = unsigned long rate, return 0; } =20 +static bool clk_dummy_div_negotiate_rates(struct clk_hw *hw, + struct clk_rate_request *req, + bool (*check_rate)(struct clk_core *, unsigned long)) +{ + unsigned long rate; + + for (int i =3D 0; i < BIT(CLK_DUMMY_DIV_WIDTH + 1); i++) { + rate =3D divider_recalc_rate(hw, req->best_parent_rate, i, NULL, + CLK_DIVIDER_ROUND_CLOSEST, + CLK_DUMMY_DIV_WIDTH); + if (check_rate(req->core, rate)) + return true; + } + + return false; +} + static const struct clk_ops clk_dummy_div_ops =3D { .recalc_rate =3D clk_dummy_div_recalc_rate, .determine_rate =3D clk_dummy_div_determine_rate, .set_rate =3D clk_dummy_div_set_rate, + .negotiate_rates =3D clk_dummy_div_negotiate_rates, }; =20 struct clk_dummy_gate { --=20 2.51.0 From nobody Thu Oct 2 02:05:50 2025 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 B0EEA220F2D for ; Tue, 23 Sep 2025 14:40:42 +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=1758638444; cv=none; b=lbX9+k4IrO5SpR5DsPZwtfk28MolKEopag2Iwmc8Fd+Pj6ZD9JehW/a5CqncQaZp7rXUBG7uCpRi9AmToccZlqnjIwHLtz/tyVsYDnn7CTjuGBLkmQKhEmCgOEOuOMb4p10IVEGR1aB3kt/wemP4aFBKBShMNCG23KXqHZjbzWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758638444; c=relaxed/simple; bh=D3UgrSosq/MOSn8K9Aaz+rOUHHRaOZ0z2hzHPegpLO8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oQBd83RI8CsUeSYYdGpCKjYmy+C4r5q2gwJ9oDcM43j7Ex2zwojw3/BjHG00tPFF0FVy5nTECCFv66GFxsLpFAjeNduQvkev29RRKWu0mr0lgss3imNYXXxTk9GKse7zsUwncIbiJE9K9Mg3w3DRWY/C5epwuT+Y39U8t7mat9M= 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=QfByfB1h; 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="QfByfB1h" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758638441; 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=D+erhI99JOuUzOc3CsexcHwDM2IOmUBQdfJnBT87dGw=; b=QfByfB1ht370cpNWFhSHlfjOwwOXoTbC7eYp8Nf0tbS84tBmL/pcqMX0/sVyXHmVntdSPx Pnk++ueS2XnhdjvTejdvybZfDbHph4CH2Qf2nQgPyf9j9dCf9LxHd4PMKoLuZzaIPpcNqB IaeGtzUPUiv7SbcbHH67p9YmhyI60CQ= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-iFmerer7OqaxaiEeA1KHhA-1; Tue, 23 Sep 2025 10:40:25 -0400 X-MC-Unique: iFmerer7OqaxaiEeA1KHhA-1 X-Mimecast-MFC-AGG-ID: iFmerer7OqaxaiEeA1KHhA_1758638425 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-828bd08624aso1152411685a.1 for ; Tue, 23 Sep 2025 07:40:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758638425; x=1759243225; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D+erhI99JOuUzOc3CsexcHwDM2IOmUBQdfJnBT87dGw=; b=ADvfzFOqt28e7e3Xi10NCe9fnGhb35L3+Dnqixt7ZIKZVdQfPU86gtxooIH3fYyy+X RLtkw0odxRtt1q6A+6wHhoQTftTJixszWF7iNXgEMRjKVXO4ybgX7DfDphjRsvGU2DBg 1L/AgTVbS8PYqmJq0BTDg/cH062bV0EljI9FP1aI6yIRyrJutuxoU66l3+yN/YVWJXkp Ag1Dj9o6aqJZccfk103sq+FtluQAaiL5rjvqROkRntwb2neeCornGkZlNVodD06LXjQT 3Bcv1/PXteuEMKENQD+i73n0c0OwIRor1Y+TmNhzeL4X1lKSaMFFUUj12XI0V3WuKzt1 +efQ== X-Forwarded-Encrypted: i=1; AJvYcCUIOFSKPHl1IbaAsi9ImfYe7FnSI/TmxeA1Z/v5zT5vkAZ5eHKpBo5Re2PBog6SH76HTpSGLqUbdMOes98=@vger.kernel.org X-Gm-Message-State: AOJu0YzbayepZfXCdKu0cCWPSCUTNQoybdLjJ5x37h9vGb7vM4g1MElK vErGV5vvndegktvb2eQLj+0+c36O5qzKXXN4qErZDA0kvDdTVCYGijbrZn5EMcOVItaUvQ7n24C KQL1EfRXhuTw/zP3zao7dBN0jpwiM36QkRwwSmj75i9fcHQWiP/UAx0XgWwLLBBGEiQ== X-Gm-Gg: ASbGncsLrQ8ltEfsrdEg6FcTm6czASh1qsrO9a4ivSpeKiDf/9QdosjiL5LV2bfRaDG nxvdnFMxIzLKUPJxBao9tfaowPEGIrvbkRp6W6nr7OGJpWTOQZ6wy9T0UJs+gN0veBhmlklrk9L 4pbgwhlu1Wafod7GypJ/mVKmg901iqGWiii60DOKQEQI4wR2oLg3rPRJbhEZ1QHwUNMGWe9TJV+ 7bx4ylbkZu2b32FtkmrD86zuTfHkzKuZ/LR2wOe5oyAP1TsC7CyZTra0QFsmHZ5tYHC0kIl38+H aryPBXkauw7kGsInxmz2/prlNiFk4ldtw6/WveaE5ZJpfzIG4YiejbX/4h81UgY7LJxNF3pdWh4 IGH51GNbiOkSyFgK11LwzJk6Lw9M7nF2O2Jf8hoQ= X-Received: by 2002:a05:620a:d8a:b0:812:c6e3:6663 with SMTP id af79cd13be357-8516ba5c35emr303165385a.34.1758638424923; Tue, 23 Sep 2025 07:40:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7D73wHsfmP93/Sd0Q4FqlIqORkx+fAcKsqHGCJ9Fpb8lMOLSJtCsdrIjyP8S4cVr0zCMXug== X-Received: by 2002:a05:620a:d8a:b0:812:c6e3:6663 with SMTP id af79cd13be357-8516ba5c35emr303161285a.34.1758638424314; Tue, 23 Sep 2025 07:40:24 -0700 (PDT) Received: from [10.175.117.224] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id af79cd13be357-84f2f6f3c25sm230272985a.49.2025.09.23.07.40.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Sep 2025 07:40:23 -0700 (PDT) From: Brian Masney Date: Tue, 23 Sep 2025 10:39:31 -0400 Subject: [PATCH RFC v4 12/12] clk: test: update divider kunit tests for v1 and v2 rate negotiation 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: <20250923-clk-tests-docs-v4-12-9205cb3d3cba@redhat.com> References: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> In-Reply-To: <20250923-clk-tests-docs-v4-0-9205cb3d3cba@redhat.com> To: Michael Turquette , Stephen Boyd , Maxime Ripard , Jonathan Corbet , Russell King Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6302; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=D3UgrSosq/MOSn8K9Aaz+rOUHHRaOZ0z2hzHPegpLO8=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDIubTRcsnyrxlvJRTGXHzxVa+Dbvcaj9kidJs+JwOKF6 1/P33TxXkcpC4MYF4OsmCLLklyjgojUVbb37miywMxhZQIZwsDFKQATSTZm+O8bY5OYtenwxQfR EVErn77OOchw21lN/b5hqIljzKEw7hiGvzLlRe1WapwMGucS/LR6hc7F9K5R9e+csvHi7b7F4Te NWAE= X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 Update the divider kunit tests to verify that the v1 and v2 rate negotiation logic is working as expected. Signed-off-by: Brian Masney --- drivers/clk/clk_test.c | 77 ++++++++++++++++++++++++++++++++++++++--------= ---- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/drivers/clk/clk_test.c b/drivers/clk/clk_test.c index 7c4d1a50a7dd0bfb66e021ba314a9a9709813d97..87af60d0782274c9faacf7729ed= 95bf04dfd4860 100644 --- a/drivers/clk/clk_test.c +++ b/drivers/clk/clk_test.c @@ -763,6 +763,7 @@ static int clk_rate_change_sibling_div_div_test_init(st= ruct kunit *test) test->priv =3D ctx; =20 ctx->parent.hw.init =3D CLK_HW_INIT_NO_PARENT("parent", &clk_dummy_rate_o= ps, 0); + ctx->parent.negotiate_step_size =3D 1 * HZ_PER_MHZ; ctx->parent.rate =3D 24 * HZ_PER_MHZ; ret =3D clk_hw_register_kunit(test, NULL, &ctx->parent.hw); if (ret) @@ -793,6 +794,20 @@ static int clk_rate_change_sibling_div_div_test_init(s= truct kunit *test) return 0; } =20 +static int clk_rate_change_sibling_div_div_v1_test_init(struct kunit *test) +{ + clk_enable_v1_rate_negotiation(); + + return clk_rate_change_sibling_div_div_test_init(test); +} + +static int clk_rate_change_sibling_div_div_v2_test_init(struct kunit *test) +{ + clk_enable_v2_rate_negotiation(); + + return clk_rate_change_sibling_div_div_test_init(test); +} + static void clk_rate_change_sibling_div_div_test_exit(struct kunit *test) { struct clk_rate_change_sibling_div_div_context *ctx =3D test->priv; @@ -833,16 +848,21 @@ static void clk_test_rate_change_sibling_div_div_2(st= ruct kunit *test) struct clk_rate_change_sibling_div_div_context *ctx =3D test->priv; int ret; =20 - kunit_skip(test, "This needs to be fixed in the core."); - ret =3D clk_set_rate(ctx->child1_clk, 48 * HZ_PER_MHZ); KUNIT_ASSERT_EQ(test, ret, 0); =20 KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->parent_clk), 48 * HZ_PER_MHZ); KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), 48 * HZ_PER_MHZ); KUNIT_EXPECT_EQ(test, ctx->child1.div, 1); - KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_MHZ); - KUNIT_EXPECT_EQ(test, ctx->child2.div, 2); + + if (clk_use_v2_rate_negotiation(ctx->child1_clk)) { + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 24 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child2.div, 2); + } else { + // Legacy behavior in v1 logic where sibling clks are expectedly changed. + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child2.div, 1); + } } =20 /* @@ -856,19 +876,26 @@ static void clk_test_rate_change_sibling_div_div_3(st= ruct kunit *test) struct clk_rate_change_sibling_div_div_context *ctx =3D test->priv; int ret; =20 - kunit_skip(test, "This needs to be fixed in the core."); - ret =3D clk_set_rate(ctx->child1_clk, 32 * HZ_PER_MHZ); KUNIT_ASSERT_EQ(test, ret, 0); =20 ret =3D clk_set_rate(ctx->child2_clk, 48 * HZ_PER_MHZ); KUNIT_ASSERT_EQ(test, ret, 0); =20 - 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), 48 * HZ_PER_MHZ); - KUNIT_EXPECT_EQ(test, ctx->child2.div, 2); + if (clk_use_v2_rate_negotiation(ctx->child1_clk)) { + 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), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child2.div, 2); + } else { + // Legacy behavior in v1 logic where sibling clks are expectedly changed. + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->parent_clk), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child1_clk), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child1.div, 1); + KUNIT_EXPECT_EQ(test, clk_get_rate(ctx->child2_clk), 48 * HZ_PER_MHZ); + KUNIT_EXPECT_EQ(test, ctx->child2.div, 1); + } } =20 static struct kunit_case clk_rate_change_sibling_div_div_cases[] =3D { @@ -879,13 +906,25 @@ static struct kunit_case clk_rate_change_sibling_div_= div_cases[] =3D { }; =20 /* - * 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. + * Test suite with v1 rate negotiation logic 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_v1_test_suite = =3D { + .name =3D "clk-rate-change-sibling-div-div-v1", + .init =3D clk_rate_change_sibling_div_div_v1_test_init, + .exit =3D clk_rate_change_sibling_div_div_test_exit, + .test_cases =3D clk_rate_change_sibling_div_div_cases, +}; + +/* + * Test suite with v2 rate negotiation logic 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 =3D { - .name =3D "clk-rate-change-sibling-div-div", - .init =3D clk_rate_change_sibling_div_div_test_init, +static struct kunit_suite clk_rate_change_sibling_div_div_v2_test_suite = =3D { + .name =3D "clk-rate-change-sibling-div-div-v2", + .init =3D clk_rate_change_sibling_div_div_v2_test_init, .exit =3D clk_rate_change_sibling_div_div_test_exit, .test_cases =3D clk_rate_change_sibling_div_div_cases, }; @@ -4017,7 +4056,8 @@ 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_rate_change_sibling_div_div_v1_test_suite, + &clk_rate_change_sibling_div_div_v2_test_suite, &clk_rate_change_sibling_test_suite, &clk_mux_no_reparent_test_suite, &clk_mux_notifier_test_suite, @@ -4033,4 +4073,5 @@ kunit_test_suites( &clk_uncached_test_suite, ); MODULE_DESCRIPTION("Kunit tests for clk framework"); +MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); MODULE_LICENSE("GPL v2"); --=20 2.51.0