Skip to content

ASoC: SOF: refine interrupt function on BDW & HSW#381

Merged
plbossart merged 1 commit intothesofproject:topic/sof-devfrom
RanderWang:bdw_hsw_irq
Dec 7, 2018
Merged

ASoC: SOF: refine interrupt function on BDW & HSW#381
plbossart merged 1 commit intothesofproject:topic/sof-devfrom
RanderWang:bdw_hsw_irq

Conversation

@RanderWang
Copy link

@RanderWang RanderWang commented Dec 6, 2018

This patch follows commit:

ASoC: SOF: byt: fix IPC handled wrong issue(thesofproject/sof@4734afb)

Align with apl/cnl, to fix the issue with dmesg shows "error: rx list
empty but received ...", add mask check for interrupt handling.

two special change:
(1) remove memory read in IRQ function, it be done in ipc_msgs_rx
So this memory read is duplicated.

(2) msg id is stored in ipcx not in hdr. Now we set zero in ipcx
and hdr is zero, so no problem is found.

Test on BDW, pass.

Signed-off-by: Keyon Jie yang.jie@linux.intel.com
Signed-off-by: Rander Wang rander.wang@linux.intel.com

@RanderWang
Copy link
Author

RanderWang commented Dec 6, 2018

@plbossart I know you are curious about why msg is zero in IPCX on BDW. This is caused by our imperfect design of msg_id. our msg_id is a 32bit cmd. On APL msg_id is set like:

u32 cmd = msg->header;
/* send IPC message to DSP */
hda_dsp_mailbox_write(sdev, sdev->host_box.offset, msg->msg_data,
		      msg->msg_size);
snd_sof_dsp_write(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCI,
		  cmd | HDA_DSP_REG_HIPCI_BUSY);

It is lucky that cmd never overwrite some bits on APL, CNL, BYT, but on BDW it would overwrite SHIM_IPCX_DONE. This makes interrupt out of order. So that is why we don't set msg_id in SHIM_IPCX.

Actually msg_id is not useful now, so IPC works on BDW

@plbossart
Copy link
Member

@RanderWang I didn't understand your explanations but will give you the benefit of doubt. Can you please rebase since there are conflicts with Keyon's cleanup

This patch follows commit:

ASoC: SOF: byt: fix IPC handled wrong issue

Align with apl/cnl, to fix the issue with dmesg shows "error: rx list
empty but received ...", add mask check for interrupt handling.

two special change:
(1) remove memory read in IRQ function, it be done in ipc_msgs_rx
    So this memory read is duplicated.

(2) msg id is stored in ipcx not in hdr. Now we set zero in ipcx
    and hdr is zero, so no problem
    is found.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
@RanderWang
Copy link
Author

RanderWang commented Dec 7, 2018

Test and update the PR , it works on BDW.

The msg_id issue is a little obscure, I also spent some time to find this. Just talk about APL.

snd_sof_dsp_write(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCI,
cmd | HDA_DSP_REG_HIPCI_BUSY);

HDA_DSP_REG_HIPCI is a 32bit register and only the 32th bit, named HDA_DSP_REG_HIPCI_BUSY, is used and other bits is unused. So we use other bits to take msg_id which uses LSB 31bits and let the 32th bit untouched. But on BDW, the 31th bit, named SHIM_IPCX_DONE, is used for IPC. So msg_id would overwrite this bit.

@RanderWang
Copy link
Author

And I think the difference between bdw_send_msg and hda_dsp_ipc_send_msg, byt_send_msg is obscure, Someone in open source community may report a bug. I think we should refine the msg id.
Actually, the idea of msg id is out of date, we don't need it now. First it is used to identify multi-thread IPC msg, but later we found that IPC message should be serialized. Now there is only one msg in each transaction, so we don't need msg id to get the correct message.

@bardliao
Copy link
Collaborator

bardliao commented Dec 7, 2018

@RanderWang We may need msg id if we implement compound ipc in the future.

@RanderWang
Copy link
Author

@RanderWang We may need msg id if we implement compound ipc in the future.

yes, but not set msg id in a 32bit register

@plbossart plbossart merged commit 4d2fd06 into thesofproject:topic/sof-dev Dec 7, 2018
@plbossart
Copy link
Member

@RanderWang if you believe the IPC definition is incorrect/confusing/suboptimal, please file a separate issue and suggest a fix. It's very difficult to follow your line of thought and what exactly you are referring to. Thanks!

plbossart pushed a commit that referenced this pull request Jun 12, 2020
Add and use snd_pcm_stream_lock_nested() in snd_pcm_link/unlink
implementation.  The code is fine, but generates a lockdep complaint:

============================================
WARNING: possible recursive locking detected
5.7.1mq+ #381 Tainted: G           O
--------------------------------------------
pulseaudio/4180 is trying to acquire lock:
ffff888402d6f508 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xda8/0xee0 [snd_pcm]

but task is already holding lock:
ffff8883f7a8cf18 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xe4e/0xee0 [snd_pcm]

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&group->lock);
  lock(&group->lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by pulseaudio/4180:
 #0: ffffffffa1a05190 (snd_pcm_link_rwsem){++++}-{3:3}, at: snd_pcm_common_ioctl+0xca0/0xee0 [snd_pcm]
 #1: ffff8883f7a8cf18 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xe4e/0xee0 [snd_pcm]
[...]

Cc: stable@vger.kernel.org
Fixes: f57f3df ("ALSA: pcm: More fine-grained PCM link locking")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/37252c65941e58473b1219ca9fab03d48f47e3e3.1591610330.git.mirq-linux@rere.qmqm.pl

Signed-off-by: Takashi Iwai <tiwai@suse.de>
naveen-manohar pushed a commit to naveen-manohar/linux that referenced this pull request Jun 26, 2020
commit e18035c upstream.

Add and use snd_pcm_stream_lock_nested() in snd_pcm_link/unlink
implementation.  The code is fine, but generates a lockdep complaint:

============================================
WARNING: possible recursive locking detected
5.7.1mq+ thesofproject#381 Tainted: G           O
--------------------------------------------
pulseaudio/4180 is trying to acquire lock:
ffff888402d6f508 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xda8/0xee0 [snd_pcm]

but task is already holding lock:
ffff8883f7a8cf18 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xe4e/0xee0 [snd_pcm]

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&group->lock);
  lock(&group->lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by pulseaudio/4180:
 #0: ffffffffa1a05190 (snd_pcm_link_rwsem){++++}-{3:3}, at: snd_pcm_common_ioctl+0xca0/0xee0 [snd_pcm]
 thesofproject#1: ffff8883f7a8cf18 (&group->lock){-...}-{2:2}, at: snd_pcm_common_ioctl+0xe4e/0xee0 [snd_pcm]
[...]

Cc: stable@vger.kernel.org
Fixes: f57f3df ("ALSA: pcm: More fine-grained PCM link locking")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/37252c65941e58473b1219ca9fab03d48f47e3e3.1591610330.git.mirq-linux@rere.qmqm.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Takashi Iwai <tiwai@suse.de>
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