Skip to contentSkip to conversation

alsabat: add power management S3 test

PATCH Applied [email protected] 2 participants 4 messages Aug 26, 2016 – Aug 30, 2016

lore
Share & tools
lore
#0 lore raw

cover alsabat: add power management S3 test

From: "Keqiao, Zhang" <[email protected]>

The patch set provide a method for QA to quick test audio during system S3

The first patch fix -86 error when system suspend/resume

The second patch provide a test script

Keqiao, Zhang (2):
alsabat: fix alsabat -86 error
alsabat: add system power management S3 test

 bat/alsa.c          | 10 ++++++++++
 bat/alsabat-test.sh | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/2 alsabat: fix alsabat -86 error

From: "Keqiao, Zhang" <[email protected]>

alsabat reports -86 error when system suspend and resume. Check the return value of read_to_pcm() and write_to_pcm(), when -x8 err is detected, do resume and wait for read/write to pcm to complete.

Write PCM device error: Streams pipe error(-86)
Read PCM device error: Streams pipe error(-86)
*** Error in alsabat: double free or corruption (out): 0x00007fb438001810 ***

---
 bat/alsa.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
bat/alsa.c +10 -0
index cef1734..7613f44 100644
@@ -319,6 +319,11 @@ static int write_to_pcm(const struct pcm_container *sndpcm,
 			if (bat->roundtriplatency)
 				bat->latency.xrun_error = true;
 			snd_pcm_prepare(sndpcm->handle);
+		} else if (err == -ESTRPIPE) {
+			while ((err = snd_pcm_resume(sndpcm->handle)) == -EAGAIN)
+				sleep(1);  /* wait until resume flag is released */
+			if (err < 0)
+				snd_pcm_prepare(sndpcm->handle);
 		} else if (err < 0) {
 			fprintf(bat->err, _("Write PCM device error: %s(%d)\n"),
 					snd_strerror(err), err);
@@ -518,6 +523,11 @@ static int read_from_pcm(struct pcm_container *sndpcm,
 					snd_strerror(err), err);
 			if (bat->roundtriplatency)
 				bat->latency.xrun_error = true;
+		} else if (err == -ESTRPIPE) {
+			while ((err = snd_pcm_resume(sndpcm->handle)) == -EAGAIN)
+				sleep(1);  /* wait until resume flag is released */
+			if (err < 0)
+				snd_pcm_prepare(sndpcm->handle);
 		} else if (err < 0) {
 			fprintf(bat->err, _("Read PCM device error: %s(%d)\n"),
 					snd_strerror(err), err);
Signature · 1 line
2.5.0
#2 lore raw

PATCH 2/2 alsabat: add system power management S3 test

In reply to [email protected]

From: "Keqiao, Zhang" <[email protected]>

Support audio pause/resume for playback and capture. The user can pause alsabat playback/capture threads by sending a signal. The patch provides a method for QA to quick test audio during system s3.

---
 bat/alsabat-test.sh | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
bat/alsabat-test.sh +34 -0
index aa0281b..bc3d512 100755
@@ -15,6 +15,10 @@ logdir="tmp"
 maxfreq=16547
 minfreq=17
 
+# sleep time and pause time
+sleep_time=5
+pause_time=2
+
 # features passes vs. features all
 feature_pass=0
 feature_cnt=0
@@ -48,6 +52,35 @@ feature_test () {
 	echo "$commands $1" >> $logdir/$((feature_cnt-1)).log
 }
 
+feature_test_power () {
+	echo "============================================"
+	echo "$feature_cnt: ALSA $2"
+	echo "-------------------------------------------"
+	echo "$commands $1 --log=$logdir/$feature_cnt.log"
+
+	# run alsabat in the background
+	nohup $commands $1 > $logdir/$feature_cnt.log 2>&1 &
+	sleep $pause_time
+	pid=`ps -aux |grep alsabat|head -1 |awk -F ' ' '{print $2}'`
+
+	# stop the alsabat thread
+	kill -STOP $pid > /dev/null
+	sleep 4
+
+	# do system S3
+	rtcwake -m mem -s $sleep_time
+	sleep $pause_time
+
+	# resume the alasbat thread to run
+	kill -CONT $pid > /dev/null
+
+	# wait for alsabat to complete the analysis
+	sleep $pause_time
+	cat $logdir/$feature_cnt.log |grep -i "Return value is 0" > /dev/null
+	evaluate_result $?
+	echo "$commands $1" >> $logdir/$((feature_cnt-1)).log
+}
+
 # test items
 feature_list_test () {
 	init_counter
@@ -87,6 +120,7 @@ feature_list_test () {
 			"noise detect threshold in SNR(dB)"
 	feature_test "--snr-pc 5" \
 			"noise detect threshold in noise percentage(%)"
+	feature_test_power "-n5s" "power management: S3 test"
 
 	print_result
 }
Signature · 1 line
2.5.0
Applied
#3 lore raw
In reply to [email protected]
Quoted 5 lines · On Fri, 26 Aug 2016 17:37:53 +0200, [email protected] wrote:

From: "Keqiao, Zhang" <[email protected]>

The patch set provide a method for QA to quick test audio during system S3

Quoted 7 lines

The first patch fix -86 error when system suspend/resume

The second patch provide a test script

Keqiao, Zhang (2):
alsabat: fix alsabat -86 error
alsabat: add system power management S3 test

Applied both patches. Thanks.

Takashi