public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@deeprootsystems.com>
To: Ohad Ben-Cohen <ohad@wizery.com>
Cc: "Kanigeri, Hari" <h-kanigeri2@ti.com>,
	"Basak, Partha" <p-basak2@ti.com>, "Que, Simon" <sque@ti.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"Shilimkar, Santosh" <santosh.shilimkar@ti.com>
Subject: Re: [RFC v.4] omap: hwspinlock: Added hwspinlock driver
Date: Mon, 20 Sep 2010 10:30:07 -0700	[thread overview]
Message-ID: <8762y0z5k0.fsf@deeprootsystems.com> (raw)
In-Reply-To: <AANLkTin3J6E8e5uTPoomfcpvP1+t4-Svuah3Mv6Nj1Fc@mail.gmail.com> (Ohad Ben-Cohen's message of "Sun, 19 Sep 2010 16:45:19 +0200")

Ohad Ben-Cohen <ohad@wizery.com> writes:

> Hi Hari,
>
> On Thu, Aug 12, 2010 at 12:44 AM, Kanigeri, Hari <h-kanigeri2@ti.com> wrote:
>>> > +/* Attempt to acquire a spinlock once */
>>> > +int hwspinlock_trylock(struct hwspinlock *handle)
>>> > +{
>>> > +       int retval = 0;
>>> > +
>>> > +       if (WARN_ON(handle == NULL))
>>> > +               return -EINVAL;
>>> > +
>>> > +       if (WARN_ON(in_irq()))
>>> > +               return -EPERM;
>>> > +
>>> > +       if (pm_runtime_get(&handle->pdev->dev) < 0)
>>> > +               return -ENODEV;
>>> > +
>>> > +       /* Attempt to acquire the lock by reading from it */
>>> > +       retval = readl(handle->lock_reg);
>>> > +
>>> > +       if (retval == HWSPINLOCK_BUSY)
>>> > +               pm_runtime_put(&handle->pdev->dev);
>>> Any reason for using pm_runtime_put instead of pm_runtime_put_sync?
>>>
>>> Using pm_runtime_gett_sync & pm_runtime_put_sync have been recommended by
>>> Kevin Hilman.
>>
>> Actually is there a need to call pm_runtime_put_sync for hwspinlock ? Spinlocks are used by the co-processors and we have to ensure that the device doesn't enter some low power mode without the knowledge of Co-processor. I don't think run time PM is needed for hwspinlock.
>>
>> Just doing pm_runtime_get_sync at probe time for all the spinlock instances should be good.
>
>
> It would probably make more sense to call pm_runtime_get_sync during
> hwspinlock_request{_specific}, and then call pm_runtime_put during
> hwspinlock_free.
>
> This way the runtime PM's usage_count will reflect the number of locks
> that are actually used, and if that number drops to (or never go
> beyond) zero, it is desirable to have the hwspinlock's clock disabled.
>
> This is also safe since no other core will use the hwspinlock if it
> wasn't requested by the MPU beforehand (and if it does, we better know
> about it and fix it).

FWIW, I agree with Ohad.

An additional benefit of using runtime PM is that the runtime PM core is
growing some useful debug and statistics features so that userspace
tools (including newer versions of powertop) can present useful stats
about which devices are active and how often etc.

Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-09-20 17:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-06 20:25 [RFC v.4] omap: hwspinlock: Added hwspinlock driver Que, Simon
2010-07-07  5:34 ` Shilimkar, Santosh
2010-08-10 15:19 ` Basak, Partha
2010-08-11 22:44   ` Kanigeri, Hari
2010-09-19 14:45     ` Ohad Ben-Cohen
2010-09-20 17:30       ` Kevin Hilman [this message]
2010-09-21  7:19         ` Cousson, Benoit
2010-09-22 15:10       ` Kanigeri, Hari
2010-08-12 14:11   ` Kevin Hilman

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=8762y0z5k0.fsf@deeprootsystems.com \
    --to=khilman@deeprootsystems.com \
    --cc=h-kanigeri2@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=p-basak2@ti.com \
    --cc=santosh.shilimkar@ti.com \
    --cc=sque@ti.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