Skip to content

ASoC: SOF: intel: don't read CTX_SAVE reply - #651

Merged
plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
bardliao:cml
Feb 27, 2019
Merged

plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
bardliao:cml

Conversation

@bardliao

Copy link
Copy Markdown
Collaborator

The memory windows are powered off before sending IPC reply back to the
host, so the host should not try to read the mailbox for CTX_SAVE reply.

Signed-off-by: Bard liao yung-chuan.liao@linux.intel.com

Fix thesofproject/sof#984

@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 use of msg->header isn't aligned with what was discussed. @lyakh @keyonjie this really touches the IPC design, can you comment?

Comment thread sound/soc/sof/intel/hda-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.

I thought we discussed that the msg->header field would no longer be used, see e.g. #586
May be that's a good counter-example that it should? Or can you use the body of the msg to find thhe command information

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.

@plbossart Yes, I can use the body to find the command information as struct sof_ipc_cmd_hdr is always the first element of msg_data. However, I think check msg->header doesn't against #586. We don't write msg->header to SHIM register in #586, but it doesn't touch msg->header. In other word, we can still use msg->header after #586 is merged.

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.

no the idea was that the msg->header would be removed if it serves no purpose.

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.

@plbossart updated. use the body of the msg to check if it is SOF_IPC_PM_CTX_SAVE

@ranj063

ranj063 commented Feb 14, 2019

Copy link
Copy Markdown
Collaborator

@bardliao should we generalize this to maybe support other IPC messages that dont require reading the mailbox?

@bardliao

Copy link
Copy Markdown
Collaborator Author

@bardliao should we generalize this to maybe support other IPC messages that dont require reading the mailbox?

@ranj063 Yes, it's a good idea. Probably to add a flag in struct snd_sof_ipc_msg? But I am thinking is it worth to do it? We will still need to check if the message is a non-reply one when we set the flag.

@plbossart

plbossart commented Feb 15, 2019 via email

Copy link
Copy Markdown
Member

@emilchudzik

Copy link
Copy Markdown

Playback and suspend works fine in loop with applied this patch. There is no error message with it.

kernel: cros-sof-v4.19 / 8492020d5967
FW: cml-002-drop-stable / dcd825b
tplg for hda: sof-hda-generic.tplg

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

Not sure if this works?

Comment thread sound/soc/sof/intel/hda-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.

Isn't the header in a memory window? How does this work if the memory is no longer powered?

It feels like we actually do need to preserve the use of the msg/msg_ext bits precisely for this case.

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.

@plbossart msg->msg_data is dynamic allocated msg->msg_data = devm_kzalloc(sdev->dev, PAGE_SIZE, GFP_KERNEL);. I think it is not in a memory window.

@xun2z

xun2z commented Feb 22, 2019 •

Copy link
Copy Markdown

I test the newest patch on WHL RVP, here is the dmesg, no CTX_SAVE error message.

Test Env:
kernel: cros-sof-v4.19 8492020 (with patch pr651)
sof: cml-002-drop-stable dcd825b
tplg: sof-whl-rt5682.tplg

dmesg:

[   51.667062] sof-audio-pci 0000:00:1f.3: ipc tx: 0x40020000: GLB_PM_MSG: CTX_RESTORE
[   51.667198] sof-audio-pci 0000:00:1f.3: ipc tx succeeded: 0x40020000: GLB_PM_MSG: CTX_RESTORE
[   51.667205] HDMI HDA Codec ehdaudio0D2: hdac_hdmi_present_sense: disconnect for pin:port 6:0
[   51.667207] HDMI HDA Codec ehdaudio0D2: hdac_hdmi_present_sense: disconnect for pin:port 7:0
[   51.667288] serial 00:06: activated
[   51.831824] ata3: SATA link down (SStatus 4 SControl 300)
[   51.897655] atkbd serio0: Failed to deactivate keyboard on isa0060/serio0
[   51.964830] acpi LNXPOWER:08: Turning OFF
[   51.965354] acpi LNXPOWER:07: Turning OFF
[   51.967427] OOM killer enabled.
[   51.967428] Restarting tasks ... done.
[   52.071071] video LNXVIDEO:00: Restoring backlight state
[   52.071075] PM: suspend exit
[   52.164210] sof-audio-pci 0000:00:1f.3: ipc rx: 0x90020000: GLB_TRACE_MSG
[   52.164293] sof-audio-pci 0000:00:1f.3: ipc rx done: 0x90020000: GLB_TRACE_MSG
[   52.281670] atkbd serio0: Failed to enable keyboard on isa0060/serio0
[   52.664314] sof-audio-pci 0000:00:1f.3: ipc rx: 0x90020000: GLB_TRACE_MSG
[   52.664399] sof-audio-pci 0000:00:1f.3: ipc rx done: 0x90020000: GLB_TRACE_MSG
[   53.068840] sof-audio-pci 0000:00:1f.3: ipc tx: 0x40010000: GLB_PM_MSG: CTX_SAVE
[   53.069112] sof-audio-pci 0000:00:1f.3: ipc tx succeeded: 0x40010000: GLB_PM_MSG: CTX_SAVE
[   53.069157] sof-audio-pci 0000:00:1f.3: FW Poll Status: reg=0x1010f0f successful
[   53.069729] sof-audio-pci 0000:00:1f.3: FW Poll Status: reg=0xf0f successful
[   53.069742] sof-audio-pci 0000:00:1f.3: DSP core(s) enabled? 0 : core_mask f
[   53.069817] sof-audio-pci 0000:00:1f.3: Debug PCIR: 00000000 at  00000044
[   53.069826] sof-audio-pci 0000:00:1f.3: Debug PCIW: 00000010 at  00000044
[   53.587822] e1000e: enp0s31f6 NIC Link is Up 100 Mbps Full Duplex, Flow Control: None
[   53.587825] e1000e 0000:00:1f.6 enp0s31f6: 10/100 speed: disabling TSO

dmesg.txt

@plbossart

plbossart commented Feb 22, 2019 via email

Copy link
Copy Markdown
Member

@bardliao

Copy link
Copy Markdown
Collaborator Author

That doesn't seem right. where is the data actually coming from? Everything we do is based on memory-windows so there's got to be a copy somewhere.

The data is from memcpy(msg->msg_data, msg_data, msg_bytes);
And the source is from https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sof/pm.c#L198

The memory windows are powered off before sending IPC reply back to the
host, so the host should not try to read the mailbox for CTX_SAVE reply.

Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
@ranj063

ranj063 commented Feb 25, 2019 •

Copy link
Copy Markdown
Collaborator
  • hdr = (struct sof_ipc_cmd_hdr )msg->msg_data; + if (hdr->cmd == (SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CTX_SAVE)) { + / + * memory windows are powered off before sending IPC reply, + * so we can't read the mailbox for CTX_SAVE reply. + */ @plbossart https://github.com/plbossart msg->msg_data is dynamic allocated msg->msg_data = devm_kzalloc(sdev->dev, PAGE_SIZE, GFP_KERNEL); https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sof/ipc.c#L816. I think it is not in a memory window.
    That doesn't seem right. where is the data actually coming from? Everything we do is based on memory-windows so there's got to be a copy somewhere.
    …

@plbossart this is not coming from the memory window. The msg_data is pre-allocated kernel memory which is used for copying to the mailbox during ipc tx. The mailbox reply reading step actually happens after this check. So this check looks legitimate.

But my concern is about the placement of this check. Should we possibly move this check to tx_wait_done() prior to

ret = snd_sof_dsp_get_reply(sdev, msg);
. @bardliao what do you think?

While I'm at it, I want to raise my original point again. I think this should be more generic by maybe adding a field/flag to the ipc msg structure which suggests that the reply should not be read for this msg.

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

ok, I get the flow now and this makes sense.
Can you rebase and resubmit to try and solve CI issues?

@bardliao
bardliao force-pushed the cml branch 2 times, most recently from 5fa0c61 to d2456f6 Compare February 26, 2019 01:17
@bardliao

Copy link
Copy Markdown
Collaborator Author

@plbossart CI issues are solved

@plbossart
plbossart merged commit e3cad63 into thesofproject:topic/sof-dev Feb 27, 2019
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.

5 participants