From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Chris Wilson <chris@chris-wilson.co.uk>,
"Mateo Lozano, Oscar" <oscar.mateo@intel.com>,
intel-gfx <intel-gfx@lists.freedesktop.org>,
Greg KH <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [Intel-gfx] [PATCH 45/53] drm/i915/bdw: Do not call intel_runtime_pm_get() in an interrupt
Date: Sun, 10 Aug 2014 03:55:34 +0200 [thread overview]
Message-ID: <1766626.v17BJSfQ4M@vostro.rjw.lan> (raw)
In-Reply-To: <CAKMK7uH8MU5awyVDLNi8h-+yrrSRW8JjV20aMZwXZ9Yw9XDZgA@mail.gmail.com>
On Saturday, August 09, 2014 10:53:03 AM Daniel Vetter wrote:
> On Sat, Aug 9, 2014 at 3:21 AM, Alan Stern <stern@rowland.harvard.edu> wrote:
> > On Sat, 9 Aug 2014, Rafael J. Wysocki wrote:
> >
> >> > > > Well it works currently. So where do you see the problem?
> >> > >
> >> > > Sampling registers from an timer - in particular, we really do not want
> >> > > to disable runtime pm whilst trying to monitor the impact of runtime pm.
> >> >
> >> > In that case you can grab a runtime pm reference iff the device is powered
> >> > on already. Which won't call anything scary, just amounts to an
> >> > atomic_add_unless or so, and then drop it again.
> >> >
> >> > Unfortunately there doesn't seem to be such a thing around already, so
> >> > need to add it first. Greg, how much would you freak out if we add
> >> > something like
> >> >
> >> > /**
> >> > * pm_runtime_get_unless_suspended - grab a rpm ref if the device is on
> >> > *
> >> > * Returns true if an rpm ref has been acquire, false otherwise. Can be
> >> > * called from atomic context to e.g. sample perfomance counters (where we
> >> > * obviously don't want to disturb system state if everything is off atm).
> >> > */
> >> > static inline bool pm_runtime_get_unless_suspended(struct device *dev)
> >> > {
> >> > return atomic_add_unless(&dev->power.usage_count, 1, 0);
> >> > }
> >>
> >> I don't think it'll work universally.
> >>
> >> That'd need to be synchronized with other stuff done under the spinlock
> >> and in fact, what you're interested in is runtime_status (and that being
> >> RPM_ACTIVE) and not just the usage count.
> >
> > That's right. You'd need to acquire the spinlock, test runtime_status,
> > do the register sampling if the status is RPM_ACTIVE, and then drop the
> > spinlock.
> >
> > I suppose wrapper routines for acquiring and releasing the spinlock
> > could be added to the runtime-PM API. Something like this:
> >
> > #define pm_runtime_lock(dev, flags) \
> > spin_lock_irqsave(&(dev)->power.lock, flags)
> > #define pm_runtime_unlock(dev, flags) \
> > spin_unlock_irqrestore(&(dev)->power.lock, flags)
> >
> > It looks a little silly but it would work.
>
> Oh right, I've totally ignored all the async resuming/suspending
> stuff. Anyway what we want to do is sample a perf monitoring unit on
> the gpu from an hrtimer and then expose that as a perf pmu. But we
> don't want to wake up the gpu for the sampling or hold a special
> reference, since that disturbs the sampling and also tends to upset
> the gpu.
The way to go is as Alan said: take the spinlock, check the runtime status,
do stuff and release the spinlock.
Rafael
prev parent reply other threads:[~2014-08-10 1:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1402673891-14618-1-git-send-email-oscar.mateo@intel.com>
[not found] ` <1402673891-14618-46-git-send-email-oscar.mateo@intel.com>
[not found] ` <20140618205413.GH5821@phenom.ffwll.local>
[not found] ` <20140726102738.GA21056@nuc-i3427.alporthouse.com>
[not found] ` <20140728085406.GX4747@phenom.ffwll.local>
[not found] ` <20140729073748.GD21570@nuc-i3427.alporthouse.com>
[not found] ` <20140729102636.GK4747@phenom.ffwll.local>
[not found] ` <20140808092040.GD3021@nuc-i3427.alporthouse.com>
2014-08-08 9:37 ` [Intel-gfx] [PATCH 45/53] drm/i915/bdw: Do not call intel_runtime_pm_get() in an interrupt Daniel Vetter
2014-08-08 13:41 ` Greg KH
2014-08-09 0:18 ` Rafael J. Wysocki
2014-08-09 0:14 ` Rafael J. Wysocki
2014-08-09 1:21 ` Alan Stern
2014-08-09 8:53 ` Daniel Vetter
2014-08-10 1:55 ` Rafael J. Wysocki [this message]
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=1766626.v17BJSfQ4M@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=chris@chris-wilson.co.uk \
--cc=daniel@ffwll.ch \
--cc=gregkh@linuxfoundation.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oscar.mateo@intel.com \
--cc=stern@rowland.harvard.edu \
/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).