aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2010-06-21 17:24:35 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2010-07-08 10:52:02 -0400
commit250b2b6dd421c9f8844a867d2ac06e0661e0ad93 (patch)
treeb86719d2c442676a52c6307471c9e278b1bd21f5
parentae948011071c12ff6a328348859c717ea885ed40 (diff)
firewire: cdev: fix fw_cdev_event_bus_reset.bm_node_id
Fix an obscure ABI feature that is a bit of a hassle to implement. However, somebody put it into the ABI, so let's fill in a sensible value there. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r--drivers/firewire/core-card.c12
-rw-r--r--drivers/firewire/core-cdev.c2
-rw-r--r--drivers/firewire/core-topology.c1
-rw-r--r--include/linux/firewire-cdev.h5
-rw-r--r--include/linux/firewire.h1
5 files changed, 17 insertions, 4 deletions
diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
index 11fc81500f82..6c316cfe70c4 100644
--- a/drivers/firewire/core-card.c
+++ b/drivers/firewire/core-card.c
@@ -239,7 +239,7 @@ static void fw_card_bm_work(struct work_struct *work)
239 struct fw_card *card = container_of(work, struct fw_card, work.work); 239 struct fw_card *card = container_of(work, struct fw_card, work.work);
240 struct fw_device *root_device; 240 struct fw_device *root_device;
241 struct fw_node *root_node; 241 struct fw_node *root_node;
242 int root_id, new_root_id, irm_id, local_id; 242 int root_id, new_root_id, irm_id, bm_id, local_id;
243 int gap_count, generation, grace, rcode; 243 int gap_count, generation, grace, rcode;
244 bool do_reset = false; 244 bool do_reset = false;
245 bool root_device_is_running; 245 bool root_device_is_running;
@@ -301,9 +301,15 @@ static void fw_card_bm_work(struct work_struct *work)
301 /* Another bus reset, BM work has been rescheduled. */ 301 /* Another bus reset, BM work has been rescheduled. */
302 goto out; 302 goto out;
303 303
304 if (rcode == RCODE_COMPLETE && 304 bm_id = be32_to_cpu(card->bm_transaction_data[0]);
305 card->bm_transaction_data[0] != cpu_to_be32(0x3f)) {
306 305
306 spin_lock_irq(&card->lock);
307 if (rcode == RCODE_COMPLETE && generation == card->generation)
308 card->bm_node_id =
309 bm_id == 0x3f ? local_id : 0xffc0 | bm_id;
310 spin_unlock_irq(&card->lock);
311
312 if (rcode == RCODE_COMPLETE && bm_id != 0x3f) {
307 /* Somebody else is BM. Only act as IRM. */ 313 /* Somebody else is BM. Only act as IRM. */
308 if (local_id == irm_id) 314 if (local_id == irm_id)
309 allocate_broadcast_channel(card, generation); 315 allocate_broadcast_channel(card, generation);
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 9b8df2039155..d8ac0ce2d6bf 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -318,7 +318,7 @@ static void fill_bus_reset_event(struct fw_cdev_event_bus_reset *event,
318 event->generation = client->device->generation; 318 event->generation = client->device->generation;
319 event->node_id = client->device->node_id; 319 event->node_id = client->device->node_id;
320 event->local_node_id = card->local_node->node_id; 320 event->local_node_id = card->local_node->node_id;
321 event->bm_node_id = 0; /* FIXME: We don't track the BM. */ 321 event->bm_node_id = card->bm_node_id;
322 event->irm_node_id = card->irm_node->node_id; 322 event->irm_node_id = card->irm_node->node_id;
323 event->root_node_id = card->root_node->node_id; 323 event->root_node_id = card->root_node->node_id;
324 324
diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topology.c
index 56e908ba43f1..88d5133ae702 100644
--- a/drivers/firewire/core-topology.c
+++ b/drivers/firewire/core-topology.c
@@ -552,6 +552,7 @@ void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation,
552 smp_wmb(); 552 smp_wmb();
553 card->generation = generation; 553 card->generation = generation;
554 card->reset_jiffies = jiffies; 554 card->reset_jiffies = jiffies;
555 card->bm_node_id = 0xffff;
555 card->bm_abdicate = bm_abdicate; 556 card->bm_abdicate = bm_abdicate;
556 fw_schedule_bm_work(card, 0); 557 fw_schedule_bm_work(card, 0);
557 558
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h
index 8b9b27373219..d31022b05bd9 100644
--- a/include/linux/firewire-cdev.h
+++ b/include/linux/firewire-cdev.h
@@ -66,6 +66,10 @@ struct fw_cdev_event_common {
66 * This event is sent when the bus the device belongs to goes through a bus 66 * This event is sent when the bus the device belongs to goes through a bus
67 * reset. It provides information about the new bus configuration, such as 67 * reset. It provides information about the new bus configuration, such as
68 * new node ID for this device, new root ID, and others. 68 * new node ID for this device, new root ID, and others.
69 *
70 * If @bm_node_id is 0xffff right after bus reset it can be reread by an
71 * %FW_CDEV_IOC_GET_INFO ioctl after bus manager selection was finished.
72 * Kernels with ABI version < 4 do not set @bm_node_id.
69 */ 73 */
70struct fw_cdev_event_bus_reset { 74struct fw_cdev_event_bus_reset {
71 __u64 closure; 75 __u64 closure;
@@ -348,6 +352,7 @@ union fw_cdev_event {
348 * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable 352 * 3 (2.6.34) - made &fw_cdev_get_cycle_timer reliable
349 * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2 353 * - added %FW_CDEV_IOC_GET_CYCLE_TIMER2
350 * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2 354 * 4 (2.6.36) - added %FW_CDEV_EVENT_REQUEST2
355 * - implemented &fw_cdev_event_bus_reset.bm_node_id
351 */ 356 */
352#define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */ 357#define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */
353 358
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index e44b502c8341..db30a752a87a 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -119,6 +119,7 @@ struct fw_card {
119 int bm_retries; 119 int bm_retries;
120 int bm_generation; 120 int bm_generation;
121 __be32 bm_transaction_data[2]; 121 __be32 bm_transaction_data[2];
122 int bm_node_id;
122 bool bm_abdicate; 123 bool bm_abdicate;
123 124
124 bool priority_budget_implemented; /* controller feature */ 125 bool priority_budget_implemented; /* controller feature */