Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALSA: hda: Unify codec construction #3775

Conversation

crojewsk-intel
Copy link

@crojewsk-intel crojewsk-intel commented Jul 21, 2022

A follow up to the recent HDAudio fixes series [1]. Given the recently reported regression [2], before the page fault occurring on codec shutdown can be fixed, codec construction procedure needs to be updated for skylake and sof-intel drivers. Drivers: pci-hda and avs need no changes - already making use of snd_hda_codec_device_init().

Changes in v2:

  • drop snd_hda_ext_core <-> snd_hda_codec dependency by calling snd_hda_codec_device_init() directly in skylake and sof drivers probe enumeration routines, as suggested by Takashi
  • skylake/sof portion of the change have been split into two separate patches
  • additional patch cleaning up unused hdac_ext code provided
  • note: first patch in the series unchanged so Mark's ack remained

1: https://lore.kernel.org/alsa-devel/20220706120230.427296-7-cezary.rojewski@intel.com/
2: https://lore.kernel.org/alsa-devel/3c40df55-3aee-1e08-493b-7b30cd84dc00@linux.intel.com/

@sofci
Copy link
Collaborator

sofci commented Jul 21, 2022

Can one of the admins verify this patch?

reply test this please to run this test once

@crojewsk-intel
Copy link
Author

For reference, v1 of the series can be found here.

@plbossart
Copy link
Member

Which of these two GitHub handles should be added to the SOF project?
@crojewsk-intel and @crojewsk

@crojewsk-intel
Copy link
Author

crojewsk-intel commented Jul 21, 2022

Which of these two GitHub handles should be added to the SOF project? @crojewsk-intel and @crojewsk

If I'm not mistaken, @crojewsk already is. This account is here as Intel requests RW rights and I don't want to lose my Warcraft III stuff lol.

@crojewsk-intel
Copy link
Author

Perhaps both if that's not the problem?

@crojewsk-intel
Copy link
Author

Update. Raw delta remained 1:1 to previous version +113, -134. A lot of code shuffling between the first three patches though.

The following has been done to make git bisect happy:

  • new functions that aim to replace hdac_ext codec init & exit functionality are added first - for skylake and sof drivers both
  • third patch now combines the "field -> pointer" change for hdac_hda_priv->codec plus the codec-enumeration adjustments for skylake and sof drivers

Dropped Mark's ack as the code changed too much. Last three patches remained basically unchanged - ALSA: hda: Remove codec init and exit routines now removes hdac_to_hda_priv() macro on top its previous cleanups.

@plbossart
Copy link
Member

plbossart commented Jul 25, 2022

CI tests don't seem too good @crojewsk-intel ? see https://sof-ci.01.org/linuxpr/PR3775/build445/devicetest/

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 @crojewsk for digging into this! The cleanup seems good, but I have one concern about the SOF patch to move to new init. Please see comments inline.

sound/soc/sof/intel/hda-codec.c Outdated Show resolved Hide resolved
@crojewsk-intel
Copy link
Author

CI tests don't seem too good @crojewsk-intel ? see https://sof-ci.01.org/linuxpr/PR3775/build445/devicetest/

Indeed! Kai helped me in understanding the logs. Update on its way.

Preliminary step in making snd_hda_codec_device_init() the only
constructor for struct hda_codec instances. To do that, existing usage
of hdac_ext equivalents has to be dropped.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Preliminary step in making snd_hda_codec_device_init() the only
constructor for struct hda_codec instances. To do that, existing usage
of hdac_ext equivalents has to be dropped.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
To make snd_hda_codec_device_init() the only constructor for struct
hda_codec instances remaining tasks are:

1) no struct may wrap struct hda_codec as its base type
2) bus drivers (skylake and sof) which are the current hdac_ext users
   need to be adjusted to make use of newly added codec init and exit
   routines instead
3) as bus drivers (skylake and sof) are to be responsible for creating
   codec device and assigning it to hdac_hda_priv->codec,
   hdac_hda_dev_probe() has to be freed of that job

To keep git bisect happy, all of these in made in one-go.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
With all HDAudio drivers aligned to make use of the same constructor,
have codec freed on the device release regardless of its type.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
There are no users for snd_hdac_ext_bus_device_init() and
snd_hdac_ext_bus_device_exit().

While at it, remove hdac_to_hda_priv() too for the exact same reason.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
If early probe of HDAudio bus driver fails e.g.: due to missing
firmware file, snd_hda_codec_shutdown() ends in manipulating
uninitialized codec->pcm_list_head causing page fault.

Iinitialization of HDAudio codec in ASoC is split in two:
- snd_hda_codec_device_init()
- snd_hda_codec_device_new()

snd_hda_codec_device_init() is called during probe_codecs() by HDAudio
bus driver while snd_hda_codec_device_new() is called by
codec-component's ->probe(). The second call will not happen until all
components required by related sound card are present within the ASoC
framework. With firmware failing to load during the PCI's deferred
initialization i.e.: probe_work(), no platform components are ever
registered. HDAudio codec enumeration is done at that point though, so
the codec components became registered to ASoC framework, calling
snd_hda_codec_device_init() in the process.

Now, during platform reboot snd_hda_codec_shutdown() is called for every
codec found on the HDAudio bus causing oops if any of them has not
completed both of their initialization steps. Relocating field
initialization fixes the issue.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
@crojewsk-intel
Copy link
Author

Results look much better now - except for 2x timeout. Guess problem with a platform? Happens a lot in my farm too..

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 @crojewsk , looks good now! One minor typo in commit msg, but nothing to block merge. The few timeouts seem unrelated to your PR.

sound/pci/hda/hda_codec.c Show resolved Hide resolved
Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

feel free to add my tag

Reviewed-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com

Probably best to send in 2+ weeks, when the merge window closes, since it's a relatively big change impacting two maintainers.

@crojewsk-intel
Copy link
Author

Closing as the PR's purpose has been fulfilled. I'll be sending this to upstream next Friday or so. Thanks!

@crojewsk-intel crojewsk-intel deleted the hda_single_ctor branch August 1, 2022 10:53
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.

None yet

4 participants