From: Takashi Iwai <tiwai@suse.de>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Takashi Iwai <tiwai@suse.de>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] snd/hda: Only get/put display_power once
Date: Wed, 10 Apr 2019 12:09:47 +0200 [thread overview]
Message-ID: <s5hk1g2uq6s.wl-tiwai@suse.de> (raw)
In-Reply-To: <20190410081733.22271-1-chris@chris-wilson.co.uk>
On Wed, 10 Apr 2019 10:17:33 +0200,
Chris Wilson wrote:
>
> While we only allow a single display power reference, the current
> acquisition/release is racy and a direct call may run concurrently with
> a runtime-pm worker. Prevent the double unreference by atomically
> tracking the display_power_active cookie.
>
> Testcase: igt/i915_pm_rpm/module-reload #glk-dsi
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Takashi Iwai <tiwai@suse.de>
> Cc: Imre Deak <imre.deak@intel.com>
I rather prefer a more straightforward conversion, e.g. something like
below. Checking the returned cookie as the state flag is not quite
intuitive, so revive the boolean state flag, and handle it
atomically.
thanks,
Takashi
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -367,7 +367,8 @@ struct hdac_bus {
/* DRM component interface */
struct drm_audio_component *audio_component;
long display_power_status;
- unsigned long display_power_active;
+ bool display_power_active;
+ unsigned long display_cookie;
/* parameters required for enhanced capabilities */
int num_streams;
diff --git a/sound/hda/hdac_component.c b/sound/hda/hdac_component.c
index 13915fdc6a54..da20f439578a 100644
--- a/sound/hda/hdac_component.c
+++ b/sound/hda/hdac_component.c
@@ -78,24 +78,19 @@ void snd_hdac_display_power(struct hdac_bus *bus, unsigned int idx, bool enable)
return;
if (bus->display_power_status) {
- if (!bus->display_power_active) {
- unsigned long cookie = -1;
-
+ if (!cmpxchg(&bus->display_power_active, false, true)) {
if (acomp->ops->get_power)
- cookie = acomp->ops->get_power(acomp->dev);
+ bus->display_cookie =
+ acomp->ops->get_power(acomp->dev);
snd_hdac_set_codec_wakeup(bus, true);
snd_hdac_set_codec_wakeup(bus, false);
- bus->display_power_active = cookie;
}
} else {
- if (bus->display_power_active) {
- unsigned long cookie = bus->display_power_active;
-
+ if (xchg(&bus->display_power_active, false)) {
if (acomp->ops->put_power)
- acomp->ops->put_power(acomp->dev, cookie);
-
- bus->display_power_active = 0;
+ acomp->ops->put_power(acomp->dev,
+ bus->display_cookie);
}
}
}
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-04-10 10:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-10 8:17 [PATCH] snd/hda: Only get/put display_power once Chris Wilson
2019-04-10 8:22 ` Chris Wilson
2019-04-10 9:24 ` ✓ Fi.CI.BAT: success for " Patchwork
2019-04-10 10:09 ` Takashi Iwai [this message]
2019-04-10 10:24 ` [PATCH] " Chris Wilson
2019-04-10 10:44 ` Takashi Iwai
2019-04-10 11:03 ` Takashi Iwai
2019-04-10 13:07 ` Chris Wilson
2019-04-10 13:24 ` Takashi Iwai
2019-04-10 10:38 ` ✗ Fi.CI.CHECKPATCH: warning for snd/hda: Only get/put display_power once (rev2) Patchwork
2019-04-10 11:08 ` ✓ Fi.CI.BAT: success " Patchwork
2019-04-10 12:29 ` ✗ Fi.CI.IGT: failure for snd/hda: Only get/put display_power once Patchwork
2019-04-10 12:34 ` ✗ Fi.CI.CHECKPATCH: warning for snd/hda: Only get/put display_power once (rev3) Patchwork
2019-04-10 13:03 ` ✓ Fi.CI.BAT: success " Patchwork
2019-04-10 18:06 ` ✓ Fi.CI.IGT: " Patchwork
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=s5hk1g2uq6s.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.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 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.