linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Mark Brown <broonie@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.3 16/81] ASoC: SOF: Intel: hda: Disable DMI L1 entry during capture
Date: Wed, 30 Oct 2019 11:48:22 -0400	[thread overview]
Message-ID: <20191030154928.9432-16-sashal@kernel.org> (raw)
In-Reply-To: <20191030154928.9432-1-sashal@kernel.org>

From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

[ Upstream commit 43b2ab9009b13bfff47fcc1893de9244b39bdd54 ]

There is a known issue on some Intel platforms which causes
pause/release to run into xrun's during capture usecases.
The suggested workaround to address the issue is to
disable the entry of lower power L1 state in the physical
DMI link when there is a capture stream open.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190927200538.660-14-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/sof/intel/Kconfig      | 10 +++++++
 sound/soc/sof/intel/hda-ctrl.c   | 12 +++------
 sound/soc/sof/intel/hda-stream.c | 45 +++++++++++++++++++++++++++-----
 sound/soc/sof/intel/hda.h        |  5 +++-
 4 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/sound/soc/sof/intel/Kconfig b/sound/soc/sof/intel/Kconfig
index dd14ce92fe102..a5fd356776ee9 100644
--- a/sound/soc/sof/intel/Kconfig
+++ b/sound/soc/sof/intel/Kconfig
@@ -241,6 +241,16 @@ config SND_SOC_SOF_HDA_AUDIO_CODEC
 	  Say Y if you want to enable HDAudio codecs with SOF.
 	  If unsure select "N".
 
+config SND_SOC_SOF_HDA_ALWAYS_ENABLE_DMI_L1
+	bool "SOF enable DMI Link L1"
+	help
+	  This option enables DMI L1 for both playback and capture
+	  and disables known workarounds for specific HDaudio platforms.
+	  Only use to look into power optimizations on platforms not
+	  affected by DMI L1 issues. This option is not recommended.
+	  Say Y if you want to enable DMI Link L1
+	  If unsure, select "N".
+
 endif ## SND_SOC_SOF_HDA_COMMON
 
 config SND_SOC_SOF_HDA_LINK_BASELINE
diff --git a/sound/soc/sof/intel/hda-ctrl.c b/sound/soc/sof/intel/hda-ctrl.c
index ea63f83a509bb..760094d49f18f 100644
--- a/sound/soc/sof/intel/hda-ctrl.c
+++ b/sound/soc/sof/intel/hda-ctrl.c
@@ -139,20 +139,16 @@ void hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable)
  */
 int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable)
 {
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
-	struct hdac_bus *bus = sof_to_bus(sdev);
-#endif
 	u32 val;
 
 	/* enable/disable audio dsp clock gating */
 	val = enable ? PCI_CGCTL_ADSPDCGE : 0;
 	snd_sof_pci_update_bits(sdev, PCI_CGCTL, PCI_CGCTL_ADSPDCGE, val);
 
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
-	/* enable/disable L1 support */
-	val = enable ? SOF_HDA_VS_EM2_L1SEN : 0;
-	snd_hdac_chip_updatel(bus, VS_EM2, SOF_HDA_VS_EM2_L1SEN, val);
-#endif
+	/* enable/disable DMI Link L1 support */
+	val = enable ? HDA_VS_INTEL_EM2_L1SEN : 0;
+	snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, HDA_VS_INTEL_EM2,
+				HDA_VS_INTEL_EM2_L1SEN, val);
 
 	/* enable/disable audio dsp power gating */
 	val = enable ? 0 : PCI_PGCTL_ADSPPGD;
diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c
index ad8d41f22e92d..2c74471884025 100644
--- a/sound/soc/sof/intel/hda-stream.c
+++ b/sound/soc/sof/intel/hda-stream.c
@@ -185,6 +185,17 @@ hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction)
 			direction == SNDRV_PCM_STREAM_PLAYBACK ?
 			"playback" : "capture");
 
+	/*
+	 * Disable DMI Link L1 entry when capture stream is opened.
+	 * Workaround to address a known issue with host DMA that results
+	 * in xruns during pause/release in capture scenarios.
+	 */
+	if (!IS_ENABLED(SND_SOC_SOF_HDA_ALWAYS_ENABLE_DMI_L1))
+		if (stream && direction == SNDRV_PCM_STREAM_CAPTURE)
+			snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
+						HDA_VS_INTEL_EM2,
+						HDA_VS_INTEL_EM2_L1SEN, 0);
+
 	return stream;
 }
 
@@ -193,23 +204,43 @@ int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag)
 {
 	struct hdac_bus *bus = sof_to_bus(sdev);
 	struct hdac_stream *s;
+	bool active_capture_stream = false;
+	bool found = false;
 
 	spin_lock_irq(&bus->reg_lock);
 
-	/* find used stream */
+	/*
+	 * close stream matching the stream tag
+	 * and check if there are any open capture streams.
+	 */
 	list_for_each_entry(s, &bus->stream_list, list) {
-		if (s->direction == direction &&
-		    s->opened && s->stream_tag == stream_tag) {
+		if (!s->opened)
+			continue;
+
+		if (s->direction == direction && s->stream_tag == stream_tag) {
 			s->opened = false;
-			spin_unlock_irq(&bus->reg_lock);
-			return 0;
+			found = true;
+		} else if (s->direction == SNDRV_PCM_STREAM_CAPTURE) {
+			active_capture_stream = true;
 		}
 	}
 
 	spin_unlock_irq(&bus->reg_lock);
 
-	dev_dbg(sdev->dev, "stream_tag %d not opened!\n", stream_tag);
-	return -ENODEV;
+	/* Enable DMI L1 entry if there are no capture streams open */
+	if (!IS_ENABLED(SND_SOC_SOF_HDA_ALWAYS_ENABLE_DMI_L1))
+		if (!active_capture_stream)
+			snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
+						HDA_VS_INTEL_EM2,
+						HDA_VS_INTEL_EM2_L1SEN,
+						HDA_VS_INTEL_EM2_L1SEN);
+
+	if (!found) {
+		dev_dbg(sdev->dev, "stream_tag %d not opened!\n", stream_tag);
+		return -ENODEV;
+	}
+
+	return 0;
 }
 
 int hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h
index d9c17146200b3..2cc789f0e83c4 100644
--- a/sound/soc/sof/intel/hda.h
+++ b/sound/soc/sof/intel/hda.h
@@ -39,7 +39,6 @@
 #define SOF_HDA_WAKESTS			0x0E
 #define SOF_HDA_WAKESTS_INT_MASK	((1 << 8) - 1)
 #define SOF_HDA_RIRBSTS			0x5d
-#define SOF_HDA_VS_EM2_L1SEN            BIT(13)
 
 /* SOF_HDA_GCTL register bist */
 #define SOF_HDA_GCTL_RESET		BIT(0)
@@ -228,6 +227,10 @@
 #define HDA_DSP_REG_HIPCIE		(HDA_DSP_IPC_BASE + 0x0C)
 #define HDA_DSP_REG_HIPCCTL		(HDA_DSP_IPC_BASE + 0x10)
 
+/* Intel Vendor Specific Registers */
+#define HDA_VS_INTEL_EM2		0x1030
+#define HDA_VS_INTEL_EM2_L1SEN		BIT(13)
+
 /*  HIPCI */
 #define HDA_DSP_REG_HIPCI_BUSY		BIT(31)
 #define HDA_DSP_REG_HIPCI_MSG_MASK	0x7FFFFFFF
-- 
2.20.1


  parent reply	other threads:[~2019-10-30 15:51 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 15:48 [PATCH AUTOSEL 5.3 01/81] regulator: of: fix suspend-min/max-voltage parsing Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 02/81] ASoC: samsung: arndale: Add missing OF node dereferencing Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 03/81] ASoC: wm8994: Do not register inapplicable controls for WM1811 Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 04/81] regulator: da9062: fix suspend_enable/disable preparation Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 05/81] ASoC: topology: Fix a signedness bug in soc_tplg_dapm_widget_create() Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 06/81] arm64: dts: allwinner: a64: pine64-plus: Add PHY regulator delay Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 07/81] arm64: dts: allwinner: a64: Drop PMU node Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 08/81] arm64: dts: allwinner: a64: sopine-baseboard: Add PHY regulator delay Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 09/81] arm64: dts: Fix gpio to pinmux mapping Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 10/81] regulator: ti-abb: Fix timeout in ti_abb_wait_txdone/ti_abb_clear_all_txdone Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 11/81] pinctrl: intel: Allocate IRQ chip dynamic Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 12/81] ASoC: SOF: loader: fix kernel oops on firmware boot failure Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 13/81] ASoC: SOF: topology: fix parse fail issue for byte/bool tuple types Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 14/81] ASoC: SOF: Intel: hda: fix warnings during FW load Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 15/81] ASoC: SOF: Intel: initialise and verify FW crash dump data Sasha Levin
2019-10-30 15:48 ` Sasha Levin [this message]
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 17/81] ASoC: rt5682: add NULL handler to set_jack function Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 18/81] ASoC: intel: sof_rt5682: add remove function to disable jack Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 19/81] ASoC: intel: bytcr_rt5651: add null check to support_button_press Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 20/81] regulator: pfuze100-regulator: Variable "val" in pfuze100_regulator_probe() could be uninitialized Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 21/81] ASoC: wm_adsp: Don't generate kcontrols without READ flags Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 22/81] ASoc: rockchip: i2s: Fix RPM imbalance Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 23/81] arm64: dts: rockchip: fix Rockpro64 RK808 interrupt line Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 24/81] ARM: dts: logicpd-torpedo-som: Remove twl_keypad Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 25/81] arm64: dts: rockchip: fix RockPro64 vdd-log regulator settings Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 26/81] arm64: dts: rockchip: fix RockPro64 sdhci settings Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 27/81] pinctrl: ns2: Fix off by one bugs in ns2_pinmux_enable() Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 28/81] pinctrl: stmfx: fix null pointer on remove Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 29/81] arm64: dts: zii-ultra: fix ARM regulator states Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 30/81] ARM: dts: am3874-iceboard: Fix 'i2c-mux-idle-disconnect' usage Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 31/81] ASoC: msm8916-wcd-digital: add missing MIX2 path for RX1/2 Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 32/81] ASoC: simple_card_utils.h: Fix potential multiple redefinition error Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 33/81] ARM: dts: Use level interrupt for omap4 & 5 wlcore Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 34/81] ARM: mm: fix alignment handler faults under memory pressure Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 35/81] scsi: qla2xxx: fix a potential NULL pointer dereference Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 36/81] scsi: scsi_dh_alua: handle RTPG sense code correctly during state transitions Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 37/81] scsi: sni_53c710: fix compilation error Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 38/81] scsi: fix kconfig dependency warning related to 53C700_LE_ON_BE Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 39/81] ARM: 8908/1: add __always_inline to functions called from __get_user_check() Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 40/81] ARM: 8914/1: NOMMU: Fix exc_ret for XIP Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 41/81] arm64: dts: rockchip: fix RockPro64 sdmmc settings Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 42/81] arm64: dts: rockchip: Fix usb-c on Hugsun X99 TV Box Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 43/81] arm64: dts: lx2160a: Correct CPU core idle state name Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 44/81] ARM: dts: imx6q-logicpd: Re-Enable SNVS power key Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 45/81] ARM: dts: vf610-zii-scu4-aib: Specify 'i2c-mux-idle-disconnect' Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 46/81] ARM: dts: imx7s: Correct GPT's ipg clock source Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 47/81] arm64: dts: imx8mq: Use correct clock for usdhc's ipg clk Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 48/81] arm64: dts: imx8mm: " Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 49/81] perf tools: Fix resource leak of closedir() on the error paths Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 50/81] perf c2c: Fix memory leak in build_cl_output() Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 51/81] USB: legousbtower: fix a signedness bug in tower_probe() Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 52/81] 8250-men-mcb: fix error checking when get_num_ports returns -ENODEV Sasha Levin
2019-10-30 15:48 ` [PATCH AUTOSEL 5.3 53/81] perf kmem: Fix memory leak in compact_gfp_flags() Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 54/81] ARM: davinci: dm365: Fix McBSP dma_slave_map entry Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 55/81] drm/amdgpu: fix potential VM faults Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 56/81] drm/amdgpu: fix error handling in amdgpu_bo_list_create Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 57/81] scsi: target: core: Do not overwrite CDB byte 1 Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 58/81] scsi: hpsa: add missing hunks in reset-patch Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 59/81] ASoC: Intel: sof-rt5682: add a check for devm_clk_get Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 60/81] ASoC: SOF: control: return true when kcontrol values change Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 61/81] tracing: Fix "gfp_t" format for synthetic events Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 62/81] ARM: dts: bcm2837-rpi-cm3: Avoid leds-gpio probing issue Sasha Levin
2019-10-30 15:49 ` [PATCH AUTOSEL 5.3 63/81] i2c: aspeed: fix master pending state handling Sasha Levin

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=20191030154928.9432-16-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=stable@vger.kernel.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 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).