Skip to content

ASoC: SOF: use spin_lock_irq to protect resource - #434

Merged
plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
RanderWang:irq_save
Dec 18, 2018
Merged

plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
RanderWang:irq_save

Conversation

@RanderWang

@RanderWang RanderWang commented Dec 13, 2018 •

Copy link
Copy Markdown

ipc_lock is used to protect ipc message list shared by user
contexts and a workqueue. So there is no need to save interrupt
status with spin_lock_irqsave, just use spin_lock_irq.

it fixs #422

@ranj063

ranj063 commented Dec 13, 2018

Copy link
Copy Markdown
Collaborator

@RanderWang im trying to educate myself better on irq...what is the definition of a IRQ function?

@RanderWang

Copy link
Copy Markdown
Author

@RanderWang im trying to educate myself better on irq...what is the definition of a IRQ function?

please refer to https://geek-university.com/linux/irq-interrupt-request/. I will refine function to handler

@ranj063

ranj063 commented Dec 13, 2018

Copy link
Copy Markdown
Collaborator

@RanderWang handler automatically clarifies what you mean here. Thanks!

@ranj063

ranj063 commented Dec 13, 2018

Copy link
Copy Markdown
Collaborator

@RanderWang btw which interrupts doe spin_lock_irq() disable? Does it disable all interrupts?

@RanderWang

Copy link
Copy Markdown
Author

@RanderWang btw which interrupts doe spin_lock_irq() disable? Does it disable all interrupts?

interrupt in local cpu, not in other cpu

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

Hi Rander,
can you add more comments for those functions according to Takashi's comments, similar as:
/* ipc_lock should not held by caller, and we should not call it in interrupt context */

@RanderWang

Copy link
Copy Markdown
Author

@keyonjie It is strange to add these comments before spin_lock. The usage of spin_lock should be in everyone's mind. I don't see any comment to spin_lock in HDA.

@plbossart

plbossart commented Dec 13, 2018 •

Copy link
Copy Markdown
Member

@keyonjie It is strange to add these comments before spin_lock. The usage of spin_lock should be in everyone's mind. I don't see any comment to spin_lock in HDA.

@RanderWang [sarcasm] it's so clear we are at the 3rd PR to fix this... [/sarcasm] Please document what the assumptions are so that everyone can figure it out for themselves. It's not because others don't explain their code that we should follow their example, and the questions above show that this knowledge on spin_locks is not widely shared in the team.

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

The commit message is a circular explanation that makes little sense. It should clearly explain why the ipc functions are not called in IRQ handler and thus the use of spin_lock_irqsave is not needed.
Also we need similar comments, e.g. before each function to state why the spin_lock_irq is used. No need to explain this at every line.

@ranj063

ranj063 commented Dec 13, 2018

Copy link
Copy Markdown
Collaborator

@plbossart thanks for this information: "It should clearly explain why the ipc functions are not called in IRQ handler and thus the use of spin_lock_irqsave is not needed"

I was so confused about spin_lock_irq and spin_lock_irqsave...this makes it clear as day!

@keyonjie

Copy link
Copy Markdown

@keyonjie It is strange to add these comments before spin_lock. The usage of spin_lock should be in everyone's mind. I don't see any comment to spin_lock in HDA.

@RanderWang I meant before the functions, not before each calling to spin_lock. similar to this one in sst-ipc.c:

/* locks held by caller */
void sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc,
	struct ipc_message *msg)
{
	msg->complete = true;

	if (!msg->wait)
		list_add_tail(&msg->list, &ipc->empty_list);
	else
		wake_up(&msg->waitq);
}
EXPORT_SYMBOL_GPL(sst_ipc_tx_msg_reply_complete);

@RanderWang

Copy link
Copy Markdown
Author

ok, I will update later

@RanderWang

Copy link
Copy Markdown
Author

sorry, I cant connect to my work PC via VPN, so I can't update my PR today

@RanderWang
RanderWang force-pushed the irq_save branch 3 times, most recently from e1816f2 to 94b4e12 Compare December 15, 2018 02:49
@RanderWang

RanderWang commented Dec 15, 2018 •

Copy link
Copy Markdown
Author

update PR, thanks for review

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

Please reword the comment and commit message. remember, the problem is not about being right but about convincing maintainers that you are right. The feedback on spin_locks came from Takashi Iwai, and you want a clear/logical explanation to avoid yet another round of reviews.

Comment thread sound/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 @RanderWang, this does not cut it. What is needed is a clear explanation on why the conditions to use spin_lock_irq are met in the SOF IPC, and why irqsave is not needed. Your comments are unclear and raise doubts for reviewers.

Your commit message is also totally unclear. It's a circular explanation with no logical line of thought. Please reword it by explaining how the IPC is used, and based on this why spin_lock_irq is sufficient. We don't want a general lecture on spin lock, but rather an explanation of how the IPC works.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I may focus on lecture and miss the target. Ok, I will update PR later.

@RanderWang
RanderWang force-pushed the irq_save branch 4 times, most recently from 289575e to 38e79ce Compare December 17, 2018 08:35
@RanderWang

Copy link
Copy Markdown
Author

update PR, thanks!

@plbossart plbossart 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 comment issue, thanks

Comment thread sound/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.

grammar: There is no need

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, I will refine it

@RanderWang

Copy link
Copy Markdown
Author

update PR, thanks!

Ipc_lock is used to protect ipc message list shared by user contexts
and a workqueue. So there is no need to save interrupt status with
spin_lock_irqsave, just use spin_lock_irq.

Signed-off-by: Rander Wang <rander.wang@linux.intel.com>

@plbossart plbossart 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 @RanderWang

@plbossart
plbossart merged commit a6a1981 into thesofproject:topic/sof-dev Dec 18, 2018
ujfalusi pushed a commit to ujfalusi/sof-linux that referenced this pull request Apr 30, 2026
With support of private stack, relevant tests must pass
on powerpc64.

#./test_progs -t struct_ops_private_stack
thesofproject#434/1   struct_ops_private_stack/private_stack:OK
thesofproject#434/2   struct_ops_private_stack/private_stack_fail:OK
thesofproject#434/3   struct_ops_private_stack/private_stack_recur:OK
thesofproject#434     struct_ops_private_stack:OK
Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: Abhishek Dubey <adubey@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260401103215.104438-2-adubey@linux.ibm.com
oder-chiou pushed a commit to oder-chiou/linux-soundwire that referenced this pull request May 5, 2026
Puranjay Mohan says:

====================
bpf,arm64: Add support for BPF Arena

Changes in V4
V3: https://lore.kernel.org/bpf/20240323103057.26499-1-puranjay12@gmail.com/
- Use more descriptive variable names.
- Use insn_is_cast_user() helper.

Changes in V3
V2: https://lore.kernel.org/bpf/20240321153102.103832-1-puranjay12@gmail.com/
- Optimize bpf_addr_space_cast as suggested by Xu Kuohai

Changes in V2
V1: https://lore.kernel.org/bpf/20240314150003.123020-1-puranjay12@gmail.com/
- Fix build warnings by using 5 in place of 32 as DONT_CLEAR marker.
  R5 is not mapped to any BPF register so it can safely be used here.

This series adds the support for PROBE_MEM32 and bpf_addr_space_cast
instructions to the ARM64 BPF JIT. These two instructions allow the
enablement of BPF Arena.

All arena related selftests are passing.

  [root@ip-172-31-6-62 bpf]# ./test_progs -a "*arena*"
  thesofproject#3/1     arena_htab/arena_htab_llvm:OK
  thesofproject#3/2     arena_htab/arena_htab_asm:OK
  thesofproject#3       arena_htab:OK
  thesofproject#4/1     arena_list/arena_list_1:OK
  thesofproject#4/2     arena_list/arena_list_1000:OK
  thesofproject#4       arena_list:OK
  thesofproject#434/1   verifier_arena/basic_alloc1:OK
  thesofproject#434/2   verifier_arena/basic_alloc2:OK
  thesofproject#434/3   verifier_arena/basic_alloc3:OK
  thesofproject#434/4   verifier_arena/iter_maps1:OK
  thesofproject#434/5   verifier_arena/iter_maps2:OK
  thesofproject#434/6   verifier_arena/iter_maps3:OK
  thesofproject#434     verifier_arena:OK
  Summary: 3/10 PASSED, 0 SKIPPED, 0 FAILED

This will need the patch [1] that introduced insn_is_cast_user() helper to
build.

The verifier_arena selftest could fail in the CI because the following
commit[2] is missing from bpf-next:

[1] https://lore.kernel.org/bpf/20240324183226.29674-1-puranjay12@gmail.com/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit/?id=fa3550dca8f02ec312727653a94115ef3ab68445

Here is a CI run with all dependencies added: kernel-patches/bpf#6641
====================

Link: https://lore.kernel.org/r/20240325150716.4387-1-puranjay12@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
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