[alsa-devel] [PATCH 0/8] ALSA: firewire: minor code refactoring and bug
Hi,
During a couple of weeks, I added code refactoring to all of drivers in ALSA firewire stack. But I can find some rooms for additional code refactoring and some bugs.
This patchset is for them.
Takashi Sakamoto (8): ALSA: firewire-tascam: unify stop and release method for duplex streams ALSA: fireface: unify stop and release method for duplex streams ALSA: firewire-motu: unify stop and release method for duplex streams ALSA: firewire-digi00x: unify stop and release method for duplex streams ALSA: dice: unify stop and release method for duplex streams ALSA: bebob: ensure to release isochronous resources in pcm.hw_params callback ALSA: fireworks: ensure to release isochronous resources in pcm.hw_params callback ALSA: oxfw: ensure to release isochronous resources in pcm.hw_params callback
sound/firewire/bebob/bebob_stream.c | 3 +++ sound/firewire/dice/dice-midi.c | 1 - sound/firewire/dice/dice-pcm.c | 1 - sound/firewire/dice/dice-stream.c | 8 ++------ sound/firewire/dice/dice.h | 1 - sound/firewire/digi00x/digi00x-midi.c | 1 - sound/firewire/digi00x/digi00x-pcm.c | 1 - sound/firewire/digi00x/digi00x-stream.c | 14 +++++--------- sound/firewire/digi00x/digi00x.h | 1 - sound/firewire/fireface/ff-pcm.c | 1 - sound/firewire/fireface/ff-stream.c | 14 +++++--------- sound/firewire/fireface/ff.h | 1 - sound/firewire/fireworks/fireworks_stream.c | 3 +++ sound/firewire/motu/motu-midi.c | 1 - sound/firewire/motu/motu-pcm.c | 1 - sound/firewire/motu/motu-stream.c | 14 +++++--------- sound/firewire/motu/motu.h | 1 - sound/firewire/oxfw/oxfw-stream.c | 2 ++ sound/firewire/tascam/tascam-pcm.c | 1 - sound/firewire/tascam/tascam-stream.c | 14 +++++--------- sound/firewire/tascam/tascam.h | 1 - 21 files changed, 30 insertions(+), 55 deletions(-)
From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit merges the two functions.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/tascam/tascam-pcm.c | 1 - sound/firewire/tascam/tascam-stream.c | 14 +++++--------- sound/firewire/tascam/tascam.h | 1 - 3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/sound/firewire/tascam/tascam-pcm.c b/sound/firewire/tascam/tascam-pcm.c index 450711bef508..300683a82c68 100644 --- a/sound/firewire/tascam/tascam-pcm.c +++ b/sound/firewire/tascam/tascam-pcm.c @@ -118,7 +118,6 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) --tscm->substreams_counter;
snd_tscm_stream_stop_duplex(tscm); - snd_tscm_stream_release_duplex(tscm);
mutex_unlock(&tscm->mutex);
diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c index f572dfc15114..0e515b7be276 100644 --- a/sound/firewire/tascam/tascam-stream.c +++ b/sound/firewire/tascam/tascam-stream.c @@ -380,14 +380,6 @@ int snd_tscm_stream_reserve_duplex(struct snd_tscm *tscm, unsigned int rate) return 0; }
-void snd_tscm_stream_release_duplex(struct snd_tscm *tscm) -{ - if (tscm->substreams_counter == 0) { - fw_iso_resources_free(&tscm->tx_resources); - fw_iso_resources_free(&tscm->rx_resources); - } -} - int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate) { unsigned int generation = tscm->rx_resources.generation; @@ -455,8 +447,12 @@ int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate)
void snd_tscm_stream_stop_duplex(struct snd_tscm *tscm) { - if (tscm->substreams_counter == 0) + if (tscm->substreams_counter == 0) { finish_session(tscm); + + fw_iso_resources_free(&tscm->tx_resources); + fw_iso_resources_free(&tscm->rx_resources); + } }
void snd_tscm_stream_lock_changed(struct snd_tscm *tscm) diff --git a/sound/firewire/tascam/tascam.h b/sound/firewire/tascam/tascam.h index 1cb75c374f11..4ed88cceaedb 100644 --- a/sound/firewire/tascam/tascam.h +++ b/sound/firewire/tascam/tascam.h @@ -148,7 +148,6 @@ int snd_tscm_stream_init_duplex(struct snd_tscm *tscm); void snd_tscm_stream_update_duplex(struct snd_tscm *tscm); void snd_tscm_stream_destroy_duplex(struct snd_tscm *tscm); int snd_tscm_stream_reserve_duplex(struct snd_tscm *tscm, unsigned int rate); -void snd_tscm_stream_release_duplex(struct snd_tscm *tscm); int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate); void snd_tscm_stream_stop_duplex(struct snd_tscm *tscm);
From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit merges the two functions.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/fireface/ff-pcm.c | 1 - sound/firewire/fireface/ff-stream.c | 14 +++++--------- sound/firewire/fireface/ff.h | 1 - 3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c index 938985c2d4a8..75228e769687 100644 --- a/sound/firewire/fireface/ff-pcm.c +++ b/sound/firewire/fireface/ff-pcm.c @@ -233,7 +233,6 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) --ff->substreams_counter;
snd_ff_stream_stop_duplex(ff); - snd_ff_stream_release_duplex(ff);
mutex_unlock(&ff->mutex);
diff --git a/sound/firewire/fireface/ff-stream.c b/sound/firewire/fireface/ff-stream.c index 884705ecf940..049920a6d43e 100644 --- a/sound/firewire/fireface/ff-stream.c +++ b/sound/firewire/fireface/ff-stream.c @@ -149,14 +149,6 @@ int snd_ff_stream_reserve_duplex(struct snd_ff *ff, unsigned int rate) return 0; }
-void snd_ff_stream_release_duplex(struct snd_ff *ff) -{ - if (ff->substreams_counter == 0) { - fw_iso_resources_free(&ff->tx_resources); - fw_iso_resources_free(&ff->rx_resources); - } -} - int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate) { int err; @@ -217,8 +209,12 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate)
void snd_ff_stream_stop_duplex(struct snd_ff *ff) { - if (ff->substreams_counter == 0) + if (ff->substreams_counter == 0) { finish_session(ff); + + fw_iso_resources_free(&ff->tx_resources); + fw_iso_resources_free(&ff->rx_resources); + } }
void snd_ff_stream_update_duplex(struct snd_ff *ff) diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h index fe5739ee1c88..9b52c368f6de 100644 --- a/sound/firewire/fireface/ff.h +++ b/sound/firewire/fireface/ff.h @@ -139,7 +139,6 @@ int snd_ff_stream_get_multiplier_mode(enum cip_sfc sfc, int snd_ff_stream_init_duplex(struct snd_ff *ff); void snd_ff_stream_destroy_duplex(struct snd_ff *ff); int snd_ff_stream_reserve_duplex(struct snd_ff *ff, unsigned int rate); -void snd_ff_stream_release_duplex(struct snd_ff *ff); int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate); void snd_ff_stream_stop_duplex(struct snd_ff *ff); void snd_ff_stream_update_duplex(struct snd_ff *ff);
From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit merges the two functions.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/motu/motu-midi.c | 1 - sound/firewire/motu/motu-pcm.c | 1 - sound/firewire/motu/motu-stream.c | 14 +++++--------- sound/firewire/motu/motu.h | 1 - 4 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/sound/firewire/motu/motu-midi.c b/sound/firewire/motu/motu-midi.c index a463730c72bc..4520c0060b83 100644 --- a/sound/firewire/motu/motu-midi.c +++ b/sound/firewire/motu/motu-midi.c @@ -40,7 +40,6 @@ static int midi_close(struct snd_rawmidi_substream *substream)
--motu->substreams_counter; snd_motu_stream_stop_duplex(motu); - snd_motu_stream_release_duplex(motu);
mutex_unlock(&motu->mutex);
diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index b9852c911b98..60c691d18952 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -224,7 +224,6 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) --motu->substreams_counter;
snd_motu_stream_stop_duplex(motu); - snd_motu_stream_release_duplex(motu);
mutex_unlock(&motu->mutex);
diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index 82891583b736..8aab5db71c0f 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -200,14 +200,6 @@ int snd_motu_stream_reserve_duplex(struct snd_motu *motu, unsigned int rate) return 0; }
-void snd_motu_stream_release_duplex(struct snd_motu *motu) -{ - if (motu->substreams_counter == 0) { - fw_iso_resources_free(&motu->tx_resources); - fw_iso_resources_free(&motu->rx_resources); - } -} - static int ensure_packet_formats(struct snd_motu *motu) { __be32 reg; @@ -301,8 +293,12 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu)
void snd_motu_stream_stop_duplex(struct snd_motu *motu) { - if (motu->substreams_counter == 0) + if (motu->substreams_counter == 0) { finish_session(motu); + + fw_iso_resources_free(&motu->tx_resources); + fw_iso_resources_free(&motu->rx_resources); + } }
static int init_stream(struct snd_motu *motu, enum amdtp_stream_direction dir) diff --git a/sound/firewire/motu/motu.h b/sound/firewire/motu/motu.h index 32cd42873fd0..a4ac320f2c9e 100644 --- a/sound/firewire/motu/motu.h +++ b/sound/firewire/motu/motu.h @@ -154,7 +154,6 @@ int snd_motu_stream_init_duplex(struct snd_motu *motu); void snd_motu_stream_destroy_duplex(struct snd_motu *motu); int snd_motu_stream_cache_packet_formats(struct snd_motu *motu); int snd_motu_stream_reserve_duplex(struct snd_motu *motu, unsigned int rate); -void snd_motu_stream_release_duplex(struct snd_motu *motu); int snd_motu_stream_start_duplex(struct snd_motu *motu); void snd_motu_stream_stop_duplex(struct snd_motu *motu); int snd_motu_stream_lock_try(struct snd_motu *motu);
From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit merges the two functions.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/digi00x/digi00x-midi.c | 1 - sound/firewire/digi00x/digi00x-pcm.c | 1 - sound/firewire/digi00x/digi00x-stream.c | 14 +++++--------- sound/firewire/digi00x/digi00x.h | 1 - 4 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/sound/firewire/digi00x/digi00x-midi.c b/sound/firewire/digi00x/digi00x-midi.c index cca888cce0d3..ca06ad318ed6 100644 --- a/sound/firewire/digi00x/digi00x-midi.c +++ b/sound/firewire/digi00x/digi00x-midi.c @@ -37,7 +37,6 @@ static int midi_close(struct snd_rawmidi_substream *substream) mutex_lock(&dg00x->mutex); --dg00x->substreams_counter; snd_dg00x_stream_stop_duplex(dg00x); - snd_dg00x_stream_release_duplex(dg00x); mutex_unlock(&dg00x->mutex);
snd_dg00x_stream_lock_release(dg00x); diff --git a/sound/firewire/digi00x/digi00x-pcm.c b/sound/firewire/digi00x/digi00x-pcm.c index 9ed2ebdcf23a..c38fbd6ded9f 100644 --- a/sound/firewire/digi00x/digi00x-pcm.c +++ b/sound/firewire/digi00x/digi00x-pcm.c @@ -189,7 +189,6 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) --dg00x->substreams_counter;
snd_dg00x_stream_stop_duplex(dg00x); - snd_dg00x_stream_release_duplex(dg00x);
mutex_unlock(&dg00x->mutex);
diff --git a/sound/firewire/digi00x/digi00x-stream.c b/sound/firewire/digi00x/digi00x-stream.c index 3c5e1c5a2e11..7c8e7ad48d03 100644 --- a/sound/firewire/digi00x/digi00x-stream.c +++ b/sound/firewire/digi00x/digi00x-stream.c @@ -293,14 +293,6 @@ int snd_dg00x_stream_reserve_duplex(struct snd_dg00x *dg00x, unsigned int rate) return 0; }
-void snd_dg00x_stream_release_duplex(struct snd_dg00x *dg00x) -{ - if (dg00x->substreams_counter == 0) { - fw_iso_resources_free(&dg00x->tx_resources); - fw_iso_resources_free(&dg00x->rx_resources); - } -} - int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x) { unsigned int generation = dg00x->rx_resources.generation; @@ -372,8 +364,12 @@ int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x)
void snd_dg00x_stream_stop_duplex(struct snd_dg00x *dg00x) { - if (dg00x->substreams_counter == 0) + if (dg00x->substreams_counter == 0) { finish_session(dg00x); + + fw_iso_resources_free(&dg00x->tx_resources); + fw_iso_resources_free(&dg00x->rx_resources); + } }
void snd_dg00x_stream_update_duplex(struct snd_dg00x *dg00x) diff --git a/sound/firewire/digi00x/digi00x.h b/sound/firewire/digi00x/digi00x.h index 3fb1c49f6f9e..2d026b5b0079 100644 --- a/sound/firewire/digi00x/digi00x.h +++ b/sound/firewire/digi00x/digi00x.h @@ -143,7 +143,6 @@ int snd_dg00x_stream_init_duplex(struct snd_dg00x *dg00x); int snd_dg00x_stream_reserve_duplex(struct snd_dg00x *dg00x, unsigned int rate); int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x); void snd_dg00x_stream_stop_duplex(struct snd_dg00x *dg00x); -void snd_dg00x_stream_release_duplex(struct snd_dg00x *dg00x); void snd_dg00x_stream_update_duplex(struct snd_dg00x *dg00x); void snd_dg00x_stream_destroy_duplex(struct snd_dg00x *dg00x);
From callbacks for pcm and rawmidi interfaces, the functions to stop
and release duplex streams are called at the same time. This commit merges the two functions.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/dice/dice-midi.c | 1 - sound/firewire/dice/dice-pcm.c | 1 - sound/firewire/dice/dice-stream.c | 8 ++------ sound/firewire/dice/dice.h | 1 - 4 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/sound/firewire/dice/dice-midi.c b/sound/firewire/dice/dice-midi.c index 6172dad87c4e..436f0c3c0fbb 100644 --- a/sound/firewire/dice/dice-midi.c +++ b/sound/firewire/dice/dice-midi.c @@ -40,7 +40,6 @@ static int midi_close(struct snd_rawmidi_substream *substream)
--dice->substreams_counter; snd_dice_stream_stop_duplex(dice); - snd_dice_stream_release_duplex(dice);
mutex_unlock(&dice->mutex);
diff --git a/sound/firewire/dice/dice-pcm.c b/sound/firewire/dice/dice-pcm.c index 00b55dfc3b2c..8368073f7fa0 100644 --- a/sound/firewire/dice/dice-pcm.c +++ b/sound/firewire/dice/dice-pcm.c @@ -265,7 +265,6 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) --dice->substreams_counter;
snd_dice_stream_stop_duplex(dice); - snd_dice_stream_release_duplex(dice);
mutex_unlock(&dice->mutex);
diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c index e9e5c5fffb70..433714a117a0 100644 --- a/sound/firewire/dice/dice-stream.c +++ b/sound/firewire/dice/dice-stream.c @@ -336,12 +336,6 @@ int snd_dice_stream_reserve_duplex(struct snd_dice *dice, unsigned int rate) return err; }
-void snd_dice_stream_release_duplex(struct snd_dice *dice) -{ - if (dice->substreams_counter == 0) - release_resources(dice); -} - static int start_streams(struct snd_dice *dice, enum amdtp_stream_direction dir, unsigned int rate, struct reg_params *params) { @@ -494,6 +488,8 @@ void snd_dice_stream_stop_duplex(struct snd_dice *dice) if (dice->substreams_counter == 0) { if (get_register_params(dice, &tx_params, &rx_params) >= 0) finish_session(dice, &tx_params, &rx_params); + + release_resources(dice); } }
diff --git a/sound/firewire/dice/dice.h b/sound/firewire/dice/dice.h index f95073b85010..fd3f483283d5 100644 --- a/sound/firewire/dice/dice.h +++ b/sound/firewire/dice/dice.h @@ -210,7 +210,6 @@ void snd_dice_stream_stop_duplex(struct snd_dice *dice); int snd_dice_stream_init_duplex(struct snd_dice *dice); void snd_dice_stream_destroy_duplex(struct snd_dice *dice); int snd_dice_stream_reserve_duplex(struct snd_dice *dice, unsigned int rate); -void snd_dice_stream_release_duplex(struct snd_dice *dice); void snd_dice_stream_update_duplex(struct snd_dice *dice); int snd_dice_stream_detect_current_formats(struct snd_dice *dice);
When stopping packet streaming in reserve function for duplex streams, isochronous resources should be released.
Fixes: 7bc93821a70a ("ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection") Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/bebob/bebob_stream.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index 1070a675179d..63e78fc8711d 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -571,6 +571,9 @@ int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate) amdtp_stream_stop(&bebob->rx_stream);
break_both_connections(bebob); + + cmp_connection_release(&bebob->out_conn); + cmp_connection_release(&bebob->in_conn); }
if (bebob->substreams_counter == 0 || curr_rate != rate) {
When stopping packet streaming in reserve function for duplex streams, isochronous resources should be released.
Fixes: 7bc93821a70a ("ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection") Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/fireworks/fireworks_stream.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 81c1bb209a89..16cf635a6f57 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -217,6 +217,9 @@ int snd_efw_stream_reserve_duplex(struct snd_efw *efw, unsigned int rate) if (rate != curr_rate) { stop_stream(efw, &efw->tx_stream); stop_stream(efw, &efw->rx_stream); + + cmp_connection_release(&efw->out_conn); + cmp_connection_release(&efw->in_conn); }
if (efw->substreams_counter == 0 || rate != curr_rate) {
When stopping packet streaming in reserve function for duplex streams, isochronous resources should be released.
Fixes: 7bc93821a70a ("ALSA: firewire-lib: split allocation of isochronous resources from establishment of connection") Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/oxfw/oxfw-stream.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index a8bc798731ff..a7502810a3ad 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -283,10 +283,12 @@ int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw, if (formation.rate != rate || formation.pcm != pcm_channels) { amdtp_stream_stop(&oxfw->rx_stream); cmp_connection_break(&oxfw->in_conn); + cmp_connection_release(&oxfw->in_conn);
if (oxfw->has_output) { amdtp_stream_stop(&oxfw->tx_stream); cmp_connection_break(&oxfw->out_conn); + cmp_connection_release(&oxfw->out_conn); } }
On Tue, 18 Jun 2019 15:26:14 +0200, Takashi Sakamoto wrote:
Hi,
During a couple of weeks, I added code refactoring to all of drivers in ALSA firewire stack. But I can find some rooms for additional code refactoring and some bugs.
This patchset is for them.
Takashi Sakamoto (8): ALSA: firewire-tascam: unify stop and release method for duplex streams ALSA: fireface: unify stop and release method for duplex streams ALSA: firewire-motu: unify stop and release method for duplex streams ALSA: firewire-digi00x: unify stop and release method for duplex streams ALSA: dice: unify stop and release method for duplex streams ALSA: bebob: ensure to release isochronous resources in pcm.hw_params callback ALSA: fireworks: ensure to release isochronous resources in pcm.hw_params callback ALSA: oxfw: ensure to release isochronous resources in pcm.hw_params callback
Applied all patches now. Thanks.
Takashi
participants (2)
-
Takashi Iwai
-
Takashi Sakamoto