linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/8] clk: mxs: add clock support for imx28
Date: Wed, 25 Apr 2012 10:05:37 +0200	[thread overview]
Message-ID: <20120425080537.GB3852@pengutronix.de> (raw)
In-Reply-To: <20120425080244.GA1503@S2100-06.ap.freescale.net>

On Wed, Apr 25, 2012 at 04:02:45PM +0800, Shawn Guo wrote:
> On Wed, Apr 25, 2012 at 09:17:47AM +0200, Sascha Hauer wrote:
> > Hi Shawn,
> > 
> > I realized that you have no register lock which means that you rely on
> > the locking of the clock framework. This may not be sufficient, see the
> > following example:
> > 
> > > +	mxs_clk_div("ssp0_div", "ssp0_sel", SSP0, 0, 9, 29);
> > > +	clk = mxs_clk_gate("ssp0", "ssp0_div", SSP0, 31);
> > 
> > You have both a divider and a gate in the same register here. The gate
> > implements clk_enable which is protected by a spinlock in the clock
> > framework. The divider implements clk_set_rate which is protected by a
> > mutex in the clock framework. This means that during a read-modify-write
> > operation for a rate change the clk_enable call can come in between.
> 
> We have SET and CLR register on mxs clocks, so do not really have to
> go through read-modify-write sequence.

You have the SET and CLR registers but you don't use them. You could use
SET/CLR in the gate, but even then:

- clk_set_rate starts and reads the divider register
- clk_enable comes in and writes to SET/CLR for the same register
- clk_set_rate continues and writes to the divider register not knowing
  that it has been modified in between.

You could try and clear all divider bits in the divider using the CLR
register and then set the wanted bits using the SET register, but this
would mean writing reserved values to the divider in between.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2012-04-25  8:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-21 15:57 [PATCH 0/8] common clk support for mxs Shawn Guo
2012-04-21 15:57 ` [PATCH 1/8] clk: mxs: add mxs specific clocks Shawn Guo
2012-04-21 15:57 ` [PATCH 2/8] clk: mxs: add clock support for imx23 Shawn Guo
2012-04-23 23:07   ` Turquette, Mike
2012-04-23 23:51     ` Shawn Guo
2012-04-23 23:59       ` Turquette, Mike
2012-04-24  1:10         ` Shawn Guo
2012-04-24  1:16           ` Turquette, Mike
2012-04-24  7:28             ` Shawn Guo
2012-04-21 15:57 ` [PATCH 3/8] clk: mxs: add clock support for imx28 Shawn Guo
2012-04-23 23:22   ` Turquette, Mike
2012-04-25  7:17   ` Sascha Hauer
2012-04-25  8:02     ` Shawn Guo
2012-04-25  8:05       ` Sascha Hauer [this message]
2012-04-25  8:48         ` Shawn Guo
2012-04-21 15:57 ` [PATCH 4/8] ARM: mxs: request clock for timer Shawn Guo
2012-04-21 15:57 ` [PATCH 5/8] ARM: mxs: change the lookup name for fec phy clock Shawn Guo
2012-04-21 15:57 ` [PATCH 6/8] ARM: mxs: switch to common clk framework Shawn Guo
2012-04-21 15:57 ` [PATCH 7/8] ARM: mxs: remove old clock support Shawn Guo
2012-04-21 15:57 ` [PATCH 8/8] ARM: mxs: remove now unused timer_clk argument from mxs_timer_init Shawn Guo
2012-04-23 23:40 ` [PATCH 0/8] common clk support for mxs Turquette, Mike
2012-04-23 23:54   ` Shawn Guo

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=20120425080537.GB3852@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).