Skip to contentSkip to conversation

ALSA: hda: Unify codec construction

PATCH Superseded Cezary Rojewski 4 participants 12 messages Aug 15, 2022 – Aug 16, 2022 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover ALSA: hda: Unify codec construction

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().

As subject touches code used by the sof-driver, additional review has been conducted on thesofproject/linux [3].

Changes in v2:

- dropped 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 has been split into two separate patches

- new functions that aim to replace hdac_ext codec init & exit functionality are added first - for skylake and sof drivers both
- third patch in the series now combines the "field -> pointer" change for hdac_hda_priv->codec plus the codec-enumeration adjustments for skylake and sof drivers
Both above are here to keep git bisect happy, as suggested by Pierre

[1]: https://lore.kernel.org/alsa-devel/[email protected]/
[2]: https://lore.kernel.org/alsa-devel/[email protected]/
[3]: https://github.com/thesofproject/linux/pull/3775

Cezary Rojewski (6):
ASoC: Intel: Skylake: Introduce HDA codec init and exit routines
ASoC: SOF: Intel: Introduce HDA codec init and exit routines
ASoC: Intel: Drop hdac_ext usage for codec device creation
ALSA: hda: Always free codec on the device release
ALSA: hda: Remove codec init and exit routines
ALSA: hda: Fix page fault in snd_hda_codec_shutdown()

 include/sound/hda_codec.h                    |  2 -
 include/sound/hdaudio_ext.h                  |  3 --
 sound/hda/ext/hdac_ext_bus.c                 | 53 -------------------
 sound/pci/hda/hda_codec.c                    | 49 ++++++++---------
 sound/soc/codecs/hdac_hda.c                  | 26 ++++-----
 sound/soc/codecs/hdac_hda.h                  |  2 +-
 sound/soc/intel/boards/hda_dsp_common.c      |  2 +-
 sound/soc/intel/boards/skl_hda_dsp_generic.c |  2 +-
 sound/soc/intel/skylake/skl.c                | 53 ++++++++++++++-----
 sound/soc/sof/intel/hda-codec.c              | 55 ++++++++++++++------
 10 files changed, 113 insertions(+), 134 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/6 ASoC: SOF: Intel: Introduce HDA codec init and exit routines

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.

---
 sound/soc/sof/intel/hda-codec.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
sound/soc/sof/intel/hda-codec.c +30 -0
index 2f3f4a733d9e..4c128ba02340 100644
@@ -109,6 +109,36 @@ EXPORT_SYMBOL_NS(hda_codec_jack_check, SND_SOC_SOF_HDA_AUDIO_CODEC);
 #define is_generic_config(x)	0
 #endif
 
+static void hda_codec_device_exit(struct device *dev)
+{
+	snd_hdac_device_exit(dev_to_hdac_dev(dev));
+}
+
+static __maybe_unused struct hda_codec *
+hda_codec_device_init(struct hdac_bus *bus, int addr, int type)
+{
+	struct hda_codec *codec;
+	int ret;
+
+	codec = snd_hda_codec_device_init(to_hda_bus(bus), addr, "ehdaudio%dD%d", bus->idx, addr);
+	if (IS_ERR(codec)) {
+		dev_err(bus->dev, "device init failed for hdac device\n");
+		return codec;
+	}
+
+	codec->core.type = type;
+	codec->core.dev.release = hda_codec_device_exit;
+
+	ret = snd_hdac_device_register(&codec->core);
+	if (ret) {
+		dev_err(bus->dev, "failed to register hdac device\n");
+		snd_hdac_device_exit(&codec->core);
+		return ERR_PTR(ret);
+	}
+
+	return codec;
+}
+
 /* probe individual codec */
 static int hda_codec_probe(struct snd_sof_dev *sdev, int address,
 			   bool hda_codec_use_common_hdmi)
Signature · 1 line
2.25.1
maintainer Acked-by on v2 2/6
#2 lore raw

Re: [PATCH v2 2/6] ASoC: SOF: Intel: Introduce HDA codec init and exit routines

Quoted 7 lines · Cezary Rojewski

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.

#3 lore raw

PATCH v2 4/6 ALSA: hda: Always free codec on the device release

In reply to Cezary Rojewski

With all HDAudio drivers aligned to make use of the same constructor, have codec freed on the device release regardless of its type.

---
 sound/pci/hda/hda_codec.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
sound/pci/hda/hda_codec.c +1 -7
index 384426d7e9dd..aa7a362be290 100644
@@ -883,13 +883,7 @@ static void snd_hda_codec_dev_release(struct device *dev)
 	snd_hda_sysfs_clear(codec);
 	kfree(codec->modelname);
 	kfree(codec->wcaps);
-
-	/*
-	 * In the case of ASoC HD-audio, hda_codec is device managed.
-	 * It will be freed when the ASoC device is removed.
-	 */
-	if (codec->core.type == HDA_DEV_LEGACY)
-		kfree(codec);
+	kfree(codec);
 }
 
 #define DEV_NAME_LEN 31
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 5/6 ALSA: hda: Remove codec init and exit routines

In reply to Cezary Rojewski

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.

---
 include/sound/hda_codec.h    |  2 --
 include/sound/hdaudio_ext.h  |  3 --
 sound/hda/ext/hdac_ext_bus.c | 53 ------------------------------------
 3 files changed, 58 deletions(-)
include/sound/hda_codec.h +0 -2
index 6d3c82c4b6ac..2a8fe7240f10 100644
@@ -293,8 +293,6 @@ struct hda_codec {
 #define dev_to_hda_codec(_dev)	container_of(_dev, struct hda_codec, core.dev)
 #define hda_codec_dev(_dev)	(&(_dev)->core.dev)
 
-#define hdac_to_hda_priv(_hdac) \
-			container_of(_hdac, struct hdac_hda_priv, codec.core)
 #define hdac_to_hda_codec(_hdac) container_of(_hdac, struct hda_codec, core)
 
 #define list_for_each_codec(c, bus) \
include/sound/hdaudio_ext.h +0 -3
index d26234f9ee46..88ebb64fd8a5 100644
@@ -11,9 +11,6 @@ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev,
 		      const struct hdac_ext_bus_ops *ext_ops);
 
 void snd_hdac_ext_bus_exit(struct hdac_bus *bus);
-int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr,
-				struct hdac_device *hdev, int type);
-void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
 void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus);
 
 #define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \
sound/hda/ext/hdac_ext_bus.c +0 -53

59 lines not on this page · raw message

Signature · 1 line
2.25.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer Acked-by
#6 lore raw

Re: [PATCH v2 3/6] ASoC: Intel: Drop hdac_ext usage for codec device creation

Quoted 2 lines · Cezary Rojewski

To make snd_hda_codec_device_init() the only constructor for struct hda_codec instances remaining tasks are:

#7 lore raw
In reply to Cezary Rojewski
Quoted 5 lines · Cezary Rojewski

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().

...

Quoted 7 lines

Cezary Rojewski (6):
ASoC: Intel: Skylake: Introduce HDA codec init and exit routines
ASoC: SOF: Intel: Introduce HDA codec init and exit routines
ASoC: Intel: Drop hdac_ext usage for codec device creation
ALSA: hda: Always free codec on the device release
ALSA: hda: Remove codec init and exit routines
ALSA: hda: Fix page fault in snd_hda_codec_shutdown()

I've received a message yesterday that patches: 1/6, 3/6 and 6/6 were not delivered to recipient: [email protected]. None else is listed there. lore.kernel.org also shows only four letters (3 + cover-letter) rather than seven. Given Mark's Ack on patch 3/6 it makes me believe that indeed just the alsa-devel did not received some of the messages.

What should I do in such situation? Is the server admin about to "recover them from the void" or should I resend the entire series as: "[RESEND PATCH v2]" as see how it goes this time?

Regards,
Czarek

#8 lore raw
Quoted 26 lines · Cezary Rojewski
Quoted 5 lines · Cezary Rojewski

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().

...

Quoted 7 lines

Cezary Rojewski (6):
ASoC: Intel: Skylake: Introduce HDA codec init and exit routines
ASoC: SOF: Intel: Introduce HDA codec init and exit routines
ASoC: Intel: Drop hdac_ext usage for codec device creation
ALSA: hda: Always free codec on the device release
ALSA: hda: Remove codec init and exit routines
ALSA: hda: Fix page fault in snd_hda_codec_shutdown()

I've received a message yesterday that patches: 1/6, 3/6 and 6/6 were not delivered to recipient: [email protected]. None else is listed there. lore.kernel.org also shows only four letters (3 + cover-letter) rather than seven. Given Mark's Ack on patch 3/6 it makes me believe that indeed just the alsa-devel did not received some of the messages.

Quoted 3 lines

What should I do in such situation? Is the server admin about to "recover them from the void" or should I resend the entire series as:
"[RESEND PATCH v2]" as see how it goes this time?

I guess the full resubmission would be better.

Takashi

#9 lore raw
Quoted 2 lines · Takashi Iwai

On Tue, 16 Aug 2022 10:15:44 +0200,
Cezary Rojewski wrote:

...

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

Cezary Rojewski (6):
ASoC: Intel: Skylake: Introduce HDA codec init and exit routines
ASoC: SOF: Intel: Introduce HDA codec init and exit routines
ASoC: Intel: Drop hdac_ext usage for codec device creation
ALSA: hda: Always free codec on the device release
ALSA: hda: Remove codec init and exit routines
ALSA: hda: Fix page fault in snd_hda_codec_shutdown()

Quoted 8 lines
Quoted 8 lines

I've received a message yesterday that patches: 1/6, 3/6 and 6/6 were not delivered to recipient: [email protected]. None else is listed there. lore.kernel.org also shows only four letters (3 + cover-letter) rather than seven. Given Mark's Ack on patch 3/6 it makes me believe that indeed just the alsa-devel did not received some of the messages.

What should I do in such situation? Is the server admin about to

Meant to say 'able' instead of 'about'.

Quoted 4 lines
Quoted 2 lines

"recover them from the void" or should I resend the entire series as:
"[RESEND PATCH v2]" as see how it goes this time?

I guess the full resubmission would be better.

Should I apply Mark's ACKs for patches 2/6 and 3/6 in the about-to-be-resent series?

maintainer
#10 lore raw
Quoted 6 lines · Cezary Rojewski
Quoted 4 lines · Takashi Iwai
Quoted 2 lines

"recover them from the void" or should I resend the entire series as:
"[RESEND PATCH v2]" as see how it goes this time?

I guess the full resubmission would be better.

Note that if you do whatever upset the server again it'll happen again. If it was a blacklisting it does look like there's something going on there which might be random, I've had some issues with the kernel.org servers there that don't seem attached to the the actual sending server as much as you'd expect.

Quoted 2 lines

Should I apply Mark's ACKs for patches 2/6 and 3/6 in the about-to-be-resent series?

Yes, if there's tags always carry them formwards unless something changed to invalidate them.

#11 lore raw
Quoted 10 lines · Mark Brown
Quoted 6 lines · Cezary Rojewski
Quoted 4 lines · Takashi Iwai
Quoted 2 lines

"recover them from the void" or should I resend the entire series as:
"[RESEND PATCH v2]" as see how it goes this time?

I guess the full resubmission would be better.

Note that if you do whatever upset the server again it'll happen again.

If this happens, we need to investigate. alsa-devel ML is maintained outside vger by Jaroslav personally. Let's see...

Takashi

maintainer
#12 lore raw
Quoted 9 lines · Takashi Iwai
Quoted 7 lines · Mark Brown
Quoted 4 lines · Cezary Rojewski
Quoted 2 lines · Takashi Iwai
Quoted 2 lines

"recover them from the void" or should I resend the entire series as:
"[RESEND PATCH v2]" as see how it goes this time?

Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

I guess the full resubmission would be better.

Note that if you do whatever upset the server again it'll happen again.

If this happens, we need to investigate. alsa-devel ML is maintained outside vger by Jaroslav personally. Let's see...

It seems that it was a temporary issue with the DNS resolver. The resend is fine.

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.