diff mbox series

ALSA: hda/hdmi: packet buffer index must be set before reading value

Message ID 20201211131613.3271407-1-kai.vehmanen@linux.intel.com (mailing list archive)
State Accepted
Commit 46c3bbd9827952f92e250fa6ee30a797a4c4e17e
Headers show
Series ALSA: hda/hdmi: packet buffer index must be set before reading value | expand

Commit Message

Kai Vehmanen Dec. 11, 2020, 1:16 p.m. UTC
The check for infoframe transmit status in hdmi_infoframe_uptodate()
makes the assumption that packet buffer index is set to zero.

Align code with specification and explicitly set the index before
AC_VERB_GET_HDMI_DIP_XMIT. The packet index setting affects both
DIP-Data and DIP-XmitCtrl verbs.

There are no known cases where the old implementation has caused driver
to work incorrectly. This change is purely based on code review against
the specification (HDA spec rev1.0a).

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 sound/pci/hda/patch_hdmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Takashi Iwai Dec. 11, 2020, 1:27 p.m. UTC | #1
On Fri, 11 Dec 2020 14:16:13 +0100,
Kai Vehmanen wrote:
> 
> The check for infoframe transmit status in hdmi_infoframe_uptodate()
> makes the assumption that packet buffer index is set to zero.
> 
> Align code with specification and explicitly set the index before
> AC_VERB_GET_HDMI_DIP_XMIT. The packet index setting affects both
> DIP-Data and DIP-XmitCtrl verbs.
> 
> There are no known cases where the old implementation has caused driver
> to work incorrectly. This change is purely based on code review against
> the specification (HDA spec rev1.0a).
> 
> Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>

Currently there is no other place to change DIP index, i.e. it's
always zero, and the bug wouldn't hit, but it's better to be addressed
beforehand, indeed.

Applied now.  Thanks.


Takashi
Kai Vehmanen Dec. 11, 2020, 1:46 p.m. UTC | #2
Hi,

On Fri, 11 Dec 2020, Takashi Iwai wrote:

> On Fri, 11 Dec 2020 14:16:13 +0100, Kai Vehmanen wrote:
> > 
> > The check for infoframe transmit status in hdmi_infoframe_uptodate()
> > makes the assumption that packet buffer index is set to zero.
> 
> Currently there is no other place to change DIP index, i.e. it's
> always zero, and the bug wouldn't hit, but it's better to be addressed
> beforehand, indeed.

indeed, agreed on that. Most likely scenario where this could actually 
cause harm if someone later adds new functionality to this driver that 
uses other DIP indices for something. That's pretty unlikely as well, but 
yeah, better align with the spec.

Br, Kai
diff mbox series

Patch

diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 2ddc27db8c01..81fd7f9a40ce 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -638,11 +638,11 @@  static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid,
 	u8 val;
 	int i;
 
+	hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
 	if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0)
 							    != AC_DIPXMIT_BEST)
 		return false;
 
-	hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
 	for (i = 0; i < size; i++) {
 		val = snd_hda_codec_read(codec, pin_nid, 0,
 					 AC_VERB_GET_HDMI_DIP_DATA, 0);