ALSA: firewire-lib: replace ack callback to flush isoc contexts in AMDTP domain
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Fri, 18 Oct 2019 06:19:08 +0000 (15:19 +0900)
committerTakashi Iwai <tiwai@suse.de>
Sat, 19 Oct 2019 07:18:22 +0000 (09:18 +0200)
An isoc context for AMDTP stream is flushed to queue packet
by a call of pcm.ack. This commit extends this for AMDTP
domain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191018061911.24909-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/amdtp-stream.c
sound/firewire/amdtp-stream.h
sound/firewire/bebob/bebob_pcm.c
sound/firewire/dice/dice-pcm.c
sound/firewire/digi00x/digi00x-pcm.c
sound/firewire/fireface/ff-pcm.c
sound/firewire/fireworks/fireworks_pcm.c
sound/firewire/motu/motu-pcm.c
sound/firewire/oxfw/oxfw-pcm.c
sound/firewire/tascam/tascam-pcm.c

index 23677b805b055354981d707e9f78518af7acade7..3d27d4ce2b45920ff80543377f4a3bbb27f6692b 100644 (file)
@@ -1139,23 +1139,29 @@ unsigned long amdtp_domain_stream_pcm_pointer(struct amdtp_domain *d,
 EXPORT_SYMBOL_GPL(amdtp_domain_stream_pcm_pointer);
 
 /**
- * amdtp_stream_pcm_ack - acknowledge queued PCM frames
+ * amdtp_domain_stream_pcm_ack - acknowledge queued PCM frames
+ * @d: the AMDTP domain.
  * @s: the AMDTP stream that transfers the PCM frames
  *
  * Returns zero always.
  */
-int amdtp_stream_pcm_ack(struct amdtp_stream *s)
+int amdtp_domain_stream_pcm_ack(struct amdtp_domain *d, struct amdtp_stream *s)
 {
-       /*
-        * Process isochronous packets for recent isochronous cycle to handle
-        * queued PCM frames.
-        */
-       if (amdtp_stream_running(s))
-               fw_iso_context_flush_completions(s->context);
+       struct amdtp_stream *irq_target = d->irq_target;
+
+       // Process isochronous packets for recent isochronous cycle to handle
+       // queued PCM frames.
+       if (irq_target && amdtp_stream_running(irq_target)) {
+               // Queued packet should be processed without any kernel
+               // preemption to keep latency against bus cycle.
+               preempt_disable();
+               fw_iso_context_flush_completions(irq_target->context);
+               preempt_enable();
+       }
 
        return 0;
 }
-EXPORT_SYMBOL(amdtp_stream_pcm_ack);
+EXPORT_SYMBOL_GPL(amdtp_domain_stream_pcm_ack);
 
 /**
  * amdtp_stream_update - update the stream after a bus reset
index ba0bbeddfdcb5e293ceeb313b9b0453c9401f2fb..470e77ca00611851d407d8cf3837f6e539b83fd6 100644 (file)
@@ -198,7 +198,6 @@ int amdtp_stream_add_pcm_hw_constraints(struct amdtp_stream *s,
                                        struct snd_pcm_runtime *runtime);
 
 void amdtp_stream_pcm_prepare(struct amdtp_stream *s);
-int amdtp_stream_pcm_ack(struct amdtp_stream *s);
 void amdtp_stream_pcm_abort(struct amdtp_stream *s);
 
 extern const unsigned int amdtp_syt_intervals[CIP_SFC_COUNT];
@@ -303,4 +302,6 @@ static inline int amdtp_domain_set_events_per_period(struct amdtp_domain *d,
 
 unsigned long amdtp_domain_stream_pcm_pointer(struct amdtp_domain *d,
                                              struct amdtp_stream *s);
+int amdtp_domain_stream_pcm_ack(struct amdtp_domain *d, struct amdtp_stream *s);
+
 #endif
index dc15ea8d0dc58302b1f4bcd5c385e6ae78f74084..1b100159f4c5940189215f66062df578a0f84a82 100644 (file)
@@ -332,14 +332,14 @@ static int pcm_capture_ack(struct snd_pcm_substream *substream)
 {
        struct snd_bebob *bebob = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&bebob->tx_stream);
+       return amdtp_domain_stream_pcm_ack(&bebob->domain, &bebob->tx_stream);
 }
 
 static int pcm_playback_ack(struct snd_pcm_substream *substream)
 {
        struct snd_bebob *bebob = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&bebob->rx_stream);
+       return amdtp_domain_stream_pcm_ack(&bebob->domain, &bebob->rx_stream);
 }
 
 int snd_bebob_create_pcm_devices(struct snd_bebob *bebob)
index 81b78e7d181dd7695d9420a052a5bef8376063f5..f1848fb39bd0e6062ff82b9952afc00ccdcbdd54 100644 (file)
@@ -394,7 +394,7 @@ static int capture_ack(struct snd_pcm_substream *substream)
        struct snd_dice *dice = substream->private_data;
        struct amdtp_stream *stream = &dice->tx_stream[substream->pcm->device];
 
-       return amdtp_stream_pcm_ack(stream);
+       return amdtp_domain_stream_pcm_ack(&dice->domain, stream);
 }
 
 static int playback_ack(struct snd_pcm_substream *substream)
@@ -402,7 +402,7 @@ static int playback_ack(struct snd_pcm_substream *substream)
        struct snd_dice *dice = substream->private_data;
        struct amdtp_stream *stream = &dice->rx_stream[substream->pcm->device];
 
-       return amdtp_stream_pcm_ack(stream);
+       return amdtp_domain_stream_pcm_ack(&dice->domain, stream);
 }
 
 int snd_dice_create_pcm(struct snd_dice *dice)
index f6a2053d5f10830def4e9753ea574e3913d6f50a..8befc5d2ef220b9df5a3c06ad209b0d3d1cd5c75 100644 (file)
@@ -315,14 +315,14 @@ static int pcm_capture_ack(struct snd_pcm_substream *substream)
 {
        struct snd_dg00x *dg00x = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&dg00x->tx_stream);
+       return amdtp_domain_stream_pcm_ack(&dg00x->domain, &dg00x->tx_stream);
 }
 
 static int pcm_playback_ack(struct snd_pcm_substream *substream)
 {
        struct snd_dg00x *dg00x = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&dg00x->rx_stream);
+       return amdtp_domain_stream_pcm_ack(&dg00x->domain, &dg00x->rx_stream);
 }
 
 int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
index 5af1dce9092101416606db4eed4df847eb71c744..c29f87a65c0fcc8f9cade0df3936873da092e537 100644 (file)
@@ -355,14 +355,14 @@ static int pcm_capture_ack(struct snd_pcm_substream *substream)
 {
        struct snd_ff *ff = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&ff->tx_stream);
+       return amdtp_domain_stream_pcm_ack(&ff->domain, &ff->tx_stream);
 }
 
 static int pcm_playback_ack(struct snd_pcm_substream *substream)
 {
        struct snd_ff *ff = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&ff->rx_stream);
+       return amdtp_domain_stream_pcm_ack(&ff->domain, &ff->rx_stream);
 }
 
 int snd_ff_create_pcm_devices(struct snd_ff *ff)
index 71f5057caa0d930c72d8b7fcb99332bd22876e97..64c1bcf28dfa2a422ad54ff46d5d03b42c005c3e 100644 (file)
@@ -362,14 +362,14 @@ static int pcm_capture_ack(struct snd_pcm_substream *substream)
 {
        struct snd_efw *efw = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&efw->tx_stream);
+       return amdtp_domain_stream_pcm_ack(&efw->domain, &efw->tx_stream);
 }
 
 static int pcm_playback_ack(struct snd_pcm_substream *substream)
 {
        struct snd_efw *efw = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&efw->rx_stream);
+       return amdtp_domain_stream_pcm_ack(&efw->domain, &efw->rx_stream);
 }
 
 int snd_efw_create_pcm_devices(struct snd_efw *efw)
index 13e2577c2a076ffd0b06401804af912373d18515..55d3d6661731e9ca05533fbcda728d471fedd459 100644 (file)
@@ -333,14 +333,14 @@ static int capture_ack(struct snd_pcm_substream *substream)
 {
        struct snd_motu *motu = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&motu->tx_stream);
+       return amdtp_domain_stream_pcm_ack(&motu->domain, &motu->tx_stream);
 }
 
 static int playback_ack(struct snd_pcm_substream *substream)
 {
        struct snd_motu *motu = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&motu->rx_stream);
+       return amdtp_domain_stream_pcm_ack(&motu->domain, &motu->rx_stream);
 }
 
 int snd_motu_create_pcm_devices(struct snd_motu *motu)
index 3be35dfcf270bdd2b19bc3945258411c051be23e..74bd1811cec2943f7c9a39b2180d2b0b9cba7ae1 100644 (file)
@@ -406,14 +406,14 @@ static int pcm_capture_ack(struct snd_pcm_substream *substream)
 {
        struct snd_oxfw *oxfw = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&oxfw->tx_stream);
+       return amdtp_domain_stream_pcm_ack(&oxfw->domain, &oxfw->tx_stream);
 }
 
 static int pcm_playback_ack(struct snd_pcm_substream *substream)
 {
        struct snd_oxfw *oxfw = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&oxfw->rx_stream);
+       return amdtp_domain_stream_pcm_ack(&oxfw->domain, &oxfw->rx_stream);
 }
 
 int snd_oxfw_create_pcm(struct snd_oxfw *oxfw)
index 1f66c8be7528ae8df001f51970659f3f051c89e1..cd45f20ba5158fed4a7175003dc02775600fcb35 100644 (file)
@@ -244,14 +244,14 @@ static int pcm_capture_ack(struct snd_pcm_substream *substream)
 {
        struct snd_tscm *tscm = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&tscm->tx_stream);
+       return amdtp_domain_stream_pcm_ack(&tscm->domain, &tscm->tx_stream);
 }
 
 static int pcm_playback_ack(struct snd_pcm_substream *substream)
 {
        struct snd_tscm *tscm = substream->private_data;
 
-       return amdtp_stream_pcm_ack(&tscm->rx_stream);
+       return amdtp_domain_stream_pcm_ack(&tscm->domain, &tscm->rx_stream);
 }
 
 int snd_tscm_create_pcm_devices(struct snd_tscm *tscm)