You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] [rt700] SDW Alert happens before codec is enumerated #2344
Describe the bug
We can see sdw IO transfer timed out when we do suspend test. And the reason of sdw IO transfer timed out is that an alert is rised before the codec is enumerated.
To Reproduce
run sudo rtcwake -m mem -s 5.
Reproduce rate
more than 50%
Expected result
No issue on the suspend test.
Actual result
See IO transfer timed out errors in dmesg.
@bardliao it's not possible to have an alert if the DeviceNumber is zero and the interrupt masks are not initialized. I wonder if this is a codec problem where on hard reset the interrupt masks are not reset.
Edit: the master driver should first go through the sdw_clear_slave_status() to mark the status as UNATTACHED on resume. Then we would first deal with enumeration. I think we have a race condition here where the codec resumes before the link is reset and its status marked as UNACTTACHED.
@plbossart I think I know the reason of IO transfer timed out now. We got an interrupt immediately after rt700 is enumerated. However, rt700 go into suspend right after that. See log below
[ 820.942039] soundwire sdw-master-0: bard: sdw_clear_slave_status 1
[ 820.942043] rt700 sdw:1:25d:700:0: sdw_modify_slave_status: initializing completion for Slave 1
[ 820.942274] rt700 sdw:1:25d:700:0: bard: rt700_dev_resume
[ 820.961605] intel-sdw intel-sdw.1: Slave status change
[ 820.961622] soundwire sdw-master-0: Slave attached, programming device number
[ 820.961924] soundwire sdw-master-0: SDW Slave Addr: 10025d070000
[ 820.961929] soundwire sdw-master-0: SDW Slave class_id 0, part_id 700, mfg_id 25d, unique_id 0, version 1
[ 820.961931] soundwire sdw-master-0: Slave already registered, reusing dev_num:1
[ 820.962166] intel-sdw intel-sdw.1: Msg Ack not received
[ 820.962167] intel-sdw intel-sdw.1: Msg Ack not received
[ 820.962168] intel-sdw intel-sdw.1: Msg Ack not received
[ 820.962170] intel-sdw intel-sdw.1: Msg Ack not received
[ 820.962171] intel-sdw intel-sdw.1: Msg Ack not received
[ 820.962172] intel-sdw intel-sdw.1: Msg Ack not received
[ 820.962174] intel-sdw intel-sdw.1: Msg ignored for Slave 0
[ 820.962176] soundwire sdw-master-0: No more devices to enumerate
[ 820.962204] intel-sdw intel-sdw.1: Slave status change
[ 820.962212] rt700 sdw:1:25d:700:0: sdw_modify_slave_status: signaling completion for Slave 1
[ 820.962450] intel-sdw intel-sdw.1: Slave status change
[ 820.962458] soundwire sdw-master-0: bard: Slave 1 status 1
[ 820.962485] rt700 sdw:1:25d:700:0: bard: rt700_dev_resume cache sync start
[ 820.967985] rt700 sdw:1:25d:700:0: bard: rt700_dev_resume cache sync end
[ 820.967992] rt700 sdw:1:25d:700:0: bard: rt700_dev_suspend
Now see sdw_handle_slave_alerts(). We call pm_runtime_get_sync() while rt700 is just suspended.
I don't think rt700 is already resumed when pm_runtime_get_sync returned and then sdw_read(slave, SDW_SCP_INT1); is called while rt700 is suspended. So IO transfer timed out happens.
it looks like we have a race condition with a system suspend happening immediately while we are still dealing with a device interrupt and we have a pending transaction. On the next system resume, there is a timeout and an error, but that doesn't seem to be a real problem. The error happens in a workqueue.
I think we should use cancel_work_sync() on the master level to make sure current transactions are completed, and no alert can be handled while the master suspends.
Activity
bardliao commentedon Aug 5, 2020
@plbossart Should we ignore the alert before codec is enumerated?
Does below change make sense?
plbossart commentedon Aug 5, 2020
@bardliao it's not possible to have an alert if the DeviceNumber is zero and the interrupt masks are not initialized. I wonder if this is a codec problem where on hard reset the interrupt masks are not reset.
Edit: the master driver should first go through the sdw_clear_slave_status() to mark the status as UNATTACHED on resume. Then we would first deal with enumeration. I think we have a race condition here where the codec resumes before the link is reset and its status marked as UNACTTACHED.
bardliao commentedon Aug 11, 2020
@plbossart I think I know the reason of
IO transfer timed outnow. We got an interrupt immediately after rt700 is enumerated. However, rt700 go into suspend right after that. See log belowNow see sdw_handle_slave_alerts(). We call pm_runtime_get_sync() while rt700 is just suspended.
I don't think rt700 is already resumed when
pm_runtime_get_syncreturned and thensdw_read(slave, SDW_SCP_INT1);is called while rt700 is suspended. SoIO transfer timed outhappens.dmesg_cml_rvp_2.txt
log_diff.txt
plbossart commentedon Aug 11, 2020
Great work @bardliao
I think the last suspend is a system suspend.
it looks like we have a race condition with a system suspend happening immediately while we are still dealing with a device interrupt and we have a pending transaction. On the next system resume, there is a timeout and an error, but that doesn't seem to be a real problem. The error happens in a workqueue.
I think we should use cancel_work_sync() on the master level to make sure current transactions are completed, and no alert can be handled while the master suspends.
soundwire: cadence: fix race condition between suspend and Slave devi…
plbossart commentedon Aug 11, 2020
@bardliao can you try #2354, not sure if this helps?
soundwire: cadence: fix race condition between suspend and Slave devi…
bardliao commentedon Aug 12, 2020
Thanks, @plbossart it works. But it should be
if (cdns->interrupt_enable)below. We need to schedule the workqueue if interrupt is enabled.soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
11 remaining items
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…
Bluetooth: Fix alt settings for incoming SCO with transparent coding …
soundwire: cadence: fix race condition between suspend and Slave devi…
soundwire: cadence: fix race condition between suspend and Slave devi…