Skip to content

ASoC: SOF: fix return values for mandatory ops - #539

Merged
plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
ranj063:upstream/ops_fixes
Feb 7, 2019
Merged

ASoC: SOF: fix return values for mandatory ops#539
plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
ranj063:upstream/ops_fixes

Conversation

@ranj063

Copy link
Copy Markdown
Collaborator

Fix return value for mandatory ops.

Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@plbossart this leaves only the PCM ops but I'm not sure whether they are mandotory or not. Could you please comment?

@plbossartplbossart 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.

this looks ok but I'd like error messages to reflect the name of the function with the _ included. That helps for searches.
Also it'd be good to tag the callbacks in the header file as mandatory/optional so that the information is in one place.

Comment threadsound/soc/sof/ops.h Outdated
@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@plbossart fixed now. Could you please cross-check if the list of mandatory and optional ops is correct?

@plbossartplbossart 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.

@lgirdwood@keyonjie can you look at the list of mandatory ops and comment? I am afraid we have no documentation of what is expected in a minimal case?

Comment threadsound/soc/sof/sof-priv.h Outdated

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.

it's not very easy to figure out where the list stops. maybe for each op so that is can be searched whether it's optional or mandatory?

@keyonjiekeyonjie 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.

  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.
  3. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

Others looks fine.

Comment threadsound/soc/sof/sof-priv.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree we should make .remove mandatory, but the fact is that we don't have it on skl- platforms yet, better to fix them together at one shot(e.g. define an empty one at least).

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.

why should .remove be mandatory? if all your driver uses devm_ stuff and the hardware is reset correctly in the .probe, why would we care?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

@plbossart going by what remove() does for SKL+, we also disable the DSP in remove(). Given that we are not really unloading the topology from the DSP like we do in the case of load, shouldnt we also be turning off the DSP here?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

@plbossart i believe for module load/unload to work in SOF, we should make remove() mandatory so that the DSP can be turned OFF here. Please let me know if you disagree and I'll make changes accordingly.

Comment threadsound/soc/sof/sof-priv.h Outdated
@ranj063

Copy link
Copy Markdown
CollaboratorAuthor
  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.

@keyonjie With SMP enabled in the driver, they are no long optional.

  1. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

Others looks fine.

@keyonjie

Copy link
Copy Markdown
  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.

@keyonjie With SMP enabled in the driver, they are no long optional.

for SKL- platforms, we don't have SMP there, I meant those callbacks are not mandatory for snd_sof_dsp_ops (e.g. no need for byt), but they are mandatory for apl/cnl?

  1. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

Others looks fine.

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor
  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.

@keyonjie With SMP enabled in the driver, they are no long optional.

for SKL- platforms, we don't have SMP there, I meant those callbacks are not mandatory for snd_sof_dsp_ops (e.g. no need for byt), but they are mandatory for apl/cnl?

  1. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

Others looks fine.

@keyonjie ok Makes sense

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor
  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.
  3. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

@keyonjie hsw-spi.c has a different set of ops!

Others looks fine.

@ranj063ranj063 closed this Jan 17, 2019
@ranj063
ranj063 deleted the upstream/ops_fixes branch January 17, 2019 07:27
@ranj063
ranj063 restored the upstream/ops_fixes branch January 17, 2019 07:29
@ranj063ranj063 reopened this Jan 17, 2019
@ranj063ranj063 closed this Jan 17, 2019
@ranj063
ranj063 deleted the upstream/ops_fixes branch January 17, 2019 07:30
@ranj063
ranj063 restored the upstream/ops_fixes branch January 17, 2019 07:30
@ranj063ranj063 reopened this Jan 17, 2019
@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@keyonjie@plbossart PR updated now.

@plbossart

Copy link
Copy Markdown
Member

@ranj063 can you rebase, there is conflict. Also please mark each function as mandatory/optional, you are mixing the two styles (per function and per block) which will make searches more complicated.
Thanks!

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@plbossart this one has been updated too. There are 2 lines over 80 chars which checkpatch complains about but I think there's no simple way to address it while keeping the style consistent for marking the ops are madatory/optional.

@plbossartplbossart 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.

Humm, I am not sure I agree with the mandatory support for PCM (SueCreek being the counter example) and there are some inconsistencies between the errors and tags. Maybe we should shoot for a lower bar of what is really mandatory?

Comment threadsound/soc/sof/ops.h Outdated

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.

Are PCM operations actually required? Take the example of Sue Creek, you may have all the processing done on the device itself with no PCM being passed back to the host?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

@plbossart ok i will make these optional

Comment threadsound/soc/sof/sof-priv.h Outdated

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.

this is inconsistent with the fact that those functions return 0 if not supported?

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@plbossart i've updated the PR based on your comments.

@wenqingfu

Copy link
Copy Markdown

ping @plbossart

@plbossart

plbossart commented Jan 29, 2019 via email

Copy link
Copy Markdown
Member

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@plbossart I've updated this PR now to address your comment about the is_ready() op. There will be conflicts between this one and my other PR where I have changed the name for this op. I will update them depending on which one gets merged first.

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@plbossart please dont merge this. with the return value of undefined values change to < 0, I need to ensure the check is done correctly.

@ranj063

Copy link
Copy Markdown
CollaboratorAuthor

@plbossart this one has been updated now.

@plbossartplbossart 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.

Sorry, this still needs more work, some of the mandatory parts are not used so something's wrong.

Comment threadsound/soc/sof/ipc.c Outdated

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.

sorry, what does this do?
The is_ready op is marked a mandatory
int (*is_ready)(struct snd_sof_dev sof_dev); / mandatory */

The comment seems wrong?

Comment threadsound/soc/sof/sof-priv.h Outdated

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.

meh, this is not defined for HDAudio.

Comment threadsound/soc/sof/sof-priv.h Outdated

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.

meh. not defined for HDaudio.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

@plbossart all 3 comments addressed and PR updated now.

@plbossartplbossart 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.

minor nit-pick on dev_err when we return void, looks ok otherwise

Comment threadsound/soc/sof/ops.h Outdated

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.

Ah sorry, I just thought about this one. Since this will not interrupt the flow, we may want to add a _once or _ratelimited qualifier to avoid polluting dmesg. Same remark for all cases where we return void.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Clarify the mandatory and optional dsp ops and fix
return value for mandatory ops.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

@plbossartplbossart 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.

Thanks, merging now.

@plbossart
plbossart merged commit 4066063 into thesofproject:topic/sof-devFeb 7, 2019
@ranj063
ranj063 deleted the upstream/ops_fixes branch February 8, 2019 06:36
oder-chiou pushed a commit to oder-chiou/linux-soundwire that referenced this pull request May 5, 2026
As arm64 JIT now supports timed may_goto instruction, make sure all
relevant tests run on this architecture. Some tests were enabled and
other required modifications to work properly on arm64.
$ ./test_progs -a "stream*","*may_goto*",verifier_bpf_fastcall
thesofproject#404 stream_errors:OK
[...]
thesofproject#406/2 stream_success/stream_cond_break:OK
[...]
thesofproject#494/23 verifier_bpf_fastcall/may_goto_interaction_x86_64:SKIP
thesofproject#494/24 verifier_bpf_fastcall/may_goto_interaction_arm64:OK
[...]
thesofproject#539/1 verifier_may_goto_1/may_goto 0:OK
thesofproject#539/2 verifier_may_goto_1/batch 2 of may_goto 0:OK
thesofproject#539/3 verifier_may_goto_1/may_goto batch with offsets 2/1/0:OK
thesofproject#539/4 verifier_may_goto_1/may_goto batch with offsets 2/0:OK
thesofproject#539 verifier_may_goto_1:OK
thesofproject#540/1 verifier_may_goto_2/C code with may_goto 0:OK
thesofproject#540 verifier_may_goto_2:OK
Summary: 7/16 PASSED, 25 SKIPPED, 0 FAILED
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Acked-by: Xu Kuohai <xukuohai@huawei.com>
Link: https://lore.kernel.org/r/20250827113245.52629-3-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
oder-chiou pushed a commit to oder-chiou/linux-soundwire that referenced this pull request May 5, 2026
Puranjay Mohan says:
====================
bpf, arm64: support for timed may_goto
Changes in v2->v3:
v2: https://lore.kernel.org/all/20250809204833.44803-1-puranjay@kernel.org/
- Rebased on bpf-next/master
- Added Acked-by: tags from Xu and Kumar
Changes in v1->v2:
v1: https://lore.kernel.org/bpf/20250724125443.26182-1-puranjay@kernel.org/
- Added comment in arch_bpf_timed_may_goto() about BPF_REG_FP setup (Xu
Kuohai)
This set adds support for the timed may_goto instruction for the arm64.
The timed may_goto instruction is implemented by the verifier by
reserving 2 8byte slots in the program stack and then calling
arch_bpf_timed_may_goto() in a loop with the stack offset of these two
slots in BPF_REG_AX. It expects the function to put a timestamp in the
first slot and the returned count in BPF_REG_AX is put into the second
slot by a store instruction emitted by the verifier.
arch_bpf_timed_may_goto() is special as it receives the parameter in
BPF_REG_AX and is expected to return the result in BPF_REG_AX as well.
It can't clobber any caller saved registers because verifier doesn't
save anything before emitting the call.
So, arch_bpf_timed_may_goto() is implemented in assembly so the exact
registers that are stored/restored can be controlled (BPF caller saved
registers here) and it also needs to take care of moving arguments and
return values to and from BPF_REG_AX <-> arm64 R0.
So, arch_bpf_timed_may_goto() acts as a trampoline to call
bpf_check_timed_may_goto() which does the main logic of placing the
timestamp and returning the count.
All tests that use may_goto instruction pass after the changing some of
them in patch 2
thesofproject#404 stream_errors:OK
[...]
thesofproject#406/2 stream_success/stream_cond_break:OK
[...]
thesofproject#494/23 verifier_bpf_fastcall/may_goto_interaction_x86_64:SKIP
thesofproject#494/24 verifier_bpf_fastcall/may_goto_interaction_arm64:OK
[...]
thesofproject#539/1 verifier_may_goto_1/may_goto 0:OK
thesofproject#539/2 verifier_may_goto_1/batch 2 of may_goto 0:OK
thesofproject#539/3 verifier_may_goto_1/may_goto batch with offsets 2/1/0:OK
thesofproject#539/4 verifier_may_goto_1/may_goto batch with offsets 2/0:OK
thesofproject#539 verifier_may_goto_1:OK
thesofproject#540/1 verifier_may_goto_2/C code with may_goto 0:OK
thesofproject#540 verifier_may_goto_2:OK
Summary: 7/16 PASSED, 25 SKIPPED, 0 FAILED
====================
Link: https://patch.msgid.link/20250827113245.52629-1-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Sign up for freeto 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

@ranj063@keyonjie@plbossart@wenqingfu