aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-device.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2008-01-25 12:57:41 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2008-01-30 16:22:27 -0500
commitb5d2a5e04e6a26cb3f77af8cbc31e74c361d706c (patch)
treecfc3b2dc141f643bcf6ef065cca802340b335799 /drivers/firewire/fw-device.c
parentcf5a56ac8083dd04ffe8b9b2ec7895e9bcff44bc (diff)
firewire: enforce access order between generation and node ID, fix "giving up on config rom"
fw_device.node_id and fw_device.generation are accessed without mutexes. We have to ensure that all readers will get to see node_id updates before generation updates. Fixes an inability to recognize devices after "giving up on config rom", https://bugzilla.redhat.com/show_bug.cgi?id=429950 Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Reviewed by Nick Piggin <nickpiggin@yahoo.com.au>. Verified to fix 'giving up on config rom' issues on multiple system and drive combinations that were previously affected. Signed-off-by: Jarod Wilson <jwilson@redhat.com> Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Diffstat (limited to 'drivers/firewire/fw-device.c')
-rw-r--r--drivers/firewire/fw-device.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 56681b3b297b..872df2238609 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -27,6 +27,7 @@
27#include <linux/idr.h> 27#include <linux/idr.h>
28#include <linux/rwsem.h> 28#include <linux/rwsem.h>
29#include <asm/semaphore.h> 29#include <asm/semaphore.h>
30#include <asm/system.h>
30#include <linux/ctype.h> 31#include <linux/ctype.h>
31#include "fw-transaction.h" 32#include "fw-transaction.h"
32#include "fw-topology.h" 33#include "fw-topology.h"
@@ -182,9 +183,14 @@ static void fw_device_release(struct device *dev)
182 183
183int fw_device_enable_phys_dma(struct fw_device *device) 184int fw_device_enable_phys_dma(struct fw_device *device)
184{ 185{
186 int generation = device->generation;
187
188 /* device->node_id, accessed below, must not be older than generation */
189 smp_rmb();
190
185 return device->card->driver->enable_phys_dma(device->card, 191 return device->card->driver->enable_phys_dma(device->card,
186 device->node_id, 192 device->node_id,
187 device->generation); 193 generation);
188} 194}
189EXPORT_SYMBOL(fw_device_enable_phys_dma); 195EXPORT_SYMBOL(fw_device_enable_phys_dma);
190 196
@@ -389,12 +395,16 @@ static int read_rom(struct fw_device *device, int index, u32 * data)
389 struct read_quadlet_callback_data callback_data; 395 struct read_quadlet_callback_data callback_data;
390 struct fw_transaction t; 396 struct fw_transaction t;
391 u64 offset; 397 u64 offset;
398 int generation = device->generation;
399
400 /* device->node_id, accessed below, must not be older than generation */
401 smp_rmb();
392 402
393 init_completion(&callback_data.done); 403 init_completion(&callback_data.done);
394 404
395 offset = 0xfffff0000400ULL + index * 4; 405 offset = 0xfffff0000400ULL + index * 4;
396 fw_send_request(device->card, &t, TCODE_READ_QUADLET_REQUEST, 406 fw_send_request(device->card, &t, TCODE_READ_QUADLET_REQUEST,
397 device->node_id, device->generation, device->max_speed, 407 device->node_id, generation, device->max_speed,
398 offset, NULL, 4, complete_transaction, &callback_data); 408 offset, NULL, 4, complete_transaction, &callback_data);
399 409
400 wait_for_completion(&callback_data.done); 410 wait_for_completion(&callback_data.done);
@@ -801,6 +811,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
801 811
802 device = node->data; 812 device = node->data;
803 device->node_id = node->node_id; 813 device->node_id = node->node_id;
814 smp_wmb(); /* update node_id before generation */
804 device->generation = card->generation; 815 device->generation = card->generation;
805 if (atomic_read(&device->state) == FW_DEVICE_RUNNING) { 816 if (atomic_read(&device->state) == FW_DEVICE_RUNNING) {
806 PREPARE_DELAYED_WORK(&device->work, fw_device_update); 817 PREPARE_DELAYED_WORK(&device->work, fw_device_update);