[PATCH 2/2] Revert "ALSA: hda - Move in_pm accessors to HDA core"

Chris Wilson chris at chris-wilson.co.uk
Wed Jun 27 14:04:58 UTC 2018


This reverts commit bd0afa8b35730ca2dbad4641201a294e3449a465.
---
 include/sound/hdaudio.h    | 27 ---------------------------
 sound/pci/hda/hda_codec.c  | 21 +++++++++++++++------
 sound/pci/hda/patch_hdmi.c |  2 +-
 3 files changed, 16 insertions(+), 34 deletions(-)

diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 294a5a21937b..c052afc27547 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -8,7 +8,6 @@
 
 #include <linux/device.h>
 #include <linux/interrupt.h>
-#include <linux/pm_runtime.h>
 #include <linux/timecounter.h>
 #include <sound/core.h>
 #include <sound/memalloc.h>
@@ -172,38 +171,12 @@ int snd_hdac_power_down(struct hdac_device *codec);
 int snd_hdac_power_up_pm(struct hdac_device *codec);
 int snd_hdac_power_down_pm(struct hdac_device *codec);
 int snd_hdac_keep_power_up(struct hdac_device *codec);
-
-/* call this at entering into suspend/resume callbacks in codec driver */
-static inline void snd_hdac_enter_pm(struct hdac_device *codec)
-{
-	atomic_inc(&codec->in_pm);
-}
-
-/* call this at leaving from suspend/resume callbacks in codec driver */
-static inline void snd_hdac_leave_pm(struct hdac_device *codec)
-{
-	atomic_dec(&codec->in_pm);
-}
-
-static inline bool snd_hdac_is_in_pm(struct hdac_device *codec)
-{
-	return atomic_read(&codec->in_pm);
-}
-
-static inline bool snd_hdac_is_power_on(struct hdac_device *codec)
-{
-	return !pm_runtime_suspended(&codec->dev);
-}
 #else
 static inline int snd_hdac_power_up(struct hdac_device *codec) { return 0; }
 static inline int snd_hdac_power_down(struct hdac_device *codec) { return 0; }
 static inline int snd_hdac_power_up_pm(struct hdac_device *codec) { return 0; }
 static inline int snd_hdac_power_down_pm(struct hdac_device *codec) { return 0; }
 static inline int snd_hdac_keep_power_up(struct hdac_device *codec) { return 0; }
-static inline void snd_hdac_enter_pm(struct hdac_device *codec) {}
-static inline void snd_hdac_leave_pm(struct hdac_device *codec) {}
-static inline bool snd_hdac_is_in_pm(struct hdac_device *codec) { return 0; }
-static inline bool snd_hdac_is_power_on(struct hdac_device *codec) { return 1; }
 #endif
 
 /*
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index d7206e2e84ed..0508c9b54ea0 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -37,8 +37,15 @@
 #include "hda_jack.h"
 #include <sound/hda_hwdep.h>
 
-#define codec_in_pm(codec)		snd_hdac_is_in_pm(&codec->core)
-#define hda_codec_is_power_on(codec)	snd_hdac_is_power_on(&codec->core)
+#ifdef CONFIG_PM
+#define codec_in_pm(codec)	atomic_read(&(codec)->core.in_pm)
+#define hda_codec_is_power_on(codec) \
+	(!pm_runtime_suspended(hda_codec_dev(codec)))
+#else
+#define codec_in_pm(codec)	0
+#define hda_codec_is_power_on(codec)	1
+#endif
+
 #define codec_has_epss(codec) \
 	((codec)->core.power_caps & AC_PWRST_EPSS)
 #define codec_has_clkstop(codec) \
@@ -2841,13 +2848,14 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
 {
 	unsigned int state;
 
-	snd_hdac_enter_pm(&codec->core);
+	atomic_inc(&codec->core.in_pm);
+
 	if (codec->patch_ops.suspend)
 		codec->patch_ops.suspend(codec);
 	hda_cleanup_all_streams(codec);
 	state = hda_set_power_state(codec, AC_PWRST_D3);
 	update_power_acct(codec, true);
-	snd_hdac_leave_pm(&codec->core);
+	atomic_dec(&codec->core.in_pm);
 	return state;
 }
 
@@ -2856,7 +2864,8 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
  */
 static void hda_call_codec_resume(struct hda_codec *codec)
 {
-	snd_hdac_enter_pm(&codec->core);
+	atomic_inc(&codec->core.in_pm);
+
 	if (codec->core.regmap)
 		regcache_mark_dirty(codec->core.regmap);
 
@@ -2879,7 +2888,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
 		hda_jackpoll_work(&codec->jackpoll_work.work);
 	else
 		snd_hda_jack_report_sync(codec);
-	snd_hdac_leave_pm(&codec->core);
+	atomic_dec(&codec->core.in_pm);
 }
 
 static int hda_codec_runtime_suspend(struct device *dev)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index c182e619ad58..e7d99a802bcc 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -2489,7 +2489,7 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
 	if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0)
 		return;
 	/* ditto during suspend/resume process itself */
-	if (snd_hdac_is_in_pm(&codec->core))
+	if (atomic_read(&(codec)->core.in_pm))
 		return;
 
 	snd_hdac_i915_set_bclk(&codec->bus->core);
-- 
2.18.0



More information about the Intel-gfx-trybot mailing list