diff options
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/fw-card.c | 56 | ||||
-rw-r--r-- | drivers/firewire/fw-cdev.c | 6 | ||||
-rw-r--r-- | drivers/firewire/fw-device.c | 37 | ||||
-rw-r--r-- | drivers/firewire/fw-sbp2.c | 116 | ||||
-rw-r--r-- | drivers/firewire/fw-transaction.c | 48 | ||||
-rw-r--r-- | drivers/firewire/fw-transaction.h | 9 |
6 files changed, 117 insertions, 155 deletions
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c index bbd73a406e53..418c18f07e9d 100644 --- a/drivers/firewire/fw-card.c +++ b/drivers/firewire/fw-card.c | |||
@@ -189,39 +189,16 @@ static const char gap_count_table[] = { | |||
189 | 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 | 189 | 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 |
190 | }; | 190 | }; |
191 | 191 | ||
192 | struct bm_data { | ||
193 | struct fw_transaction t; | ||
194 | struct { | ||
195 | __be32 arg; | ||
196 | __be32 data; | ||
197 | } lock; | ||
198 | u32 old; | ||
199 | int rcode; | ||
200 | struct completion done; | ||
201 | }; | ||
202 | |||
203 | static void | ||
204 | complete_bm_lock(struct fw_card *card, int rcode, | ||
205 | void *payload, size_t length, void *data) | ||
206 | { | ||
207 | struct bm_data *bmd = data; | ||
208 | |||
209 | if (rcode == RCODE_COMPLETE) | ||
210 | bmd->old = be32_to_cpu(*(__be32 *) payload); | ||
211 | bmd->rcode = rcode; | ||
212 | complete(&bmd->done); | ||
213 | } | ||
214 | |||
215 | static void | 192 | static void |
216 | fw_card_bm_work(struct work_struct *work) | 193 | fw_card_bm_work(struct work_struct *work) |
217 | { | 194 | { |
218 | struct fw_card *card = container_of(work, struct fw_card, work.work); | 195 | struct fw_card *card = container_of(work, struct fw_card, work.work); |
219 | struct fw_device *root_device; | 196 | struct fw_device *root_device; |
220 | struct fw_node *root_node, *local_node; | 197 | struct fw_node *root_node, *local_node; |
221 | struct bm_data bmd; | ||
222 | unsigned long flags; | 198 | unsigned long flags; |
223 | int root_id, new_root_id, irm_id, gap_count, generation, grace; | 199 | int root_id, new_root_id, irm_id, gap_count, generation, grace, rcode; |
224 | bool do_reset = false; | 200 | bool do_reset = false; |
201 | __be32 lock_data[2]; | ||
225 | 202 | ||
226 | spin_lock_irqsave(&card->lock, flags); | 203 | spin_lock_irqsave(&card->lock, flags); |
227 | local_node = card->local_node; | 204 | local_node = card->local_node; |
@@ -263,33 +240,28 @@ fw_card_bm_work(struct work_struct *work) | |||
263 | goto pick_me; | 240 | goto pick_me; |
264 | } | 241 | } |
265 | 242 | ||
266 | bmd.lock.arg = cpu_to_be32(0x3f); | 243 | lock_data[0] = cpu_to_be32(0x3f); |
267 | bmd.lock.data = cpu_to_be32(local_node->node_id); | 244 | lock_data[1] = cpu_to_be32(local_node->node_id); |
268 | 245 | ||
269 | spin_unlock_irqrestore(&card->lock, flags); | 246 | spin_unlock_irqrestore(&card->lock, flags); |
270 | 247 | ||
271 | init_completion(&bmd.done); | 248 | rcode = fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, |
272 | fw_send_request(card, &bmd.t, TCODE_LOCK_COMPARE_SWAP, | 249 | irm_id, generation, SCODE_100, |
273 | irm_id, generation, | 250 | CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, |
274 | SCODE_100, CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, | 251 | lock_data, sizeof(lock_data)); |
275 | &bmd.lock, sizeof(bmd.lock), | ||
276 | complete_bm_lock, &bmd); | ||
277 | wait_for_completion(&bmd.done); | ||
278 | 252 | ||
279 | if (bmd.rcode == RCODE_GENERATION) { | 253 | if (rcode == RCODE_GENERATION) |
280 | /* | 254 | /* Another bus reset, BM work has been rescheduled. */ |
281 | * Another bus reset happened. Just return, | ||
282 | * the BM work has been rescheduled. | ||
283 | */ | ||
284 | goto out; | 255 | goto out; |
285 | } | ||
286 | 256 | ||
287 | if (bmd.rcode == RCODE_COMPLETE && bmd.old != 0x3f) | 257 | if (rcode == RCODE_COMPLETE && |
258 | lock_data[0] != cpu_to_be32(0x3f)) | ||
288 | /* Somebody else is BM, let them do the work. */ | 259 | /* Somebody else is BM, let them do the work. */ |
289 | goto out; | 260 | goto out; |
290 | 261 | ||
291 | spin_lock_irqsave(&card->lock, flags); | 262 | spin_lock_irqsave(&card->lock, flags); |
292 | if (bmd.rcode != RCODE_COMPLETE) { | 263 | |
264 | if (rcode != RCODE_COMPLETE) { | ||
293 | /* | 265 | /* |
294 | * The lock request failed, maybe the IRM | 266 | * The lock request failed, maybe the IRM |
295 | * isn't really IRM capable after all. Let's | 267 | * isn't really IRM capable after all. Let's |
diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c index 2e6d5848d217..ed03234cbea8 100644 --- a/drivers/firewire/fw-cdev.c +++ b/drivers/firewire/fw-cdev.c | |||
@@ -720,8 +720,8 @@ static int ioctl_create_iso_context(struct client *client, void *buffer) | |||
720 | #define GET_PAYLOAD_LENGTH(v) ((v) & 0xffff) | 720 | #define GET_PAYLOAD_LENGTH(v) ((v) & 0xffff) |
721 | #define GET_INTERRUPT(v) (((v) >> 16) & 0x01) | 721 | #define GET_INTERRUPT(v) (((v) >> 16) & 0x01) |
722 | #define GET_SKIP(v) (((v) >> 17) & 0x01) | 722 | #define GET_SKIP(v) (((v) >> 17) & 0x01) |
723 | #define GET_TAG(v) (((v) >> 18) & 0x02) | 723 | #define GET_TAG(v) (((v) >> 18) & 0x03) |
724 | #define GET_SY(v) (((v) >> 20) & 0x04) | 724 | #define GET_SY(v) (((v) >> 20) & 0x0f) |
725 | #define GET_HEADER_LENGTH(v) (((v) >> 24) & 0xff) | 725 | #define GET_HEADER_LENGTH(v) (((v) >> 24) & 0xff) |
726 | 726 | ||
727 | static int ioctl_queue_iso(struct client *client, void *buffer) | 727 | static int ioctl_queue_iso(struct client *client, void *buffer) |
@@ -913,7 +913,7 @@ dispatch_ioctl(struct client *client, unsigned int cmd, void __user *arg) | |||
913 | return -EFAULT; | 913 | return -EFAULT; |
914 | } | 914 | } |
915 | 915 | ||
916 | return 0; | 916 | return retval; |
917 | } | 917 | } |
918 | 918 | ||
919 | static long | 919 | static long |
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c index 0855fb5568e8..3fccdd484100 100644 --- a/drivers/firewire/fw-device.c +++ b/drivers/firewire/fw-device.c | |||
@@ -381,46 +381,21 @@ static struct device_attribute fw_device_attributes[] = { | |||
381 | __ATTR_NULL, | 381 | __ATTR_NULL, |
382 | }; | 382 | }; |
383 | 383 | ||
384 | struct read_quadlet_callback_data { | ||
385 | struct completion done; | ||
386 | int rcode; | ||
387 | u32 data; | ||
388 | }; | ||
389 | |||
390 | static void | ||
391 | complete_transaction(struct fw_card *card, int rcode, | ||
392 | void *payload, size_t length, void *data) | ||
393 | { | ||
394 | struct read_quadlet_callback_data *callback_data = data; | ||
395 | |||
396 | if (rcode == RCODE_COMPLETE) | ||
397 | callback_data->data = be32_to_cpu(*(__be32 *)payload); | ||
398 | callback_data->rcode = rcode; | ||
399 | complete(&callback_data->done); | ||
400 | } | ||
401 | |||
402 | static int | 384 | static int |
403 | read_rom(struct fw_device *device, int generation, int index, u32 *data) | 385 | read_rom(struct fw_device *device, int generation, int index, u32 *data) |
404 | { | 386 | { |
405 | struct read_quadlet_callback_data callback_data; | 387 | int rcode; |
406 | struct fw_transaction t; | ||
407 | u64 offset; | ||
408 | 388 | ||
409 | /* device->node_id, accessed below, must not be older than generation */ | 389 | /* device->node_id, accessed below, must not be older than generation */ |
410 | smp_rmb(); | 390 | smp_rmb(); |
411 | 391 | ||
412 | init_completion(&callback_data.done); | 392 | rcode = fw_run_transaction(device->card, TCODE_READ_QUADLET_REQUEST, |
413 | |||
414 | offset = (CSR_REGISTER_BASE | CSR_CONFIG_ROM) + index * 4; | ||
415 | fw_send_request(device->card, &t, TCODE_READ_QUADLET_REQUEST, | ||
416 | device->node_id, generation, device->max_speed, | 393 | device->node_id, generation, device->max_speed, |
417 | offset, NULL, 4, complete_transaction, &callback_data); | 394 | (CSR_REGISTER_BASE | CSR_CONFIG_ROM) + index * 4, |
418 | 395 | data, 4); | |
419 | wait_for_completion(&callback_data.done); | 396 | be32_to_cpus(data); |
420 | |||
421 | *data = callback_data.data; | ||
422 | 397 | ||
423 | return callback_data.rcode; | 398 | return rcode; |
424 | } | 399 | } |
425 | 400 | ||
426 | #define READ_BIB_ROM_SIZE 256 | 401 | #define READ_BIB_ROM_SIZE 256 |
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index aaff50ebba1d..ef0b9b419c27 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c | |||
@@ -29,6 +29,7 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/blkdev.h> | 31 | #include <linux/blkdev.h> |
32 | #include <linux/bug.h> | ||
32 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
33 | #include <linux/device.h> | 34 | #include <linux/device.h> |
34 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
@@ -181,10 +182,16 @@ struct sbp2_target { | |||
181 | #define SBP2_MAX_LOGIN_ORB_TIMEOUT 40000U /* Timeout in ms */ | 182 | #define SBP2_MAX_LOGIN_ORB_TIMEOUT 40000U /* Timeout in ms */ |
182 | #define SBP2_ORB_TIMEOUT 2000U /* Timeout in ms */ | 183 | #define SBP2_ORB_TIMEOUT 2000U /* Timeout in ms */ |
183 | #define SBP2_ORB_NULL 0x80000000 | 184 | #define SBP2_ORB_NULL 0x80000000 |
184 | #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 | ||
185 | #define SBP2_RETRY_LIMIT 0xf /* 15 retries */ | 185 | #define SBP2_RETRY_LIMIT 0xf /* 15 retries */ |
186 | #define SBP2_CYCLE_LIMIT (0xc8 << 12) /* 200 125us cycles */ | 186 | #define SBP2_CYCLE_LIMIT (0xc8 << 12) /* 200 125us cycles */ |
187 | 187 | ||
188 | /* | ||
189 | * The default maximum s/g segment size of a FireWire controller is | ||
190 | * usually 0x10000, but SBP-2 only allows 0xffff. Since buffers have to | ||
191 | * be quadlet-aligned, we set the length limit to 0xffff & ~3. | ||
192 | */ | ||
193 | #define SBP2_MAX_SEG_SIZE 0xfffc | ||
194 | |||
188 | /* Unit directory keys */ | 195 | /* Unit directory keys */ |
189 | #define SBP2_CSR_UNIT_CHARACTERISTICS 0x3a | 196 | #define SBP2_CSR_UNIT_CHARACTERISTICS 0x3a |
190 | #define SBP2_CSR_FIRMWARE_REVISION 0x3c | 197 | #define SBP2_CSR_FIRMWARE_REVISION 0x3c |
@@ -621,25 +628,15 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, | |||
621 | return retval; | 628 | return retval; |
622 | } | 629 | } |
623 | 630 | ||
624 | static void | ||
625 | complete_agent_reset_write(struct fw_card *card, int rcode, | ||
626 | void *payload, size_t length, void *done) | ||
627 | { | ||
628 | complete(done); | ||
629 | } | ||
630 | |||
631 | static void sbp2_agent_reset(struct sbp2_logical_unit *lu) | 631 | static void sbp2_agent_reset(struct sbp2_logical_unit *lu) |
632 | { | 632 | { |
633 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 633 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); |
634 | DECLARE_COMPLETION_ONSTACK(done); | 634 | __be32 d = 0; |
635 | struct fw_transaction t; | ||
636 | static u32 z; | ||
637 | 635 | ||
638 | fw_send_request(device->card, &t, TCODE_WRITE_QUADLET_REQUEST, | 636 | fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, |
639 | lu->tgt->node_id, lu->generation, device->max_speed, | 637 | lu->tgt->node_id, lu->generation, device->max_speed, |
640 | lu->command_block_agent_address + SBP2_AGENT_RESET, | 638 | lu->command_block_agent_address + SBP2_AGENT_RESET, |
641 | &z, sizeof(z), complete_agent_reset_write, &done); | 639 | &d, sizeof(d)); |
642 | wait_for_completion(&done); | ||
643 | } | 640 | } |
644 | 641 | ||
645 | static void | 642 | static void |
@@ -653,7 +650,7 @@ static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu) | |||
653 | { | 650 | { |
654 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 651 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); |
655 | struct fw_transaction *t; | 652 | struct fw_transaction *t; |
656 | static u32 z; | 653 | static __be32 d; |
657 | 654 | ||
658 | t = kmalloc(sizeof(*t), GFP_ATOMIC); | 655 | t = kmalloc(sizeof(*t), GFP_ATOMIC); |
659 | if (t == NULL) | 656 | if (t == NULL) |
@@ -662,7 +659,7 @@ static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu) | |||
662 | fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST, | 659 | fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST, |
663 | lu->tgt->node_id, lu->generation, device->max_speed, | 660 | lu->tgt->node_id, lu->generation, device->max_speed, |
664 | lu->command_block_agent_address + SBP2_AGENT_RESET, | 661 | lu->command_block_agent_address + SBP2_AGENT_RESET, |
665 | &z, sizeof(z), complete_agent_reset_write_no_wait, t); | 662 | &d, sizeof(d), complete_agent_reset_write_no_wait, t); |
666 | } | 663 | } |
667 | 664 | ||
668 | static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation) | 665 | static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation) |
@@ -823,13 +820,6 @@ static void sbp2_target_put(struct sbp2_target *tgt) | |||
823 | kref_put(&tgt->kref, sbp2_release_target); | 820 | kref_put(&tgt->kref, sbp2_release_target); |
824 | } | 821 | } |
825 | 822 | ||
826 | static void | ||
827 | complete_set_busy_timeout(struct fw_card *card, int rcode, | ||
828 | void *payload, size_t length, void *done) | ||
829 | { | ||
830 | complete(done); | ||
831 | } | ||
832 | |||
833 | /* | 823 | /* |
834 | * Write retransmit retry values into the BUSY_TIMEOUT register. | 824 | * Write retransmit retry values into the BUSY_TIMEOUT register. |
835 | * - The single-phase retry protocol is supported by all SBP-2 devices, but the | 825 | * - The single-phase retry protocol is supported by all SBP-2 devices, but the |
@@ -849,17 +839,12 @@ complete_set_busy_timeout(struct fw_card *card, int rcode, | |||
849 | static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu) | 839 | static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu) |
850 | { | 840 | { |
851 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 841 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); |
852 | DECLARE_COMPLETION_ONSTACK(done); | 842 | __be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT); |
853 | struct fw_transaction t; | ||
854 | static __be32 busy_timeout; | ||
855 | |||
856 | busy_timeout = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT); | ||
857 | 843 | ||
858 | fw_send_request(device->card, &t, TCODE_WRITE_QUADLET_REQUEST, | 844 | fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, |
859 | lu->tgt->node_id, lu->generation, device->max_speed, | 845 | lu->tgt->node_id, lu->generation, device->max_speed, |
860 | CSR_REGISTER_BASE + CSR_BUSY_TIMEOUT, &busy_timeout, | 846 | CSR_REGISTER_BASE + CSR_BUSY_TIMEOUT, |
861 | sizeof(busy_timeout), complete_set_busy_timeout, &done); | 847 | &d, sizeof(d)); |
862 | wait_for_completion(&done); | ||
863 | } | 848 | } |
864 | 849 | ||
865 | static void sbp2_reconnect(struct work_struct *work); | 850 | static void sbp2_reconnect(struct work_struct *work); |
@@ -1121,6 +1106,10 @@ static int sbp2_probe(struct device *dev) | |||
1121 | struct Scsi_Host *shost; | 1106 | struct Scsi_Host *shost; |
1122 | u32 model, firmware_revision; | 1107 | u32 model, firmware_revision; |
1123 | 1108 | ||
1109 | if (dma_get_max_seg_size(device->card->device) > SBP2_MAX_SEG_SIZE) | ||
1110 | BUG_ON(dma_set_max_seg_size(device->card->device, | ||
1111 | SBP2_MAX_SEG_SIZE)); | ||
1112 | |||
1124 | shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt)); | 1113 | shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt)); |
1125 | if (shost == NULL) | 1114 | if (shost == NULL) |
1126 | return -ENOMEM; | 1115 | return -ENOMEM; |
@@ -1369,14 +1358,12 @@ static int | |||
1369 | sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device, | 1358 | sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device, |
1370 | struct sbp2_logical_unit *lu) | 1359 | struct sbp2_logical_unit *lu) |
1371 | { | 1360 | { |
1372 | struct scatterlist *sg; | 1361 | struct scatterlist *sg = scsi_sglist(orb->cmd); |
1373 | int sg_len, l, i, j, count; | 1362 | int i, n; |
1374 | dma_addr_t sg_addr; | 1363 | |
1375 | 1364 | n = dma_map_sg(device->card->device, sg, scsi_sg_count(orb->cmd), | |
1376 | sg = scsi_sglist(orb->cmd); | 1365 | orb->cmd->sc_data_direction); |
1377 | count = dma_map_sg(device->card->device, sg, scsi_sg_count(orb->cmd), | 1366 | if (n == 0) |
1378 | orb->cmd->sc_data_direction); | ||
1379 | if (count == 0) | ||
1380 | goto fail; | 1367 | goto fail; |
1381 | 1368 | ||
1382 | /* | 1369 | /* |
@@ -1386,7 +1373,7 @@ sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device, | |||
1386 | * as the second generation iPod which doesn't support page | 1373 | * as the second generation iPod which doesn't support page |
1387 | * tables. | 1374 | * tables. |
1388 | */ | 1375 | */ |
1389 | if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) { | 1376 | if (n == 1) { |
1390 | orb->request.data_descriptor.high = | 1377 | orb->request.data_descriptor.high = |
1391 | cpu_to_be32(lu->tgt->address_high); | 1378 | cpu_to_be32(lu->tgt->address_high); |
1392 | orb->request.data_descriptor.low = | 1379 | orb->request.data_descriptor.low = |
@@ -1396,29 +1383,9 @@ sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device, | |||
1396 | return 0; | 1383 | return 0; |
1397 | } | 1384 | } |
1398 | 1385 | ||
1399 | /* | 1386 | for_each_sg(sg, sg, n, i) { |
1400 | * Convert the scatterlist to an sbp2 page table. If any | 1387 | orb->page_table[i].high = cpu_to_be32(sg_dma_len(sg) << 16); |
1401 | * scatterlist entries are too big for sbp2, we split them as we | 1388 | orb->page_table[i].low = cpu_to_be32(sg_dma_address(sg)); |
1402 | * go. Even if we ask the block I/O layer to not give us sg | ||
1403 | * elements larger than 65535 bytes, some IOMMUs may merge sg elements | ||
1404 | * during DMA mapping, and Linux currently doesn't prevent this. | ||
1405 | */ | ||
1406 | for (i = 0, j = 0; i < count; i++, sg = sg_next(sg)) { | ||
1407 | sg_len = sg_dma_len(sg); | ||
1408 | sg_addr = sg_dma_address(sg); | ||
1409 | while (sg_len) { | ||
1410 | /* FIXME: This won't get us out of the pinch. */ | ||
1411 | if (unlikely(j >= ARRAY_SIZE(orb->page_table))) { | ||
1412 | fw_error("page table overflow\n"); | ||
1413 | goto fail_page_table; | ||
1414 | } | ||
1415 | l = min(sg_len, SBP2_MAX_SG_ELEMENT_LENGTH); | ||
1416 | orb->page_table[j].low = cpu_to_be32(sg_addr); | ||
1417 | orb->page_table[j].high = cpu_to_be32(l << 16); | ||
1418 | sg_addr += l; | ||
1419 | sg_len -= l; | ||
1420 | j++; | ||
1421 | } | ||
1422 | } | 1389 | } |
1423 | 1390 | ||
1424 | orb->page_table_bus = | 1391 | orb->page_table_bus = |
@@ -1437,13 +1404,13 @@ sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device, | |||
1437 | orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high); | 1404 | orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high); |
1438 | orb->request.data_descriptor.low = cpu_to_be32(orb->page_table_bus); | 1405 | orb->request.data_descriptor.low = cpu_to_be32(orb->page_table_bus); |
1439 | orb->request.misc |= cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT | | 1406 | orb->request.misc |= cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT | |
1440 | COMMAND_ORB_DATA_SIZE(j)); | 1407 | COMMAND_ORB_DATA_SIZE(n)); |
1441 | 1408 | ||
1442 | return 0; | 1409 | return 0; |
1443 | 1410 | ||
1444 | fail_page_table: | 1411 | fail_page_table: |
1445 | dma_unmap_sg(device->card->device, sg, scsi_sg_count(orb->cmd), | 1412 | dma_unmap_sg(device->card->device, scsi_sglist(orb->cmd), |
1446 | orb->cmd->sc_data_direction); | 1413 | scsi_sg_count(orb->cmd), orb->cmd->sc_data_direction); |
1447 | fail: | 1414 | fail: |
1448 | return -ENOMEM; | 1415 | return -ENOMEM; |
1449 | } | 1416 | } |
@@ -1456,7 +1423,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) | |||
1456 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 1423 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); |
1457 | struct sbp2_command_orb *orb; | 1424 | struct sbp2_command_orb *orb; |
1458 | unsigned int max_payload; | 1425 | unsigned int max_payload; |
1459 | int retval = SCSI_MLQUEUE_HOST_BUSY; | 1426 | int generation, retval = SCSI_MLQUEUE_HOST_BUSY; |
1460 | 1427 | ||
1461 | /* | 1428 | /* |
1462 | * Bidirectional commands are not yet implemented, and unknown | 1429 | * Bidirectional commands are not yet implemented, and unknown |
@@ -1500,6 +1467,9 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) | |||
1500 | if (cmd->sc_data_direction == DMA_FROM_DEVICE) | 1467 | if (cmd->sc_data_direction == DMA_FROM_DEVICE) |
1501 | orb->request.misc |= cpu_to_be32(COMMAND_ORB_DIRECTION); | 1468 | orb->request.misc |= cpu_to_be32(COMMAND_ORB_DIRECTION); |
1502 | 1469 | ||
1470 | generation = device->generation; | ||
1471 | smp_rmb(); /* sbp2_map_scatterlist looks at tgt->address_high */ | ||
1472 | |||
1503 | if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0) | 1473 | if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0) |
1504 | goto out; | 1474 | goto out; |
1505 | 1475 | ||
@@ -1512,7 +1482,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) | |||
1512 | if (dma_mapping_error(device->card->device, orb->base.request_bus)) | 1482 | if (dma_mapping_error(device->card->device, orb->base.request_bus)) |
1513 | goto out; | 1483 | goto out; |
1514 | 1484 | ||
1515 | sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, lu->generation, | 1485 | sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation, |
1516 | lu->command_block_agent_address + SBP2_ORB_POINTER); | 1486 | lu->command_block_agent_address + SBP2_ORB_POINTER); |
1517 | retval = 0; | 1487 | retval = 0; |
1518 | out: | 1488 | out: |
@@ -1564,6 +1534,8 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev) | |||
1564 | if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) | 1534 | if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) |
1565 | blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512); | 1535 | blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512); |
1566 | 1536 | ||
1537 | blk_queue_max_segment_size(sdev->request_queue, SBP2_MAX_SEG_SIZE); | ||
1538 | |||
1567 | return 0; | 1539 | return 0; |
1568 | } | 1540 | } |
1569 | 1541 | ||
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c index e5d1a0b64fcf..022ac4fabb67 100644 --- a/drivers/firewire/fw-transaction.c +++ b/drivers/firewire/fw-transaction.c | |||
@@ -247,7 +247,7 @@ fw_fill_request(struct fw_packet *packet, int tcode, int tlabel, | |||
247 | */ | 247 | */ |
248 | void | 248 | void |
249 | fw_send_request(struct fw_card *card, struct fw_transaction *t, | 249 | fw_send_request(struct fw_card *card, struct fw_transaction *t, |
250 | int tcode, int node_id, int generation, int speed, | 250 | int tcode, int destination_id, int generation, int speed, |
251 | unsigned long long offset, | 251 | unsigned long long offset, |
252 | void *payload, size_t length, | 252 | void *payload, size_t length, |
253 | fw_transaction_callback_t callback, void *callback_data) | 253 | fw_transaction_callback_t callback, void *callback_data) |
@@ -279,13 +279,14 @@ 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 | t->node_id = node_id; | 282 | t->node_id = destination_id; |
283 | t->tlabel = tlabel; | 283 | t->tlabel = tlabel; |
284 | t->callback = callback; | 284 | t->callback = callback; |
285 | t->callback_data = callback_data; | 285 | t->callback_data = callback_data; |
286 | 286 | ||
287 | fw_fill_request(&t->packet, tcode, t->tlabel, node_id, card->node_id, | 287 | fw_fill_request(&t->packet, tcode, t->tlabel, |
288 | generation, speed, offset, payload, length); | 288 | destination_id, card->node_id, generation, |
289 | speed, offset, payload, length); | ||
289 | t->packet.callback = transmit_complete_callback; | 290 | t->packet.callback = transmit_complete_callback; |
290 | 291 | ||
291 | list_add_tail(&t->link, &card->transaction_list); | 292 | list_add_tail(&t->link, &card->transaction_list); |
@@ -296,6 +297,45 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t, | |||
296 | } | 297 | } |
297 | EXPORT_SYMBOL(fw_send_request); | 298 | EXPORT_SYMBOL(fw_send_request); |
298 | 299 | ||
300 | struct transaction_callback_data { | ||
301 | struct completion done; | ||
302 | void *payload; | ||
303 | int rcode; | ||
304 | }; | ||
305 | |||
306 | static void transaction_callback(struct fw_card *card, int rcode, | ||
307 | void *payload, size_t length, void *data) | ||
308 | { | ||
309 | struct transaction_callback_data *d = data; | ||
310 | |||
311 | if (rcode == RCODE_COMPLETE) | ||
312 | memcpy(d->payload, payload, length); | ||
313 | d->rcode = rcode; | ||
314 | complete(&d->done); | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * fw_run_transaction - send request and sleep until transaction is completed | ||
319 | * | ||
320 | * Returns the RCODE. | ||
321 | */ | ||
322 | int fw_run_transaction(struct fw_card *card, int tcode, int destination_id, | ||
323 | int generation, int speed, unsigned long long offset, | ||
324 | void *data, size_t length) | ||
325 | { | ||
326 | struct transaction_callback_data d; | ||
327 | struct fw_transaction t; | ||
328 | |||
329 | init_completion(&d.done); | ||
330 | d.payload = data; | ||
331 | fw_send_request(card, &t, tcode, destination_id, generation, speed, | ||
332 | offset, data, length, transaction_callback, &d); | ||
333 | wait_for_completion(&d.done); | ||
334 | |||
335 | return d.rcode; | ||
336 | } | ||
337 | EXPORT_SYMBOL(fw_run_transaction); | ||
338 | |||
299 | static DEFINE_MUTEX(phy_config_mutex); | 339 | static DEFINE_MUTEX(phy_config_mutex); |
300 | static DECLARE_COMPLETION(phy_config_done); | 340 | static DECLARE_COMPLETION(phy_config_done); |
301 | 341 | ||
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h index 2ae1b0d6cb7b..027f58ce81ad 100644 --- a/drivers/firewire/fw-transaction.h +++ b/drivers/firewire/fw-transaction.h | |||
@@ -426,11 +426,14 @@ fw_core_initiate_bus_reset(struct fw_card *card, int short_reset); | |||
426 | 426 | ||
427 | void | 427 | void |
428 | fw_send_request(struct fw_card *card, struct fw_transaction *t, | 428 | fw_send_request(struct fw_card *card, struct fw_transaction *t, |
429 | int tcode, int node_id, int generation, int speed, | 429 | int tcode, int destination_id, int generation, int speed, |
430 | unsigned long long offset, | 430 | unsigned long long offset, void *data, size_t length, |
431 | void *data, size_t length, | ||
432 | fw_transaction_callback_t callback, void *callback_data); | 431 | fw_transaction_callback_t callback, void *callback_data); |
433 | 432 | ||
433 | int fw_run_transaction(struct fw_card *card, int tcode, int destination_id, | ||
434 | int generation, int speed, unsigned long long offset, | ||
435 | void *data, size_t length); | ||
436 | |||
434 | int fw_cancel_transaction(struct fw_card *card, | 437 | int fw_cancel_transaction(struct fw_card *card, |
435 | struct fw_transaction *transaction); | 438 | struct fw_transaction *transaction); |
436 | 439 | ||