Re: [PATCH v6 3/3] clk: tenstorrent: Add Atlantis clock controller driver

From: Brian Masney

Date: Tue Feb 17 2026 - 19:35:24 EST


On Tue, Feb 17, 2026 at 05:29:56PM -0600, Anirudh Srinivasan wrote:
> Hi Brian,
>
> On Tue, Feb 17, 2026 at 5:22 PM Brian Masney <bmasney@xxxxxxxxxx> wrote:
> > >
> > > We have a group of gate clocks that have a single enable bit shared
> > > among them (instead of individual enable bits for each clock). We need
> > > to keep track of the number of clocks within a group that have
> > > requested an enable, and only unset the bit if all the clocks are
> > > disabled. share_count is used to keep track of this. It gets updated
> > > by each clock. Hence it's a pointer (and the mutexes around access to
> > > it).
> >
> > The code currently has:
> >
> > struct atlantis_clk_gate_shared_config {
> > ...
> > unsigned int *share_count;
> > }
> >
> > That pointer is dereferenced like this in several places:
> >
> > need_enable = (*gate->config.share_count)++ == 0;
> >
> > I don't see why the pointer is needed. Can you drop the pointer
> > and the dereference like this?
> >
> > struct atlantis_clk_gate_shared_config {
> > ...
> > unsigned int share_count;
> > }
> >
> > need_enable = gate->config.share_count++ == 0;
> >
>
> In this case, wouldn't each atlantis_clk_gate_shared end up getting
> its own copy of share_count? Which is not what we want. Or maybe I'm
> not quite understanding what you're saying.
>
> Every time we create a group of these shared gate clks, we create a
> refcnt variable like this and pass the var to all clks that share it.

OK, I see now. Thanks for the explanation.

Brian