public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Hans de Goede" <hdegoede@redhat.com>
Cc: "Jaroslav Kysela" <perex@perex.cz>, <alsa-devel@alsa-project.org>,
	<stable@vger.kernel.org>
Subject: Re: [RFC v2] ALSA: hda: Add a power_save blacklist
Date: Thu, 22 Feb 2018 14:01:42 +0100	[thread overview]
Message-ID: <s5hfu5tdvpl.wl-tiwai@suse.de> (raw)
In-Reply-To: <20180222123128.7776-1-hdegoede@redhat.com>

On Thu, 22 Feb 2018 13:31:28 +0100,
Hans de Goede wrote:
> 
> 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 an user explicitly sets the module-option then the blacklist is not
> used.
> 
> BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1525104
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=198611
> Cc: stable@vger.kernel.org
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in RFC v2:
> -Only use the blacklist if the power_save module-option is not explicitly
>  set by the user
> ---
>  sound/pci/hda/hda_intel.c | 29 ++++++++++++++++++++++++++++-
>  1 file changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> index c71dcacea807..7c588b0d6c96 100644
> --- a/sound/pci/hda/hda_intel.c
> +++ b/sound/pci/hda/hda_intel.c
> @@ -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,6 +2213,7 @@ 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 err;
>  
> @@ -2278,6 +2295,16 @@ static int azx_probe_continue(struct azx *chip)
>  
>  	chip->running = 1;
>  	azx_add_card_list(chip);
> +
> +	if (power_save == -1) {
> +		power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
> +		q = snd_pci_quirk_lookup(chip->pci, power_save_blacklist);
> +		if (q && power_save) {
> +			dev_info(chip->card->dev, "device %04x:%04x is on the power_save blacklist, forcing power_save to 0\n",
> +				 q->subvendor, q->subdevice);
> +			power_save = 0;
> +		}
> +	}

This won't work always, as there can be multiple HD-audio
controllers.  e.g. Haswell and Broadwell usually probe the HDMI
controller at first.  Then it doesn't match with the blacklist, thus
power_save is set to 1, and the second PCI device probe also takes 1
even if it's matching with the blacklist.


thanks,

Takashi

      reply	other threads:[~2018-02-22 13:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-22 12:31 [RFC v2] ALSA: hda: Add a power_save blacklist Hans de Goede
2018-02-22 13:01 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hfu5tdvpl.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=hdegoede@redhat.com \
    --cc=perex@perex.cz \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox