Patch "soundwire: intel: don't save hw_params for use in prepare" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    soundwire: intel: don't save hw_params for use in prepare

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     soundwire-intel-don-t-save-hw_params-for-use-in-prep.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 80b0cb7696d02829e586bb5558d0929e62a81e00
Author: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>
Date:   Tue Mar 21 10:26:42 2023 +0800

    soundwire: intel: don't save hw_params for use in prepare
    
    [ Upstream commit 0a0d1740bd8fd7dafb81fcb102fb5d0b83b1ce73 ]
    
    The existing code copies the hw_params pointer and reuses it later in
    .prepare, specifically to re-initialize the ALH DMA channel
    information that's lost in suspend-resume cycles.
    
    This is not needed, we can directly access the information from the
    substream/rtd - as done for the HDAudio DAIs in
    sound/soc/sof/intel/hda-dai.c
    
    In addition, using the saved pointer causes the suspend-resume test
    cases to fail on specific platforms, depending on which version of GCC
    is used. Péter Ujfalusi and I have spent long hours to root-cause this
    problem that was reported by the Intel CI first with 6.2-rc1 and again
    v6.3-rc1. In the latter case we were lucky that the problem was 100%
    reproducible on local test devices, and found out that adding a
    dev_dbg() or adding a call to usleep_range() just before accessing the
    saved pointer "fixed" the issue. With errors appearing just by
    changing the compiler version or minor changes in the code generated,
    clearly we have a memory management Heisenbug.
    
    The root-cause seems to be that the hw_params pointer is not
    persistent. The soc-pcm code allocates the hw_params structure on the
    stack, and passes it to the BE dailink hw_params and DAIs
    hw_params. Saving such a pointer and reusing it later during the
    .prepare stage cannot possibly work reliably, it's broken-by-design
    since v5.10. It's astonishing that the problem was not seen earlier.
    
    This simple fix will have to be back-ported to -stable, due to changes
    to avoid the use of the get/set_dmadata routines this patch will only
    apply on kernels older than v6.1.
    
    Fixes: a5a0239c27fe ("soundwire: intel: reinitialize IP+DSP in .prepare(), but only when resuming")
    Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>
    Reviewed-by: Ranjani Sridharan <ranjani.sridharan@xxxxxxxxxxxxxxx>
    Reviewed-by: Péter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx>
    Signed-off-by: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230321022642.1426611-1-yung-chuan.liao@xxxxxxxxxxxxxxx
    Signed-off-by: Vinod Koul <vkoul@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence_master.h
index 9b0113d48e419..fea3a90550d37 100644
--- a/drivers/soundwire/cadence_master.h
+++ b/drivers/soundwire/cadence_master.h
@@ -84,7 +84,6 @@ struct sdw_cdns_stream_config {
  * @bus: Bus handle
  * @stream_type: Stream type
  * @link_id: Master link id
- * @hw_params: hw_params to be applied in .prepare step
  * @suspended: status set when suspended, to be used in .prepare
  * @paused: status set in .trigger, to be used in suspend
  */
@@ -95,7 +94,6 @@ struct sdw_cdns_dai_runtime {
 	struct sdw_bus *bus;
 	enum sdw_stream_type stream_type;
 	int link_id;
-	struct snd_pcm_hw_params *hw_params;
 	bool suspended;
 	bool paused;
 };
diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c
index 52e5c54b4f36a..89f8cab3f5141 100644
--- a/drivers/soundwire/intel.c
+++ b/drivers/soundwire/intel.c
@@ -857,7 +857,6 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
 	dai_runtime->paused = false;
 	dai_runtime->suspended = false;
 	dai_runtime->pdi = pdi;
-	dai_runtime->hw_params = params;
 
 	/* Inform DSP about PDI stream number */
 	ret = intel_params_stream(sdw, substream->stream, dai, params,
@@ -910,6 +909,11 @@ static int intel_prepare(struct snd_pcm_substream *substream,
 	}
 
 	if (dai_runtime->suspended) {
+		struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+		struct snd_pcm_hw_params *hw_params;
+
+		hw_params = &rtd->dpcm[substream->stream].hw_params;
+
 		dai_runtime->suspended = false;
 
 		/*
@@ -921,7 +925,7 @@ static int intel_prepare(struct snd_pcm_substream *substream,
 		 */
 
 		/* configure stream */
-		ch = params_channels(dai_runtime->hw_params);
+		ch = params_channels(hw_params);
 		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
 			dir = SDW_DATA_DIR_RX;
 		else
@@ -933,7 +937,7 @@ static int intel_prepare(struct snd_pcm_substream *substream,
 
 		/* Inform DSP about PDI stream number */
 		ret = intel_params_stream(sdw, substream->stream, dai,
-					  dai_runtime->hw_params,
+					  hw_params,
 					  sdw->instance,
 					  dai_runtime->pdi->intel_alh_id);
 	}
@@ -972,7 +976,6 @@ intel_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
 		return ret;
 	}
 
-	dai_runtime->hw_params = NULL;
 	dai_runtime->pdi = NULL;
 
 	return 0;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux