Linux clock framework development
 help / color / mirror / Atom feed
From: Brian Masney <masneyb@kernel.org>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Stephen Boyd <sboyd@kernel.org>,
	Brian Masney <bmasney+clk@redhat.com>,
	Jerome Brunet <jbrunet+clk@baylibre.com>,
	linux-clk@vger.kernel.org
Subject: Re: [PATCH v8 2/2] clk: en7523: add support for .set_rate for en7581
Date: Sun, 29 Nov 2026 19:22:24 -0500	[thread overview]
Message-ID: <awzBwNv7LQDoGgol@x1g10> (raw)
In-Reply-To: <6b0cc0a2.202ed97a.2b44d3.211f@mx.google.com>

On Mon, Nov 30, 2026 at 01:17:36AM +0100, Christian Marangi wrote:
> On Sun, Nov 29, 2026 at 07:10:36PM -0500, Brian Masney wrote:
> > Is there a case where the register can be 0? Should there be this entry
> > as well?
> > 
> > 	{ .val = 0, .div = 1 }
> >
> 
> BUS is special. val 0 is invalid and rejected by the HW. This was already
> handled by the pre-div-api implementation.

OK makes sense. Thanks for confirming.

> > >  static int en7523_pci_is_enabled(struct clk_hw *hw)
> > > @@ -710,10 +775,18 @@ static void en7523_register_clocks(struct device *dev, struct clk_hw_onecell_dat
> > >  		const struct en_clk_desc *desc = &en7523_base_clks[i];
> > >  		u32 reg = desc->div_reg ? desc->div_reg : desc->base_reg;
> > >  		u32 val = readl(base + desc->base_reg);
> > > +		u32 div;
> > >  
> > >  		rate = en7523_get_base_rate(desc, val);
> > > +
> > >  		val = readl(base + reg);
> > > -		rate /= en7523_get_div(desc, val);
> > > +		if (desc->div_bits) {
> > > +			div = en7523_get_div(desc, val);
> > > +			if (!div)
> > > +				continue;
> > 
> > Should there be some kind of log message here?
> > 
> 
> dbg or err?

Since this is called in the setup via probe, dev_err.

> > > +static void en7581_find_best_rate(struct clk_hw *hw,
> > > +				  struct clk_rate_request *req,
> > > +				  const struct en_clk_desc *desc,
> > > +				  unsigned long parent_rate,
> > > +				  unsigned long requested_rate,
> > > +				  unsigned long *best_diff)
> > > +{
> > > +	struct clk_rate_request div_req = *req;
> > > +	int ret;
> > > +
> > > +	if (!desc->div_bits) {
> > > +		en7581_update_best_rate(req, requested_rate, parent_rate,
> > > +					best_diff);
> > > +		return;
> > > +	}
> > > +
> > > +	/* Treat each internal base rate as a fixed parent for the divider. */
> > > +	div_req.rate = clamp(requested_rate, req->min_rate, req->max_rate);
> > > +	div_req.rate = min(div_req.rate, parent_rate);
> > 
> > The min() here shouldn't be needed. When rate >= parent_rate, the
> > smallest table divider is returned.
> > 
> > Also just a heads up that I posted a guidelines file for the Common Clk
> > Subsystem to the review prompts repo. It's not merged as of this
> > writing, but Sashiko will start using this once it's merged. You can
> > download the clk.md file and point your favorite $AI_AGENT at this
> > review file before posting your next version.
> > 
> > https://github.com/masoncl/review-prompts/pull/123
> > 
> 
> This was something that sashiko pointed out... the min is needed to prevent
> a div by zero. The previous revision pointed out this.

OK that's fine. It's harmless.

> Since you requested these changes, I should merge these changes with the
> 7583 series correct?

Yes please since it depends on the set_rate() changes.

Brian

  reply	other threads:[~2026-11-30  0:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 21:59 [PATCH v8 0/2] clk: en7523: full clk_hw + set_rate for en7581 Christian Marangi
2026-11-21 21:59 ` [PATCH v8 1/2] clk: en7523: convert to full clk_hw implementation " Christian Marangi
2026-11-30  0:10   ` Brian Masney
2026-11-21 21:59 ` [PATCH v8 2/2] clk: en7523: add support for .set_rate " Christian Marangi
2026-11-30  0:10   ` Brian Masney
2026-11-30  0:17     ` Christian Marangi
2026-11-30  0:22       ` Brian Masney [this message]
2026-11-24 22:44 ` [PATCH v8 0/2] clk: en7523: full clk_hw + set_rate " Christian Marangi (Ansuel)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awzBwNv7LQDoGgol@x1g10 \
    --to=masneyb@kernel.org \
    --cc=ansuelsmth@gmail.com \
    --cc=bmasney+clk@redhat.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox