]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
firewire: unnecessary BM delay after generation rollover
authorStefan Richter <stefanr@s5r6.in-berlin.de>
Mon, 24 Mar 2008 19:56:40 +0000 (20:56 +0100)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Tue, 20 Jan 2009 18:29:51 +0000 (19:29 +0100)
Noticed by Jarod Wilson:  The bus manager work was unnecessarily delayed
each time the bus generation counter rolled over.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jarod Wilson <jwilson@redhat.com>
drivers/firewire/fw-card.c
drivers/firewire/fw-topology.c
drivers/firewire/fw-transaction.h

index 6bd91a15d5e6a8397f9aa0988c510cb97f11df4b..17a80cecdc14c3d6baec90ecc6c5ab02e536b2b3 100644 (file)
@@ -232,7 +232,7 @@ fw_card_bm_work(struct work_struct *work)
        root_id = root_node->node_id;
        grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10));
 
-       if (card->bm_generation + 1 == generation ||
+       if (is_next_generation(generation, card->bm_generation) ||
            (card->bm_generation != generation && grace)) {
                /*
                 * This first step is to figure out who is IRM and
index e7520e4bd6bcea739655b16a0b8c826d3068e172..8dd6703b55cd00702f64f84272d3d523d7112ec6 100644 (file)
@@ -523,7 +523,7 @@ fw_core_handle_bus_reset(struct fw_card *card,
         * previously processed one, we cannot reliably compare the
         * old and new topologies.
         */
-       if ((generation & 0xff) != ((card->generation + 1) & 0xff) &&
+       if (!is_next_generation(generation, card->generation) &&
            card->local_node != NULL) {
                fw_notify("skipped bus generations, destroying all nodes\n");
                fw_destroy_nodes(card);
index c9ab12a15f6eb2974fd65e9b98b3e41d3c72faa0..1d78e9cc5940a5a2c51be2c8724157bd25b5369f 100644 (file)
@@ -275,6 +275,15 @@ static inline void fw_card_put(struct fw_card *card)
 
 extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);
 
+/*
+ * Check whether new_generation is the immediate successor of old_generation.
+ * Take counter roll-over at 255 (as per to OHCI) into account.
+ */
+static inline bool is_next_generation(int new_generation, int old_generation)
+{
+       return (new_generation & 0xff) == ((old_generation + 1) & 0xff);
+}
+
 /*
  * The iso packet format allows for an immediate header/payload part
  * stored in 'header' immediately after the packet info plus an