Skip to content

ASoC: SOF: Intel: only detect codecs when HDA DSP probe#5492

Merged
bardliao merged 2 commits intothesofproject:topic/sof-devfrom
bardliao:for-ptl-jd
Jul 31, 2025
Merged

ASoC: SOF: Intel: only detect codecs when HDA DSP probe#5492
bardliao merged 2 commits intothesofproject:topic/sof-devfrom
bardliao:for-ptl-jd

Conversation

@bardliao
Copy link
Collaborator

SDW codecs use the global HDaudio WAKEEN/STS to detect wakes since LNL. But the wakeen is handled in the SDW driver. We should filter the bus->codec_mask to only include HDA and IDISP codecs to avoid clearing the wakeen status before it is handled.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies the HDA codec detection logic to filter the codec mask to only include HDA and IDISP codecs, excluding SDW (SoundWire) codecs. This change prevents interference with SDW codec wake handling since LNL (Lunar Lake) platforms where SDW codecs use the global HDaudio WAKEEN/STS mechanism but have their wake events handled separately by the SDW driver.

  • Filters bus->codec_mask to only include HDA and IDISP codecs using a bitmask
  • Adds explanatory comment about SDW codec wake handling separation
  • Prevents clearing wake status before SDW driver can handle it

@bardliao bardliao requested a review from kv2019i July 22, 2025 11:49
@bardliao bardliao requested a review from lyakh as a code owner July 22, 2025 12:45
@bardliao bardliao changed the title ASoC: SOF: Intel: filter HDA and IDISP codecs to bus->codec_mask ASoC: SOF: Intel: only detect codecs when HDA DSP probe Jul 22, 2025
lgirdwood
lgirdwood previously approved these changes Jul 22, 2025
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this patch need to be a fix for back porting ?

ranj063
ranj063 previously approved these changes Jul 22, 2025
Copy link
Collaborator

@ranj063 ranj063 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great finding @bardliao

@macchian
Copy link

@bardliao Thank you for your full support! I have verified it in non-HDMI case.

@bardliao
Copy link
Collaborator Author

Does this patch need to be a fix for back porting ?

@lgirdwood Not sure if it is needed. No one reported the issue and I think all Intel SDW devices have HDMI supported. And I don't know which commit should be the fix tag target to. https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/commit/?id=ab9182441ee5a94dd6f47743ed1b7b6b07b63cb2 could be a good candidate. However, the patch can't apply to the commit. But there is no issue if I cherry pick the patch on top of the "ASoC: SOF: Intel: lnl: add helper to detect SoundWire wakes" commit. Can we add a fix tag with this commit in this case?

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments inline, please check.

@@ -183,7 +183,7 @@ int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in commit: "waken event" -> "wake event"


hda_codec_detect_mask(sdev);
if (detect_codec)
hda_codec_detect_mask(sdev);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we had a discussion on the need for this in #5458 . If the display runtime-pm link is removed, the display codec might not be fully up by the time we do resume, but in the end, consensus was that this is harmless, the initial detect_mask at probe should be sufficient.

This is departing from the HDA legacy driver flow though. Aside setting codec_mask, hda_codec_detect_mask() also programs GCTL_UNSOL . With this patch, we drop this programming at resume. Not an issue for HDMI codecs, but for regular HDA jack/speaker codecs this can be a real issue.

Could we instead just look at the HDA bits in hda_codec_detect_mask() and ignore the SDW codec bits?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kv2019i Yes, initially, my commit is 9a56dbf
But I don't know if (BIT(HDA_EXT_ADDR) | BIT(HDA_IDISP_ADDR)) can represent all HDA codecs. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao Let me think and return to this tomorrow. I think that limitation to SDI0/2 might actually be most practical as SOF doesn't really support anything else (not now and not expected we need this in the future for HDA). But let me still think of other options.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao I think we need to keep UNSOL programming anyways. The reset value is 0 so it must be programmed on resume when we have normal cases with some HDA codecs.

But yeah, I think I'd be ok with both 1) commit 9a56dbf

And also ok would be 2)
split out UNSOL programming from detect_mask(), call detect mask only from probe and unsol from both probe and from resume. This would not reset the codec_mask upon resume on SDW-only machines (i.e. fix the bug this PR is addressing).

Not sure which (1 or 2) is cleaner...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kv2019i I chose option 2 :).
Do we need the

        if (IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT) &&
            sof_debug_check_flag(SOF_DBG_FORCE_NOCODEC))

test before programing UNSOL?

We only need to detect codec mask in probe, but need to program UNSOL
in probe and resume. We will detect codec mask and program UNSOL
separately in the follow up commit.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
@bardliao bardliao dismissed stale reviews from ranj063 and lgirdwood via 03e1aae July 29, 2025 02:45
SDW codecs use the global HDaudio WAKEEN/STS to detect wakes since LNL.
But the wake event is handled in the SDW driver. We should only clear
WAKESTS for the HDA and IDISP codecs that was detected when HDA DSP
probe. The SoundWire codec will be included in the codec_mask if we read
the STATESTS register when a SoundWire codec wake event happens.
The commit avoid updating bus->codec_mask in resume to not clear WAKESTS
of SoundWire codecs.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bardliao !

@bardliao bardliao merged commit 3e75531 into thesofproject:topic/sof-dev Jul 31, 2025
9 of 16 checks passed
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.

7 participants