mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] firewire: unnecessary BM delay after generation rollover
@ 2008-03-24 19:56 Stefan Richter
  2008-03-24 20:11 ` Jarod Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Richter @ 2008-03-24 19:56 UTC (permalink / raw)
  To: linux1394-devel; +Cc: linux-kernel

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>
---
 drivers/firewire/fw-card.c        |    2 +-
 drivers/firewire/fw-topology.c    |    2 +-
 drivers/firewire/fw-transaction.h |    9 +++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

Index: linux/drivers/firewire/fw-card.c
===================================================================
--- linux.orig/drivers/firewire/fw-card.c
+++ linux/drivers/firewire/fw-card.c
@@ -240,7 +240,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: linux/drivers/firewire/fw-topology.c
===================================================================
--- linux.orig/drivers/firewire/fw-topology.c
+++ linux/drivers/firewire/fw-topology.c
@@ -518,7 +518,7 @@ fw_core_handle_bus_reset(struct fw_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: linux/drivers/firewire/fw-transaction.h
===================================================================
--- linux.orig/drivers/firewire/fw-transaction.h
+++ linux/drivers/firewire/fw-transaction.h
@@ -261,6 +261,15 @@ struct fw_card {
 };
 
 /*
+ * 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
  * indirect payload part that is pointer to by the 'payload' field.

-- 
Stefan Richter
-=====-==--- --== ==---
http://arcgraph.de/sr/


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] firewire: unnecessary BM delay after generation rollover
  2008-03-24 19:56 [PATCH] firewire: unnecessary BM delay after generation rollover Stefan Richter
@ 2008-03-24 20:11 ` Jarod Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jarod Wilson @ 2008-03-24 20:11 UTC (permalink / raw)
  To: linux1394-devel; +Cc: Stefan Richter, linux-kernel

On Monday 24 March 2008 03:56:40 pm Stefan Richter wrote:
> 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>

Much nicer than the crappy patch I had in mind (just adding another && 
0xff). :)

Signed-off-by: Jarod Wilson <jwilson@redhat.com>


-- 
Jarod Wilson
jwilson@redhat.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-03-24 20:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-24 19:56 [PATCH] firewire: unnecessary BM delay after generation rollover Stefan Richter
2008-03-24 20:11 ` Jarod Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome