Skip to content

Pcm converter: return error code - #3251

Merged
lgirdwood merged 3 commits into
thesofproject:masterfrom
ktrzcinx:pcm-return-value
Aug 31, 2020
Merged

lgirdwood merged 3 commits into
thesofproject:masterfrom
ktrzcinx:pcm-return-value

Conversation

@ktrzcinx

Copy link
Copy Markdown
Member

Assertion may be replaced with error code return, then error won't be so fatal and error log may be traced in client component context.

@ktrzcinx

Copy link
Copy Markdown
Member Author

@xiulipan do you know why there is no output logs (slogger) in CI for platforms like BYT/BSW/BDW (eg. test check-pause-resume-capture-10.sh), for other platforms logs looks fine.

@mmaka1 mmaka1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sof does not use errno_t yet which would be more appropriate as a type of return value in case only error codes are returned. Using int for a function that process data would suggest that ret >= 0 is set to the size of successfully processed data (unit could be samples here, not necessarily bytes - see fread/fwrite case).

@ktrzcinx

Copy link
Copy Markdown
Member Author

Using int for a function that process data would suggest that ret >= 0 is set to the size of successfully processed data (unit could be samples here, not necessarily bytes - see fread/fwrite case)

Updated to this version

Comment thread src/audio/pcm_converter/pcm_converter.c Resolved
@lgirdwood

Copy link
Copy Markdown
Member

SOFCI TEST

@lgirdwood

Copy link
Copy Markdown
Member

@ktrzcinx rerunning CI, looks like another unrelated driver failed on CML.

@ktrzcinx

Copy link
Copy Markdown
Member Author

@lgirdwood now looks good

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.

Unrelated, but if (!(samples % 2)) is very expensive. Can we have a subsequent PR that uses AND instead of % n (where n is a power of 2). A quick search show some dubious uses.

grep  -rn "% " --include *.c src/
src/arch/xtensa/init.c:26:STATIC_ASSERT((sizeof(UserFrame) % 16) == 0, invalid_UserFrame_alignment);
src/trace/dma-trace.c:553:	/* schedule copy now if buffer > 50% full */
src/drivers/intel/ssp/ssp.c:333:	if (ssp_freq[SSP_DEFAULT_IDX].freq % config->ssp.bclk_rate != 0) {
src/drivers/intel/ssp/ssp.c:360:	if (config->ssp.bclk_rate % config->ssp.fsync_rate) {
src/drivers/intel/ssp/ssp.c:411:		if (bdiv % 2) {
src/drivers/intel/ssp/ssp.c:433:		if (frame_end_padding % 2) {
src/drivers/intel/ssp/ssp.c:465:		if (bdiv % 2) {
src/drivers/intel/ssp/ssp.c:487:		if (frame_end_padding % 2) {
src/drivers/intel/ssp/mn.c:126:		if (ssp_freq[i].freq % mclk_rate == 0)
src/drivers/intel/ssp/mn.c:167:	if (ssp_freq[mn->mclk_source_clock].freq % mclk_rate != 0) {
src/drivers/intel/ssp/mn.c:273:	if (freq % bclk == 0 && scr_div < (SSCR0_SCR_MASK >> 8) + 1) {
src/drivers/intel/ssp/mn.c:286:	if (scr_div > 1 && scr_div % 2 != 0)
src/drivers/intel/ssp/mn.c:293:	while (scr_div > 1 && freq % scr_div != 0)
src/drivers/intel/ssp/mn.c:330:		if (ssp_freq[i].freq % bclk == 0) {
src/drivers/intel/ssp/mn.c:461:		if (ssp_freq[i].freq % bclk != 0)
src/drivers/intel/baytrail/ssp.c:281:	if (config->ssp.mclk_rate % config->ssp.bclk_rate) {
src/drivers/intel/baytrail/ssp.c:299:	if (config->ssp.bclk_rate % config->ssp.fsync_rate) {
src/drivers/intel/dmic.c:319:		 * odd dividers cause non-50% duty cycle.
src/drivers/intel/haswell/ssp.c:197:	if (config->ssp.mclk_rate % config->ssp.bclk_rate) {
src/drivers/intel/haswell/ssp.c:215:	if (config->ssp.bclk_rate % config->ssp.fsync_rate) {
src/drivers/intel/haswell/ssp.c:283:		if (bdiv % 2) {
src/drivers/intel/haswell/ssp.c:296:		if (frame_end_padding % 2) {
src/drivers/intel/hda/hda-dma.c:733:	if (buffer_bytes % HDA_DMA_BUFFER_ALIGNMENT) {
src/drivers/imx/sdma.c:595:	idx = (pdata->next_bd + 1) % 2;
src/drivers/imx/edma.c:318:		if ((elem_size % size) == 0UL)
src/drivers/imx/interrupt.c:95:#define IRQSTR_INT_BIT(irq)		((irq) % 32)
src/drivers/imx/interrupt.c:435:	irq = irqstr_int % IRQSTR_IRQS_PER_LINE;
src/lib/agent.c:11: * tick. If the core exceeds the threshold by over 5% then the SA will emit
src/lib/agent.c:12: * error trace. However if it will be exceeded by over 100% the panic will be
src/lib/agent.c:118:	sof->sa->panic_timeout = 2 * ticks;	/* 100% delay */
src/lib/agent.c:119:	sof->sa->warn_timeout = ticks + ticks / 20;	/* 5% delay */
src/lib/alloc.c:169:	if (cpu_heap->info.used % PLATFORM_DCACHE_ALIGN)
src/lib/alloc.c:171:			(cpu_heap->info.used % PLATFORM_DCACHE_ALIGN);
src/lib/alloc.c:207:	if (alignment && (uintptr_t)ptr % alignment)
src/lib/alloc.c:208:		mod_align = alignment - ((uintptr_t)ptr % alignment);
src/lib/alloc.c:265:	if (bytes % map->block_size)
src/lib/alloc.c:770:		    % alignment)
src/platform/intel/cavs/lib/pm_memory.c:40:	if ((uintptr_t)start % SRAM_BANK_SIZE)
src/platform/intel/cavs/lib/pm_memory.c:43:	if ((uintptr_t)end % SRAM_BANK_SIZE)
src/platform/intel/cavs/lib/dai.c:187:			(i % DAI_NUM_ALH_BI_DIR_LINKS_GROUP);
src/platform/intel/cavs/boot_loader.c:180:	ebb_in_use = (!(memory_size % SRAM_BANK_SIZE)) ?
src/audio/pcm_converter/pcm_converter_hifi3.c:501:	if (!(samples % 2))
src/audio/pcm_converter/pcm_converter_hifi3.c:592:	if (!(samples % 2))

@dbaluta imx has a usage in your IRQ code...

@lgirdwood

Copy link
Copy Markdown
Member

@mmaka1 good for you now ?

It allows to trace error with proper (client) trace context
after hitting some error.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This function should error code from 'process' to their client.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
After error in lower layers, this issue should be traced in
proper context.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
@lgirdwood
lgirdwood merged commit 1732064 into thesofproject:master Aug 31, 2020
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.

3 participants