linux icon indicating copy to clipboard operation
linux copied to clipboard

[BUG][Chrome] Gen4.1 AIOC rt256 jack detection will fail if we connect in DSP runtime suspend state.

Open Vamshigopal opened this issue 1 year ago • 19 comments

Describe the bug On ADL-P RVP we connected Gen4.1 AIOC to check ALC256 in HD-A mode. We found that headset jack detection is not working when DSP is in runtime suspend state. evtest also couldnt detect any event after jack plug. But headset jack detection is working fine when DSP is in active state.

To Reproduce connect headset when DSP is in runtime suspend state. cat /sys/bus/pci/devices/0000:00:1f.3/power/runtime_status suspended

Expected result Should detect headset when plugged in

Actual result Jack detection not working

Firmware https://github.com/thesofproject/sof/tree/cavs2.5-001-drop-stable top commit: f91af22e53ab6fc652713240dee38bec68b15c7e

Topology sof-hda-generic-2ch.tplg

Kernel https://chromium.googlesource.com/chromiumos/third_party/kernel/+/refs/tags/v6.6.16

Reproduction Rate 100%

logs dmesg_jack_insert_in_active.log amixer_jack_insert_in_active.txt dmesg_jack_insert_in_suspend.log amixerdump_jack_insert_in_suspend.txt

Vamshigopal avatar Feb 15 '24 08:02 Vamshigopal

@mengdonglin @plbossart @ujfalusi @bardliao @kv2019i @sathya-nujella

Vamshigopal avatar Feb 15 '24 08:02 Vamshigopal

are the patches from https://github.com/thesofproject/linux/pull/4769 in your kernel @Vamshigopal ?

plbossart avatar Feb 15 '24 14:02 plbossart

Also please clarify the expected behavior a) wake-up and resume when the headset is inserted, or b) detect the headset when the system resumes, e.g. by playing a sound.

Different code paths.

plbossart avatar Feb 15 '24 14:02 plbossart

are the patches from #4769 in your kernel @Vamshigopal ?

I have taken this patch in kernel, still issue reproduces.

Also please clarify the expected behavior a) wake-up and resume when the headset is inserted, or b) detect the headset when the system resumes, e.g. by playing a sound.

a. Just the jack detection when headset is inserted when DSP is in runtime suspend state. b. Headset inserted during suspend detects when playing a sound.

Vamshigopal avatar Feb 16 '24 07:02 Vamshigopal

Also please clarify the expected behavior a) wake-up and resume when the headset is inserted, or b) detect the headset when the system resumes, e.g. by playing a sound.

a. Just the jack detection when headset is inserted when DSP is in runtime suspend state. b. Headset inserted during suspend detects when playing a sound.

I was asking an a) or b) question, you replied with both... I can't figure out what you are trying to say @Vamshigopal

plbossart avatar Feb 16 '24 15:02 plbossart

I was asking an a) or b) question, you replied with both... I can't figure out what you are trying to say @Vamshigopal

@plbossart I meant b is already working, issue is with a.

Vamshigopal avatar Feb 20 '24 06:02 Vamshigopal

@Vamshigopal please double-check what the behavior is with the snd-hda-intel driver, I would bet a) is not handled as well with HDaudio codecs.

plbossart avatar Feb 20 '24 11:02 plbossart

@plbossart , i double checked with snd_hda_intel driver , i wouldnt see DSP going runtime suspend state it always in active state. So my observation with snd_hda_intel is not valid. Changing in issue description.

Vamshigopal avatar Feb 20 '24 13:02 Vamshigopal

@Vamshigopal with snd-hda-intel there is no DSP enabled. So not sure what you are referring to. I believe the PCI device will go to runtime suspend state, doesn't it?

plbossart avatar Mar 04 '24 17:03 plbossart

@Vamshigopal @plbossart But with runtime-pm enabled, snd-hda-intel is a good reference (CONFIG_SND_HDA_POWER_SAVE_DEFAULT=1). With audio controller+codec in runtime suspend, we should wake-up on jack-detect (but not if system is suspended)

kv2019i avatar Mar 04 '24 18:03 kv2019i

I believe the PCI device will go to runtime suspend state, doesn't it?

@plbossart with snd-hda-intel driver PCI device is not going to runtime suspend.

localhost ~ # cat /sys/class/pci_bus/0000:00/device/0000:00:1f.3/power/runtime_enabled enabled localhost ~ # cat /sys/class/pci_bus/0000:00/device/0000:00:1f.3/power/runtime_status active

Vamshigopal avatar Mar 05 '24 05:03 Vamshigopal

CONFIG_SND_HDA_POWER_SAVE_DEFAULT=1

with snd-hda-intel driver default value was 15 i changed it to 1 , still i see PCI device is active localhost ~ # cat /sys/class/pci_bus/0000:00/device/0000:00:1f.3/power/runtime_status active

Vamshigopal avatar Mar 05 '24 11:03 Vamshigopal

Well for any HDaudio problem the rule is that we want to see what happens without SOF.

Since without SOF there is no pm_runtime suspend, we have no means to compare or triangulate what happens.

So for now, it's just not possible to make any progress... You'll have to check WHY the snd-hda-intel keeps the device active and only then can we try to look at SOF issues.

plbossart avatar Mar 05 '24 15:03 plbossart

@plbossart

So for now, it's just not possible to make any progress... You'll have to check WHY the snd-hda-intel keeps the device active and only then can we try to look at SOF issues.

I used options snd-sof-pci sof_pci_debug=0x01 to disable runtime PM with SOF driver , issue dont reproduce.

Vamshigopal avatar Mar 27 '24 10:03 Vamshigopal

I think this will enable rpm for the legacy stack:

options snd-hda-intel dyndbg=+pmf power_save=2 power_save_controller=1

This will cause rpm suspend after two seconds of inactivity.

ujfalusi avatar Mar 27 '24 11:03 ujfalusi

options snd-hda-intel dyndbg=+pmf power_save=2 power_save_controller=1

This is not helping for rpm suspend.

Vamshigopal avatar Mar 27 '24 12:03 Vamshigopal

After tested with latest chrome kernel ( https://chromium.googlesource.com/chromiumos/third_party/kernel/+/refs/tags/v6.6.22), we observe that when we insert jack in rpm state it detects as headset playback device , it wont detect headset mic. Issue reproduces in 2/10 times.

Vamshigopal avatar Mar 27 '24 12:03 Vamshigopal

I tested with today's sof-dev on a generic HDA system and jack detection works 10/10 with both legacy driver and SOF. Let's try to get snd-hda-intel driver going to suspend in your system, so we can exclude the DSP from this analysis. It is possible there's something in the kernel between sof-dev and 6.6.22, but that we can exclude by testing with snd-hda-intel.

kv2019i avatar Mar 27 '24 12:03 kv2019i

options snd-hda-intel dyndbg=+pmf power_save=2 power_save_controller=1

This is not helping for rpm suspend.

Applied the above parameters in /etc/modprobe.d/*.conf and its not taking into effect , not sure on this.

But when we apply manually , its working

echo Y >/sys/module/snd_hda_intel/parameters/power_save_controller echo 2 >/sys/module/snd_hda_intel/parameters/power_save cat /sys/devices/pci0000:00/0000:00:1f.3/power/runtime_status suspended

Issue reproduces with legacy driver as well.

Vamshigopal avatar Mar 28 '24 09:03 Vamshigopal

I've lost the plot on this one @Vamshigopal @kv2019i @bardliao

Is this a case of missing verbs in CoreBoot?

plbossart avatar Apr 24 '24 17:04 plbossart

Appologies for late update. After updating the verbs provided by realtek in coreboot. Issue is not reproducible.

Thanks @plbossart @kv2019i @ujfalusi for debug suggestions , I've learnt couple of new things from this bug.

Vamshigopal avatar Apr 25 '24 04:04 Vamshigopal