alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
To: Harsha Priya <harshapriya.n@intel.com>
Cc: Takashi Iwai <tiwai@suse.de>,
	kai.vehmanen@intel.com, alsa-devel@alsa-project.org,
	Emmanuel Jillela <emmanuel.jillela@intel.com>
Subject: Re: [PATCH v2] ALSA: hda/hdmi: Add Intel silent stream support
Date: Tue, 30 Jun 2020 14:58:13 +0300 (EEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2006301432390.3186@eliteleevi.tm.intel.com> (raw)
In-Reply-To: <1593476606-24147-1-git-send-email-harshapriya.n@intel.com>

Hi,

hmm, I think a few review comments from Takashi were missed. See inline:

On Mon, 29 Jun 2020, Harsha Priya wrote:

> --- a/sound/pci/hda/Kconfig
> +++ b/sound/pci/hda/Kconfig
> @@ -232,4 +232,20 @@ config SND_HDA_POWER_SAVE_DEFAULT
>  
>  endif
>  
> +config SND_HDA_INTEL_HDMI_SILENT_STREAM
> +	bool "Enable Silent Stream always for HDMI"
> +	depends on SND_HDA_INTEL

Takashi requested to limit this to Intel hardware only, and despite the 
its name, SND_HDA_INTEL is not sufficient to do this.

I think best would be to take silent stream into use in
intel_hsw_common_init(). That indirection would also protect against 
user-space modifying the module parameter value during execution (it is 
only evaluated in intel_hsw_common_init()).

> +	if (enable_silent_stream && eld->eld_valid) {
> +		int pm_ret;
> +
> +		if (!monitor_prev && monitor_next && eld->eld_valid) {
> +			pm_ret = snd_hda_power_up_pm(codec);
> +			if (pm_ret < 0)
> +				codec_err(codec,
> +				"Monitor plugged-in, Failed to power up codec ret=[%d]\n",
> +				pm_ret);
> +			silent_stream_enable(codec, per_pin);
> +		} else if (monitor_prev && !monitor_next && !eld->eld_valid) {
> +			pm_ret = snd_hda_power_down_pm(codec);
> +			if (pm_ret < 0)
> +				codec_err(codec,
> +				"Monitor plugged-out, Failed to power down codec ret=[%d]\n",
> +				pm_ret);
> +		}
> +	}

There a bug in above, outer "if" checks for "eld_valid" while inner 
"else-if" checks for "!eld_valid" -> latter can never be reached.

Takashi, I was checking older code history on the acomp interface, and at 
least on Intel platforms using acomp, it is sufficient to check for 
eld->monitor_present. I.e. in

»       eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid,
»       »       »       »             per_pin->dev_id, &eld->monitor_present,
»       »       »       »             eld->eld_buffer, ELD_MAX_SIZE);
»       eld->eld_valid = (eld->eld_size > 0);

... monitor_present will always be 0 if eld_size<0 (and eld_valid is 
set to 0). An error monitor_present will not be set, but 
sync_eld_via_acomp() initialized the value to 0 for this case.

The additional checks in the patch are thus harmless, but make the code a 
bit suspicious looking. If the above did not hold, you could have a 
sequence like

monitor_prev=0, monitor_next=1, eld_valid=1   -> power-up
monitor_prev=1, monitor_next=0, eld_valid=0   -> no op
monitor_prev=0, monitor_next=1, eld_valid=1   -> power-up again

.. so the refcounting would go out of sync. So I'd rather just track the 
two variables.

Br, Kai

  reply	other threads:[~2020-06-30 11:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30  0:23 [PATCH v2] ALSA: hda/hdmi: Add Intel silent stream support Harsha Priya
2020-06-30 11:58 ` Kai Vehmanen [this message]
2020-07-01  9:02 ` kernel test robot

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=alpine.DEB.2.22.394.2006301432390.3186@eliteleevi.tm.intel.com \
    --to=kai.vehmanen@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=emmanuel.jillela@intel.com \
    --cc=harshapriya.n@intel.com \
    --cc=kai.vehmanen@intel.com \
    --cc=tiwai@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).