linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Burton <paulburton@kernel.org>
To: Paul Cercueil <paul@crapouillou.net>, Zhou Yanjie <zhouyanjie@zoho.com>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	robh+dt@kernel.org, paul.burton@mips.com,
	mturquette@baylibre.com, sboyd@kernel.org, mark.rutland@arm.com,
	syq@debian.org, sernia.zhou@foxmail.com, zhenwenjin@gmail.com
Subject: Re: [PATCH 1/5] clk: Ingenic: Adjust code to make it compatible with X1830.
Date: Tue, 10 Dec 2019 14:55:03 -0800	[thread overview]
Message-ID: <20191210225503.nf77ksu2sznngbp2@lantea.localdomain> (raw)
In-Reply-To: <1575026622.3.2@crapouillou.net>

Hi Paul, Zhou,

On Fri, Nov 29, 2019 at 12:23:42PM +0100, Paul Cercueil wrote:
> > > > @@ -93,8 +93,17 @@ ingenic_pll_recalc_rate(struct clk_hw *hw,
> > > > \x7f\x7funsigned long parent_rate)
> > > >      n += pll_info->n_offset;
> > > >      od_enc = ctl >> pll_info->od_shift;
> > > >      od_enc &= GENMASK(pll_info->od_bits - 1, 0);
> > > > -    bypass = !pll_info->no_bypass_bit &&
> > > > -         !!(ctl & BIT(pll_info->bypass_bit));
> > > > +
> > > > +    if (pll_info->version >= CGU_X1830) {
> > > > +        spin_lock_irqsave(&cgu->lock, flags);
> > > > +        ctl = readl(cgu->base + pll_info->reg[0]);
> > > > +        spin_unlock_irqrestore(&cgu->lock, flags);
> > > 
> > > Why the spinlock?
> > > 
> > 
> > The original code used spinlock when reading the control register,
> > so when reading this new control register, I think it should also
> > be added with spinlock.
> 
> Well, the original code looks wrong to me. There's nothing to protect here.
> 
> Maybe @Paul Burton can shed some light?

I wish I could remember, but I agree it seems pointless here. The only
way I can think it could be of any use is if writes to the CGU register
we're accessing aren't atomic (ie. if we could observe a partially
completed write), but I don't believe that's the case.

So Zhou, if you want to drop the spinlock here from your X1830 path &
ideally also add a patch to remove it in the non-X1830 path that would
be great.

Thanks,
    Paul

  reply	other threads:[~2019-12-10 22:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27  3:32 clk: Ingenic: Add support for the X1830 and add USB clk for X1000 Zhou Yanjie
2019-11-27  3:32 ` [PATCH 1/5] clk: Ingenic: Adjust code to make it compatible with X1830 Zhou Yanjie
2019-11-27 17:37   ` Paul Cercueil
2019-11-28  6:29     ` Zhou Yanjie
2019-11-29 11:23       ` Paul Cercueil
2019-12-10 22:55         ` Paul Burton [this message]
2019-11-27  3:32 ` [PATCH 2/5] dt-bindings: clock: Add X1830 bindings Zhou Yanjie
2019-12-05 20:38   ` Rob Herring
2019-11-27  3:32 ` [PATCH 3/5] clk: Ingenic: Add CGU driver for X1830 Zhou Yanjie
2019-11-27  3:32 ` [PATCH 4/5] dt-bindings: clock: Add USB OTG clock for X1000 Zhou Yanjie
2019-11-27 17:19   ` Paul Cercueil
2019-11-28  5:44     ` Zhou Yanjie
2019-11-27  3:32 ` [PATCH 5/5] clk: Ingenic: " Zhou Yanjie

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=20191210225503.nf77ksu2sznngbp2@lantea.localdomain \
    --to=paulburton@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=paul.burton@mips.com \
    --cc=paul@crapouillou.net \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=sernia.zhou@foxmail.com \
    --cc=syq@debian.org \
    --cc=zhenwenjin@gmail.com \
    --cc=zhouyanjie@zoho.com \
    /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;
as well as URLs for NNTP newsgroup(s).