Skip to contentSkip to conversation

bug: reconfig broken on kernel 4.5

DISCUSSION Jochen Henneberg 2 participants 5 messages May 9, 2016 – May 10, 2016 Sound

lore
Share & tools
lore
#0 lore raw

Hi,

it looks as if 'reconfig' feature is broken since the sysfs attributes have been moved to device attributes. In hda_sysfs.c:reconfig_codec() the device is cleared with snd_hda_codec_reset() which calls snd_hdac_device_unregister() which removes the sysfs entries (including the currently in-use 'reconfig'), the re-registration fails afterwards in snd_hda_codec_build_controls().
I am not sure when things got broken, but snd_hda_codec_reset() called from reconfig_codec() unregisters the device and removes the sysfs entries where in the past it only stripped all configurations (pcms, controls ...) from the device.

Regards,
Jochen

#1 lore raw
Quoted 13 lines · Jochen Henneberg

Hi,

it looks as if 'reconfig' feature is broken since the sysfs attributes have been moved to device attributes. In hda_sysfs.c:reconfig_codec() the device is cleared with snd_hda_codec_reset() which calls snd_hdac_device_unregister() which removes the sysfs entries (including the currently in-use 'reconfig'), the re-registration fails afterwards in snd_hda_codec_build_controls().
I am not sure when things got broken, but snd_hda_codec_reset() called from reconfig_codec() unregisters the device and removes the sysfs entries where in the past it only stripped all configurations (pcms, controls ...) from the device.

Hrm, OK, something got broken indeed there. I'll check it later.

thanks,

Takashi

#2 lore raw
Quoted 17 lines · Takashi Iwai
Quoted 13 lines · Jochen Henneberg

Hi,

it looks as if 'reconfig' feature is broken since the sysfs attributes have been moved to device attributes. In hda_sysfs.c:reconfig_codec() the device is cleared with snd_hda_codec_reset() which calls snd_hdac_device_unregister() which removes the sysfs entries (including the currently in-use 'reconfig'), the re-registration fails afterwards in snd_hda_codec_build_controls().
I am not sure when things got broken, but snd_hda_codec_reset() called from reconfig_codec() unregisters the device and removes the sysfs entries where in the past it only stripped all configurations (pcms, controls ...) from the device.

Quoted 1 line

Hrm, OK, something got broken indeed there. I'll check it later.

Actually it's not about the sysfs, but rather the superfluous calls of snd_hda_codec_build_controls() & co. The fix patch is below.

Takashi

-- 8< --
From: Takashi Iwai <[email protected]>
Subject: [PATCH] ALSA: hda - Fix broken reconfig

The HD-audio reconfig function got broken in the recent kernels, typically resulting in a failure like:
snd_hda_intel 0000:00:1b.0: control 3:0:0:Playback Channel Map:0 is already present

This is because of the code restructuring to move the PCM and control instantiation into the codec drive probe, by the commit [bcd96557bd0a:
ALSA: hda - Build PCMs and controls at codec driver probe]. Although the commit above removed the calls of snd_hda_codec_build_pcms() and *_build_controls() at the controller driver probe, the similar calls in the reconfig were still left forgotten. This caused the conflicting and duplicated PCMs and controls.

The fix is trivial: just remove these superfluous calls from reconfig_codec().

Fixes bcd96557bd0a ('ALSA: hda - Build PCMs and controls at codec driver probe')
Cc <[email protected]> # v4.1+
---
 sound/pci/hda/hda_sysfs.c | 8 --------
 1 file changed, 8 deletions(-)
sound/pci/hda/hda_sysfs.c +0 -8
index 64e0d1d81ca5..9739fce9e032 100644
@@ -141,14 +141,6 @@ static int reconfig_codec(struct hda_codec *codec)
 	err = snd_hda_codec_configure(codec);
 	if (err < 0)
 		goto error;
-	/* rebuild PCMs */
-	err = snd_hda_codec_build_pcms(codec);
-	if (err < 0)
-		goto error;
-	/* rebuild mixers */
-	err = snd_hda_codec_build_controls(codec);
-	if (err < 0)
-		goto error;
 	err = snd_card_register(codec->card);
  error:
 	snd_hda_power_down(codec);
Signature · 1 line
2.8.2
#3 lore raw
Quoted 19 lines · Takashi Iwai
Quoted 17 lines · Takashi Iwai
Quoted 13 lines · Jochen Henneberg

Hi,

it looks as if 'reconfig' feature is broken since the sysfs attributes have been moved to device attributes. In hda_sysfs.c:reconfig_codec() the device is cleared with snd_hda_codec_reset() which calls snd_hdac_device_unregister() which removes the sysfs entries (including the currently in-use 'reconfig'), the re-registration fails afterwards in snd_hda_codec_build_controls().
I am not sure when things got broken, but snd_hda_codec_reset() called from reconfig_codec() unregisters the device and removes the sysfs entries where in the past it only stripped all configurations (pcms, controls ...) from the device.

Quoted 5 lines
Quoted 1 line

Hrm, OK, something got broken indeed there. I'll check it later.

Actually it's not about the sysfs, but rather the superfluous calls of snd_hda_codec_build_controls() & co. The fix patch is below.

Sorry for the confusion, I did not notice. Anyway, I have tested the patch with 4.5, changed codec hints, reconfig and no error messages and the changed hints have been respected after reconfig, looks good for me.

Jochen

Quoted 49 lines

Takashi

-- 8< --
From: Takashi Iwai <[email protected]>
Subject: [PATCH] ALSA: hda - Fix broken reconfig

The HD-audio reconfig function got broken in the recent kernels, typically resulting in a failure like:
snd_hda_intel 0000:00:1b.0: control 3:0:0:Playback Channel Map:0 is already present

This is because of the code restructuring to move the PCM and control instantiation into the codec drive probe, by the commit [bcd96557bd0a:
ALSA: hda - Build PCMs and controls at codec driver probe]. Although the commit above removed the calls of snd_hda_codec_build_pcms() and *_build_controls() at the controller driver probe, the similar calls in the reconfig were still left forgotten. This caused the conflicting and duplicated PCMs and controls.

The fix is trivial: just remove these superfluous calls from reconfig_codec().

Fixes bcd96557bd0a ('ALSA: hda - Build PCMs and controls at codec driver probe')
Cc <[email protected]> # v4.1+
---
 sound/pci/hda/hda_sysfs.c | 8 --------
 1 file changed, 8 deletions(-)
sound/pci/hda/hda_sysfs.c +0 -8
index 64e0d1d81ca5..9739fce9e032 100644
@@ -141,14 +141,6 @@ static int reconfig_codec(struct hda_codec *codec)
 	err = snd_hda_codec_configure(codec);
 	if (err < 0)
 		goto error;
-	/* rebuild PCMs */
-	err = snd_hda_codec_build_pcms(codec);
-	if (err < 0)
-		goto error;
-	/* rebuild mixers */
-	err = snd_hda_codec_build_controls(codec);
-	if (err < 0)
-		goto error;
 	err = snd_card_register(codec->card);
  error:
 	snd_hda_power_down(codec);
Signature · 9 lines
Henneberg - Systemdesign
Jochen Henneberg
Loehnfeld 26
21423 Winsen (Luhe)
--
Fon: +49 4174 668 773
Mobile: +49 172 160 14 69
Fax: +49 321 210 761 64
www: www.henneberg-systemdesign.com
#4 lore raw
Quoted 23 lines · Jochen Henneberg
Quoted 21 lines · Takashi Iwai
Quoted 18 lines · Takashi Iwai
Quoted 13 lines · Jochen Henneberg

Hi,

it looks as if 'reconfig' feature is broken since the sysfs attributes have been moved to device attributes. In hda_sysfs.c:reconfig_codec() the device is cleared with snd_hda_codec_reset() which calls snd_hdac_device_unregister() which removes the sysfs entries (including the currently in-use 'reconfig'), the re-registration fails afterwards in snd_hda_codec_build_controls().
I am not sure when things got broken, but snd_hda_codec_reset() called from reconfig_codec() unregisters the device and removes the sysfs entries where in the past it only stripped all configurations (pcms, controls ...) from the device.

Hrm, OK, something got broken indeed there. I'll check it later.

Quoted 7 lines
Quoted 3 lines

Actually it's not about the sysfs, but rather the superfluous calls of snd_hda_codec_build_controls() & co. The fix patch is below.

Sorry for the confusion, I did not notice. Anyway, I have tested the patch with 4.5, changed codec hints, reconfig and no error messages and the changed hints have been respected after reconfig, looks good for me.

The patch has been merged now.

thanks,

Takashi