Skip to content

SRC: Add support for timer based scheduling - #1219

Merged
lgirdwood merged 1 commit into
thesofproject:masterfrom
singalsu:src_timer_sched_buffers
Apr 5, 2019
Merged

lgirdwood merged 1 commit into
thesofproject:masterfrom
singalsu:src_timer_sched_buffers

Conversation

@singalsu

@singalsu singalsu commented Apr 3, 2019

Copy link
Copy Markdown
Collaborator

This patch adds to SRC for timer based scheduling capability to
determine in copy() the number of frames to process. Due to
potentially high computational load the max amount to process is
limited to just exceed the nominal number of frames per
scheduling rate. It prevents SRC to be preempted due to too long
processing time and cause pipeline xruns in the start of playback
when the buffers contain a large number of frames.

The pre-fill of samples in first copy() is removed since the just
above period length of data processing target avoids the sink
buffer to get too small number of frames for the downstream
pipeline.

The currently happening bad metallic sound with SRC in pipeline
is fixed by this patch.

Signed-off-by: Seppo Ingalsuo seppo.ingalsuo@linux.intel.com

@singalsu

singalsu commented Apr 3, 2019

Copy link
Copy Markdown
Collaborator Author

Note: There is still problem that often but not always with 44.1 -> 48 kHz playback just when the playback ends the firmware crashes. It does not happen with 8/16/32/48 -> 48 KHz. Also build with xt-xcc does not have this issue (both identical source code to gcc and the intrinsic optimized version). I haven't found out why. Anyway, I made this PR available because currently SRC pipes do not work at all.

@singalsu

singalsu commented Apr 3, 2019

Copy link
Copy Markdown
Collaborator Author

This fixes SOF issue #1147.

@lgirdwood

lgirdwood commented Apr 3, 2019 •

Copy link
Copy Markdown
Member

@singalsu have you used the crash-dump script to investigate the crash. Is it a consistent crash between builds/boots ?

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant' see any obvious changes that would kill stream stop, but it maybe that certain combinations are corrupting heap/stack.

Comment thread src/audio/src.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to wrap it up into some function.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, fixed.

Comment thread src/audio/src.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces not needed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, yes.

@singalsu

singalsu commented Apr 4, 2019 •

Copy link
Copy Markdown
Collaborator Author

@lgirdwood I haven't been able to decode manually anything useful from this crash dump

[  170.818244] sof-audio-pci 0000:00:0e.0: ipc tx: 0x60050000: GLB_STREAM_MSG: TRIG_STOP
[  170.818725] sof-audio-pci 0000:00:0e.0: ipc tx succeeded: 0x60050000: GLB_STREAM_MSG: TRIG_STOP
[  170.818944] sof-audio-pci 0000:00:0e.0: pcm: free stream 0 dir 0
[  170.818959] sof-audio-pci 0000:00:0e.0: ipc tx: 0x60030000: GLB_STREAM_MSG: PCM_FREE
[  170.819237] sof-audio-pci 0000:00:0e.0: ipc tx succeeded: 0x60030000: GLB_STREAM_MSG: PCM_FREE
[  170.819353] sof-audio-pci 0000:00:0e.0: error : DSP panic!
[  170.819368] sof-audio-pci 0000:00:0e.0: panic: dsp_oops_offset 788480 offset 788480
[  170.819376] sof-audio-pci 0000:00:0e.0: status: fw entered - code 00000005
[  170.819420] sof-audio-pci 0000:00:0e.0: error: runtime exception
[  170.819427] sof-audio-pci 0000:00:0e.0: error: trace point 00004000
[  170.819433] sof-audio-pci 0000:00:0e.0: error: panic happen at :0
[  170.819439] sof-audio-pci 0000:00:0e.0: error: DSP Firmware Oops
[  170.819446] sof-audio-pci 0000:00:0e.0: error: Exception Cause: IllegalInstructionCause, Illegal instruction
[  170.819454] sof-audio-pci 0000:00:0e.0: EXCCAUSE 0x00000000 EXCVADDR 0x00000000 PS       0x00000000 SAR     0x00000000
[  170.819461] sof-audio-pci 0000:00:0e.0: EPC1     0x00000000 EPC2     0x00000000 EPC3     0x00000000 EPC4    0x00000000
[  170.819468] sof-audio-pci 0000:00:0e.0: EPC5     0x00000000 EPC6     0x00000000 EPC7     0x00000000 DEPC    0x00000000
[  170.819475] sof-audio-pci 0000:00:0e.0: EPS2     0x00000000 EPS3     0x00000000 EPS4     0x00000000 EPS5    0x00000000
[  170.819483] sof-audio-pci 0000:00:0e.0: EPS6     0x00000000 EPS7     0x00000000 INTENABL 0x00000000 INTERRU 0x00000000
[  170.819489] sof-audio-pci 0000:00:0e.0: stack dump from 0x00000000
[  170.819499] sof-audio-pci 0000:00:0e.0: 0x00000000: 00000000 00000000 00000000 00000000
[  170.819508] sof-audio-pci 0000:00:0e.0: 0x00000004: 00000000 00000000 00000000 00000000
[  170.819517] sof-audio-pci 0000:00:0e.0: 0x00000008: b910ee00 c66532a0 776d1028 ffff9559
[  170.819525] sof-audio-pci 0000:00:0e.0: 0x0000000c: 77d6dd00 ffff9559 7766e800 ffff9559
[  170.819534] sof-audio-pci 0000:00:0e.0: 0x00000010: 9c0b4772 ffffffff 00000000 00000000
[  170.819542] sof-audio-pci 0000:00:0e.0: 0x00000014: 78723400 ffff9559 77d6dd00 ffff9559
[  170.819551] sof-audio-pci 0000:00:0e.0: 0x00000018: 00000000 00000000 00000000 00000000
[  170.819559] sof-audio-pci 0000:00:0e.0: 0x0000001c: 00000000 00000000 00000000 00000000
[  170.819565] sof-audio-pci 0000:00:0e.0: error: waking up any trace sleepers
[  170.833389] sof-audio-pci 0000:00:0e.0: pcm: close stream 0 dir 0

I noticed today that the error trace gets updates just at time time of playback stop and crash. The normal DMA trace doesn't contain this. Here's the trace:

 CORE  LEVEL      COMP_ID                TIMESTAMP            DELTA                FILE_NAME	CONTENT
    0      2          IPC          21132806.510417  21132806.000000 /home/singalsu/work/current/sof/sof/src/ipc/handler.c:464 	ipc: comp 0 -> trigger cmd 0x50000
    0      2         PIPE 1.7      21132810.885417         4.375000 /home/singalsu/work/current/sof/sof/src/audio/pipeline.c:533 	pipeline_trigger()
    0      2         HOST          21132814.114583         3.229167 /home/singalsu/work/current/sof/sof/src/audio/host.c:281 	host_trigger()
    0      2          DMA          21132817.864583         3.750000 /home/singalsu/work/current/sof/sof/src/drivers/intel/cavs/hda-dma.c:645 	hda-dmac: 5 channel 0 -> stop
    0      2          SRC          21132821.614583         3.750000 /home/singalsu/work/current/sof/sof/src/audio/src.c:713 	src_trigger()
    0      2       VOLUME          21132825.104167         3.489583 /home/singalsu/work/current/sof/sof/src/audio/volume.c:454 	volume_trigger()
    0      2          DAI 1.6      21132828.593750         3.489583 /home/singalsu/work/current/sof/sof/src/audio/dai.c:544 	dai_comp_trigger(), command = 0
    0      2          DAI 1.6      21132831.822917         3.229167 /home/singalsu/work/current/sof/sof/src/audio/dai.c:608 	dai_comp_trigger(), PAUSE/STOP
    0      2          DMA          21132834.843750         3.020833 /home/singalsu/work/current/sof/sof/src/drivers/dw/dma.c:675 	dw-dma: 0 channel 0 stop
    0      2          SSP          21132842.083333         7.239583 /home/singalsu/work/current/sof/sof/src/drivers/intel/cavs/ssp.c:861 	ssp_trigger() cmd 0
    0      2          SSP          21132972.031250       129.947922 /home/singalsu/work/current/sof/sof/src/drivers/intel/cavs/ssp.c:842 	ssp_stop(), TX stop
    0      2          SSP          21132975.156250         3.125000 /home/singalsu/work/current/sof/sof/src/drivers/intel/cavs/ssp.c:851 	ssp_stop(), SSP port disabled
    0      2          IPC          21133521.666667       546.510437 /home/singalsu/work/current/sof/sof/src/ipc/handler.c:367 	ipc: comp 0 -> free
    0      2         PIPE 1.7      21133525.625000         3.958333 /home/singalsu/work/current/sof/sof/src/audio/pipeline.c:576 	pipeline_reset()
    0      2         HOST          21133528.697917         3.072917 /home/singalsu/work/current/sof/sof/src/audio/host.c:704 	host_reset()
    0      2          DMA          21133532.083333         3.385417 /home/singalsu/work/current/sof/sof/src/drivers/intel/cavs/hda-dma.c:645 	hda-dmac: 5 channel 0 -> stop
    0      2          SRC          21133537.760417         5.677083 /home/singalsu/work/current/sof/sof/src/audio/src.c:909 	src_reset()
    0      2       VOLUME          21133541.197917         3.437500 /home/singalsu/work/current/sof/sof/src/audio/volume.c:621 	volume_reset()
    0      2          DAI 1.6      21133544.583333         3.385417 /home/singalsu/work/current/sof/sof/src/audio/dai.c:521 	dai_reset()

Though no errors those I could spot seen there. Maybe the 44.1 kHz playback (and gcc build) does something that causes the idle to crash.

@singalsu

singalsu commented Apr 4, 2019

Copy link
Copy Markdown
Collaborator Author

I'll see also if testbench can catch something.

This patch adds to SRC for timer based scheduling capability to
determine in copy() the number of frames to process. Due to
potentially high computational load the max amount to process is
limited to just exceed the nominal number of frames per
scheduling rate. It prevents SRC to be preempted due to too long
processing time and cause pipeline xruns in the start of playback
when the buffers contain a large number of frames.

The pre-fill of samples in first copy() is removed since the just
above period length of data processing target avoids the sink
buffer to get too small number of frames for the downstream
pipeline.

The currently happening bad metallic sound with SRC in pipeline
is fixed by this patch.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu
singalsu force-pushed the src_timer_sched_buffers branch from 061e376 to 1499795 Compare April 4, 2019 14:53
@singalsu

singalsu commented Apr 4, 2019

Copy link
Copy Markdown
Collaborator Author

@tlauda I just pushed fixes for the issues you found. The fail probability possibly decreased with this change but still exists. I'll continue testing in testbench this with valgrind etc.

@lgirdwood

Copy link
Copy Markdown
Member

@singalsu some updates have been merged to crash dump very recently, can you try todays HEAD. I would expect to see registers but they all appear zero.

@singalsu

singalsu commented Apr 4, 2019

Copy link
Copy Markdown
Collaborator Author

Hmm, if I change SRC code to free the filter delay lines in reset() the 44.1 kHz crash does not happen... I'm confused why this changes things since xt-xcc code build was fine. It could be still some memory corruption somewhere. Tomorrow valgrind...

@lgirdwood

Copy link
Copy Markdown
Member

@singalsu still blocking on some CI.... @xiulipan any CI blockers ?

@tlauda

tlauda commented Apr 5, 2019

Copy link
Copy Markdown
Contributor

@singalsu Try to force push the branch - it will reschedule the CI.

@singalsu

singalsu commented Apr 5, 2019

Copy link
Copy Markdown
Collaborator Author

@lgirdwood @tlauda I'm now able thanks to PR by @jajanusz run this is testbench. It doesn't crash so no obvious mistake found yet. However valgrind found two issues that I need to check. One is for allocation and one is condition test with uninitialized variable.

@lgirdwood

Copy link
Copy Markdown
Member

@singalsu looks like some CI is down. merging. @xiulipan FYI

@lgirdwood
lgirdwood merged commit 9c11127 into thesofproject:master Apr 5, 2019
@singalsu

singalsu commented Apr 5, 2019

Copy link
Copy Markdown
Collaborator Author

The test bench issues found by valgrind were in file.c component. I'll make a separate PR.

@xiulipan

xiulipan commented Apr 6, 2019

Copy link
Copy Markdown
Contributor

@singalsu @lgirdwood Network down for CI.

@singalsu
singalsu deleted the src_timer_sched_buffers branch May 9, 2019 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants