From mboxrd@z Thu Jan 1 00:00:00 1970 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 BF73337D136 for ; Wed, 8 Apr 2026 22:33:04 +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=1775687586; cv=none; b=VbzlRh6aMrdlsvPAGZ/624A9OAiD8tWpYYwd/cJfYXPvMhs+UM2XM700IlMBwLlSi+krEwk1JMkJnJvtlbg3O6XvThQy4MmmvmH6pZWb8fWgd/c6cze2Xxzhz9T+yvamuIhRmRS76mPOXLS90aUMNZCQq/h0PgG6BNJ5IRjFJ0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775687586; c=relaxed/simple; bh=9YURxhx7fNEuUVEkfz24VOFN50gBXwcF/UAJ4miyN6A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ArocJoGVXf4iEn/umbCQ7ZO0FpgXNGcZ4FWpgxXkSUtxEHfWdVyfVJDlvKHAhPR6dh6s6bSb2G3e34gIrFe47pF+Mc0EhAiuuMZa+zIbtciGNuEb1KVy204R5axAr5MoKSIQ8Ql5+tY8LvdSGBLv+sdBTYWJsGyzEXNyXX6jgpA= 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=SWZGDdit; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Yy61Zb2E; 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="SWZGDdit"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Yy61Zb2E" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775687583; 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=LtTJZ2wfNEt2cLQXV6l/PRWSpcHnG0qmiWEptUKrHmM=; b=SWZGDditYS2PxXxyQZr9syg8fRSODTtwfVz7MC74aHZr55FJpxHPCdWm81ARcWD7iMO8VP X8+jbWofsFygX9HZy8IgpAk+lo6wjHP9Aati/L5AsEkx//RkO7/OJU1wrbon/SMAx6Acqc sPbV24wNDBNgB4bK+Jjcim5SVw1TTSU= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-711-GeS1kId5PzGuLqkdrGUQYw-1; Wed, 08 Apr 2026 18:30:35 -0400 X-MC-Unique: GeS1kId5PzGuLqkdrGUQYw-1 X-Mimecast-MFC-AGG-ID: GeS1kId5PzGuLqkdrGUQYw_1775687435 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-89ebd9e1ee4so19011206d6.1 for ; Wed, 08 Apr 2026 15:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775687435; x=1776292235; darn=vger.kernel.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LtTJZ2wfNEt2cLQXV6l/PRWSpcHnG0qmiWEptUKrHmM=; b=Yy61Zb2EQApF5zUtYufiZwIB9W7M6J8nIvJExxAX58OuwACVF9X1cc8wRTU4Bjesfy L39lPqGJvckBmtcCyNycCBb1NJ2/KErogz52fi5N9ktHh0auw+7WxV/F5twRzIHMHk7D pKpzWxpFSmh91Y/vYBH8wHv9/6b1qiiKdLHTd0htSD3tUjqVPfkY24SoAREGLaVHNhrw jfZp1KNby/KRZduxWHTFo0PAV/Jd2hxQik4Oodp62XK9tzs7wVBfPFyoUs5/mhq3UzOi 3zmEtV77xpBqYsvojrl21ken2B+Yu5u5C/UKOF3cdN1GXpgLYXZg23ec/XGqSGP1zPPc aNIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775687435; x=1776292235; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LtTJZ2wfNEt2cLQXV6l/PRWSpcHnG0qmiWEptUKrHmM=; b=SjT9ooFiIsiupHI3KlJ8Qn4+XjT1LdaxYLN7Op+ZzgaXRBtTa7ziEsDYJmnFzBU8UJ Eii+T6pSLCo2zwmvThZbA+ai5x2b57brvw4SJWwLdzfi0LTOpvWLS4dO1wZwTRKjKEu3 zvSNJ5LD2p6twHMZEaSt/Cfe89rvIhxhVwms+QDQ7h20b8rQkeqHQUBoXvyRuYhxPWjv ENZ7Pm2cRcHt4MkIoD3lmX2vOdGfNrmpqteEiZe8dsZG8qgD+DaJ1FymHswQpnmpC07t diwfeY0NDEpSIZc0hrSAKy1Y+dvXj4J+hApSQFkG9DfzYl6qaI++IHMnWU9pbJtZekyY ZWOQ== X-Forwarded-Encrypted: i=1; AJvYcCUFz68eV71w7NQhRmzz/+WwPFZjQk7Kjhx+SodapUPQm2aYhwQIYmgTMR5nrzDlz+fR3DmnjSuZRQPCj70=@vger.kernel.org X-Gm-Message-State: AOJu0Ywx3dXxOXVYZ/kK4ny/9qbjKwnul+/aRz2yT27Rt1E2+GR3lU// Y8GeQirKUnRH3T7RcXGJNX01Yvjm9PC2PTefX9RSxxAEO0haQLJh1gHerJg3qQbeqL2/VgW1H0o 2eAC0s2EJBX5YK9FudcOgmy+cWhpOtoAOQ8SXzWseBPgHB5YPEsMJaQx9PveRxeJjtTXI018gtQ == X-Gm-Gg: AeBDievviPgq6oAVgtpzbYB1Q0KOdSwvyzifrmnM1UP0J5inBFC7ce5yQYgeDcBlrP0 3c5dCLQhRMDjMmzoHfHRrayd91NXWuQgHUUAuaQ5ZWbbXHCfPQ7pjgKNgNQCzj9KQgan3YwqmrL Rl1K/tz1xH0KLXDH9OKXoI635+QIe9xqqdHbtaXRkf81FJtNCVWxjZ9ED72EE3HxNr3a8Q8XQQ/ PLhTWOu+XGyBOGBQbtnq765+ecET1xg1dBTLXw3aUYwhZhfPiGYk/L6/VMqbZuG2TvJkexlEy6s ZQP0BAevCmq2zWKoYhlBVIBV0MG4qLKfJr0IbdD/doLolLdto1m7rAmJb47dXXa8MfiWV4r78hx dzBj2C+Uzkac9cWj0K5KtLiovzd8l6tNzZHbeUR1kPDTyFEh4iFKcLBV+ X-Received: by 2002:a0c:f114:0:b0:8a3:221d:9095 with SMTP id 6a1803df08f44-8ac743038b7mr23717366d6.15.1775687434743; Wed, 08 Apr 2026 15:30:34 -0700 (PDT) X-Received: by 2002:a0c:f114:0:b0:8a3:221d:9095 with SMTP id 6a1803df08f44-8ac743038b7mr23716276d6.15.1775687434158; Wed, 08 Apr 2026 15:30:34 -0700 (PDT) Received: from redhat.com (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8a59323a0dasm184620536d6.4.2026.04.08.15.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 15:30:33 -0700 (PDT) Date: Wed, 8 Apr 2026 18:30:31 -0400 From: Brian Masney To: "Thomas Richard (TI)" Cc: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Michael Turquette , Stephen Boyd , Gregory CLEMENT , richard.genoud@bootlin.com, Udit Kumar , Prasanth Mantena , Abhash Kumar , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Dhruva Gole Subject: Re: [PATCH v5 3/4] clk: keystone: sci-clk: add restore_context() operation Message-ID: References: <20260407-ti-sci-jacinto-s2r-restore-irq-v5-0-97b28f2d93f9@bootlin.com> <20260407-ti-sci-jacinto-s2r-restore-irq-v5-3-97b28f2d93f9@bootlin.com> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260407-ti-sci-jacinto-s2r-restore-irq-v5-3-97b28f2d93f9@bootlin.com> User-Agent: Mutt/2.3.0 (2026-01-25) Hi Thomas, On Tue, Apr 07, 2026 at 04:25:08PM +0200, Thomas Richard (TI) wrote: > Implement the restore_context() operation to restore the clock rate and the > clock parent state. The clock rate is saved in sci_clk struct during > set_rate() operation. The parent index is saved in sci_clk struct during > set_parent() operation. During clock registration, the core retrieves each > clock’s parent using get_parent() operation to ensure the internal clock > tree reflects the actual hardware state, including any configurations made > by the bootloader. So we also save the parent index in get_parent(). > > Reviewed-by: Dhruva Gole > Signed-off-by: Thomas Richard (TI) > --- > drivers/clk/keystone/sci-clk.c | 42 ++++++++++++++++++++++++++++++++++-------- > 1 file changed, 34 insertions(+), 8 deletions(-) > > diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c > index 9d5071223f4c..428050a05de3 100644 > --- a/drivers/clk/keystone/sci-clk.c > +++ b/drivers/clk/keystone/sci-clk.c > @@ -47,6 +47,8 @@ struct sci_clk_provider { > * @node: Link for handling clocks probed via DT > * @cached_req: Cached requested freq for determine rate calls > * @cached_res: Cached result freq for determine rate calls > + * @parent_id: Parent index for this clock > + * @rate: Clock rate > */ > struct sci_clk { > struct clk_hw hw; > @@ -58,6 +60,8 @@ struct sci_clk { > struct list_head node; > unsigned long cached_req; > unsigned long cached_res; > + u8 parent_id; > + unsigned long rate; > }; > > #define to_sci_clk(_hw) container_of(_hw, struct sci_clk, hw) > @@ -210,10 +214,16 @@ static int sci_clk_set_rate(struct clk_hw *hw, unsigned long rate, > unsigned long parent_rate) > { > struct sci_clk *clk = to_sci_clk(hw); > + int ret; > + > + ret = clk->provider->ops->set_freq(clk->provider->sci, clk->dev_id, > + clk->clk_id, rate / 10 * 9, rate, > + rate / 10 * 11); > > - return clk->provider->ops->set_freq(clk->provider->sci, clk->dev_id, > - clk->clk_id, rate / 10 * 9, rate, > - rate / 10 * 11); > + if (!ret) > + clk->rate = rate; > + > + return ret; > } Should the computed rate from sci_clk_recalc_rate() be saved as well? > > /** > @@ -237,9 +247,9 @@ static u8 sci_clk_get_parent(struct clk_hw *hw) > return 0; > } > > - parent_id = parent_id - clk->clk_id - 1; > + clk->parent_id = (u8)(parent_id - clk->clk_id - 1); > > - return (u8)parent_id; > + return clk->parent_id; > } > > /** > @@ -252,12 +262,27 @@ static u8 sci_clk_get_parent(struct clk_hw *hw) > static int sci_clk_set_parent(struct clk_hw *hw, u8 index) > { > struct sci_clk *clk = to_sci_clk(hw); > + int ret; > > clk->cached_req = 0; > > - return clk->provider->ops->set_parent(clk->provider->sci, clk->dev_id, > - clk->clk_id, > - index + 1 + clk->clk_id); > + ret = clk->provider->ops->set_parent(clk->provider->sci, clk->dev_id, > + clk->clk_id, > + index + 1 + clk->clk_id); > + if (!ret) > + clk->parent_id = index; > + > + return ret; > +} > + > +static void sci_clk_restore_context(struct clk_hw *hw) > +{ > + struct sci_clk *clk = to_sci_clk(hw); > + > + sci_clk_set_parent(hw, clk->parent_id); Are all of these clocks muxes? Brian > + > + if (clk->rate) > + sci_clk_set_rate(hw, clk->rate, 0); > } > > static const struct clk_ops sci_clk_ops = { > @@ -269,6 +294,7 @@ static const struct clk_ops sci_clk_ops = { > .set_rate = sci_clk_set_rate, > .get_parent = sci_clk_get_parent, > .set_parent = sci_clk_set_parent, > + .restore_context = sci_clk_restore_context, > }; > > /** > > -- > 2.53.0 >