diff options
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/fw-card.c | 13 | ||||
-rw-r--r-- | drivers/firewire/fw-device.c | 123 | ||||
-rw-r--r-- | drivers/firewire/fw-device.h | 1 | ||||
-rw-r--r-- | drivers/firewire/fw-ohci.c | 6 | ||||
-rw-r--r-- | drivers/firewire/fw-sbp2.c | 89 | ||||
-rw-r--r-- | drivers/firewire/fw-topology.c | 12 | ||||
-rw-r--r-- | drivers/firewire/fw-transaction.h | 9 |
7 files changed, 186 insertions, 67 deletions
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c index 6bd91a15d5e6..a5dd7a665aa8 100644 --- a/drivers/firewire/fw-card.c +++ b/drivers/firewire/fw-card.c | |||
@@ -232,7 +232,7 @@ fw_card_bm_work(struct work_struct *work) | |||
232 | root_id = root_node->node_id; | 232 | root_id = root_node->node_id; |
233 | grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); | 233 | grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); |
234 | 234 | ||
235 | if (card->bm_generation + 1 == generation || | 235 | if (is_next_generation(generation, card->bm_generation) || |
236 | (card->bm_generation != generation && grace)) { | 236 | (card->bm_generation != generation && grace)) { |
237 | /* | 237 | /* |
238 | * This first step is to figure out who is IRM and | 238 | * This first step is to figure out who is IRM and |
@@ -412,6 +412,7 @@ fw_card_add(struct fw_card *card, | |||
412 | { | 412 | { |
413 | u32 *config_rom; | 413 | u32 *config_rom; |
414 | size_t length; | 414 | size_t length; |
415 | int err; | ||
415 | 416 | ||
416 | card->max_receive = max_receive; | 417 | card->max_receive = max_receive; |
417 | card->link_speed = link_speed; | 418 | card->link_speed = link_speed; |
@@ -422,7 +423,13 @@ fw_card_add(struct fw_card *card, | |||
422 | list_add_tail(&card->link, &card_list); | 423 | list_add_tail(&card->link, &card_list); |
423 | mutex_unlock(&card_mutex); | 424 | mutex_unlock(&card_mutex); |
424 | 425 | ||
425 | return card->driver->enable(card, config_rom, length); | 426 | err = card->driver->enable(card, config_rom, length); |
427 | if (err < 0) { | ||
428 | mutex_lock(&card_mutex); | ||
429 | list_del(&card->link); | ||
430 | mutex_unlock(&card_mutex); | ||
431 | } | ||
432 | return err; | ||
426 | } | 433 | } |
427 | EXPORT_SYMBOL(fw_card_add); | 434 | EXPORT_SYMBOL(fw_card_add); |
428 | 435 | ||
@@ -512,7 +519,7 @@ fw_core_remove_card(struct fw_card *card) | |||
512 | fw_core_initiate_bus_reset(card, 1); | 519 | fw_core_initiate_bus_reset(card, 1); |
513 | 520 | ||
514 | mutex_lock(&card_mutex); | 521 | mutex_lock(&card_mutex); |
515 | list_del(&card->link); | 522 | list_del_init(&card->link); |
516 | mutex_unlock(&card_mutex); | 523 | mutex_unlock(&card_mutex); |
517 | 524 | ||
518 | /* Set up the dummy driver. */ | 525 | /* Set up the dummy driver. */ |
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c index 2af5a8d1e012..bf53acb45652 100644 --- a/drivers/firewire/fw-device.c +++ b/drivers/firewire/fw-device.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/device.h> | 25 | #include <linux/device.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/idr.h> | 27 | #include <linux/idr.h> |
28 | #include <linux/jiffies.h> | ||
28 | #include <linux/string.h> | 29 | #include <linux/string.h> |
29 | #include <linux/rwsem.h> | 30 | #include <linux/rwsem.h> |
30 | #include <linux/semaphore.h> | 31 | #include <linux/semaphore.h> |
@@ -634,12 +635,39 @@ struct fw_device *fw_device_get_by_devt(dev_t devt) | |||
634 | return device; | 635 | return device; |
635 | } | 636 | } |
636 | 637 | ||
638 | /* | ||
639 | * These defines control the retry behavior for reading the config | ||
640 | * rom. It shouldn't be necessary to tweak these; if the device | ||
641 | * doesn't respond to a config rom read within 10 seconds, it's not | ||
642 | * going to respond at all. As for the initial delay, a lot of | ||
643 | * devices will be able to respond within half a second after bus | ||
644 | * reset. On the other hand, it's not really worth being more | ||
645 | * aggressive than that, since it scales pretty well; if 10 devices | ||
646 | * are plugged in, they're all getting read within one second. | ||
647 | */ | ||
648 | |||
649 | #define MAX_RETRIES 10 | ||
650 | #define RETRY_DELAY (3 * HZ) | ||
651 | #define INITIAL_DELAY (HZ / 2) | ||
652 | #define SHUTDOWN_DELAY (2 * HZ) | ||
653 | |||
637 | static void fw_device_shutdown(struct work_struct *work) | 654 | static void fw_device_shutdown(struct work_struct *work) |
638 | { | 655 | { |
639 | struct fw_device *device = | 656 | struct fw_device *device = |
640 | container_of(work, struct fw_device, work.work); | 657 | container_of(work, struct fw_device, work.work); |
641 | int minor = MINOR(device->device.devt); | 658 | int minor = MINOR(device->device.devt); |
642 | 659 | ||
660 | if (time_is_after_jiffies(device->card->reset_jiffies + SHUTDOWN_DELAY) | ||
661 | && !list_empty(&device->card->link)) { | ||
662 | schedule_delayed_work(&device->work, SHUTDOWN_DELAY); | ||
663 | return; | ||
664 | } | ||
665 | |||
666 | if (atomic_cmpxchg(&device->state, | ||
667 | FW_DEVICE_GONE, | ||
668 | FW_DEVICE_SHUTDOWN) != FW_DEVICE_GONE) | ||
669 | return; | ||
670 | |||
643 | fw_device_cdev_remove(device); | 671 | fw_device_cdev_remove(device); |
644 | device_for_each_child(&device->device, NULL, shutdown_unit); | 672 | device_for_each_child(&device->device, NULL, shutdown_unit); |
645 | device_unregister(&device->device); | 673 | device_unregister(&device->device); |
@@ -647,6 +675,7 @@ static void fw_device_shutdown(struct work_struct *work) | |||
647 | down_write(&fw_device_rwsem); | 675 | down_write(&fw_device_rwsem); |
648 | idr_remove(&fw_device_idr, minor); | 676 | idr_remove(&fw_device_idr, minor); |
649 | up_write(&fw_device_rwsem); | 677 | up_write(&fw_device_rwsem); |
678 | |||
650 | fw_device_put(device); | 679 | fw_device_put(device); |
651 | } | 680 | } |
652 | 681 | ||
@@ -654,25 +683,63 @@ static struct device_type fw_device_type = { | |||
654 | .release = fw_device_release, | 683 | .release = fw_device_release, |
655 | }; | 684 | }; |
656 | 685 | ||
686 | static void fw_device_update(struct work_struct *work); | ||
687 | |||
657 | /* | 688 | /* |
658 | * These defines control the retry behavior for reading the config | 689 | * If a device was pending for deletion because its node went away but its |
659 | * rom. It shouldn't be necessary to tweak these; if the device | 690 | * bus info block and root directory header matches that of a newly discovered |
660 | * doesn't respond to a config rom read within 10 seconds, it's not | 691 | * device, revive the existing fw_device. |
661 | * going to respond at all. As for the initial delay, a lot of | 692 | * The newly allocated fw_device becomes obsolete instead. |
662 | * devices will be able to respond within half a second after bus | ||
663 | * reset. On the other hand, it's not really worth being more | ||
664 | * aggressive than that, since it scales pretty well; if 10 devices | ||
665 | * are plugged in, they're all getting read within one second. | ||
666 | */ | 693 | */ |
694 | static int lookup_existing_device(struct device *dev, void *data) | ||
695 | { | ||
696 | struct fw_device *old = fw_device(dev); | ||
697 | struct fw_device *new = data; | ||
698 | struct fw_card *card = new->card; | ||
699 | int match = 0; | ||
700 | |||
701 | down_read(&fw_device_rwsem); /* serialize config_rom access */ | ||
702 | spin_lock_irq(&card->lock); /* serialize node access */ | ||
703 | |||
704 | if (memcmp(old->config_rom, new->config_rom, 6 * 4) == 0 && | ||
705 | atomic_cmpxchg(&old->state, | ||
706 | FW_DEVICE_GONE, | ||
707 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) { | ||
708 | struct fw_node *current_node = new->node; | ||
709 | struct fw_node *obsolete_node = old->node; | ||
710 | |||
711 | new->node = obsolete_node; | ||
712 | new->node->data = new; | ||
713 | old->node = current_node; | ||
714 | old->node->data = old; | ||
715 | |||
716 | old->max_speed = new->max_speed; | ||
717 | old->node_id = current_node->node_id; | ||
718 | smp_wmb(); /* update node_id before generation */ | ||
719 | old->generation = card->generation; | ||
720 | old->config_rom_retries = 0; | ||
721 | fw_notify("rediscovered device %s\n", dev_name(dev)); | ||
667 | 722 | ||
668 | #define MAX_RETRIES 10 | 723 | PREPARE_DELAYED_WORK(&old->work, fw_device_update); |
669 | #define RETRY_DELAY (3 * HZ) | 724 | schedule_delayed_work(&old->work, 0); |
670 | #define INITIAL_DELAY (HZ / 2) | 725 | |
726 | if (current_node == card->root_node) | ||
727 | fw_schedule_bm_work(card, 0); | ||
728 | |||
729 | match = 1; | ||
730 | } | ||
731 | |||
732 | spin_unlock_irq(&card->lock); | ||
733 | up_read(&fw_device_rwsem); | ||
734 | |||
735 | return match; | ||
736 | } | ||
671 | 737 | ||
672 | static void fw_device_init(struct work_struct *work) | 738 | static void fw_device_init(struct work_struct *work) |
673 | { | 739 | { |
674 | struct fw_device *device = | 740 | struct fw_device *device = |
675 | container_of(work, struct fw_device, work.work); | 741 | container_of(work, struct fw_device, work.work); |
742 | struct device *revived_dev; | ||
676 | int minor, err; | 743 | int minor, err; |
677 | 744 | ||
678 | /* | 745 | /* |
@@ -696,6 +763,15 @@ static void fw_device_init(struct work_struct *work) | |||
696 | return; | 763 | return; |
697 | } | 764 | } |
698 | 765 | ||
766 | revived_dev = device_find_child(device->card->device, | ||
767 | device, lookup_existing_device); | ||
768 | if (revived_dev) { | ||
769 | put_device(revived_dev); | ||
770 | fw_device_release(&device->device); | ||
771 | |||
772 | return; | ||
773 | } | ||
774 | |||
699 | device_initialize(&device->device); | 775 | device_initialize(&device->device); |
700 | 776 | ||
701 | fw_device_get(device); | 777 | fw_device_get(device); |
@@ -734,9 +810,10 @@ static void fw_device_init(struct work_struct *work) | |||
734 | * fw_node_event(). | 810 | * fw_node_event(). |
735 | */ | 811 | */ |
736 | if (atomic_cmpxchg(&device->state, | 812 | if (atomic_cmpxchg(&device->state, |
737 | FW_DEVICE_INITIALIZING, | 813 | FW_DEVICE_INITIALIZING, |
738 | FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) { | 814 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) { |
739 | fw_device_shutdown(work); | 815 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); |
816 | schedule_delayed_work(&device->work, SHUTDOWN_DELAY); | ||
740 | } else { | 817 | } else { |
741 | if (device->config_rom_retries) | 818 | if (device->config_rom_retries) |
742 | fw_notify("created device %s: GUID %08x%08x, S%d00, " | 819 | fw_notify("created device %s: GUID %08x%08x, S%d00, " |
@@ -847,8 +924,8 @@ static void fw_device_refresh(struct work_struct *work) | |||
847 | 924 | ||
848 | case REREAD_BIB_UNCHANGED: | 925 | case REREAD_BIB_UNCHANGED: |
849 | if (atomic_cmpxchg(&device->state, | 926 | if (atomic_cmpxchg(&device->state, |
850 | FW_DEVICE_INITIALIZING, | 927 | FW_DEVICE_INITIALIZING, |
851 | FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) | 928 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) |
852 | goto gone; | 929 | goto gone; |
853 | 930 | ||
854 | fw_device_update(work); | 931 | fw_device_update(work); |
@@ -879,8 +956,8 @@ static void fw_device_refresh(struct work_struct *work) | |||
879 | create_units(device); | 956 | create_units(device); |
880 | 957 | ||
881 | if (atomic_cmpxchg(&device->state, | 958 | if (atomic_cmpxchg(&device->state, |
882 | FW_DEVICE_INITIALIZING, | 959 | FW_DEVICE_INITIALIZING, |
883 | FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) | 960 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) |
884 | goto gone; | 961 | goto gone; |
885 | 962 | ||
886 | fw_notify("refreshed device %s\n", dev_name(&device->device)); | 963 | fw_notify("refreshed device %s\n", dev_name(&device->device)); |
@@ -890,8 +967,9 @@ static void fw_device_refresh(struct work_struct *work) | |||
890 | give_up: | 967 | give_up: |
891 | fw_notify("giving up on refresh of device %s\n", dev_name(&device->device)); | 968 | fw_notify("giving up on refresh of device %s\n", dev_name(&device->device)); |
892 | gone: | 969 | gone: |
893 | atomic_set(&device->state, FW_DEVICE_SHUTDOWN); | 970 | atomic_set(&device->state, FW_DEVICE_GONE); |
894 | fw_device_shutdown(work); | 971 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); |
972 | schedule_delayed_work(&device->work, SHUTDOWN_DELAY); | ||
895 | out: | 973 | out: |
896 | if (node_id == card->root_node->node_id) | 974 | if (node_id == card->root_node->node_id) |
897 | fw_schedule_bm_work(card, 0); | 975 | fw_schedule_bm_work(card, 0); |
@@ -995,9 +1073,10 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event) | |||
995 | */ | 1073 | */ |
996 | device = node->data; | 1074 | device = node->data; |
997 | if (atomic_xchg(&device->state, | 1075 | if (atomic_xchg(&device->state, |
998 | FW_DEVICE_SHUTDOWN) == FW_DEVICE_RUNNING) { | 1076 | FW_DEVICE_GONE) == FW_DEVICE_RUNNING) { |
999 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); | 1077 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); |
1000 | schedule_delayed_work(&device->work, 0); | 1078 | schedule_delayed_work(&device->work, |
1079 | list_empty(&card->link) ? 0 : SHUTDOWN_DELAY); | ||
1001 | } | 1080 | } |
1002 | break; | 1081 | break; |
1003 | } | 1082 | } |
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h index df51732608d9..8ef6ec2ca21c 100644 --- a/drivers/firewire/fw-device.h +++ b/drivers/firewire/fw-device.h | |||
@@ -28,6 +28,7 @@ | |||
28 | enum fw_device_state { | 28 | enum fw_device_state { |
29 | FW_DEVICE_INITIALIZING, | 29 | FW_DEVICE_INITIALIZING, |
30 | FW_DEVICE_RUNNING, | 30 | FW_DEVICE_RUNNING, |
31 | FW_DEVICE_GONE, | ||
31 | FW_DEVICE_SHUTDOWN, | 32 | FW_DEVICE_SHUTDOWN, |
32 | }; | 33 | }; |
33 | 34 | ||
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c index ab9c01e462ef..6d19828a93a5 100644 --- a/drivers/firewire/fw-ohci.c +++ b/drivers/firewire/fw-ohci.c | |||
@@ -226,7 +226,7 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card) | |||
226 | #define CONTEXT_DEAD 0x0800 | 226 | #define CONTEXT_DEAD 0x0800 |
227 | #define CONTEXT_ACTIVE 0x0400 | 227 | #define CONTEXT_ACTIVE 0x0400 |
228 | 228 | ||
229 | #define OHCI1394_MAX_AT_REQ_RETRIES 0x2 | 229 | #define OHCI1394_MAX_AT_REQ_RETRIES 0xf |
230 | #define OHCI1394_MAX_AT_RESP_RETRIES 0x2 | 230 | #define OHCI1394_MAX_AT_RESP_RETRIES 0x2 |
231 | #define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 | 231 | #define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8 |
232 | 232 | ||
@@ -896,11 +896,11 @@ static void context_stop(struct context *ctx) | |||
896 | for (i = 0; i < 10; i++) { | 896 | for (i = 0; i < 10; i++) { |
897 | reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs)); | 897 | reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs)); |
898 | if ((reg & CONTEXT_ACTIVE) == 0) | 898 | if ((reg & CONTEXT_ACTIVE) == 0) |
899 | break; | 899 | return; |
900 | 900 | ||
901 | fw_notify("context_stop: still active (0x%08x)\n", reg); | ||
902 | mdelay(1); | 901 | mdelay(1); |
903 | } | 902 | } |
903 | fw_error("Error: DMA context still active (0x%08x)\n", reg); | ||
904 | } | 904 | } |
905 | 905 | ||
906 | struct driver_data { | 906 | struct driver_data { |
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index e88d5067448c..c71c4419d9e8 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c | |||
@@ -168,6 +168,7 @@ struct sbp2_target { | |||
168 | int address_high; | 168 | int address_high; |
169 | unsigned int workarounds; | 169 | unsigned int workarounds; |
170 | unsigned int mgt_orb_timeout; | 170 | unsigned int mgt_orb_timeout; |
171 | unsigned int max_payload; | ||
171 | 172 | ||
172 | int dont_block; /* counter for each logical unit */ | 173 | int dont_block; /* counter for each logical unit */ |
173 | int blocked; /* ditto */ | 174 | int blocked; /* ditto */ |
@@ -310,14 +311,16 @@ struct sbp2_command_orb { | |||
310 | dma_addr_t page_table_bus; | 311 | dma_addr_t page_table_bus; |
311 | }; | 312 | }; |
312 | 313 | ||
314 | #define SBP2_ROM_VALUE_WILDCARD ~0 /* match all */ | ||
315 | #define SBP2_ROM_VALUE_MISSING 0xff000000 /* not present in the unit dir. */ | ||
316 | |||
313 | /* | 317 | /* |
314 | * List of devices with known bugs. | 318 | * List of devices with known bugs. |
315 | * | 319 | * |
316 | * The firmware_revision field, masked with 0xffff00, is the best | 320 | * The firmware_revision field, masked with 0xffff00, is the best |
317 | * indicator for the type of bridge chip of a device. It yields a few | 321 | * indicator for the type of bridge chip of a device. It yields a few |
318 | * false positives but this did not break correctly behaving devices | 322 | * false positives but this did not break correctly behaving devices |
319 | * so far. We use ~0 as a wildcard, since the 24 bit values we get | 323 | * so far. |
320 | * from the config rom can never match that. | ||
321 | */ | 324 | */ |
322 | static const struct { | 325 | static const struct { |
323 | u32 firmware_revision; | 326 | u32 firmware_revision; |
@@ -339,33 +342,35 @@ static const struct { | |||
339 | }, | 342 | }, |
340 | /* Initio bridges, actually only needed for some older ones */ { | 343 | /* Initio bridges, actually only needed for some older ones */ { |
341 | .firmware_revision = 0x000200, | 344 | .firmware_revision = 0x000200, |
342 | .model = ~0, | 345 | .model = SBP2_ROM_VALUE_WILDCARD, |
343 | .workarounds = SBP2_WORKAROUND_INQUIRY_36, | 346 | .workarounds = SBP2_WORKAROUND_INQUIRY_36, |
344 | }, | 347 | }, |
345 | /* PL-3507 bridge with Prolific firmware */ { | 348 | /* PL-3507 bridge with Prolific firmware */ { |
346 | .firmware_revision = 0x012800, | 349 | .firmware_revision = 0x012800, |
347 | .model = ~0, | 350 | .model = SBP2_ROM_VALUE_WILDCARD, |
348 | .workarounds = SBP2_WORKAROUND_POWER_CONDITION, | 351 | .workarounds = SBP2_WORKAROUND_POWER_CONDITION, |
349 | }, | 352 | }, |
350 | /* Symbios bridge */ { | 353 | /* Symbios bridge */ { |
351 | .firmware_revision = 0xa0b800, | 354 | .firmware_revision = 0xa0b800, |
352 | .model = ~0, | 355 | .model = SBP2_ROM_VALUE_WILDCARD, |
353 | .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, | 356 | .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, |
354 | }, | 357 | }, |
355 | /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { | 358 | /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ { |
356 | .firmware_revision = 0x002600, | 359 | .firmware_revision = 0x002600, |
357 | .model = ~0, | 360 | .model = SBP2_ROM_VALUE_WILDCARD, |
358 | .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, | 361 | .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS, |
359 | }, | 362 | }, |
360 | |||
361 | /* | 363 | /* |
362 | * There are iPods (2nd gen, 3rd gen) with model_id == 0, but | 364 | * iPod 2nd generation: needs 128k max transfer size workaround |
363 | * these iPods do not feature the read_capacity bug according | 365 | * iPod 3rd generation: needs fix capacity workaround |
364 | * to one report. Read_capacity behaviour as well as model_id | ||
365 | * could change due to Apple-supplied firmware updates though. | ||
366 | */ | 366 | */ |
367 | 367 | { | |
368 | /* iPod 4th generation. */ { | 368 | .firmware_revision = 0x0a2700, |
369 | .model = 0x000000, | ||
370 | .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS | | ||
371 | SBP2_WORKAROUND_FIX_CAPACITY, | ||
372 | }, | ||
373 | /* iPod 4th generation */ { | ||
369 | .firmware_revision = 0x0a2700, | 374 | .firmware_revision = 0x0a2700, |
370 | .model = 0x000021, | 375 | .model = 0x000021, |
371 | .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, | 376 | .workarounds = SBP2_WORKAROUND_FIX_CAPACITY, |
@@ -1092,7 +1097,7 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model, | |||
1092 | continue; | 1097 | continue; |
1093 | 1098 | ||
1094 | if (sbp2_workarounds_table[i].model != model && | 1099 | if (sbp2_workarounds_table[i].model != model && |
1095 | sbp2_workarounds_table[i].model != ~0) | 1100 | sbp2_workarounds_table[i].model != SBP2_ROM_VALUE_WILDCARD) |
1096 | continue; | 1101 | continue; |
1097 | 1102 | ||
1098 | w |= sbp2_workarounds_table[i].workarounds; | 1103 | w |= sbp2_workarounds_table[i].workarounds; |
@@ -1142,20 +1147,28 @@ static int sbp2_probe(struct device *dev) | |||
1142 | fw_device_get(device); | 1147 | fw_device_get(device); |
1143 | fw_unit_get(unit); | 1148 | fw_unit_get(unit); |
1144 | 1149 | ||
1145 | /* Initialize to values that won't match anything in our table. */ | ||
1146 | firmware_revision = 0xff000000; | ||
1147 | model = 0xff000000; | ||
1148 | |||
1149 | /* implicit directory ID */ | 1150 | /* implicit directory ID */ |
1150 | tgt->directory_id = ((unit->directory - device->config_rom) * 4 | 1151 | tgt->directory_id = ((unit->directory - device->config_rom) * 4 |
1151 | + CSR_CONFIG_ROM) & 0xffffff; | 1152 | + CSR_CONFIG_ROM) & 0xffffff; |
1152 | 1153 | ||
1154 | firmware_revision = SBP2_ROM_VALUE_MISSING; | ||
1155 | model = SBP2_ROM_VALUE_MISSING; | ||
1156 | |||
1153 | if (sbp2_scan_unit_dir(tgt, unit->directory, &model, | 1157 | if (sbp2_scan_unit_dir(tgt, unit->directory, &model, |
1154 | &firmware_revision) < 0) | 1158 | &firmware_revision) < 0) |
1155 | goto fail_tgt_put; | 1159 | goto fail_tgt_put; |
1156 | 1160 | ||
1157 | sbp2_init_workarounds(tgt, model, firmware_revision); | 1161 | sbp2_init_workarounds(tgt, model, firmware_revision); |
1158 | 1162 | ||
1163 | /* | ||
1164 | * At S100 we can do 512 bytes per packet, at S200 1024 bytes, | ||
1165 | * and so on up to 4096 bytes. The SBP-2 max_payload field | ||
1166 | * specifies the max payload size as 2 ^ (max_payload + 2), so | ||
1167 | * if we set this to max_speed + 7, we get the right value. | ||
1168 | */ | ||
1169 | tgt->max_payload = min(device->max_speed + 7, 10U); | ||
1170 | tgt->max_payload = min(tgt->max_payload, device->card->max_receive - 1); | ||
1171 | |||
1159 | /* Do the login in a workqueue so we can easily reschedule retries. */ | 1172 | /* Do the login in a workqueue so we can easily reschedule retries. */ |
1160 | list_for_each_entry(lu, &tgt->lu_list, link) | 1173 | list_for_each_entry(lu, &tgt->lu_list, link) |
1161 | sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5)); | 1174 | sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5)); |
@@ -1273,6 +1286,19 @@ static struct fw_driver sbp2_driver = { | |||
1273 | .id_table = sbp2_id_table, | 1286 | .id_table = sbp2_id_table, |
1274 | }; | 1287 | }; |
1275 | 1288 | ||
1289 | static void sbp2_unmap_scatterlist(struct device *card_device, | ||
1290 | struct sbp2_command_orb *orb) | ||
1291 | { | ||
1292 | if (scsi_sg_count(orb->cmd)) | ||
1293 | dma_unmap_sg(card_device, scsi_sglist(orb->cmd), | ||
1294 | scsi_sg_count(orb->cmd), | ||
1295 | orb->cmd->sc_data_direction); | ||
1296 | |||
1297 | if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT)) | ||
1298 | dma_unmap_single(card_device, orb->page_table_bus, | ||
1299 | sizeof(orb->page_table), DMA_TO_DEVICE); | ||
1300 | } | ||
1301 | |||
1276 | static unsigned int | 1302 | static unsigned int |
1277 | sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data) | 1303 | sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data) |
1278 | { | 1304 | { |
@@ -1352,15 +1378,7 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status) | |||
1352 | 1378 | ||
1353 | dma_unmap_single(device->card->device, orb->base.request_bus, | 1379 | dma_unmap_single(device->card->device, orb->base.request_bus, |
1354 | sizeof(orb->request), DMA_TO_DEVICE); | 1380 | sizeof(orb->request), DMA_TO_DEVICE); |
1355 | 1381 | sbp2_unmap_scatterlist(device->card->device, orb); | |
1356 | if (scsi_sg_count(orb->cmd) > 0) | ||
1357 | dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd), | ||
1358 | scsi_sg_count(orb->cmd), | ||
1359 | orb->cmd->sc_data_direction); | ||
1360 | |||
1361 | if (orb->page_table_bus != 0) | ||
1362 | dma_unmap_single(device->card->device, orb->page_table_bus, | ||
1363 | sizeof(orb->page_table), DMA_TO_DEVICE); | ||
1364 | 1382 | ||
1365 | orb->cmd->result = result; | 1383 | orb->cmd->result = result; |
1366 | orb->done(orb->cmd); | 1384 | orb->done(orb->cmd); |
@@ -1434,7 +1452,6 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) | |||
1434 | struct sbp2_logical_unit *lu = cmd->device->hostdata; | 1452 | struct sbp2_logical_unit *lu = cmd->device->hostdata; |
1435 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 1453 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); |
1436 | struct sbp2_command_orb *orb; | 1454 | struct sbp2_command_orb *orb; |
1437 | unsigned int max_payload; | ||
1438 | int generation, retval = SCSI_MLQUEUE_HOST_BUSY; | 1455 | int generation, retval = SCSI_MLQUEUE_HOST_BUSY; |
1439 | 1456 | ||
1440 | /* | 1457 | /* |
@@ -1462,17 +1479,9 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) | |||
1462 | orb->done = done; | 1479 | orb->done = done; |
1463 | orb->cmd = cmd; | 1480 | orb->cmd = cmd; |
1464 | 1481 | ||
1465 | orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL); | 1482 | orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL); |
1466 | /* | ||
1467 | * At speed 100 we can do 512 bytes per packet, at speed 200, | ||
1468 | * 1024 bytes per packet etc. The SBP-2 max_payload field | ||
1469 | * specifies the max payload size as 2 ^ (max_payload + 2), so | ||
1470 | * if we set this to max_speed + 7, we get the right value. | ||
1471 | */ | ||
1472 | max_payload = min(device->max_speed + 7, | ||
1473 | device->card->max_receive - 1); | ||
1474 | orb->request.misc = cpu_to_be32( | 1483 | orb->request.misc = cpu_to_be32( |
1475 | COMMAND_ORB_MAX_PAYLOAD(max_payload) | | 1484 | COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) | |
1476 | COMMAND_ORB_SPEED(device->max_speed) | | 1485 | COMMAND_ORB_SPEED(device->max_speed) | |
1477 | COMMAND_ORB_NOTIFY); | 1486 | COMMAND_ORB_NOTIFY); |
1478 | 1487 | ||
@@ -1491,8 +1500,10 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) | |||
1491 | orb->base.request_bus = | 1500 | orb->base.request_bus = |
1492 | dma_map_single(device->card->device, &orb->request, | 1501 | dma_map_single(device->card->device, &orb->request, |
1493 | sizeof(orb->request), DMA_TO_DEVICE); | 1502 | sizeof(orb->request), DMA_TO_DEVICE); |
1494 | if (dma_mapping_error(device->card->device, orb->base.request_bus)) | 1503 | if (dma_mapping_error(device->card->device, orb->base.request_bus)) { |
1504 | sbp2_unmap_scatterlist(device->card->device, orb); | ||
1495 | goto out; | 1505 | goto out; |
1506 | } | ||
1496 | 1507 | ||
1497 | sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation, | 1508 | sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation, |
1498 | lu->command_block_agent_address + SBP2_ORB_POINTER); | 1509 | lu->command_block_agent_address + SBP2_ORB_POINTER); |
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c index c9be6e6948c4..8dd6703b55cd 100644 --- a/drivers/firewire/fw-topology.c +++ b/drivers/firewire/fw-topology.c | |||
@@ -518,6 +518,18 @@ fw_core_handle_bus_reset(struct fw_card *card, | |||
518 | struct fw_node *local_node; | 518 | struct fw_node *local_node; |
519 | unsigned long flags; | 519 | unsigned long flags; |
520 | 520 | ||
521 | /* | ||
522 | * If the selfID buffer is not the immediate successor of the | ||
523 | * previously processed one, we cannot reliably compare the | ||
524 | * old and new topologies. | ||
525 | */ | ||
526 | if (!is_next_generation(generation, card->generation) && | ||
527 | card->local_node != NULL) { | ||
528 | fw_notify("skipped bus generations, destroying all nodes\n"); | ||
529 | fw_destroy_nodes(card); | ||
530 | card->bm_retries = 0; | ||
531 | } | ||
532 | |||
521 | spin_lock_irqsave(&card->lock, flags); | 533 | spin_lock_irqsave(&card->lock, flags); |
522 | 534 | ||
523 | card->node_id = node_id; | 535 | card->node_id = node_id; |
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h index c9ab12a15f6e..1d78e9cc5940 100644 --- a/drivers/firewire/fw-transaction.h +++ b/drivers/firewire/fw-transaction.h | |||
@@ -276,6 +276,15 @@ static inline void fw_card_put(struct fw_card *card) | |||
276 | extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay); | 276 | extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay); |
277 | 277 | ||
278 | /* | 278 | /* |
279 | * Check whether new_generation is the immediate successor of old_generation. | ||
280 | * Take counter roll-over at 255 (as per to OHCI) into account. | ||
281 | */ | ||
282 | static inline bool is_next_generation(int new_generation, int old_generation) | ||
283 | { | ||
284 | return (new_generation & 0xff) == ((old_generation + 1) & 0xff); | ||
285 | } | ||
286 | |||
287 | /* | ||
279 | * The iso packet format allows for an immediate header/payload part | 288 | * The iso packet format allows for an immediate header/payload part |
280 | * stored in 'header' immediately after the packet info plus an | 289 | * stored in 'header' immediately after the packet info plus an |
281 | * indirect payload part that is pointer to by the 'payload' field. | 290 | * indirect payload part that is pointer to by the 'payload' field. |