Skip to content

Doing sof-eqctl EQ response set during playback causes next playback to fail  #753

Closed

Description

@singalsu

The firmware currently does not support change of EQ configuration during streaming so it returns -EBUSY error if the configuration cannot be changed immediately. The change of response should happen with next playback start without errors.

It's not clear that this is a driver issue. While the switch capability is not yet implemented in EQ the choice what is done in this situation could be different. Eventually the FW will have capability for on-the-fly reconfiguration, at least when the needed allocation sizes for configuration data and filter delay lines is equal or smaller than previous configuration.

But since it creates a fail in the current shape it must be treated as bug in driver and/or FW.

The sequence to this error is to start playback in one window with aplay. Then immediately in other window do command:

$ amixer controls | grep EQ
numid=23,iface=MIXER,name='EQFIR1.0 EQFIR'
numid=22,iface=MIXER,name='EQIIR1.0 EQIIR'

$ sof-eqctl -n 22 -s eq_iir_bassboost.txt 
Control size is 304.
Applying configuration "eq_iir_bassboost.txt" into device hw:0 control numid=22.
4607827,0,116,50331648,0,0,0,0,116,2,1,0,0,0,0,0,0,2,2,0,0,0,0,3227172081,2141520527,536653443,3221660410,536653443,0,16384,3260252783,2107733822,161646111,3961037800,172645501,4294967294,27910
Success.

The command appears to pass but after next playback attempt dmesg shows this

[63012.786246] sof-audio-pci 0000:00:0e.0: ipc tx: 0x60010000: GLB_STREAM_MSG: PCM_PARAMS
[63012.786513] sof-audio-pci 0000:00:0e.0: ipc tx succeeded: 0x60010000: GLB_STREAM_MSG: PCM_PARAMS
[63012.800463] sof-audio-pci 0000:00:0e.0: pcm: trigger stream 0 dir 0 cmd 1
[63012.800475] sof-audio-pci 0000:00:0e.0: ipc tx: 0x60040000: GLB_STREAM_MSG: TRIG_START
[63012.800735] sof-audio-pci 0000:00:0e.0: ipc tx succeeded: 0x60040000: GLB_STREAM_MSG: TRIG_START
[63013.769847] sof-audio-pci 0000:00:0e.0: ipc rx: 0x90020000: GLB_TRACE_MSG
[63013.769861] sof-audio-pci 0000:00:0e.0: ipc rx done: 0x90020000: GLB_TRACE_MSG
[63022.640975] sof-audio-pci 0000:00:0e.0: ipc tx: 0x50030000: GLB_COMP_MSG: SET_VALUE: SET_DATA
[63022.641159] sof-audio-pci 0000:00:0e.0: error: ipc error for 0x50030000 size 240
[63022.641167] sof-audio-pci 0000:00:0e.0: error: set/get ctrl ipc comp 0

In firmware trace it looks like the re-sent binary command to FIR becomes corrupt and fails the ABI check. The configuration was sent to IIR.

    0      2          IPC             47998.958333        65.677086 /home/singalsu/work/current/sof/sof/src/ipc/handler.c:865 	ipc: hdr 0x50030000 tx (180) > rx (92)
    0      2          IPC             48002.447917         3.489583 /home/singalsu/work/current/sof/sof/src/ipc/handler.c:867 	ipc: comp 3 -> cmd 3
    0      2       EQ_FIR             48007.083333         4.635417 /home/singalsu/work/current/sof/sof/src/audio/eq_fir.c:614 	eq_fir_cmd()
    0      2       EQ_FIR             48009.947917         2.864583 /home/singalsu/work/current/sof/sof/src/audio/eq_fir.c:561 	fir_cmd_set_data(), SOF_CTRL_CMD_BINARY
    0      2       EQ_FIR             48014.166667         4.218750 /home/singalsu/work/current/sof/sof/src/audio/eq_fir.c:581 	fir_cmd_set_data(): blob size: 56
    0      2          IPC             48108.541667        94.375000 /home/singalsu/work/current/sof/sof/src/ipc/handler.c:865 	ipc: hdr 0x50030000 tx (125) > rx (92)
    0      2          IPC             48111.666667         3.125000 /home/singalsu/work/current/sof/sof/src/ipc/handler.c:867 	ipc: comp 2 -> cmd 3
    0      1         COMP             48115.937500         4.270833 /home/singalsu/work/current/sof/sof/src/include/sof/audio/component.h:424 	comp_cmd() error: invalid version, data->magic = 0, data->abi = 65536

Activity

  1. added
    bug
    P2
    on Mar 27, 2019
  2. singalsu commented on Mar 27, 2019

    @singalsu
    CollaboratorAuthor

    @cujomalainey @juimonen @ranj063 I've now entered this issue that I briefly described in email.

  3. cujomalainey commented on Mar 28, 2019

    @cujomalainey

    Is there a case where we could change config in the middle of playback? I'm thinking for someone running tuning tools, this way they could make changes without having to constantly restart playback.

  4. singalsu commented on Mar 29, 2019

    @singalsu
    CollaboratorAuthor

    Yep that would be one case. Also if there's an audio server it likely also extends the playback to be continuous from ALSA point of view over successive music tracks.

  5. self-assigned this
    on Mar 29, 2019
  6. singalsu commented on Apr 23, 2019

    @singalsu
    CollaboratorAuthor

    I'm starting with this now.

    Edit: I worked with volume overflow instead. So far only confirmed exactly this same happens. The driver is busy not handled properly by kernel.

  7. singalsu commented on Apr 29, 2019

    @singalsu
    CollaboratorAuthor

    This quick fix shows that the DSP response with -EBUSY corrupts the PM cache. If we omit this copy the next playback starts with new EQ configuration.

    --- a/sound/soc/sof/ipc.c
    +++ b/sound/soc/sof/ipc.c
    @@ -212,7 +212,8 @@ static int tx_wait_done(struct snd_sof_ipc *ipc, struct snd_sof_ipc_msg *msg,
            } else {
                    /* copy the data returned from DSP */
                    ret = msg->reply_error;
    -               if (msg->reply_size)
    +               dev_dbg(sdev->dev, "ret = %d, reply_size = %d\n", ret, msg->reply_size);
    +               if (msg->reply_size  && ret != -EBUSY)
                            memcpy(reply_data, msg->reply_data, msg->reply_size);
                    if (ret < 0)
                            dev_err(sdev->dev, "error: ipc error for 0x%x size %zu\n",
    
    

    However I think it's better to instead in snd_sof_bytes_ext_put() to copy the data from userspace into a temporary buffer, send it, and copy to cache only if IPC was successful. Thanks for help @kv2019i !

  8. singalsu commented on Jun 14, 2019

    @singalsu
    CollaboratorAuthor

    ETA to continue fixing this is end of June after my vacation. I need to change the approach because of fundamental changes done into control.c in SOF kernel.

  9. singalsu commented on Jan 13, 2020

    @singalsu
    CollaboratorAuthor

    The PRs to avoid this are under review in SOF.

  10. singalsu commented on Jan 14, 2020

    @singalsu
    CollaboratorAuthor

    Merge of SOF PRs thesofproject/sof#2259 and thesofproject/sof#2065 fix this issue on FW side. Due to new scontrols caching for power management the fix on Linux kernel side would have been much more complex.

  11. singalsu commented on Jan 14, 2020

    @singalsu
    CollaboratorAuthor

    It's now OK to close this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions