All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lu, Brent" <brent.lu@intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Mohan Kumar" <mkumard@nvidia.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Zhi, Yong" <yong.zhi@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] ALSA: hda/hdmi: run eld notify in delay work
Date: Wed, 28 Sep 2022 02:06:45 +0000	[thread overview]
Message-ID: <CY5PR11MB6257CB33E1EDA90CE2B2F99D97549@CY5PR11MB6257.namprd11.prod.outlook.com> (raw)
In-Reply-To: <87ill8gb5c.wl-tiwai@suse.de>

> >
> > During resolution change, display driver would disable HDMI audio then
> > enable it in a short time. There is possibility that eld notify for
> > HDMI audio enable is called when previous runtime suspend is still
> > running. In this case, the elf nofity just returns and not updating
> > the status of corresponding HDMI pin/port. Here we move the eld nofity
> > to a delay work so we don't lose it.
> >
> > Signed-off-by: Brent Lu <brent.lu@intel.com>
> 
> We have already a dedicated per-pin work for the delayed ELD check.
> Can we reuse it instead of inventing yet another work?
> More work needs more cares, and better to avoid unless really needed (e.g.
> you forgot cleanup at suspend/removal in this patch).
> 
> 
> thanks,
> 
> Takashi

Hi Takashi,

I've checked the hdmi_repoll_eld() and check_presence_and_report() function to see
if we can reuse the per-pin work. I've some questions about reusing the per-pin work:

1. hdmi_repoll_eld() calls snd_hda_jack_tbl_get_mst() function while
   check_presence_and_report() doesn't. Is it ok? 
2. snd_hdac_i915_set_bclk() is called in intel_pin_eld_notify() function. Since it's
   skipped, we need to call it in the per-pin work. Need to add a flag in hdmi_spec_per_pin
   to indicate this situation.
3. We can schedule the per-pin work in intel_pin_eld_notify() when snd_hdac_is_in_pm()
   returns true but there is no guarantee the runtime suspend will finished when the per-pin
  work is schedule to run.

static void hdmi_repoll_eld(struct work_struct *work)
{
	struct hdmi_spec_per_pin *per_pin =
	container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work);
	struct hda_codec *codec = per_pin->codec;
	struct hdmi_spec *spec = codec->spec;
	struct hda_jack_tbl *jack;

	jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid,
					per_pin->dev_id);
	if (jack)
		jack->jack_dirty = 1;

	if (per_pin->repoll_count++ > 6)
		per_pin->repoll_count = 0;

	mutex_lock(&spec->pcm_lock);
	hdmi_present_sense(per_pin, per_pin->repoll_count);
	mutex_unlock(&spec->pcm_lock);
}

static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid,
				      int dev_id)
{
	struct hdmi_spec *spec = codec->spec;
	int pin_idx = pin_id_to_pin_index(codec, nid, dev_id);

	if (pin_idx < 0)
		return;
	mutex_lock(&spec->pcm_lock);
	hdmi_present_sense(get_pin(spec, pin_idx), 1);
	mutex_unlock(&spec->pcm_lock);
}

Regards,
Brent


WARNING: multiple messages have this Message-ID (diff)
From: "Lu, Brent" <brent.lu@intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Mohan Kumar" <mkumard@nvidia.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Zhi,  Yong" <yong.zhi@intel.com>
Subject: RE: [PATCH] ALSA: hda/hdmi: run eld notify in delay work
Date: Wed, 28 Sep 2022 02:06:45 +0000	[thread overview]
Message-ID: <CY5PR11MB6257CB33E1EDA90CE2B2F99D97549@CY5PR11MB6257.namprd11.prod.outlook.com> (raw)
In-Reply-To: <87ill8gb5c.wl-tiwai@suse.de>

> >
> > During resolution change, display driver would disable HDMI audio then
> > enable it in a short time. There is possibility that eld notify for
> > HDMI audio enable is called when previous runtime suspend is still
> > running. In this case, the elf nofity just returns and not updating
> > the status of corresponding HDMI pin/port. Here we move the eld nofity
> > to a delay work so we don't lose it.
> >
> > Signed-off-by: Brent Lu <brent.lu@intel.com>
> 
> We have already a dedicated per-pin work for the delayed ELD check.
> Can we reuse it instead of inventing yet another work?
> More work needs more cares, and better to avoid unless really needed (e.g.
> you forgot cleanup at suspend/removal in this patch).
> 
> 
> thanks,
> 
> Takashi

Hi Takashi,

I've checked the hdmi_repoll_eld() and check_presence_and_report() function to see
if we can reuse the per-pin work. I've some questions about reusing the per-pin work:

1. hdmi_repoll_eld() calls snd_hda_jack_tbl_get_mst() function while
   check_presence_and_report() doesn't. Is it ok? 
2. snd_hdac_i915_set_bclk() is called in intel_pin_eld_notify() function. Since it's
   skipped, we need to call it in the per-pin work. Need to add a flag in hdmi_spec_per_pin
   to indicate this situation.
3. We can schedule the per-pin work in intel_pin_eld_notify() when snd_hdac_is_in_pm()
   returns true but there is no guarantee the runtime suspend will finished when the per-pin
  work is schedule to run.

static void hdmi_repoll_eld(struct work_struct *work)
{
	struct hdmi_spec_per_pin *per_pin =
	container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work);
	struct hda_codec *codec = per_pin->codec;
	struct hdmi_spec *spec = codec->spec;
	struct hda_jack_tbl *jack;

	jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid,
					per_pin->dev_id);
	if (jack)
		jack->jack_dirty = 1;

	if (per_pin->repoll_count++ > 6)
		per_pin->repoll_count = 0;

	mutex_lock(&spec->pcm_lock);
	hdmi_present_sense(per_pin, per_pin->repoll_count);
	mutex_unlock(&spec->pcm_lock);
}

static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid,
				      int dev_id)
{
	struct hdmi_spec *spec = codec->spec;
	int pin_idx = pin_id_to_pin_index(codec, nid, dev_id);

	if (pin_idx < 0)
		return;
	mutex_lock(&spec->pcm_lock);
	hdmi_present_sense(get_pin(spec, pin_idx), 1);
	mutex_unlock(&spec->pcm_lock);
}

Regards,
Brent


  reply	other threads:[~2022-09-28  2:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27 13:58 [PATCH] ALSA: hda/hdmi: run eld notify in delay work Brent Lu
2022-09-27 13:58 ` Brent Lu
2022-09-27 14:11 ` Takashi Iwai
2022-09-27 14:11   ` Takashi Iwai
2022-09-28  2:06   ` Lu, Brent [this message]
2022-09-28  2:06     ` Lu, Brent
2022-09-28  7:14     ` Takashi Iwai
2022-09-28  7:14       ` Takashi Iwai
2022-09-28  8:09       ` Takashi Iwai
2022-09-28  8:09         ` Takashi Iwai
2022-09-28  8:37         ` Takashi Iwai
2022-09-28  8:37           ` Takashi Iwai
2022-10-05  8:14           ` Lu, Brent
2022-10-05  8:14             ` Lu, Brent
2022-10-05  9:45             ` Takashi Iwai
2022-10-05  9:45               ` Takashi Iwai

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=CY5PR11MB6257CB33E1EDA90CE2B2F99D97549@CY5PR11MB6257.namprd11.prod.outlook.com \
    --to=brent.lu@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkumard@nvidia.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    --cc=tiwai@suse.de \
    --cc=ville.syrjala@linux.intel.com \
    --cc=yong.zhi@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.