Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp492312pxb; Wed, 27 Oct 2021 06:55:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz64IriIdl6VVN4v+gSPcjlXDhsRKLyG2ijoq4rOkn8kgSFxtGE6gKZ3HFw3NLpRMHcvHtE X-Received: by 2002:aa7:8652:0:b0:47b:e2f1:96e1 with SMTP id a18-20020aa78652000000b0047be2f196e1mr24921585pfo.74.1635342905525; Wed, 27 Oct 2021 06:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635342905; cv=none; d=google.com; s=arc-20160816; b=EChRy1mK15RWnC8Lns4Op9CqOQlQhv3/dZG85/cOeWSFloVvLqkLyouuTj1yOoABdg 0z3xxaOj2N2V1Lv2MHJnY9k8hmHHqeqlq1RdAGP62CbL/Ua1I08L8gCVB4SsA3PQnpa8 6EgM0jg+2GbzXnnM6B7ONnTBV0mrWVsE/HWoriCAixu7YQd6mMAN4sAfWVcaAtvpsuH8 PQ/VOjZu4fCQFDRquvM025/ZoxUKwT1pCXOMo3iTIXexfRryeLIUcMjYR3OurVMTMb7w sSmxGRUrwfSzlfL3NBH/kh5UIx/6z+gGHag7WEqHu88qxY+JM7BcHSEXcYCHS2q8Icux WkSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:date:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=LgM7Kysji5pnOEwG+S650R33O0cEBVKst2YFnjctVNQ=; b=t5wVnVnOh0GGA15wR+3EdPgibs2p8YrRFqhKiEIgh8+mvCjM/V5DgFJULTcD4aK8ki h2ew52kRSDatpticujiZ35MuzYDldFZZsZoK3deGnIJiRm8Zat1e6X22vitd/4LvDvQx zbdeLsB+xjWby65euzWTWpmGc+z3LPgnSAaV+mWwCJ5DITtkVaiFgrJ7SSRVzgnpTk4B TBrHmYBL8PW+Pu++VGaFvUrQath68Yc9YDsa2jGLo06l1UEl+fI/JZZNEREziUscVOZv 8Bn0nlE9Xpz2XKSH4au6NGCLhtqnwRppAlpSNrIHmnAiVrRcmYsCKOg6uTMKIJhGU18L /L8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W+ESkAeC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si36456pji.85.2021.10.27.06.54.53; Wed, 27 Oct 2021 06:55:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W+ESkAeC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236037AbhJ0A4b (ORCPT + 99 others); Tue, 26 Oct 2021 20:56:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:47760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232410AbhJ0A4a (ORCPT ); Tue, 26 Oct 2021 20:56:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 560CA60F0F; Wed, 27 Oct 2021 00:54:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635296045; bh=3wmPlMfs7SR783XTmRV7cR81LzMiYBMO+8TaAiydWkM=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=W+ESkAeCUUskZxyaPVVNJSQLz8HBAG1zufvbuDBBq9aLfbxvCgVHNRyEwDhpCaD0u oHHGrJIuVMsKaMJN660eES9zVI6ZuTGSw+QtEXO/3kNu3VZXMRhFWVZUkOOWNHimJi zwKtwSFHkDdtmvJke91XPGHWmVbRSdg9eDy3e7anPX0kaH9xI3vYQEjDhTb1at4OTz xu10tcE+mm6SIX4xTkKFgEdkljbuOldIgZu8uNAgyjBJvV4HzMV/nHGOmgwlG26lFQ f/aBZYM0FGmjzdEFKrU813jTsN8gcKRjB95RH2fdQDNMon7HF1UI4ATU4wQRmWG34j k9u9vXzRpknvA== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <20211021174223.43310-1-kernel@esmil.dk> <20211021174223.43310-7-kernel@esmil.dk> <163527959276.15791.14765586510805526101@swboyd.mtv.corp.google.com> Subject: Re: [PATCH v2 06/16] clk: starfive: Add JH7100 clock generator driver From: Stephen Boyd Cc: , linux-clk , , linux-riscv , , Geert Uytterhoeven , Palmer Dabbelt , Paul Walmsley , Rob Herring , Michael Turquette , Thomas Gleixner , Marc Zyngier , Philipp Zabel , Linus Walleij , Greg Kroah-Hartman , Daniel Lezcano , Andy Shevchenko , Jiri Slaby , Maximilian Luz , Sagar Kadam , Drew Fustini , Michael Zhu , Fu Wei , Anup Patel , Atish Patra , Matteo Croce , Linux Kernel Mailing List To: Emil Renner Berthing Date: Tue, 26 Oct 2021 17:54:03 -0700 Message-ID: <163529604399.15791.378104318036812951@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Emil Renner Berthing (2021-10-26 15:35:36) > On Tue, 26 Oct 2021 at 22:20, Stephen Boyd 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? >=20 > Yes, sorry. >=20 > > Do different clks share the same registers? >=20 > 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". >=20 > > > + return ERR_PTR(-EINVAL); > > > + } > > > + > > > + if (idx >=3D 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. >=20 > 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. >=20 > 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. >=20 > > > + > > > + clk->hw.init =3D &init; > > > + clk->idx =3D idx; > > > + clk->max =3D jh7100_clk_data[idx].max; > > > + > > > + ret =3D clk_hw_register(priv->dev, &clk->hw); > > > > Why not use devm_clk_hw_register()? >=20 > 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 >=20 > > > + if (ret) > > > + goto err; > > > + } > > > + > > > + ret =3D devm_of_clk_add_hw_provider(priv->dev, clk_starfive_j= h7100_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[] =3D { > > > + { .compatible =3D "starfive,jh7100-clkgen" }, > > > + { /* sentinel */ } > > > +}; > > > > Please add MODULE_DEVICE_TABLE() >=20 > Will do! If it's never going to be a module then don't add any module_* things.