aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-27 13:24:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-27 13:24:06 -0400
commit837b41b5de356aa67abb2cadb5eef3efc7776f91 (patch)
treeb63a9898c9a2b6563d8aec75c2abbec379898613
parent211c8d4942edf2f3337820dda101da6b13c8a19a (diff)
parentf05e21b39f7dddcebab03ff329fef5783fea58d4 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6: firewire: state userland requirements in Kconfig help firewire: avoid memleak after phy config transmit failure firewire: fw-ohci: TSB43AB22/A dualbuffer workaround firewire: queue the right number of data firewire: warn on unfinished transactions during card removal firewire: small fw_fill_request cleanup firewire: fully initialize fw_transaction before marking it pending firewire: fix race of bus reset with request transmission
-rw-r--r--drivers/firewire/Kconfig9
-rw-r--r--drivers/firewire/fw-card.c2
-rw-r--r--drivers/firewire/fw-cdev.c6
-rw-r--r--drivers/firewire/fw-ohci.c37
-rw-r--r--drivers/firewire/fw-topology.c2
-rw-r--r--drivers/firewire/fw-transaction.c79
-rw-r--r--include/linux/pci_ids.h1
7 files changed, 66 insertions, 70 deletions
diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig
index 76f26710fc16..fa6d6abefd4d 100644
--- a/drivers/firewire/Kconfig
+++ b/drivers/firewire/Kconfig
@@ -16,8 +16,13 @@ config FIREWIRE
16 enable the new stack. 16 enable the new stack.
17 17
18 To compile this driver as a module, say M here: the module will be 18 To compile this driver as a module, say M here: the module will be
19 called firewire-core. It functionally replaces ieee1394, raw1394, 19 called firewire-core.
20 and video1394. 20
21 This module functionally replaces ieee1394, raw1394, and video1394.
22 To access it from application programs, you generally need at least
23 libraw1394 version 2. IIDC/DCAM applications also need libdc1394
24 version 2. No libraries are required to access storage devices
25 through the firewire-sbp2 driver.
21 26
22config FIREWIRE_OHCI 27config FIREWIRE_OHCI
23 tristate "OHCI-1394 controllers" 28 tristate "OHCI-1394 controllers"
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index da873d795aad..bbd73a406e53 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -539,7 +539,7 @@ fw_core_remove_card(struct fw_card *card)
539 wait_for_completion(&card->done); 539 wait_for_completion(&card->done);
540 540
541 cancel_delayed_work_sync(&card->work); 541 cancel_delayed_work_sync(&card->work);
542 fw_flush_transactions(card); 542 WARN_ON(!list_empty(&card->transaction_list));
543 del_timer_sync(&card->flush_timer); 543 del_timer_sync(&card->flush_timer);
544} 544}
545EXPORT_SYMBOL(fw_core_remove_card); 545EXPORT_SYMBOL(fw_core_remove_card);
diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c
index c639915fc3cb..bc81d6fcd2fd 100644
--- a/drivers/firewire/fw-cdev.c
+++ b/drivers/firewire/fw-cdev.c
@@ -382,9 +382,9 @@ complete_transaction(struct fw_card *card, int rcode,
382 382
383 response->response.type = FW_CDEV_EVENT_RESPONSE; 383 response->response.type = FW_CDEV_EVENT_RESPONSE;
384 response->response.rcode = rcode; 384 response->response.rcode = rcode;
385 queue_event(client, &response->event, 385 queue_event(client, &response->event, &response->response,
386 &response->response, sizeof(response->response), 386 sizeof(response->response) + response->response.length,
387 response->response.data, response->response.length); 387 NULL, 0);
388} 388}
389 389
390static int ioctl_send_request(struct client *client, void *buffer) 390static int ioctl_send_request(struct client *client, void *buffer)
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index 566672e0bcff..251416f2148f 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -171,7 +171,6 @@ struct iso_context {
171struct fw_ohci { 171struct fw_ohci {
172 struct fw_card card; 172 struct fw_card card;
173 173
174 u32 version;
175 __iomem char *registers; 174 __iomem char *registers;
176 dma_addr_t self_id_bus; 175 dma_addr_t self_id_bus;
177 __le32 *self_id_cpu; 176 __le32 *self_id_cpu;
@@ -180,6 +179,8 @@ struct fw_ohci {
180 int generation; 179 int generation;
181 int request_generation; /* for timestamping incoming requests */ 180 int request_generation; /* for timestamping incoming requests */
182 u32 bus_seconds; 181 u32 bus_seconds;
182
183 bool use_dualbuffer;
183 bool old_uninorth; 184 bool old_uninorth;
184 bool bus_reset_packet_quirk; 185 bool bus_reset_packet_quirk;
185 186
@@ -1885,7 +1886,7 @@ ohci_allocate_iso_context(struct fw_card *card, int type, size_t header_size)
1885 } else { 1886 } else {
1886 mask = &ohci->ir_context_mask; 1887 mask = &ohci->ir_context_mask;
1887 list = ohci->ir_context_list; 1888 list = ohci->ir_context_list;
1888 if (ohci->version >= OHCI_VERSION_1_1) 1889 if (ohci->use_dualbuffer)
1889 callback = handle_ir_dualbuffer_packet; 1890 callback = handle_ir_dualbuffer_packet;
1890 else 1891 else
1891 callback = handle_ir_packet_per_buffer; 1892 callback = handle_ir_packet_per_buffer;
@@ -1949,7 +1950,7 @@ static int ohci_start_iso(struct fw_iso_context *base,
1949 } else { 1950 } else {
1950 index = ctx - ohci->ir_context_list; 1951 index = ctx - ohci->ir_context_list;
1951 control = IR_CONTEXT_ISOCH_HEADER; 1952 control = IR_CONTEXT_ISOCH_HEADER;
1952 if (ohci->version >= OHCI_VERSION_1_1) 1953 if (ohci->use_dualbuffer)
1953 control |= IR_CONTEXT_DUAL_BUFFER_MODE; 1954 control |= IR_CONTEXT_DUAL_BUFFER_MODE;
1954 match = (tags << 28) | (sync << 8) | ctx->base.channel; 1955 match = (tags << 28) | (sync << 8) | ctx->base.channel;
1955 if (cycle >= 0) { 1956 if (cycle >= 0) {
@@ -2279,7 +2280,7 @@ ohci_queue_iso(struct fw_iso_context *base,
2279 spin_lock_irqsave(&ctx->context.ohci->lock, flags); 2280 spin_lock_irqsave(&ctx->context.ohci->lock, flags);
2280 if (base->type == FW_ISO_CONTEXT_TRANSMIT) 2281 if (base->type == FW_ISO_CONTEXT_TRANSMIT)
2281 retval = ohci_queue_iso_transmit(base, packet, buffer, payload); 2282 retval = ohci_queue_iso_transmit(base, packet, buffer, payload);
2282 else if (ctx->context.ohci->version >= OHCI_VERSION_1_1) 2283 else if (ctx->context.ohci->use_dualbuffer)
2283 retval = ohci_queue_iso_receive_dualbuffer(base, packet, 2284 retval = ohci_queue_iso_receive_dualbuffer(base, packet,
2284 buffer, payload); 2285 buffer, payload);
2285 else 2286 else
@@ -2341,7 +2342,7 @@ static int __devinit
2341pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) 2342pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2342{ 2343{
2343 struct fw_ohci *ohci; 2344 struct fw_ohci *ohci;
2344 u32 bus_options, max_receive, link_speed; 2345 u32 bus_options, max_receive, link_speed, version;
2345 u64 guid; 2346 u64 guid;
2346 int err; 2347 int err;
2347 size_t size; 2348 size_t size;
@@ -2366,12 +2367,6 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2366 pci_write_config_dword(dev, OHCI1394_PCI_HCI_Control, 0); 2367 pci_write_config_dword(dev, OHCI1394_PCI_HCI_Control, 0);
2367 pci_set_drvdata(dev, ohci); 2368 pci_set_drvdata(dev, ohci);
2368 2369
2369#if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)
2370 ohci->old_uninorth = dev->vendor == PCI_VENDOR_ID_APPLE &&
2371 dev->device == PCI_DEVICE_ID_APPLE_UNI_N_FW;
2372#endif
2373 ohci->bus_reset_packet_quirk = dev->vendor == PCI_VENDOR_ID_TI;
2374
2375 spin_lock_init(&ohci->lock); 2370 spin_lock_init(&ohci->lock);
2376 2371
2377 tasklet_init(&ohci->bus_reset_tasklet, 2372 tasklet_init(&ohci->bus_reset_tasklet,
@@ -2390,6 +2385,23 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2390 goto fail_iomem; 2385 goto fail_iomem;
2391 } 2386 }
2392 2387
2388 version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
2389 ohci->use_dualbuffer = version >= OHCI_VERSION_1_1;
2390
2391/* x86-32 currently doesn't use highmem for dma_alloc_coherent */
2392#if !defined(CONFIG_X86_32)
2393 /* dual-buffer mode is broken with descriptor addresses above 2G */
2394 if (dev->vendor == PCI_VENDOR_ID_TI &&
2395 dev->device == PCI_DEVICE_ID_TI_TSB43AB22)
2396 ohci->use_dualbuffer = false;
2397#endif
2398
2399#if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32)
2400 ohci->old_uninorth = dev->vendor == PCI_VENDOR_ID_APPLE &&
2401 dev->device == PCI_DEVICE_ID_APPLE_UNI_N_FW;
2402#endif
2403 ohci->bus_reset_packet_quirk = dev->vendor == PCI_VENDOR_ID_TI;
2404
2393 ar_context_init(&ohci->ar_request_ctx, ohci, 2405 ar_context_init(&ohci->ar_request_ctx, ohci,
2394 OHCI1394_AsReqRcvContextControlSet); 2406 OHCI1394_AsReqRcvContextControlSet);
2395 2407
@@ -2441,9 +2453,8 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent)
2441 if (err < 0) 2453 if (err < 0)
2442 goto fail_self_id; 2454 goto fail_self_id;
2443 2455
2444 ohci->version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
2445 fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n", 2456 fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n",
2446 dev->dev.bus_id, ohci->version >> 16, ohci->version & 0xff); 2457 dev->dev.bus_id, version >> 16, version & 0xff);
2447 return 0; 2458 return 0;
2448 2459
2449 fail_self_id: 2460 fail_self_id:
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c
index 213b0ff8f3d6..c1b81077c4a8 100644
--- a/drivers/firewire/fw-topology.c
+++ b/drivers/firewire/fw-topology.c
@@ -510,8 +510,6 @@ fw_core_handle_bus_reset(struct fw_card *card,
510 struct fw_node *local_node; 510 struct fw_node *local_node;
511 unsigned long flags; 511 unsigned long flags;
512 512
513 fw_flush_transactions(card);
514
515 spin_lock_irqsave(&card->lock, flags); 513 spin_lock_irqsave(&card->lock, flags);
516 514
517 /* 515 /*
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 40db80752272..e5d1a0b64fcf 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -22,6 +22,7 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/kref.h> 23#include <linux/kref.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/mutex.h>
25#include <linux/init.h> 26#include <linux/init.h>
26#include <linux/interrupt.h> 27#include <linux/interrupt.h>
27#include <linux/pci.h> 28#include <linux/pci.h>
@@ -151,7 +152,7 @@ transmit_complete_callback(struct fw_packet *packet,
151 152
152static void 153static void
153fw_fill_request(struct fw_packet *packet, int tcode, int tlabel, 154fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
154 int node_id, int source_id, int generation, int speed, 155 int destination_id, int source_id, int generation, int speed,
155 unsigned long long offset, void *payload, size_t length) 156 unsigned long long offset, void *payload, size_t length)
156{ 157{
157 int ext_tcode; 158 int ext_tcode;
@@ -166,7 +167,7 @@ fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
166 HEADER_RETRY(RETRY_X) | 167 HEADER_RETRY(RETRY_X) |
167 HEADER_TLABEL(tlabel) | 168 HEADER_TLABEL(tlabel) |
168 HEADER_TCODE(tcode) | 169 HEADER_TCODE(tcode) |
169 HEADER_DESTINATION(node_id); 170 HEADER_DESTINATION(destination_id);
170 packet->header[1] = 171 packet->header[1] =
171 HEADER_OFFSET_HIGH(offset >> 32) | HEADER_SOURCE(source_id); 172 HEADER_OFFSET_HIGH(offset >> 32) | HEADER_SOURCE(source_id);
172 packet->header[2] = 173 packet->header[2] =
@@ -252,7 +253,7 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
252 fw_transaction_callback_t callback, void *callback_data) 253 fw_transaction_callback_t callback, void *callback_data)
253{ 254{
254 unsigned long flags; 255 unsigned long flags;
255 int tlabel, source; 256 int tlabel;
256 257
257 /* 258 /*
258 * Bump the flush timer up 100ms first of all so we 259 * Bump the flush timer up 100ms first of all so we
@@ -268,7 +269,6 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
268 269
269 spin_lock_irqsave(&card->lock, flags); 270 spin_lock_irqsave(&card->lock, flags);
270 271
271 source = card->node_id;
272 tlabel = card->current_tlabel; 272 tlabel = card->current_tlabel;
273 if (card->tlabel_mask & (1 << tlabel)) { 273 if (card->tlabel_mask & (1 << tlabel)) {
274 spin_unlock_irqrestore(&card->lock, flags); 274 spin_unlock_irqrestore(&card->lock, flags);
@@ -279,77 +279,58 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
279 card->current_tlabel = (card->current_tlabel + 1) & 0x1f; 279 card->current_tlabel = (card->current_tlabel + 1) & 0x1f;
280 card->tlabel_mask |= (1 << tlabel); 280 card->tlabel_mask |= (1 << tlabel);
281 281
282 list_add_tail(&t->link, &card->transaction_list);
283
284 spin_unlock_irqrestore(&card->lock, flags);
285
286 /* Initialize rest of transaction, fill out packet and send it. */
287 t->node_id = node_id; 282 t->node_id = node_id;
288 t->tlabel = tlabel; 283 t->tlabel = tlabel;
289 t->callback = callback; 284 t->callback = callback;
290 t->callback_data = callback_data; 285 t->callback_data = callback_data;
291 286
292 fw_fill_request(&t->packet, tcode, t->tlabel, 287 fw_fill_request(&t->packet, tcode, t->tlabel, node_id, card->node_id,
293 node_id, source, generation, 288 generation, speed, offset, payload, length);
294 speed, offset, payload, length);
295 t->packet.callback = transmit_complete_callback; 289 t->packet.callback = transmit_complete_callback;
296 290
291 list_add_tail(&t->link, &card->transaction_list);
292
293 spin_unlock_irqrestore(&card->lock, flags);
294
297 card->driver->send_request(card, &t->packet); 295 card->driver->send_request(card, &t->packet);
298} 296}
299EXPORT_SYMBOL(fw_send_request); 297EXPORT_SYMBOL(fw_send_request);
300 298
301struct fw_phy_packet { 299static DEFINE_MUTEX(phy_config_mutex);
302 struct fw_packet packet; 300static DECLARE_COMPLETION(phy_config_done);
303 struct completion done;
304 struct kref kref;
305};
306
307static void phy_packet_release(struct kref *kref)
308{
309 struct fw_phy_packet *p =
310 container_of(kref, struct fw_phy_packet, kref);
311 kfree(p);
312}
313 301
314static void transmit_phy_packet_callback(struct fw_packet *packet, 302static void transmit_phy_packet_callback(struct fw_packet *packet,
315 struct fw_card *card, int status) 303 struct fw_card *card, int status)
316{ 304{
317 struct fw_phy_packet *p = 305 complete(&phy_config_done);
318 container_of(packet, struct fw_phy_packet, packet);
319
320 complete(&p->done);
321 kref_put(&p->kref, phy_packet_release);
322} 306}
323 307
308static struct fw_packet phy_config_packet = {
309 .header_length = 8,
310 .payload_length = 0,
311 .speed = SCODE_100,
312 .callback = transmit_phy_packet_callback,
313};
314
324void fw_send_phy_config(struct fw_card *card, 315void fw_send_phy_config(struct fw_card *card,
325 int node_id, int generation, int gap_count) 316 int node_id, int generation, int gap_count)
326{ 317{
327 struct fw_phy_packet *p;
328 long timeout = DIV_ROUND_UP(HZ, 10); 318 long timeout = DIV_ROUND_UP(HZ, 10);
329 u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) | 319 u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) |
330 PHY_CONFIG_ROOT_ID(node_id) | 320 PHY_CONFIG_ROOT_ID(node_id) |
331 PHY_CONFIG_GAP_COUNT(gap_count); 321 PHY_CONFIG_GAP_COUNT(gap_count);
332 322
333 p = kmalloc(sizeof(*p), GFP_KERNEL); 323 mutex_lock(&phy_config_mutex);
334 if (p == NULL) 324
335 return; 325 phy_config_packet.header[0] = data;
326 phy_config_packet.header[1] = ~data;
327 phy_config_packet.generation = generation;
328 INIT_COMPLETION(phy_config_done);
329
330 card->driver->send_request(card, &phy_config_packet);
331 wait_for_completion_timeout(&phy_config_done, timeout);
336 332
337 p->packet.header[0] = data; 333 mutex_unlock(&phy_config_mutex);
338 p->packet.header[1] = ~data;
339 p->packet.header_length = 8;
340 p->packet.payload_length = 0;
341 p->packet.speed = SCODE_100;
342 p->packet.generation = generation;
343 p->packet.callback = transmit_phy_packet_callback;
344 init_completion(&p->done);
345 kref_set(&p->kref, 2);
346
347 card->driver->send_request(card, &p->packet);
348 timeout = wait_for_completion_timeout(&p->done, timeout);
349 kref_put(&p->kref, phy_packet_release);
350
351 /* will leak p if the callback is never executed */
352 WARN_ON(timeout == 0);
353} 334}
354 335
355void fw_flush_transactions(struct fw_card *card) 336void fw_flush_transactions(struct fw_card *card)
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index ffe479ba0779..35a78415accc 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -748,6 +748,7 @@
748#define PCI_VENDOR_ID_TI 0x104c 748#define PCI_VENDOR_ID_TI 0x104c
749#define PCI_DEVICE_ID_TI_TVP4020 0x3d07 749#define PCI_DEVICE_ID_TI_TVP4020 0x3d07
750#define PCI_DEVICE_ID_TI_4450 0x8011 750#define PCI_DEVICE_ID_TI_4450 0x8011
751#define PCI_DEVICE_ID_TI_TSB43AB22 0x8023
751#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031 752#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031
752#define PCI_DEVICE_ID_TI_XX21_XX11_FM 0x8033 753#define PCI_DEVICE_ID_TI_XX21_XX11_FM 0x8033
753#define PCI_DEVICE_ID_TI_XX21_XX11_SD 0x8034 754#define PCI_DEVICE_ID_TI_XX21_XX11_SD 0x8034