All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk@arm.linux.org.uk>
To: "C.A, Subramaniam" <subramaniam.ca@ti.com>
Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"tony@atomide.com" <tony@atomide.com>,
	"Hiroshi.DOYU@nokia.com" <Hiroshi.DOYU@nokia.com>,
	"Kanigeri, Hari" <h-kanigeri2@ti.com>,
	"Gupta, Ramesh" <grgupta@ti.com>
Subject: Re: [PATCH 8/10] omap mailbox: OMAP4-Mailbox - Adds code changes to support OMAP4 mailbox.
Date: Mon, 7 Sep 2009 16:05:20 +0100	[thread overview]
Message-ID: <20090907150520.GC6538@flint.arm.linux.org.uk> (raw)
In-Reply-To: <B85A65D85D7EB246BE421B3FB0FBB59301DD6108F2@dbde02.ent.ti.com>

On Fri, Sep 04, 2009 at 05:18:11PM +0530, C.A, Subramaniam wrote:
> @@ -70,31 +89,37 @@ static inline void mbox_write_reg(u32 val, size_t ofs)
>  static int omap2_mbox_startup(struct omap_mbox *mbox)
>  {
>  	unsigned int l;
> +	if (!mbox_configured) {
> +		mbox_ick_handle = clk_get(NULL, "mailboxes_ick");
> +		if (IS_ERR(mbox_ick_handle)) {
> +			printk(KERN_ERR "Could not get mailboxes_ick\n");
> +			return -ENODEV;
> +		}
> +		clk_enable(mbox_ick_handle);
>  
> -	mbox_ick_handle = clk_get(NULL, "mailboxes_ick");
> -	if (IS_ERR(mbox_ick_handle)) {
> -		printk("Could not get mailboxes_ick\n");
> -		return -ENODEV;
> -	}
> -	clk_enable(mbox_ick_handle);
> -
> -	l = mbox_read_reg(MAILBOX_REVISION);
> -	pr_info("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f));
> -
> -	/* set smart-idle & autoidle */
> -	l = mbox_read_reg(MAILBOX_SYSCONFIG);
> -	l |= 0x00000011;
> -	mbox_write_reg(l, MAILBOX_SYSCONFIG);
> +		l = mbox_read_reg(MAILBOX_REVISION);
> +		pr_info("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4,
> +							(l & 0x0f));
>  
> +		/* set smart-idle & autoidle */
> +		l = mbox_read_reg(MAILBOX_SYSCONFIG);
> +		l |= 0x00000011;
> +		mbox_write_reg(l, MAILBOX_SYSCONFIG);
> +	}
> +	mbox_configured++;

I assume you're doing this because this function can be called multiple
times.  What protects this against races?

>  	omap2_mbox_enable_irq(mbox, IRQ_RX);
>  
>  	return 0;
>  }
>  
>  static void omap2_mbox_shutdown(struct omap_mbox *mbox)
> -{
> -	clk_disable(mbox_ick_handle);
> -	clk_put(mbox_ick_handle);
> +{	if (mbox_configured > 0)
> +		mbox_configured--;
> +		if (!mbox_configured) {
> +			clk_disable(mbox_ick_handle);
> +			clk_put(mbox_ick_handle);
> +			mbox_ick_handle = NULL;
> +		}

Same concern - what protects mbox_configured and the associated code against
races?

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:

  parent reply	other threads:[~2009-09-07 15:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-04 11:48 [PATCH 8/10] omap mailbox: OMAP4-Mailbox - Adds code changes to support OMAP4 mailbox C.A, Subramaniam
2009-09-07  8:25 ` Hiroshi DOYU
2009-09-07 15:05 ` Russell King [this message]
2009-09-07 15:12   ` C.A, Subramaniam
  -- strict thread matches above, loose matches on Subject: below --
2009-09-22 14:33 C.A, Subramaniam
2009-09-22 15:11 ` Hiroshi DOYU
2009-09-22 17:48   ` Tony Lindgren
2009-09-23  9:56 ` Russell King
2009-09-24 15:01   ` C.A, Subramaniam
2009-11-13 12:34 C.A, Subramaniam
2009-11-14  0:45 ` Tony Lindgren
2009-11-17 13:08   ` C.A, Subramaniam

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=20090907150520.GC6538@flint.arm.linux.org.uk \
    --to=rmk@arm.linux.org.uk \
    --cc=Hiroshi.DOYU@nokia.com \
    --cc=grgupta@ti.com \
    --cc=h-kanigeri2@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=subramaniam.ca@ti.com \
    --cc=tony@atomide.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.