ALSA: firewire/bebob: Add a workaround for M-Audio special Firewire series
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Fri, 25 Apr 2014 13:45:30 +0000 (22:45 +0900)
committerTakashi Iwai <tiwai@suse.de>
Mon, 26 May 2014 12:33:10 +0000 (14:33 +0200)
In post commit, a quirk of this firmware about transactions is reported.
This commit apply a workaround for this quirk.

They often fail transactions due to gap_count mismatch. This state is changed
by generating bus reset.

The fw_schedule_bus_reset() is an exported symbol in firewire-core. But there
are no header for public. This commit moves its prototype from
drivers/firewire/core.h to include/linux/firewire.h.

This mismatch still affects bus management before generating this bus reset.
It still takes a time to call driver's probe() because transactions are still
often failed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
drivers/firewire/core.h
include/linux/firewire.h
sound/firewire/bebob/bebob.c
sound/firewire/bebob/bebob.h

index c98764aeeec6112928fcde7ac0907949aab001ea..870044e82316dadde3ff2edc4db7bf25318718db 100644 (file)
@@ -118,7 +118,6 @@ int fw_card_add(struct fw_card *card,
                u32 max_receive, u32 link_speed, u64 guid);
 void fw_core_remove_card(struct fw_card *card);
 int fw_compute_block_crc(__be32 *block);
-void fw_schedule_bus_reset(struct fw_card *card, bool delayed, bool short_reset);
 void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);
 
 /* -cdev */
index c3683bdf28fe4e677959f33d524bd724a9a1d59d..d4b7683c722d6311f05a2e60d1849e91f4e34dca 100644 (file)
@@ -367,6 +367,9 @@ static inline int fw_stream_packet_destination_id(int tag, int channel, int sy)
        return tag << 14 | channel << 8 | sy;
 }
 
+void fw_schedule_bus_reset(struct fw_card *card, bool delayed,
+                          bool short_reset);
+
 struct fw_descriptor {
        struct list_head link;
        size_t length;
index e1dd4219ea6c69af579480cadd85f233b41d45c3..31b96b7264cf0d9d530f9d2cb8333a6e7b0d5356 100644 (file)
@@ -247,10 +247,26 @@ bebob_probe(struct fw_unit *unit,
        if (err < 0)
                goto error;
 
-       err = snd_card_register(card);
-       if (err < 0) {
-               snd_bebob_stream_destroy_duplex(bebob);
-               goto error;
+       if (!bebob->maudio_special_quirk) {
+               err = snd_card_register(card);
+               if (err < 0) {
+                       snd_bebob_stream_destroy_duplex(bebob);
+                       goto error;
+               }
+       } else {
+               /*
+                * This is a workaround. This bus reset seems to have an effect
+                * to make devices correctly handling transactions. Without
+                * this, the devices have gap_count mismatch. This causes much
+                * failure of transaction.
+                *
+                * Just after registration, user-land application receive
+                * signals from dbus and starts I/Os. To avoid I/Os till the
+                * future bus reset, registration is done in next update().
+                */
+               bebob->deferred_registration = true;
+               fw_schedule_bus_reset(fw_parent_device(bebob->unit)->card,
+                                     false, true);
        }
 
        dev_set_drvdata(&unit->device, bebob);
@@ -273,6 +289,14 @@ bebob_update(struct fw_unit *unit)
 
        fcp_bus_reset(bebob->unit);
        snd_bebob_stream_update_duplex(bebob);
+
+       if (bebob->deferred_registration) {
+               if (snd_card_register(bebob->card) < 0) {
+                       snd_bebob_stream_destroy_duplex(bebob);
+                       snd_card_free(bebob->card);
+               }
+               bebob->deferred_registration = false;
+       }
 }
 
 static void bebob_remove(struct fw_unit *unit)
index 4a54e746c5c66c1201a57564ec44cce3760e7b83..91b26b0c649a259f720ea97b031c62cfe47fd990 100644 (file)
@@ -109,6 +109,7 @@ struct snd_bebob {
 
        /* for M-Audio special devices */
        void *maudio_special_quirk;
+       bool deferred_registration;
 };
 
 static inline int