[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <163529604399.15791.378104318036812951@swboyd.mtv.corp.google.com>
Date: Tue, 26 Oct 2021 17:54:03 -0700
From: Stephen Boyd <sboyd@...nel.org>
To: Emil Renner Berthing <kernel@...il.dk>
Cc: <devicetree@...r.kernel.org>,
linux-clk <linux-clk@...r.kernel.org>,
<linux-gpio@...r.kernel.org>,
linux-riscv <linux-riscv@...ts.infradead.org>,
<linux-serial@...r.kernel.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Palmer Dabbelt <palmer@...belt.com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Rob Herring <robh+dt@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Thomas Gleixner <tglx@...utronix.de>,
Marc Zyngier <maz@...nel.org>,
Philipp Zabel <p.zabel@...gutronix.de>,
Linus Walleij <linus.walleij@...aro.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Jiri Slaby <jirislaby@...nel.org>,
Maximilian Luz <luzmaximilian@...il.com>,
Sagar Kadam <sagar.kadam@...ive.com>,
Drew Fustini <drew@...gleboard.org>,
Michael Zhu <michael.zhu@...rfivetech.com>,
Fu Wei <tekkamanninja@...il.com>,
Anup Patel <anup.patel@....com>,
Atish Patra <atish.patra@....com>,
Matteo Croce <mcroce@...rosoft.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 06/16] clk: starfive: Add JH7100 clock generator driver
Quoting Emil Renner Berthing (2021-10-26 15:35:36)
> On Tue, 26 Oct 2021 at 22:20, Stephen Boyd <sboyd@...nel.org> wrote:
> > Quoting Emil Renner Berthing (2021-10-21 10:42:13)
> > > +};
> > > +
> > > +struct clk_starfive_jh7100_priv {
> > > + /* protect registers against overlapping read-modify-write */
> > > + spinlock_t rmw_lock;
> >
> > Does overlapping mean concurrent?
>
> Yes, sorry.
>
> > Do different clks share the same registers?
>
> No, each clock has their own register, but they use that register both
> to gate the clock and other configuration. The Locking chapter of
> Documentation/driver-api/clk.rst talks about the prepare lock and the
> enable lock and then says:
> "However, access to resources that are shared between operations of
> the two groups needs to be protected by the drivers. An example of
> such a resource would be a register that controls both the clock rate
> and the clock enable/disable state."
Alright got it. Maybe say "protect clk enable and set rate from
happening at the same time".
>
> > > + return ERR_PTR(-EINVAL);
> > > + }
> > > +
> > > + if (idx >= JH7100_CLK_PLL0_OUT)
> > > + return priv->pll[idx - JH7100_CLK_PLL0_OUT];
> > > +
> > > + return &priv->reg[idx].hw;
> > > +}
> > > +
> > > +static int __init clk_starfive_jh7100_probe(struct platform_device *pdev)
> >
> > Drop __init as this can be called after kernel init is over.
>
> Oh interesting, I'd like to know when that can happen. The comment for
> the builtin_platform_driver macro says it's just a wrapper for
I thought this was using module_platform_driver() macro?
> device_initcall.
>
> Won't we then need to remove all the __initconst tags too since the
> probe function walks through jh7100_clk_data which eventually
> references all __initconst data?
Yes. If it's builtin_platform_driver() it can't be a module/tristate
Kconfig, in which case all the init markings can stay.
>
> > > +
> > > + clk->hw.init = &init;
> > > + clk->idx = idx;
> > > + clk->max = jh7100_clk_data[idx].max;
> > > +
> > > + ret = clk_hw_register(priv->dev, &clk->hw);
> >
> > Why not use devm_clk_hw_register()?
>
> I probably could. Just for my understanding that's just to avoid the
> loop on error below, because as a builtin driver the device won't
> otherwise go away, right?
Yes
>
> > > + if (ret)
> > > + goto err;
> > > + }
> > > +
> > > + ret = devm_of_clk_add_hw_provider(priv->dev, clk_starfive_jh7100_get, priv);
> > > + if (ret)
> > > + goto err;
> > > +
> > > + return 0;
> > > +err:
> > > + while (idx)
> > > + clk_hw_unregister(&priv->reg[--idx].hw);
> > > + return ret;
> > > +}
> > > +
> > > +static const struct of_device_id clk_starfive_jh7100_match[] = {
> > > + { .compatible = "starfive,jh7100-clkgen" },
> > > + { /* sentinel */ }
> > > +};
> >
> > Please add MODULE_DEVICE_TABLE()
>
> Will do!
If it's never going to be a module then don't add any module_* things.
Powered by blists - more mailing lists