diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-24 15:57:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-24 15:57:47 -0400 |
commit | 2f78d8e249973f1eeb88315e6444e616c60177ae (patch) | |
tree | 2f6fae6c781622301c40378ea404096d8f231a33 /drivers/firewire | |
parent | f2fde3a65e88330017b816faf2ef75f141d21375 (diff) | |
parent | 26c72e22c94fbc28604c94e3a96fdae9c6fd0a42 (diff) |
Merge tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394
Pull IEEE 1394 (FireWire) subsystem updates from Stefan Richter:
- Fix mismatch between DMA mapping direction (was wrong) and DMA
synchronization direction (was correct) of isochronous reception
buffers of userspace drivers if vma-mapped for R/W access. For
example, libdc1394 was affected.
- more consistent retry stategy in device discovery/ rediscovery, and
improved failure diagnostics
- various small cleanups, e.g. use SCSI layer's DMA mapping API in
firewire-sbp2
* tag 'firewire-updates' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394:
firewire: sbp2: document the absence of alignment requirements
firewire: sbp2: remove superfluous blk_queue_max_segment_size() call
firewire: sbp2: use scsi_dma_(un)map
firewire: sbp2: give correct DMA device to scsi framework
firewire: core: fw_device_refresh(): clean up error handling
firewire: core: log config rom reading errors
firewire: core: log error in case of failed bus manager lock
firewire: move rcode_string() to core
firewire: core: improve reread_config_rom() interface
firewire: core: wait for inaccessible devices after bus reset
firewire: ohci: omit spinlock IRQ flags where possible
firewire: ohci: correct signedness of a local variable
firewire: core: fix DMA mapping direction
firewire: use module_pci_driver
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/core-card.c | 4 | ||||
-rw-r--r-- | drivers/firewire/core-cdev.c | 51 | ||||
-rw-r--r-- | drivers/firewire/core-device.c | 116 | ||||
-rw-r--r-- | drivers/firewire/core-iso.c | 80 | ||||
-rw-r--r-- | drivers/firewire/core-transaction.c | 26 | ||||
-rw-r--r-- | drivers/firewire/core.h | 7 | ||||
-rw-r--r-- | drivers/firewire/nosy.c | 20 | ||||
-rw-r--r-- | drivers/firewire/ohci.c | 42 | ||||
-rw-r--r-- | drivers/firewire/sbp2.c | 28 |
9 files changed, 214 insertions, 160 deletions
diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index f5552b362efc..57ea7f464178 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c | |||
@@ -421,8 +421,8 @@ static void bm_work(struct work_struct *work) | |||
421 | * root, and thus, IRM. | 421 | * root, and thus, IRM. |
422 | */ | 422 | */ |
423 | new_root_id = local_id; | 423 | new_root_id = local_id; |
424 | fw_notice(card, "%s, making local node (%02x) root\n", | 424 | fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", |
425 | "BM lock failed", new_root_id); | 425 | fw_rcode_string(rcode), new_root_id); |
426 | goto pick_me; | 426 | goto pick_me; |
427 | } | 427 | } |
428 | } else if (card->bm_generation != generation) { | 428 | } else if (card->bm_generation != generation) { |
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 2e6b24547e2a..2783f69dada6 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/compat.h> | 22 | #include <linux/compat.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/dma-mapping.h> | ||
25 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
26 | #include <linux/firewire.h> | 27 | #include <linux/firewire.h> |
27 | #include <linux/firewire-cdev.h> | 28 | #include <linux/firewire-cdev.h> |
@@ -70,6 +71,7 @@ struct client { | |||
70 | u64 iso_closure; | 71 | u64 iso_closure; |
71 | struct fw_iso_buffer buffer; | 72 | struct fw_iso_buffer buffer; |
72 | unsigned long vm_start; | 73 | unsigned long vm_start; |
74 | bool buffer_is_mapped; | ||
73 | 75 | ||
74 | struct list_head phy_receiver_link; | 76 | struct list_head phy_receiver_link; |
75 | u64 phy_receiver_closure; | 77 | u64 phy_receiver_closure; |
@@ -959,11 +961,20 @@ static void iso_mc_callback(struct fw_iso_context *context, | |||
959 | sizeof(e->interrupt), NULL, 0); | 961 | sizeof(e->interrupt), NULL, 0); |
960 | } | 962 | } |
961 | 963 | ||
964 | static enum dma_data_direction iso_dma_direction(struct fw_iso_context *context) | ||
965 | { | ||
966 | if (context->type == FW_ISO_CONTEXT_TRANSMIT) | ||
967 | return DMA_TO_DEVICE; | ||
968 | else | ||
969 | return DMA_FROM_DEVICE; | ||
970 | } | ||
971 | |||
962 | static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg) | 972 | static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg) |
963 | { | 973 | { |
964 | struct fw_cdev_create_iso_context *a = &arg->create_iso_context; | 974 | struct fw_cdev_create_iso_context *a = &arg->create_iso_context; |
965 | struct fw_iso_context *context; | 975 | struct fw_iso_context *context; |
966 | fw_iso_callback_t cb; | 976 | fw_iso_callback_t cb; |
977 | int ret; | ||
967 | 978 | ||
968 | BUILD_BUG_ON(FW_CDEV_ISO_CONTEXT_TRANSMIT != FW_ISO_CONTEXT_TRANSMIT || | 979 | BUILD_BUG_ON(FW_CDEV_ISO_CONTEXT_TRANSMIT != FW_ISO_CONTEXT_TRANSMIT || |
969 | FW_CDEV_ISO_CONTEXT_RECEIVE != FW_ISO_CONTEXT_RECEIVE || | 980 | FW_CDEV_ISO_CONTEXT_RECEIVE != FW_ISO_CONTEXT_RECEIVE || |
@@ -1004,8 +1015,21 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg) | |||
1004 | if (client->iso_context != NULL) { | 1015 | if (client->iso_context != NULL) { |
1005 | spin_unlock_irq(&client->lock); | 1016 | spin_unlock_irq(&client->lock); |
1006 | fw_iso_context_destroy(context); | 1017 | fw_iso_context_destroy(context); |
1018 | |||
1007 | return -EBUSY; | 1019 | return -EBUSY; |
1008 | } | 1020 | } |
1021 | if (!client->buffer_is_mapped) { | ||
1022 | ret = fw_iso_buffer_map_dma(&client->buffer, | ||
1023 | client->device->card, | ||
1024 | iso_dma_direction(context)); | ||
1025 | if (ret < 0) { | ||
1026 | spin_unlock_irq(&client->lock); | ||
1027 | fw_iso_context_destroy(context); | ||
1028 | |||
1029 | return ret; | ||
1030 | } | ||
1031 | client->buffer_is_mapped = true; | ||
1032 | } | ||
1009 | client->iso_closure = a->closure; | 1033 | client->iso_closure = a->closure; |
1010 | client->iso_context = context; | 1034 | client->iso_context = context; |
1011 | spin_unlock_irq(&client->lock); | 1035 | spin_unlock_irq(&client->lock); |
@@ -1651,7 +1675,6 @@ static long fw_device_op_compat_ioctl(struct file *file, | |||
1651 | static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) | 1675 | static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) |
1652 | { | 1676 | { |
1653 | struct client *client = file->private_data; | 1677 | struct client *client = file->private_data; |
1654 | enum dma_data_direction direction; | ||
1655 | unsigned long size; | 1678 | unsigned long size; |
1656 | int page_count, ret; | 1679 | int page_count, ret; |
1657 | 1680 | ||
@@ -1674,20 +1697,28 @@ static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) | |||
1674 | if (size & ~PAGE_MASK) | 1697 | if (size & ~PAGE_MASK) |
1675 | return -EINVAL; | 1698 | return -EINVAL; |
1676 | 1699 | ||
1677 | if (vma->vm_flags & VM_WRITE) | 1700 | ret = fw_iso_buffer_alloc(&client->buffer, page_count); |
1678 | direction = DMA_TO_DEVICE; | ||
1679 | else | ||
1680 | direction = DMA_FROM_DEVICE; | ||
1681 | |||
1682 | ret = fw_iso_buffer_init(&client->buffer, client->device->card, | ||
1683 | page_count, direction); | ||
1684 | if (ret < 0) | 1701 | if (ret < 0) |
1685 | return ret; | 1702 | return ret; |
1686 | 1703 | ||
1687 | ret = fw_iso_buffer_map(&client->buffer, vma); | 1704 | spin_lock_irq(&client->lock); |
1705 | if (client->iso_context) { | ||
1706 | ret = fw_iso_buffer_map_dma(&client->buffer, | ||
1707 | client->device->card, | ||
1708 | iso_dma_direction(client->iso_context)); | ||
1709 | client->buffer_is_mapped = (ret == 0); | ||
1710 | } | ||
1711 | spin_unlock_irq(&client->lock); | ||
1688 | if (ret < 0) | 1712 | if (ret < 0) |
1689 | fw_iso_buffer_destroy(&client->buffer, client->device->card); | 1713 | goto fail; |
1690 | 1714 | ||
1715 | ret = fw_iso_buffer_map_vma(&client->buffer, vma); | ||
1716 | if (ret < 0) | ||
1717 | goto fail; | ||
1718 | |||
1719 | return 0; | ||
1720 | fail: | ||
1721 | fw_iso_buffer_destroy(&client->buffer, client->device->card); | ||
1691 | return ret; | 1722 | return ret; |
1692 | } | 1723 | } |
1693 | 1724 | ||
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 68109e9bb04e..4d460ef87161 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c | |||
@@ -481,6 +481,7 @@ static int read_rom(struct fw_device *device, | |||
481 | * generation changes under us, read_config_rom will fail and get retried. | 481 | * generation changes under us, read_config_rom will fail and get retried. |
482 | * It's better to start all over in this case because the node from which we | 482 | * It's better to start all over in this case because the node from which we |
483 | * are reading the ROM may have changed the ROM during the reset. | 483 | * are reading the ROM may have changed the ROM during the reset. |
484 | * Returns either a result code or a negative error code. | ||
484 | */ | 485 | */ |
485 | static int read_config_rom(struct fw_device *device, int generation) | 486 | static int read_config_rom(struct fw_device *device, int generation) |
486 | { | 487 | { |
@@ -488,7 +489,7 @@ static int read_config_rom(struct fw_device *device, int generation) | |||
488 | const u32 *old_rom, *new_rom; | 489 | const u32 *old_rom, *new_rom; |
489 | u32 *rom, *stack; | 490 | u32 *rom, *stack; |
490 | u32 sp, key; | 491 | u32 sp, key; |
491 | int i, end, length, ret = -1; | 492 | int i, end, length, ret; |
492 | 493 | ||
493 | rom = kmalloc(sizeof(*rom) * MAX_CONFIG_ROM_SIZE + | 494 | rom = kmalloc(sizeof(*rom) * MAX_CONFIG_ROM_SIZE + |
494 | sizeof(*stack) * MAX_CONFIG_ROM_SIZE, GFP_KERNEL); | 495 | sizeof(*stack) * MAX_CONFIG_ROM_SIZE, GFP_KERNEL); |
@@ -502,18 +503,21 @@ static int read_config_rom(struct fw_device *device, int generation) | |||
502 | 503 | ||
503 | /* First read the bus info block. */ | 504 | /* First read the bus info block. */ |
504 | for (i = 0; i < 5; i++) { | 505 | for (i = 0; i < 5; i++) { |
505 | if (read_rom(device, generation, i, &rom[i]) != RCODE_COMPLETE) | 506 | ret = read_rom(device, generation, i, &rom[i]); |
507 | if (ret != RCODE_COMPLETE) | ||
506 | goto out; | 508 | goto out; |
507 | /* | 509 | /* |
508 | * As per IEEE1212 7.2, during power-up, devices can | 510 | * As per IEEE1212 7.2, during initialization, devices can |
509 | * reply with a 0 for the first quadlet of the config | 511 | * reply with a 0 for the first quadlet of the config |
510 | * rom to indicate that they are booting (for example, | 512 | * rom to indicate that they are booting (for example, |
511 | * if the firmware is on the disk of a external | 513 | * if the firmware is on the disk of a external |
512 | * harddisk). In that case we just fail, and the | 514 | * harddisk). In that case we just fail, and the |
513 | * retry mechanism will try again later. | 515 | * retry mechanism will try again later. |
514 | */ | 516 | */ |
515 | if (i == 0 && rom[i] == 0) | 517 | if (i == 0 && rom[i] == 0) { |
518 | ret = RCODE_BUSY; | ||
516 | goto out; | 519 | goto out; |
520 | } | ||
517 | } | 521 | } |
518 | 522 | ||
519 | device->max_speed = device->node->max_speed; | 523 | device->max_speed = device->node->max_speed; |
@@ -563,11 +567,14 @@ static int read_config_rom(struct fw_device *device, int generation) | |||
563 | */ | 567 | */ |
564 | key = stack[--sp]; | 568 | key = stack[--sp]; |
565 | i = key & 0xffffff; | 569 | i = key & 0xffffff; |
566 | if (WARN_ON(i >= MAX_CONFIG_ROM_SIZE)) | 570 | if (WARN_ON(i >= MAX_CONFIG_ROM_SIZE)) { |
571 | ret = -ENXIO; | ||
567 | goto out; | 572 | goto out; |
573 | } | ||
568 | 574 | ||
569 | /* Read header quadlet for the block to get the length. */ | 575 | /* Read header quadlet for the block to get the length. */ |
570 | if (read_rom(device, generation, i, &rom[i]) != RCODE_COMPLETE) | 576 | ret = read_rom(device, generation, i, &rom[i]); |
577 | if (ret != RCODE_COMPLETE) | ||
571 | goto out; | 578 | goto out; |
572 | end = i + (rom[i] >> 16) + 1; | 579 | end = i + (rom[i] >> 16) + 1; |
573 | if (end > MAX_CONFIG_ROM_SIZE) { | 580 | if (end > MAX_CONFIG_ROM_SIZE) { |
@@ -590,8 +597,8 @@ static int read_config_rom(struct fw_device *device, int generation) | |||
590 | * it references another block, and push it in that case. | 597 | * it references another block, and push it in that case. |
591 | */ | 598 | */ |
592 | for (; i < end; i++) { | 599 | for (; i < end; i++) { |
593 | if (read_rom(device, generation, i, &rom[i]) != | 600 | ret = read_rom(device, generation, i, &rom[i]); |
594 | RCODE_COMPLETE) | 601 | if (ret != RCODE_COMPLETE) |
595 | goto out; | 602 | goto out; |
596 | 603 | ||
597 | if ((key >> 30) != 3 || (rom[i] >> 30) < 2) | 604 | if ((key >> 30) != 3 || (rom[i] >> 30) < 2) |
@@ -619,8 +626,10 @@ static int read_config_rom(struct fw_device *device, int generation) | |||
619 | 626 | ||
620 | old_rom = device->config_rom; | 627 | old_rom = device->config_rom; |
621 | new_rom = kmemdup(rom, length * 4, GFP_KERNEL); | 628 | new_rom = kmemdup(rom, length * 4, GFP_KERNEL); |
622 | if (new_rom == NULL) | 629 | if (new_rom == NULL) { |
630 | ret = -ENOMEM; | ||
623 | goto out; | 631 | goto out; |
632 | } | ||
624 | 633 | ||
625 | down_write(&fw_device_rwsem); | 634 | down_write(&fw_device_rwsem); |
626 | device->config_rom = new_rom; | 635 | device->config_rom = new_rom; |
@@ -628,7 +637,7 @@ static int read_config_rom(struct fw_device *device, int generation) | |||
628 | up_write(&fw_device_rwsem); | 637 | up_write(&fw_device_rwsem); |
629 | 638 | ||
630 | kfree(old_rom); | 639 | kfree(old_rom); |
631 | ret = 0; | 640 | ret = RCODE_COMPLETE; |
632 | device->max_rec = rom[2] >> 12 & 0xf; | 641 | device->max_rec = rom[2] >> 12 & 0xf; |
633 | device->cmc = rom[2] >> 30 & 1; | 642 | device->cmc = rom[2] >> 30 & 1; |
634 | device->irmc = rom[2] >> 31 & 1; | 643 | device->irmc = rom[2] >> 31 & 1; |
@@ -967,15 +976,17 @@ static void fw_device_init(struct work_struct *work) | |||
967 | * device. | 976 | * device. |
968 | */ | 977 | */ |
969 | 978 | ||
970 | if (read_config_rom(device, device->generation) < 0) { | 979 | ret = read_config_rom(device, device->generation); |
980 | if (ret != RCODE_COMPLETE) { | ||
971 | if (device->config_rom_retries < MAX_RETRIES && | 981 | if (device->config_rom_retries < MAX_RETRIES && |
972 | atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { | 982 | atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { |
973 | device->config_rom_retries++; | 983 | device->config_rom_retries++; |
974 | fw_schedule_device_work(device, RETRY_DELAY); | 984 | fw_schedule_device_work(device, RETRY_DELAY); |
975 | } else { | 985 | } else { |
976 | if (device->node->link_on) | 986 | if (device->node->link_on) |
977 | fw_notice(card, "giving up on Config ROM for node id %x\n", | 987 | fw_notice(card, "giving up on node %x: reading config rom failed: %s\n", |
978 | device->node_id); | 988 | device->node_id, |
989 | fw_rcode_string(ret)); | ||
979 | if (device->node == card->root_node) | 990 | if (device->node == card->root_node) |
980 | fw_schedule_bm_work(card, 0); | 991 | fw_schedule_bm_work(card, 0); |
981 | fw_device_release(&device->device); | 992 | fw_device_release(&device->device); |
@@ -1069,31 +1080,30 @@ static void fw_device_init(struct work_struct *work) | |||
1069 | put_device(&device->device); /* our reference */ | 1080 | put_device(&device->device); /* our reference */ |
1070 | } | 1081 | } |
1071 | 1082 | ||
1072 | enum { | ||
1073 | REREAD_BIB_ERROR, | ||
1074 | REREAD_BIB_GONE, | ||
1075 | REREAD_BIB_UNCHANGED, | ||
1076 | REREAD_BIB_CHANGED, | ||
1077 | }; | ||
1078 | |||
1079 | /* Reread and compare bus info block and header of root directory */ | 1083 | /* Reread and compare bus info block and header of root directory */ |
1080 | static int reread_config_rom(struct fw_device *device, int generation) | 1084 | static int reread_config_rom(struct fw_device *device, int generation, |
1085 | bool *changed) | ||
1081 | { | 1086 | { |
1082 | u32 q; | 1087 | u32 q; |
1083 | int i; | 1088 | int i, rcode; |
1084 | 1089 | ||
1085 | for (i = 0; i < 6; i++) { | 1090 | for (i = 0; i < 6; i++) { |
1086 | if (read_rom(device, generation, i, &q) != RCODE_COMPLETE) | 1091 | rcode = read_rom(device, generation, i, &q); |
1087 | return REREAD_BIB_ERROR; | 1092 | if (rcode != RCODE_COMPLETE) |
1093 | return rcode; | ||
1088 | 1094 | ||
1089 | if (i == 0 && q == 0) | 1095 | if (i == 0 && q == 0) |
1090 | return REREAD_BIB_GONE; | 1096 | /* inaccessible (see read_config_rom); retry later */ |
1097 | return RCODE_BUSY; | ||
1091 | 1098 | ||
1092 | if (q != device->config_rom[i]) | 1099 | if (q != device->config_rom[i]) { |
1093 | return REREAD_BIB_CHANGED; | 1100 | *changed = true; |
1101 | return RCODE_COMPLETE; | ||
1102 | } | ||
1094 | } | 1103 | } |
1095 | 1104 | ||
1096 | return REREAD_BIB_UNCHANGED; | 1105 | *changed = false; |
1106 | return RCODE_COMPLETE; | ||
1097 | } | 1107 | } |
1098 | 1108 | ||
1099 | static void fw_device_refresh(struct work_struct *work) | 1109 | static void fw_device_refresh(struct work_struct *work) |
@@ -1101,23 +1111,14 @@ static void fw_device_refresh(struct work_struct *work) | |||
1101 | struct fw_device *device = | 1111 | struct fw_device *device = |
1102 | container_of(work, struct fw_device, work.work); | 1112 | container_of(work, struct fw_device, work.work); |
1103 | struct fw_card *card = device->card; | 1113 | struct fw_card *card = device->card; |
1104 | int node_id = device->node_id; | 1114 | int ret, node_id = device->node_id; |
1105 | 1115 | bool changed; | |
1106 | switch (reread_config_rom(device, device->generation)) { | ||
1107 | case REREAD_BIB_ERROR: | ||
1108 | if (device->config_rom_retries < MAX_RETRIES / 2 && | ||
1109 | atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { | ||
1110 | device->config_rom_retries++; | ||
1111 | fw_schedule_device_work(device, RETRY_DELAY / 2); | ||
1112 | |||
1113 | return; | ||
1114 | } | ||
1115 | goto give_up; | ||
1116 | 1116 | ||
1117 | case REREAD_BIB_GONE: | 1117 | ret = reread_config_rom(device, device->generation, &changed); |
1118 | goto gone; | 1118 | if (ret != RCODE_COMPLETE) |
1119 | goto failed_config_rom; | ||
1119 | 1120 | ||
1120 | case REREAD_BIB_UNCHANGED: | 1121 | if (!changed) { |
1121 | if (atomic_cmpxchg(&device->state, | 1122 | if (atomic_cmpxchg(&device->state, |
1122 | FW_DEVICE_INITIALIZING, | 1123 | FW_DEVICE_INITIALIZING, |
1123 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) | 1124 | FW_DEVICE_RUNNING) == FW_DEVICE_GONE) |
@@ -1126,9 +1127,6 @@ static void fw_device_refresh(struct work_struct *work) | |||
1126 | fw_device_update(work); | 1127 | fw_device_update(work); |
1127 | device->config_rom_retries = 0; | 1128 | device->config_rom_retries = 0; |
1128 | goto out; | 1129 | goto out; |
1129 | |||
1130 | case REREAD_BIB_CHANGED: | ||
1131 | break; | ||
1132 | } | 1130 | } |
1133 | 1131 | ||
1134 | /* | 1132 | /* |
@@ -1137,16 +1135,9 @@ static void fw_device_refresh(struct work_struct *work) | |||
1137 | */ | 1135 | */ |
1138 | device_for_each_child(&device->device, NULL, shutdown_unit); | 1136 | device_for_each_child(&device->device, NULL, shutdown_unit); |
1139 | 1137 | ||
1140 | if (read_config_rom(device, device->generation) < 0) { | 1138 | ret = read_config_rom(device, device->generation); |
1141 | if (device->config_rom_retries < MAX_RETRIES && | 1139 | if (ret != RCODE_COMPLETE) |
1142 | atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { | 1140 | goto failed_config_rom; |
1143 | device->config_rom_retries++; | ||
1144 | fw_schedule_device_work(device, RETRY_DELAY); | ||
1145 | |||
1146 | return; | ||
1147 | } | ||
1148 | goto give_up; | ||
1149 | } | ||
1150 | 1141 | ||
1151 | fw_device_cdev_update(device); | 1142 | fw_device_cdev_update(device); |
1152 | create_units(device); | 1143 | create_units(device); |
@@ -1163,9 +1154,16 @@ static void fw_device_refresh(struct work_struct *work) | |||
1163 | device->config_rom_retries = 0; | 1154 | device->config_rom_retries = 0; |
1164 | goto out; | 1155 | goto out; |
1165 | 1156 | ||
1166 | give_up: | 1157 | failed_config_rom: |
1167 | fw_notice(card, "giving up on refresh of device %s\n", | 1158 | if (device->config_rom_retries < MAX_RETRIES && |
1168 | dev_name(&device->device)); | 1159 | atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { |
1160 | device->config_rom_retries++; | ||
1161 | fw_schedule_device_work(device, RETRY_DELAY); | ||
1162 | return; | ||
1163 | } | ||
1164 | |||
1165 | fw_notice(card, "giving up on refresh of device %s: %s\n", | ||
1166 | dev_name(&device->device), fw_rcode_string(ret)); | ||
1169 | gone: | 1167 | gone: |
1170 | atomic_set(&device->state, FW_DEVICE_GONE); | 1168 | atomic_set(&device->state, FW_DEVICE_GONE); |
1171 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); | 1169 | PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); |
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index d1565828ae2c..8382e27e9a27 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c | |||
@@ -39,52 +39,73 @@ | |||
39 | * Isochronous DMA context management | 39 | * Isochronous DMA context management |
40 | */ | 40 | */ |
41 | 41 | ||
42 | int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, | 42 | int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count) |
43 | int page_count, enum dma_data_direction direction) | ||
44 | { | 43 | { |
45 | int i, j; | 44 | int i; |
46 | dma_addr_t address; | ||
47 | |||
48 | buffer->page_count = page_count; | ||
49 | buffer->direction = direction; | ||
50 | 45 | ||
46 | buffer->page_count = 0; | ||
47 | buffer->page_count_mapped = 0; | ||
51 | buffer->pages = kmalloc(page_count * sizeof(buffer->pages[0]), | 48 | buffer->pages = kmalloc(page_count * sizeof(buffer->pages[0]), |
52 | GFP_KERNEL); | 49 | GFP_KERNEL); |
53 | if (buffer->pages == NULL) | 50 | if (buffer->pages == NULL) |
54 | goto out; | 51 | return -ENOMEM; |
55 | 52 | ||
56 | for (i = 0; i < buffer->page_count; i++) { | 53 | for (i = 0; i < page_count; i++) { |
57 | buffer->pages[i] = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); | 54 | buffer->pages[i] = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); |
58 | if (buffer->pages[i] == NULL) | 55 | if (buffer->pages[i] == NULL) |
59 | goto out_pages; | 56 | break; |
57 | } | ||
58 | buffer->page_count = i; | ||
59 | if (i < page_count) { | ||
60 | fw_iso_buffer_destroy(buffer, NULL); | ||
61 | return -ENOMEM; | ||
62 | } | ||
60 | 63 | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, struct fw_card *card, | ||
68 | enum dma_data_direction direction) | ||
69 | { | ||
70 | dma_addr_t address; | ||
71 | int i; | ||
72 | |||
73 | buffer->direction = direction; | ||
74 | |||
75 | for (i = 0; i < buffer->page_count; i++) { | ||
61 | address = dma_map_page(card->device, buffer->pages[i], | 76 | address = dma_map_page(card->device, buffer->pages[i], |
62 | 0, PAGE_SIZE, direction); | 77 | 0, PAGE_SIZE, direction); |
63 | if (dma_mapping_error(card->device, address)) { | 78 | if (dma_mapping_error(card->device, address)) |
64 | __free_page(buffer->pages[i]); | 79 | break; |
65 | goto out_pages; | 80 | |
66 | } | ||
67 | set_page_private(buffer->pages[i], address); | 81 | set_page_private(buffer->pages[i], address); |
68 | } | 82 | } |
83 | buffer->page_count_mapped = i; | ||
84 | if (i < buffer->page_count) | ||
85 | return -ENOMEM; | ||
69 | 86 | ||
70 | return 0; | 87 | return 0; |
88 | } | ||
71 | 89 | ||
72 | out_pages: | 90 | int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, |
73 | for (j = 0; j < i; j++) { | 91 | int page_count, enum dma_data_direction direction) |
74 | address = page_private(buffer->pages[j]); | 92 | { |
75 | dma_unmap_page(card->device, address, | 93 | int ret; |
76 | PAGE_SIZE, direction); | 94 | |
77 | __free_page(buffer->pages[j]); | 95 | ret = fw_iso_buffer_alloc(buffer, page_count); |
78 | } | 96 | if (ret < 0) |
79 | kfree(buffer->pages); | 97 | return ret; |
80 | out: | 98 | |
81 | buffer->pages = NULL; | 99 | ret = fw_iso_buffer_map_dma(buffer, card, direction); |
100 | if (ret < 0) | ||
101 | fw_iso_buffer_destroy(buffer, card); | ||
82 | 102 | ||
83 | return -ENOMEM; | 103 | return ret; |
84 | } | 104 | } |
85 | EXPORT_SYMBOL(fw_iso_buffer_init); | 105 | EXPORT_SYMBOL(fw_iso_buffer_init); |
86 | 106 | ||
87 | int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma) | 107 | int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer, |
108 | struct vm_area_struct *vma) | ||
88 | { | 109 | { |
89 | unsigned long uaddr; | 110 | unsigned long uaddr; |
90 | int i, err; | 111 | int i, err; |
@@ -107,15 +128,18 @@ void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, | |||
107 | int i; | 128 | int i; |
108 | dma_addr_t address; | 129 | dma_addr_t address; |
109 | 130 | ||
110 | for (i = 0; i < buffer->page_count; i++) { | 131 | for (i = 0; i < buffer->page_count_mapped; i++) { |
111 | address = page_private(buffer->pages[i]); | 132 | address = page_private(buffer->pages[i]); |
112 | dma_unmap_page(card->device, address, | 133 | dma_unmap_page(card->device, address, |
113 | PAGE_SIZE, buffer->direction); | 134 | PAGE_SIZE, buffer->direction); |
114 | __free_page(buffer->pages[i]); | ||
115 | } | 135 | } |
136 | for (i = 0; i < buffer->page_count; i++) | ||
137 | __free_page(buffer->pages[i]); | ||
116 | 138 | ||
117 | kfree(buffer->pages); | 139 | kfree(buffer->pages); |
118 | buffer->pages = NULL; | 140 | buffer->pages = NULL; |
141 | buffer->page_count = 0; | ||
142 | buffer->page_count_mapped = 0; | ||
119 | } | 143 | } |
120 | EXPORT_SYMBOL(fw_iso_buffer_destroy); | 144 | EXPORT_SYMBOL(fw_iso_buffer_destroy); |
121 | 145 | ||
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c index db8a965cf712..780708dc6e25 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c | |||
@@ -1003,6 +1003,32 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p) | |||
1003 | } | 1003 | } |
1004 | EXPORT_SYMBOL(fw_core_handle_response); | 1004 | EXPORT_SYMBOL(fw_core_handle_response); |
1005 | 1005 | ||
1006 | /** | ||
1007 | * fw_rcode_string - convert a firewire result code to an error description | ||
1008 | * @rcode: the result code | ||
1009 | */ | ||
1010 | const char *fw_rcode_string(int rcode) | ||
1011 | { | ||
1012 | static const char *const names[] = { | ||
1013 | [RCODE_COMPLETE] = "no error", | ||
1014 | [RCODE_CONFLICT_ERROR] = "conflict error", | ||
1015 | [RCODE_DATA_ERROR] = "data error", | ||
1016 | [RCODE_TYPE_ERROR] = "type error", | ||
1017 | [RCODE_ADDRESS_ERROR] = "address error", | ||
1018 | [RCODE_SEND_ERROR] = "send error", | ||
1019 | [RCODE_CANCELLED] = "timeout", | ||
1020 | [RCODE_BUSY] = "busy", | ||
1021 | [RCODE_GENERATION] = "bus reset", | ||
1022 | [RCODE_NO_ACK] = "no ack", | ||
1023 | }; | ||
1024 | |||
1025 | if ((unsigned int)rcode < ARRAY_SIZE(names) && names[rcode]) | ||
1026 | return names[rcode]; | ||
1027 | else | ||
1028 | return "unknown"; | ||
1029 | } | ||
1030 | EXPORT_SYMBOL(fw_rcode_string); | ||
1031 | |||
1006 | static const struct fw_address_region topology_map_region = | 1032 | static const struct fw_address_region topology_map_region = |
1007 | { .start = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP, | 1033 | { .start = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP, |
1008 | .end = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP_END, }; | 1034 | .end = CSR_REGISTER_BASE | CSR_TOPOLOGY_MAP_END, }; |
diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index b5a2f6197053..515a42c786d0 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
5 | #include <linux/device.h> | 5 | #include <linux/device.h> |
6 | #include <linux/dma-mapping.h> | ||
6 | #include <linux/fs.h> | 7 | #include <linux/fs.h> |
7 | #include <linux/list.h> | 8 | #include <linux/list.h> |
8 | #include <linux/idr.h> | 9 | #include <linux/idr.h> |
@@ -154,7 +155,11 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event); | |||
154 | 155 | ||
155 | /* -iso */ | 156 | /* -iso */ |
156 | 157 | ||
157 | int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma); | 158 | int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count); |
159 | int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, struct fw_card *card, | ||
160 | enum dma_data_direction direction); | ||
161 | int fw_iso_buffer_map_vma(struct fw_iso_buffer *buffer, | ||
162 | struct vm_area_struct *vma); | ||
158 | 163 | ||
159 | 164 | ||
160 | /* -topology */ | 165 | /* -topology */ |
diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c index a7c4422a688e..4ebfb2273672 100644 --- a/drivers/firewire/nosy.c +++ b/drivers/firewire/nosy.c | |||
@@ -693,6 +693,8 @@ static struct pci_device_id pci_table[] __devinitdata = { | |||
693 | { } /* Terminating entry */ | 693 | { } /* Terminating entry */ |
694 | }; | 694 | }; |
695 | 695 | ||
696 | MODULE_DEVICE_TABLE(pci, pci_table); | ||
697 | |||
696 | static struct pci_driver lynx_pci_driver = { | 698 | static struct pci_driver lynx_pci_driver = { |
697 | .name = driver_name, | 699 | .name = driver_name, |
698 | .id_table = pci_table, | 700 | .id_table = pci_table, |
@@ -700,22 +702,8 @@ static struct pci_driver lynx_pci_driver = { | |||
700 | .remove = remove_card, | 702 | .remove = remove_card, |
701 | }; | 703 | }; |
702 | 704 | ||
705 | module_pci_driver(lynx_pci_driver); | ||
706 | |||
703 | MODULE_AUTHOR("Kristian Hoegsberg"); | 707 | MODULE_AUTHOR("Kristian Hoegsberg"); |
704 | MODULE_DESCRIPTION("Snoop mode driver for TI pcilynx 1394 controllers"); | 708 | MODULE_DESCRIPTION("Snoop mode driver for TI pcilynx 1394 controllers"); |
705 | MODULE_LICENSE("GPL"); | 709 | MODULE_LICENSE("GPL"); |
706 | MODULE_DEVICE_TABLE(pci, pci_table); | ||
707 | |||
708 | static int __init nosy_init(void) | ||
709 | { | ||
710 | return pci_register_driver(&lynx_pci_driver); | ||
711 | } | ||
712 | |||
713 | static void __exit nosy_cleanup(void) | ||
714 | { | ||
715 | pci_unregister_driver(&lynx_pci_driver); | ||
716 | |||
717 | pr_info("Unloaded %s\n", driver_name); | ||
718 | } | ||
719 | |||
720 | module_init(nosy_init); | ||
721 | module_exit(nosy_cleanup); | ||
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 2b5460075a9f..c1af05e834b6 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -1821,9 +1821,8 @@ static void bus_reset_work(struct work_struct *work) | |||
1821 | { | 1821 | { |
1822 | struct fw_ohci *ohci = | 1822 | struct fw_ohci *ohci = |
1823 | container_of(work, struct fw_ohci, bus_reset_work); | 1823 | container_of(work, struct fw_ohci, bus_reset_work); |
1824 | int self_id_count, i, j, reg; | 1824 | int self_id_count, generation, new_generation, i, j; |
1825 | int generation, new_generation; | 1825 | u32 reg; |
1826 | unsigned long flags; | ||
1827 | void *free_rom = NULL; | 1826 | void *free_rom = NULL; |
1828 | dma_addr_t free_rom_bus = 0; | 1827 | dma_addr_t free_rom_bus = 0; |
1829 | bool is_new_root; | 1828 | bool is_new_root; |
@@ -1930,13 +1929,13 @@ static void bus_reset_work(struct work_struct *work) | |||
1930 | } | 1929 | } |
1931 | 1930 | ||
1932 | /* FIXME: Document how the locking works. */ | 1931 | /* FIXME: Document how the locking works. */ |
1933 | spin_lock_irqsave(&ohci->lock, flags); | 1932 | spin_lock_irq(&ohci->lock); |
1934 | 1933 | ||
1935 | ohci->generation = -1; /* prevent AT packet queueing */ | 1934 | ohci->generation = -1; /* prevent AT packet queueing */ |
1936 | context_stop(&ohci->at_request_ctx); | 1935 | context_stop(&ohci->at_request_ctx); |
1937 | context_stop(&ohci->at_response_ctx); | 1936 | context_stop(&ohci->at_response_ctx); |
1938 | 1937 | ||
1939 | spin_unlock_irqrestore(&ohci->lock, flags); | 1938 | spin_unlock_irq(&ohci->lock); |
1940 | 1939 | ||
1941 | /* | 1940 | /* |
1942 | * Per OHCI 1.2 draft, clause 7.2.3.3, hardware may leave unsent | 1941 | * Per OHCI 1.2 draft, clause 7.2.3.3, hardware may leave unsent |
@@ -1946,7 +1945,7 @@ static void bus_reset_work(struct work_struct *work) | |||
1946 | at_context_flush(&ohci->at_request_ctx); | 1945 | at_context_flush(&ohci->at_request_ctx); |
1947 | at_context_flush(&ohci->at_response_ctx); | 1946 | at_context_flush(&ohci->at_response_ctx); |
1948 | 1947 | ||
1949 | spin_lock_irqsave(&ohci->lock, flags); | 1948 | spin_lock_irq(&ohci->lock); |
1950 | 1949 | ||
1951 | ohci->generation = generation; | 1950 | ohci->generation = generation; |
1952 | reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset); | 1951 | reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset); |
@@ -1990,7 +1989,7 @@ static void bus_reset_work(struct work_struct *work) | |||
1990 | reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0); | 1989 | reg_write(ohci, OHCI1394_PhyReqFilterLoSet, ~0); |
1991 | #endif | 1990 | #endif |
1992 | 1991 | ||
1993 | spin_unlock_irqrestore(&ohci->lock, flags); | 1992 | spin_unlock_irq(&ohci->lock); |
1994 | 1993 | ||
1995 | if (free_rom) | 1994 | if (free_rom) |
1996 | dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, | 1995 | dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE, |
@@ -2402,7 +2401,6 @@ static int ohci_set_config_rom(struct fw_card *card, | |||
2402 | const __be32 *config_rom, size_t length) | 2401 | const __be32 *config_rom, size_t length) |
2403 | { | 2402 | { |
2404 | struct fw_ohci *ohci; | 2403 | struct fw_ohci *ohci; |
2405 | unsigned long flags; | ||
2406 | __be32 *next_config_rom; | 2404 | __be32 *next_config_rom; |
2407 | dma_addr_t uninitialized_var(next_config_rom_bus); | 2405 | dma_addr_t uninitialized_var(next_config_rom_bus); |
2408 | 2406 | ||
@@ -2441,7 +2439,7 @@ static int ohci_set_config_rom(struct fw_card *card, | |||
2441 | if (next_config_rom == NULL) | 2439 | if (next_config_rom == NULL) |
2442 | return -ENOMEM; | 2440 | return -ENOMEM; |
2443 | 2441 | ||
2444 | spin_lock_irqsave(&ohci->lock, flags); | 2442 | spin_lock_irq(&ohci->lock); |
2445 | 2443 | ||
2446 | /* | 2444 | /* |
2447 | * If there is not an already pending config_rom update, | 2445 | * If there is not an already pending config_rom update, |
@@ -2467,7 +2465,7 @@ static int ohci_set_config_rom(struct fw_card *card, | |||
2467 | 2465 | ||
2468 | reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); | 2466 | reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus); |
2469 | 2467 | ||
2470 | spin_unlock_irqrestore(&ohci->lock, flags); | 2468 | spin_unlock_irq(&ohci->lock); |
2471 | 2469 | ||
2472 | /* If we didn't use the DMA allocation, delete it. */ | 2470 | /* If we didn't use the DMA allocation, delete it. */ |
2473 | if (next_config_rom != NULL) | 2471 | if (next_config_rom != NULL) |
@@ -2891,10 +2889,9 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card, | |||
2891 | descriptor_callback_t uninitialized_var(callback); | 2889 | descriptor_callback_t uninitialized_var(callback); |
2892 | u64 *uninitialized_var(channels); | 2890 | u64 *uninitialized_var(channels); |
2893 | u32 *uninitialized_var(mask), uninitialized_var(regs); | 2891 | u32 *uninitialized_var(mask), uninitialized_var(regs); |
2894 | unsigned long flags; | ||
2895 | int index, ret = -EBUSY; | 2892 | int index, ret = -EBUSY; |
2896 | 2893 | ||
2897 | spin_lock_irqsave(&ohci->lock, flags); | 2894 | spin_lock_irq(&ohci->lock); |
2898 | 2895 | ||
2899 | switch (type) { | 2896 | switch (type) { |
2900 | case FW_ISO_CONTEXT_TRANSMIT: | 2897 | case FW_ISO_CONTEXT_TRANSMIT: |
@@ -2938,7 +2935,7 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card, | |||
2938 | ret = -ENOSYS; | 2935 | ret = -ENOSYS; |
2939 | } | 2936 | } |
2940 | 2937 | ||
2941 | spin_unlock_irqrestore(&ohci->lock, flags); | 2938 | spin_unlock_irq(&ohci->lock); |
2942 | 2939 | ||
2943 | if (index < 0) | 2940 | if (index < 0) |
2944 | return ERR_PTR(ret); | 2941 | return ERR_PTR(ret); |
@@ -2964,7 +2961,7 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card, | |||
2964 | out_with_header: | 2961 | out_with_header: |
2965 | free_page((unsigned long)ctx->header); | 2962 | free_page((unsigned long)ctx->header); |
2966 | out: | 2963 | out: |
2967 | spin_lock_irqsave(&ohci->lock, flags); | 2964 | spin_lock_irq(&ohci->lock); |
2968 | 2965 | ||
2969 | switch (type) { | 2966 | switch (type) { |
2970 | case FW_ISO_CONTEXT_RECEIVE: | 2967 | case FW_ISO_CONTEXT_RECEIVE: |
@@ -2977,7 +2974,7 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card, | |||
2977 | } | 2974 | } |
2978 | *mask |= 1 << index; | 2975 | *mask |= 1 << index; |
2979 | 2976 | ||
2980 | spin_unlock_irqrestore(&ohci->lock, flags); | 2977 | spin_unlock_irq(&ohci->lock); |
2981 | 2978 | ||
2982 | return ERR_PTR(ret); | 2979 | return ERR_PTR(ret); |
2983 | } | 2980 | } |
@@ -3789,6 +3786,8 @@ static struct pci_driver fw_ohci_pci_driver = { | |||
3789 | #endif | 3786 | #endif |
3790 | }; | 3787 | }; |
3791 | 3788 | ||
3789 | module_pci_driver(fw_ohci_pci_driver); | ||
3790 | |||
3792 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); | 3791 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); |
3793 | MODULE_DESCRIPTION("Driver for PCI OHCI IEEE1394 controllers"); | 3792 | MODULE_DESCRIPTION("Driver for PCI OHCI IEEE1394 controllers"); |
3794 | MODULE_LICENSE("GPL"); | 3793 | MODULE_LICENSE("GPL"); |
@@ -3797,16 +3796,3 @@ MODULE_LICENSE("GPL"); | |||
3797 | #ifndef CONFIG_IEEE1394_OHCI1394_MODULE | 3796 | #ifndef CONFIG_IEEE1394_OHCI1394_MODULE |
3798 | MODULE_ALIAS("ohci1394"); | 3797 | MODULE_ALIAS("ohci1394"); |
3799 | #endif | 3798 | #endif |
3800 | |||
3801 | static int __init fw_ohci_init(void) | ||
3802 | { | ||
3803 | return pci_register_driver(&fw_ohci_pci_driver); | ||
3804 | } | ||
3805 | |||
3806 | static void __exit fw_ohci_cleanup(void) | ||
3807 | { | ||
3808 | pci_unregister_driver(&fw_ohci_pci_driver); | ||
3809 | } | ||
3810 | |||
3811 | module_init(fw_ohci_init); | ||
3812 | module_exit(fw_ohci_cleanup); | ||
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index b7e65d7eab64..1162d6b3bf85 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c | |||
@@ -207,9 +207,8 @@ static const struct device *lu_dev(const struct sbp2_logical_unit *lu) | |||
207 | #define SBP2_MAX_CDB_SIZE 16 | 207 | #define SBP2_MAX_CDB_SIZE 16 |
208 | 208 | ||
209 | /* | 209 | /* |
210 | * The default maximum s/g segment size of a FireWire controller is | 210 | * The maximum SBP-2 data buffer size is 0xffff. We quadlet-align this |
211 | * usually 0x10000, but SBP-2 only allows 0xffff. Since buffers have to | 211 | * for compatibility with earlier versions of this driver. |
212 | * be quadlet-aligned, we set the length limit to 0xffff & ~3. | ||
213 | */ | 212 | */ |
214 | #define SBP2_MAX_SEG_SIZE 0xfffc | 213 | #define SBP2_MAX_SEG_SIZE 0xfffc |
215 | 214 | ||
@@ -1163,7 +1162,8 @@ static int sbp2_probe(struct device *dev) | |||
1163 | 1162 | ||
1164 | shost->max_cmd_len = SBP2_MAX_CDB_SIZE; | 1163 | shost->max_cmd_len = SBP2_MAX_CDB_SIZE; |
1165 | 1164 | ||
1166 | if (scsi_add_host(shost, &unit->device) < 0) | 1165 | if (scsi_add_host_with_dma(shost, &unit->device, |
1166 | device->card->device) < 0) | ||
1167 | goto fail_shost_put; | 1167 | goto fail_shost_put; |
1168 | 1168 | ||
1169 | /* implicit directory ID */ | 1169 | /* implicit directory ID */ |
@@ -1295,10 +1295,7 @@ static struct fw_driver sbp2_driver = { | |||
1295 | static void sbp2_unmap_scatterlist(struct device *card_device, | 1295 | static void sbp2_unmap_scatterlist(struct device *card_device, |
1296 | struct sbp2_command_orb *orb) | 1296 | struct sbp2_command_orb *orb) |
1297 | { | 1297 | { |
1298 | if (scsi_sg_count(orb->cmd)) | 1298 | scsi_dma_unmap(orb->cmd); |
1299 | dma_unmap_sg(card_device, scsi_sglist(orb->cmd), | ||
1300 | scsi_sg_count(orb->cmd), | ||
1301 | orb->cmd->sc_data_direction); | ||
1302 | 1299 | ||
1303 | if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT)) | 1300 | if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT)) |
1304 | dma_unmap_single(card_device, orb->page_table_bus, | 1301 | dma_unmap_single(card_device, orb->page_table_bus, |
@@ -1404,9 +1401,8 @@ static int sbp2_map_scatterlist(struct sbp2_command_orb *orb, | |||
1404 | struct scatterlist *sg = scsi_sglist(orb->cmd); | 1401 | struct scatterlist *sg = scsi_sglist(orb->cmd); |
1405 | int i, n; | 1402 | int i, n; |
1406 | 1403 | ||
1407 | n = dma_map_sg(device->card->device, sg, scsi_sg_count(orb->cmd), | 1404 | n = scsi_dma_map(orb->cmd); |
1408 | orb->cmd->sc_data_direction); | 1405 | if (n <= 0) |
1409 | if (n == 0) | ||
1410 | goto fail; | 1406 | goto fail; |
1411 | 1407 | ||
1412 | /* | 1408 | /* |
@@ -1452,8 +1448,7 @@ static int sbp2_map_scatterlist(struct sbp2_command_orb *orb, | |||
1452 | return 0; | 1448 | return 0; |
1453 | 1449 | ||
1454 | fail_page_table: | 1450 | fail_page_table: |
1455 | dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd), | 1451 | scsi_dma_unmap(orb->cmd); |
1456 | scsi_sg_count(orb->cmd), orb->cmd->sc_data_direction); | ||
1457 | fail: | 1452 | fail: |
1458 | return -ENOMEM; | 1453 | return -ENOMEM; |
1459 | } | 1454 | } |
@@ -1534,7 +1529,10 @@ static int sbp2_scsi_slave_alloc(struct scsi_device *sdev) | |||
1534 | 1529 | ||
1535 | sdev->allow_restart = 1; | 1530 | sdev->allow_restart = 1; |
1536 | 1531 | ||
1537 | /* SBP-2 requires quadlet alignment of the data buffers. */ | 1532 | /* |
1533 | * SBP-2 does not require any alignment, but we set it anyway | ||
1534 | * for compatibility with earlier versions of this driver. | ||
1535 | */ | ||
1538 | blk_queue_update_dma_alignment(sdev->request_queue, 4 - 1); | 1536 | blk_queue_update_dma_alignment(sdev->request_queue, 4 - 1); |
1539 | 1537 | ||
1540 | if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36) | 1538 | if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36) |
@@ -1568,8 +1566,6 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev) | |||
1568 | if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) | 1566 | if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) |
1569 | blk_queue_max_hw_sectors(sdev->request_queue, 128 * 1024 / 512); | 1567 | blk_queue_max_hw_sectors(sdev->request_queue, 128 * 1024 / 512); |
1570 | 1568 | ||
1571 | blk_queue_max_segment_size(sdev->request_queue, SBP2_MAX_SEG_SIZE); | ||
1572 | |||
1573 | return 0; | 1569 | return 0; |
1574 | } | 1570 | } |
1575 | 1571 | ||