mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viswanath L <viswanathl@nvidia.com>
To: <perex@perex.cz>, <tiwai@suse.com>, <mkumard@nvidia.com>,
	<jonathanh@nvidia.com>
Cc: <arnd@arndb.de>, <yung-chuan.liao@linux.intel.com>,
	<baolin.wang@linaro.org>, <kstewart@linuxfoundation.org>,
	<Julia.Lawall@inria.fr>, <tglx@linutronix.de>,
	<alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
	<spujar@nvidia.com>, <sharadg@nvidia.com>, <rlokhande@nvidia.com>,
	<DRAMESH@nvidia.com>, <atalambedu@nvidia.com>,
	Viswanath L <viswanathl@nvidia.com>
Subject: [PATCH] ALSA: hda: Clear RIRB status before reading WP
Date: Thu, 6 Feb 2020 15:40:53 +0530	[thread overview]
Message-ID: <1580983853-351-1-git-send-email-viswanathl@nvidia.com> (raw)

From: Mohan Kumar <mkumard@nvidia.com>

RIRB interrupt status getting cleared after the write pointer is read
causes a race condition, where last response(s) into RIRB may remain
unserviced by IRQ, eventually causing azx_rirb_get_response to fall
back to polling mode. Clearing the RIRB interrupt status ahead of
write pointer access ensures that this condition is avoided.

Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Signed-off-by: Viswanath L <viswanathl@nvidia.com>
---
 sound/pci/hda/hda_controller.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index 9757667..2609e39 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -1110,16 +1110,23 @@ irqreturn_t azx_interrupt(int irq, void *dev_id)
 		if (snd_hdac_bus_handle_stream_irq(bus, status, stream_update))
 			active = true;
 
-		/* clear rirb int */
 		status = azx_readb(chip, RIRBSTS);
 		if (status & RIRB_INT_MASK) {
+			/*
+			 * Clearing the interrupt status here ensures that no
+			 * interrupt gets masked after the RIRB wp is read in
+			 * snd_hdac_bus_update_rirb. This avoids a possible
+			 * race condition where codec response in RIRB may
+			 * remain unserviced by IRQ, eventually falling back
+			 * to polling mode in azx_rirb_get_response.
+			 */
+			azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
 			active = true;
 			if (status & RIRB_INT_RESPONSE) {
 				if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
 					udelay(80);
 				snd_hdac_bus_update_rirb(bus);
 			}
-			azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
 		}
 	} while (active && ++repeat < 10);
 
-- 
2.7.4


             reply	other threads:[~2020-02-06 10:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 10:10 Viswanath L [this message]
2020-02-06 10:47 ` 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=1580983853-351-1-git-send-email-viswanathl@nvidia.com \
    --to=viswanathl@nvidia.com \
    --cc=DRAMESH@nvidia.com \
    --cc=Julia.Lawall@inria.fr \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=atalambedu@nvidia.com \
    --cc=baolin.wang@linaro.org \
    --cc=jonathanh@nvidia.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkumard@nvidia.com \
    --cc=perex@perex.cz \
    --cc=rlokhande@nvidia.com \
    --cc=sharadg@nvidia.com \
    --cc=spujar@nvidia.com \
    --cc=tglx@linutronix.de \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®