ALSA: hda: Add a power_save blacklist
Subsystems (2)
RFC v3 1/1 ALSA: hda: Add a power_save blacklist
On some boards setting power_save to a non 0 value leads to clicking / popping sounds when ever we enter/leave powersaving mode. Ideally we would figure out how to avoid these sounds, but that is not always feasible.
This commit adds a blacklist for devices where powersaving is known to cause problems and disables it on these devices.
Note I tried to put this blacklist in userspace first:
https://github.com/systemd/systemd/pull/8128
But the systemd maintainers rightfully pointed out that it would be impossible to then later remove entries once we actually find a way to make power-saving work on listed boards without issues. Having this list in the kernel will allow removal of the blacklist entry in the same commit which fixes the clicks / plops.
The blacklist only applies to the default power_save module-option value, if a user explicitly sets the module-option then the blacklist is not used.
---
Changes in RFC v2:
-Only use the blacklist if the power_save module-option is not explicitly
set by the user
Changes in RFC v2:
-Fix logic to work on boards with more then 1 HDA device
--- sound/pci/hda/hda_intel.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)
sound/pci/hda/hda_intel.c +31 -2
@@ -181,7 +181,7 @@ static const struct kernel_param_ops param_ops_xint = { };#define param_check_xint param_check_int -static int power_save =CONFIG_SND_HDA_POWER_SAVE_DEFAULT ; +static int power_save =-1 ;module_param (power_save, xint,0644 );MODULE_PARM_DESC (power_save,"Automatic power-saving timeout " "(in second, 0 = disable)." );
@@ -2186,6 +2186,22 @@ static int azx_probe(struct pci_dev *pci,return err; } +/* On some boards setting power_save to a non 0 value leads to clicking / +* popping sounds when ever we enter/leave powersaving mode. Ideally we would +* figure out how to avoid these sounds, but that is not always feasible. +* So we keep a list of devices where we disable powersaving as its known +* to causes problems on these devices. +*/ +static struct snd_pci_quirk power_save_blacklist[] = { +/* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ +SND_PCI_QUIRK (0x1849 ,0x0c0c ,"Asrock B85M-ITX" ,0 ), +/* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ +SND_PCI_QUIRK (0x1043 ,0x8733 ,"Asus Prime X370-Pro" ,0 ), +/* https://bugzilla.kernel.org/show_bug.cgi?id=198611 */ +SND_PCI_QUIRK (0x17aa ,0x2227 ,"Lenovo X1 Carbon 3rd Gen" ,0 ), + {} +}; +/* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS ] = { [AZX_DRIVER_NVIDIA ] =8 ,
@@ -2197,7 +2213,9 @@ static int azx_probe_continue(struct azx *chip) struct hda_intel *hda = container_of(chip, struct hda_intel, chip);struct hdac_bus *bus =azx_bus (chip);struct pci_dev *pci = chip->pci; +const struct snd_pci_quirk *q;int dev = chip->dev_index; +int val;int err; hda->probe_continued =1 ;
@@ -2278,7 +2296,18 @@ static int azx_probe_continue(struct azx *chip) chip->running =1 ;azx_add_card_list (chip); -snd_hda_set_power_save (&chip->bus, power_save *1000 ); + + val = power_save; +if (val ==-1 ) { + val =CONFIG_SND_HDA_POWER_SAVE_DEFAULT ; + q =snd_pci_quirk_lookup (chip->pci, power_save_blacklist); +if (q && val) { +dev_info (chip->card->dev,"device %04x:%04x is on the power_save blacklist, forcing power_save to 0\n" , + q->subvendor, q->subdevice); + val =0 ; + } + } +snd_hda_set_power_save (&chip->bus, val *1000 );if (azx_has_pm_runtime (chip) || hda->use_vga_switcheroo)pm_runtime_put_autosuspend (&pci->dev);
Signature · 1 line
2.14.3
Hi,
Quoted 16 lines · Hans de Goede
On some boards setting
power_saveto a non 0 value leads to clicking / popping sounds when ever we enter/leave powersaving mode. Ideally we would figure out how to avoid these sounds, but that is not always feasible.This commit adds a blacklist for devices where powersaving is known to cause problems and disables it on these devices.
Note I tried to put this blacklist in userspace first:
https://github.com/systemd/systemd/pull/8128But the systemd maintainers rightfully pointed out that it would be impossible to then later remove entries once we actually find a way to make power-saving work on listed boards without issues. Having this list in the kernel will allow removal of the blacklist entry in the same commit which fixes the clicks / plops.
Quoted 8 lines
The blacklist only applies to the default
power_savemodule-option value, if a user explicitly sets the module-option then the blacklist is not used.
This has been tested now, so this may be applied now, assuming people are happy with this version.
Let me know if you want me to re-submit as a non-RFC.
Regards,
Hans
Quoted 78 lines
---
Changes in RFC v2:
-Only use the blacklist if thepower_savemodule-option is not explicitly
set by the userChanges in RFC v2:
(quoted diff) +0
-2-Fix logic to work on boards with more then 1 HDA device --- sound/pci/hda/hda_intel.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)sound/pci/hda/hda_intel.c +31
-2@@ -181,7 +181,7 @@ static const struct kernel_param_ops param_ops_xint = { };#define param_check_xint param_check_int -static int power_save =CONFIG_SND_HDA_POWER_SAVE_DEFAULT ; +static int power_save =-1 ;module_param (power_save, xint,0644 );MODULE_PARM_DESC (power_save,"Automatic power-saving timeout " "(in second, 0 = disable)." );@@ -2186,6 +2186,22 @@ static int azx_probe(struct pci_dev *pci,return err; } +/* On some boards setting power_save to a non 0 value leads to clicking / +* popping sounds when ever we enter/leave powersaving mode. Ideally we would +* figure out how to avoid these sounds, but that is not always feasible. +* So we keep a list of devices where we disable powersaving as its known +* to causes problems on these devices. +*/ +static struct snd_pci_quirk power_save_blacklist[] = { +/* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ +SND_PCI_QUIRK (0x1849 ,0x0c0c ,"Asrock B85M-ITX" ,0 ), +/* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ +SND_PCI_QUIRK (0x1043 ,0x8733 ,"Asus Prime X370-Pro" ,0 ), +/* https://bugzilla.kernel.org/show_bug.cgi?id=198611 */ +SND_PCI_QUIRK (0x17aa ,0x2227 ,"Lenovo X1 Carbon 3rd Gen" ,0 ), + {} +}; +/* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS ] = { [AZX_DRIVER_NVIDIA ] =8 ,@@ -2197,7 +2213,9 @@ static int azx_probe_continue(struct azx *chip) struct hda_intel *hda = container_of(chip, struct hda_intel, chip);struct hdac_bus *bus =azx_bus (chip);struct pci_dev *pci = chip->pci; +const struct snd_pci_quirk *q;int dev = chip->dev_index; +int val;int err; hda->probe_continued =1 ;@@ -2278,7 +2296,18 @@ static int azx_probe_continue(struct azx *chip) chip->running =1 ;azx_add_card_list (chip); -snd_hda_set_power_save (&chip->bus, power_save *1000 ); + + val = power_save; +if (val ==-1 ) { + val =CONFIG_SND_HDA_POWER_SAVE_DEFAULT ; + q =snd_pci_quirk_lookup (chip->pci, power_save_blacklist); +if (q && val) { +dev_info (chip->card->dev,"device %04x:%04x is on the power_save blacklist, forcing power_save to 0\n" , + q->subvendor, q->subdevice); + val =0 ; + } + } +snd_hda_set_power_save (&chip->bus, val *1000 );if (azx_has_pm_runtime (chip) || hda->use_vga_switcheroo)pm_runtime_put_autosuspend (&pci->dev);
Takashi Iwai
AppliedQuoted 29 lines · Hans de Goede
Hi,
Quoted 16 lines · Hans de Goede
On some boards setting
power_saveto a non 0 value leads to clicking / popping sounds when ever we enter/leave powersaving mode. Ideally we would figure out how to avoid these sounds, but that is not always feasible.This commit adds a blacklist for devices where powersaving is known to cause problems and disables it on these devices.
Note I tried to put this blacklist in userspace first:
https://github.com/systemd/systemd/pull/8128But the systemd maintainers rightfully pointed out that it would be impossible to then later remove entries once we actually find a way to make power-saving work on listed boards without issues. Having this list in the kernel will allow removal of the blacklist entry in the same commit which fixes the clicks / plops.
Quoted 8 lines
The blacklist only applies to the default
power_savemodule-option value, if a user explicitly sets the module-option then the blacklist is not used.
Quoted 4 lines
This has been tested now, so this may be applied now, assuming people are happy with this version.
Let me know if you want me to re-submit as a non-RFC.
I applied it now, thanks.
Takashi