All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brent Lu <brent.lu@intel.com>
To: alsa-devel@alsa-project.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
	"added_lines:21/248=8"@, "commit_signer:6/16=38"@,
	Keyon Jie <yang.jie@linux.intel.com>,
	"Liam Girdwood DRIVERS \)" <lgirdwood@gmail.com>,
	"commit_signer:15/16=94"@,
	Bard Liao <yung-chuan.liao@linux.intel.com>, "authored:2/16=12"@,
	Pierre-Louis Bossart DRIVERS
	<pierre-louis.bossart@linux.intel.com>,
	Brent Lu <brent.lu@intel.com>,
	Ranjani Sridharan DRIVERS <ranjani.sridharan@linux.intel.com>,
	"added_lines:123/248=50"@,
	sound-open-firmware@alsa-project.orgDRIVERS, "authored:6/16=38"@,
	Mark Brown <broonie@kernel.org>, "removed_lines:36/84=43"@,
	")"@alsa-project.org,
	"Daniel Baluta DRIVERS \)" <daniel.baluta@nxp.com>,
	Zhu Yingjiang <yingjiang.zhu@linux.intel.com>,
	"Kai Vehmanen DRIVERS \)" <kai.vehmanen@linux.intel.com>,
	Takashi Iwai <tiwai@suse.com>,
	linux-kernel@vger.kernel.org, "removed_lines:5/84=6"@
Subject: [PATCH] ASoC: SOF: Intel: hda: unsolicited RIRB response
Date: Thu, 11 Jun 2020 21:44:33 +0800	[thread overview]
Message-ID: <1591883073-17190-1-git-send-email-brent.lu@intel.com> (raw)

The loop implementation could not solve the unsolicited response
issue because the RIRBSTS is cleared after leaving the
snd_hdac_bus_update_rirb() function. So the next loop will fail the
status test against the RIRB_INT_MASK and skip all the RIRB handling
stuff. On the other hand, there alwasy could be unsolicited responses
in the last loop regardless the number of loops.

Clear the RIRB interrupt before handling it so unsolicited response
could trigger another RIRB interrupt to handle it later.

Signed-off-by: Brent Lu <brent.lu@intel.com>
---
 sound/soc/sof/intel/hda-stream.c | 48 +++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 28 deletions(-)

diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c
index 7f65dcc..d21ac42 100644
--- a/sound/soc/sof/intel/hda-stream.c
+++ b/sound/soc/sof/intel/hda-stream.c
@@ -589,11 +589,10 @@ hda_dsp_set_bytes_transferred(struct hdac_stream *hstream, u64 buffer_size)
 	hstream->curr_pos += num_bytes;
 }
 
-static bool hda_dsp_stream_check(struct hdac_bus *bus, u32 status)
+static void hda_dsp_stream_check(struct hdac_bus *bus, u32 status)
 {
 	struct sof_intel_hda_dev *sof_hda = bus_to_sof_hda(bus);
 	struct hdac_stream *s;
-	bool active = false;
 	u32 sd_status;
 
 	list_for_each_entry(s, &bus->stream_list, list) {
@@ -605,7 +604,6 @@ static bool hda_dsp_stream_check(struct hdac_bus *bus, u32 status)
 
 			snd_hdac_stream_writeb(s, SD_STS, sd_status);
 
-			active = true;
 			if ((!s->substream && !s->cstream) ||
 			    !s->running ||
 			    (sd_status & SOF_HDA_CL_DMA_SD_INT_COMPLETE) == 0)
@@ -621,8 +619,6 @@ static bool hda_dsp_stream_check(struct hdac_bus *bus, u32 status)
 			}
 		}
 	}
-
-	return active;
 }
 
 irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context)
@@ -632,37 +628,33 @@ irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context)
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
 	u32 rirb_status;
 #endif
-	bool active;
 	u32 status;
-	int i;
 
-	/*
-	 * Loop 10 times to handle missed interrupts caused by
-	 * unsolicited responses from the codec
-	 */
-	for (i = 0, active = true; i < 10 && active; i++) {
-		spin_lock_irq(&bus->reg_lock);
+	spin_lock_irq(&bus->reg_lock);
 
-		status = snd_hdac_chip_readl(bus, INTSTS);
+	status = snd_hdac_chip_readl(bus, INTSTS);
 
-		/* check streams */
-		active = hda_dsp_stream_check(bus, status);
+	/* check streams */
+	hda_dsp_stream_check(bus, status);
 
-		/* check and clear RIRB interrupt */
+	/* check and clear RIRB interrupt */
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
-		if (status & AZX_INT_CTRL_EN) {
-			rirb_status = snd_hdac_chip_readb(bus, RIRBSTS);
-			if (rirb_status & RIRB_INT_MASK) {
-				active = true;
-				if (rirb_status & RIRB_INT_RESPONSE)
-					snd_hdac_bus_update_rirb(bus);
-				snd_hdac_chip_writeb(bus, RIRBSTS,
-						     RIRB_INT_MASK);
-			}
+	if (status & AZX_INT_CTRL_EN) {
+		rirb_status = snd_hdac_chip_readb(bus, RIRBSTS);
+		if (rirb_status & RIRB_INT_MASK) {
+			/*
+			 * clear current interrupt before reading RIRBWP
+			 * so unsolicited response could trigger another
+			 * interrupt
+			 */
+			snd_hdac_chip_writeb(bus, RIRBSTS, RIRB_INT_MASK);
+
+			if (rirb_status & RIRB_INT_RESPONSE)
+				snd_hdac_bus_update_rirb(bus);
 		}
-#endif
-		spin_unlock_irq(&bus->reg_lock);
 	}
+#endif
+	spin_unlock_irq(&bus->reg_lock);
 
 	return IRQ_HANDLED;
 }
-- 
2.7.4


             reply	other threads:[~2020-06-11 13:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11 13:44 Brent Lu [this message]
2020-06-11 14:26 ` [PATCH] ASoC: SOF: Intel: hda: unsolicited RIRB response Ranjani Sridharan
2020-06-11 17:09   ` Lu, Brent
2020-06-11 17:09     ` Lu, Brent
2020-06-11 17:59     ` Takashi Iwai
2020-06-11 17:59       ` Takashi Iwai
2020-06-11 18:12       ` Ranjani Sridharan
2020-06-11 18:12         ` Ranjani Sridharan
2020-06-11 20:14         ` Takashi Iwai
2020-06-11 20:14           ` Takashi Iwai
2020-06-11 20:36           ` Pierre-Louis Bossart
2020-06-11 20:36             ` Pierre-Louis Bossart
2020-06-11 23:33             ` Lu, Brent
2020-06-11 23:33               ` Lu, Brent
2020-06-12  6:15       ` Lu, Brent
2020-06-12  6:15         ` Lu, Brent
2020-06-11 18:01     ` Pierre-Louis Bossart
2020-06-11 18:01       ` Pierre-Louis Bossart

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=1591883073-17190-1-git-send-email-brent.lu@intel.com \
    --to=brent.lu@intel.com \
    --cc=")"@alsa-project.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=daniel.baluta@nxp.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=sound-open-firmware@alsa-project.orgDRIVERS \
    --cc=tiwai@suse.com \
    --cc=yang.jie@linux.intel.com \
    --cc=yingjiang.zhu@linux.intel.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 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.