All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sriram Periyasamy <sriramx.periyasamy@intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: ALSA ML <alsa-devel@alsa-project.org>,
	Patches Audio <patches.audio@intel.com>,
	Guneshwor Singh <guneshwor.o.singh@intel.com>,
	Liam Girdwood <liam.r.girdwood@linux.intel.com>,
	Mark Brown <broonie@kernel.org>, Jeeja KP <jeeja.kp@intel.com>,
	Sanyog Kale <sanyog.r.kale@intel.com>
Subject: Re: [PATCH v2] ASoC: hdac_hdmi: Program pin-port-mux during jack report event
Date: Wed, 11 Jul 2018 14:55:46 +0530	[thread overview]
Message-ID: <20180711092545.GA30345@intel.com> (raw)
In-Reply-To: <s5hpnzup8y6.wl-tiwai@suse.de>

On Wed, Jul 11, 2018 at 08:45:05AM +0200, Takashi Iwai wrote:
> On Wed, 11 Jul 2018 08:30:43 +0200,
> Sriram Periyasamy wrote:
> > 
> > @@ -167,6 +171,30 @@ static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm,
> >  
> >  	if (is_connect) {
> >  		/*
> > +		 * Increment the usage count to ensure that the device
> > +		 * is runtime active to send verb across.
> > +		 */
> > +		pm_runtime_get_sync(&edev->hdev.dev);
> 
> This looks more reasonable now, but...
> 
> > +		/* set the device if pin is mst_capable */
> > +		if (hdac_hdmi_port_select_set(edev, port) < 0) {
> > +			dev_err(&edev->hdev.dev,
> > +				"port %d device select fail\n", port->id);
> > +			return;
> 
> It appears like an unbalanced pm refcount here in the error path.
> 

Thanks for pointing out. Will fix it.

> > +		}
> > +
> > +		/*
> > +		 * Restore the connection selection index of the
> > +		 * respective pin.
> > +		 */
> > +		if (port->pin->conn_index > 0)
> > +			snd_hdac_codec_write(&edev->hdev, port->pin->nid,
> > +						0, AC_VERB_SET_CONNECT_SEL,
> > +						port->pin->conn_index - 1);
> 
> And, here checks conn_index > 0 while...
> 
> > @@ -903,6 +931,9 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol,
> >  		}
> >  	}
> >  
> > +	if (ucontrol->value.enumerated.item[0] > 0)
> > +		port->pin->conn_index =	ucontrol->value.enumerated.item[0];
> 
> ... conn_index is set only non-zero here.
> 
> That is, once after a non-zero is passed, conn_index can't any longer
> back to zero.  I guess it's not intentional?
> 

No, it is intentional. For example, two ports are connected to the
display and user land set mux only for one port. Hence other port's
conn_index is set to default 0. When jack report happens for that port,
we would be writing invalid connection select index which will lead to
undefined hardware behaviour as per the HDA spec.

Though it is userland's mistake, it is better to take care in the driver.

Thanks,
Sriram.

  reply	other threads:[~2018-07-11  9:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11  6:30 [PATCH v2] ASoC: hdac_hdmi: Program pin-port-mux during jack report event Sriram Periyasamy
2018-07-11  6:45 ` Takashi Iwai
2018-07-11  9:25   ` Sriram Periyasamy [this message]
2018-07-11 10:03     ` Takashi Iwai
2018-07-11 10:56       ` Sriram Periyasamy
2018-07-11 11:06         ` 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=20180711092545.GA30345@intel.com \
    --to=sriramx.periyasamy@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=guneshwor.o.singh@intel.com \
    --cc=jeeja.kp@intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=patches.audio@intel.com \
    --cc=sanyog.r.kale@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 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.