All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mohan Kumar <mkumard@nvidia.com>
To: <tiwai@suse.com>, <perex@perex.cz>
Cc: <alsa-devel@alsa-project.org>, <linux-tegra@vger.kernel.org>,
	<treding@nvidia.com>, <jonathanh@nvidia.com>, <spujar@nvidia.com>,
	Mohan Kumar <mkumard@nvidia.com>
Subject: [PATCH v2 3/3] ALSA: hda/tegra: Add 100us dma stop delay
Date: Wed, 5 Aug 2020 15:22:21 +0530	[thread overview]
Message-ID: <20200805095221.5476-4-mkumard@nvidia.com> (raw)
In-Reply-To: <20200805095221.5476-1-mkumard@nvidia.com>

Tegra HDA has audio data buffer for upto tens of frames, this buffer
can help to avoid underflow. HW will keep issuing new data fetch
request when buffers are not full and current BDL is not done. When SW
disable DMA RUN bit for a stream, HW can't cancel the already issued data
fetch request and hence it can't stop DMA. HW has to wait for all issued
data fetch request get data returned before it stops DMA.

This HW behavior is not in sync with HDA spec which says DMA RUN bit
should be cleared within 1 audio frame. For Tegra, DMA RUN bit was
active for more than one audio frame, due to this the timeout in
snd_hdac_stream_sync function is not helping. When Stream reset set
and clear happens during DMA RUN bit active state it results in Memory
Decode error.

Unfortunately, there is no way to detect when these data accesses have
completed, but testing has shown that a 100us delay between Stream reset
set and clear operation for Tegra avoids the memory decode error.
Therefore, adding a 100us dma stop delay.

Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
---
 sound/pci/hda/hda_tegra.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
index ecf98eb9df36..c94553bcca88 100644
--- a/sound/pci/hda/hda_tegra.c
+++ b/sound/pci/hda/hda_tegra.c
@@ -308,6 +308,7 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev)
 		return err;
 	}
 	bus->irq = irq_id;
+	bus->dma_stop_delay = 100;
 	card->sync_irq = bus->irq;
 
 	/*
-- 
2.17.1


WARNING: multiple messages have this Message-ID (diff)
From: Mohan Kumar <mkumard@nvidia.com>
To: <tiwai@suse.com>, <perex@perex.cz>
Cc: alsa-devel@alsa-project.org, spujar@nvidia.com,
	jonathanh@nvidia.com, linux-tegra@vger.kernel.org,
	treding@nvidia.com, Mohan Kumar <mkumard@nvidia.com>
Subject: [PATCH v2 3/3] ALSA: hda/tegra: Add 100us dma stop delay
Date: Wed, 5 Aug 2020 15:22:21 +0530	[thread overview]
Message-ID: <20200805095221.5476-4-mkumard@nvidia.com> (raw)
In-Reply-To: <20200805095221.5476-1-mkumard@nvidia.com>

Tegra HDA has audio data buffer for upto tens of frames, this buffer
can help to avoid underflow. HW will keep issuing new data fetch
request when buffers are not full and current BDL is not done. When SW
disable DMA RUN bit for a stream, HW can't cancel the already issued data
fetch request and hence it can't stop DMA. HW has to wait for all issued
data fetch request get data returned before it stops DMA.

This HW behavior is not in sync with HDA spec which says DMA RUN bit
should be cleared within 1 audio frame. For Tegra, DMA RUN bit was
active for more than one audio frame, due to this the timeout in
snd_hdac_stream_sync function is not helping. When Stream reset set
and clear happens during DMA RUN bit active state it results in Memory
Decode error.

Unfortunately, there is no way to detect when these data accesses have
completed, but testing has shown that a 100us delay between Stream reset
set and clear operation for Tegra avoids the memory decode error.
Therefore, adding a 100us dma stop delay.

Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
---
 sound/pci/hda/hda_tegra.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
index ecf98eb9df36..c94553bcca88 100644
--- a/sound/pci/hda/hda_tegra.c
+++ b/sound/pci/hda/hda_tegra.c
@@ -308,6 +308,7 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev)
 		return err;
 	}
 	bus->irq = irq_id;
+	bus->dma_stop_delay = 100;
 	card->sync_irq = bus->irq;
 
 	/*
-- 
2.17.1


  parent reply	other threads:[~2020-08-05  9:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05  9:52 [PATCH v2 0/3] Tegra Specific fixes Mohan Kumar
2020-08-05  9:52 ` Mohan Kumar
2020-08-05  9:52 ` [PATCH v2 1/3] ASoC: hda/tegra: Set buffer alignment to 128 bytes Mohan Kumar
2020-08-05  9:52   ` Mohan Kumar
2020-08-05  9:52 ` [PATCH v2 2/3] ALSA: hda: Add dma stop delay variable Mohan Kumar
2020-08-05  9:52   ` Mohan Kumar
2020-08-05  9:52 ` Mohan Kumar [this message]
2020-08-05  9:52   ` [PATCH v2 3/3] ALSA: hda/tegra: Add 100us dma stop delay Mohan Kumar
2020-08-05 10:29 ` [PATCH v2 0/3] Tegra Specific fixes Takashi Iwai
2020-08-05 10:29   ` 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=20200805095221.5476-4-mkumard@nvidia.com \
    --to=mkumard@nvidia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=spujar@nvidia.com \
    --cc=tiwai@suse.com \
    --cc=treding@nvidia.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.