All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de
Cc: alsa-devel@alsa-project.org
Subject: [alsa-devel] [PATCH 11/12] ALSA: firewire-lib: tune the maximum available size of PCM period
Date: Fri, 18 Oct 2019 00:54:23 +0900	[thread overview]
Message-ID: <20191017155424.885-12-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20191017155424.885-1-o-takashi@sakamocchi.jp>

Linux driver for 1394 OHCI controller voluntarily flushes isoc context
when total size of accumulated context header reached PAGE_SIZE. This
kicks tasklet for the isoc context. This is inconvenient to process
runtime of PCM substream.

This commit adds a restriction of the maximum size of PCM period to
avoid this behaviour.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/amdtp-stream.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c
index fd7c3e4d5374..8a7818130382 100644
--- a/sound/firewire/amdtp-stream.c
+++ b/sound/firewire/amdtp-stream.c
@@ -176,6 +176,8 @@ int amdtp_stream_add_pcm_hw_constraints(struct amdtp_stream *s,
 					struct snd_pcm_runtime *runtime)
 {
 	struct snd_pcm_hardware *hw = &runtime->hw;
+	unsigned int ctx_header_size;
+	unsigned int maximum_usec_per_period;
 	int err;
 
 	hw->info = SNDRV_PCM_INFO_BATCH |
@@ -196,19 +198,24 @@ int amdtp_stream_add_pcm_hw_constraints(struct amdtp_stream *s,
 	hw->period_bytes_max = hw->period_bytes_min * 2048;
 	hw->buffer_bytes_max = hw->period_bytes_max * hw->periods_min;
 
-	/*
-	 * Currently firewire-lib processes 16 packets in one software
-	 * interrupt callback. This equals to 2msec but actually the
-	 * interval of the interrupts has a jitter.
-	 * Additionally, even if adding a constraint to fit period size to
-	 * 2msec, actual calculated frames per period doesn't equal to 2msec,
-	 * depending on sampling rate.
-	 * Anyway, the interval to call snd_pcm_period_elapsed() cannot 2msec.
-	 * Here let us use 5msec for safe period interrupt.
-	 */
+	// Linux driver for 1394 OHCI controller voluntarily flushes isoc
+	// context when total size of accumulated context header reaches
+	// PAGE_SIZE. This kicks tasklet for the isoc context and brings
+	// callback in the middle of scheduled interrupts.
+	// Although AMDTP streams in the same domain use the same events per
+	// IRQ, use the largest size of context header between IT/IR contexts.
+	// Here, use the value of context header in IR context is for both
+	// contexts.
+	if (!(s->flags & CIP_NO_HEADER))
+		ctx_header_size = IR_CTX_HEADER_SIZE_CIP;
+	else
+		ctx_header_size = IR_CTX_HEADER_SIZE_NO_CIP;
+	maximum_usec_per_period = USEC_PER_SEC * PAGE_SIZE /
+				  CYCLES_PER_SECOND / ctx_header_size;
+
 	err = snd_pcm_hw_constraint_minmax(runtime,
 					   SNDRV_PCM_HW_PARAM_PERIOD_TIME,
-					   5000, UINT_MAX);
+					   5000, maximum_usec_per_period);
 	if (err < 0)
 		goto end;
 
-- 
2.20.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  parent reply	other threads:[~2019-10-17 16:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 15:54 [alsa-devel] [PATCH 00/12] ALSA: firewire: configure interval of hw IRQ via ALSA PCM interface Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 01/12] ALSA: firewire-lib: use variable size of queue for isoc packets instead of fixed size Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 02/12] ALSA: bebob: share PCM buffer size for both direction Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 03/12] ALSA: fireworks: " Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 04/12] ALSA: oxfw: " Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 05/12] ALSA: dice: " Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 06/12] ALSA: firewire-digi00x: " Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 07/12] ALSA: firewire-tascam: " Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 08/12] ALSA: firewire-motu: " Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 09/12] ALSA: fireface: " Takashi Sakamoto
2019-10-17 15:54 ` [alsa-devel] [PATCH 10/12] ALSA: firewire-lib: schedule hardware IRQ according to the size of PCM period Takashi Sakamoto
2019-10-17 15:54 ` Takashi Sakamoto [this message]
2019-10-17 15:54 ` [alsa-devel] [PATCH 12/12] ALSA: firewire-lib: tune the minimum available " Takashi Sakamoto
2019-10-18  2:37 ` [alsa-devel] [PATCH 00/12] ALSA: firewire: configure interval of hw IRQ via ALSA PCM interface 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=20191017155424.885-12-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --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.