Lines Matching +full:max +full:- +full:retries

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net>
14 * Stefan Richter <stefanr@s5r6.in-berlin.de>
23 #include <linux/dma-mapping.h>
25 #include <linux/firewire-constants.h>
63 * - 128kB max transfer
66 * - 36 byte inquiry
70 * - skip mode page 8
74 * - fix capacity
76 * Avoids access beyond actual disk limits on devices with an off-by-one bug.
79 * - delay inquiry
82 * - power condition
88 * - override internal blacklist
89 * Instead of adding to the built-in blacklist, use only the workarounds
91 * Useful if a blacklist entry interfered with a non-broken device.
105 ", 128kB max transfer = " __stringify(SBP2_WORKAROUND_128K_MAX_TRANS)
116 * We create one struct sbp2_logical_unit per SBP-2 Logical Unit Number Entry
136 int retries; member
145 queue_delayed_work(fw_workqueue, &lu->work, delay); in sbp2_queue_work()
172 return fw_parent_device(tgt->unit); in target_parent_device()
177 return &tgt->unit->device; in tgt_dev()
182 return &lu->tgt->unit->device; in lu_dev()
190 #define SBP2_RETRY_LIMIT 0xf /* 15 retries */
200 * The maximum SBP-2 data buffer size is 0xffff. We quadlet-align this
335 /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
342 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
352 /* PL-3507 bridge with Prolific firmware */ {
362 /* Datafab MD2-FW2 with Symbios/LSILogic SYM13FW500 bridge */ {
368 * iPod 2nd generation: needs 128k max transfer size workaround
426 memcpy(status.data, payload + 8, length - 8); in sbp2_status_write()
430 "non-ORB related status write, not handled\n"); in sbp2_status_write()
436 spin_lock_irqsave(&lu->tgt->lock, flags); in sbp2_status_write()
437 list_for_each_entry(iter, &lu->orb_list, link) { in sbp2_status_write()
439 STATUS_GET_ORB_LOW(status) == iter->request_bus) { in sbp2_status_write()
440 iter->rcode = RCODE_COMPLETE; in sbp2_status_write()
441 list_del(&iter->link); in sbp2_status_write()
446 spin_unlock_irqrestore(&lu->tgt->lock, flags); in sbp2_status_write()
449 orb->callback(orb, &status); in sbp2_status_write()
450 kref_put(&orb->kref, free_orb); /* orb callback reference */ in sbp2_status_write()
473 spin_lock_irqsave(&orb->lu->tgt->lock, flags); in complete_transaction()
475 if (orb->rcode == -1) in complete_transaction()
476 orb->rcode = rcode; in complete_transaction()
477 if (orb->rcode != RCODE_COMPLETE) { in complete_transaction()
478 list_del(&orb->link); in complete_transaction()
479 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags); in complete_transaction()
481 orb->callback(orb, NULL); in complete_transaction()
482 kref_put(&orb->kref, free_orb); /* orb callback reference */ in complete_transaction()
484 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags); in complete_transaction()
487 kref_put(&orb->kref, free_orb); /* transaction callback reference */ in complete_transaction()
493 struct fw_device *device = target_parent_device(lu->tgt); in sbp2_send_orb()
498 orb_pointer.low = cpu_to_be32(orb->request_bus); in sbp2_send_orb()
500 orb->lu = lu; in sbp2_send_orb()
501 spin_lock_irqsave(&lu->tgt->lock, flags); in sbp2_send_orb()
502 list_add_tail(&orb->link, &lu->orb_list); in sbp2_send_orb()
503 spin_unlock_irqrestore(&lu->tgt->lock, flags); in sbp2_send_orb()
505 kref_get(&orb->kref); /* transaction callback reference */ in sbp2_send_orb()
506 kref_get(&orb->kref); /* orb callback reference */ in sbp2_send_orb()
508 fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST, in sbp2_send_orb()
509 node_id, generation, device->max_speed, offset, in sbp2_send_orb()
515 struct fw_device *device = target_parent_device(lu->tgt); in sbp2_cancel_orbs()
518 int retval = -ENOENT; in sbp2_cancel_orbs()
521 spin_lock_irq(&lu->tgt->lock); in sbp2_cancel_orbs()
522 list_splice_init(&lu->orb_list, &list); in sbp2_cancel_orbs()
523 spin_unlock_irq(&lu->tgt->lock); in sbp2_cancel_orbs()
527 if (fw_cancel_transaction(device->card, &orb->t) == 0) in sbp2_cancel_orbs()
530 orb->rcode = RCODE_CANCELLED; in sbp2_cancel_orbs()
531 orb->callback(orb, NULL); in sbp2_cancel_orbs()
532 kref_put(&orb->kref, free_orb); /* orb callback reference */ in sbp2_cancel_orbs()
545 memcpy(&orb->status, status, sizeof(*status)); in complete_management_orb()
546 complete(&orb->done); in complete_management_orb()
553 struct fw_device *device = target_parent_device(lu->tgt); in sbp2_send_management_orb()
556 int retval = -ENOMEM; in sbp2_send_management_orb()
563 return -ENOMEM; in sbp2_send_management_orb()
565 kref_init(&orb->base.kref); in sbp2_send_management_orb()
566 orb->response_bus = in sbp2_send_management_orb()
567 dma_map_single(device->card->device, &orb->response, in sbp2_send_management_orb()
568 sizeof(orb->response), DMA_FROM_DEVICE); in sbp2_send_management_orb()
569 if (dma_mapping_error(device->card->device, orb->response_bus)) in sbp2_send_management_orb()
572 orb->request.response.high = 0; in sbp2_send_management_orb()
573 orb->request.response.low = cpu_to_be32(orb->response_bus); in sbp2_send_management_orb()
575 orb->request.misc = cpu_to_be32( in sbp2_send_management_orb()
579 orb->request.length = cpu_to_be32( in sbp2_send_management_orb()
580 MANAGEMENT_ORB_RESPONSE_LENGTH(sizeof(orb->response))); in sbp2_send_management_orb()
582 orb->request.status_fifo.high = in sbp2_send_management_orb()
583 cpu_to_be32(lu->address_handler.offset >> 32); in sbp2_send_management_orb()
584 orb->request.status_fifo.low = in sbp2_send_management_orb()
585 cpu_to_be32(lu->address_handler.offset); in sbp2_send_management_orb()
589 orb->request.misc |= cpu_to_be32( in sbp2_send_management_orb()
592 timeout = lu->tgt->mgt_orb_timeout; in sbp2_send_management_orb()
597 init_completion(&orb->done); in sbp2_send_management_orb()
598 orb->base.callback = complete_management_orb; in sbp2_send_management_orb()
600 orb->base.request_bus = in sbp2_send_management_orb()
601 dma_map_single(device->card->device, &orb->request, in sbp2_send_management_orb()
602 sizeof(orb->request), DMA_TO_DEVICE); in sbp2_send_management_orb()
603 if (dma_mapping_error(device->card->device, orb->base.request_bus)) in sbp2_send_management_orb()
606 sbp2_send_orb(&orb->base, lu, node_id, generation, in sbp2_send_management_orb()
607 lu->tgt->management_agent_address); in sbp2_send_management_orb()
609 wait_for_completion_timeout(&orb->done, msecs_to_jiffies(timeout)); in sbp2_send_management_orb()
611 retval = -EIO; in sbp2_send_management_orb()
614 orb->base.rcode); in sbp2_send_management_orb()
618 if (orb->base.rcode != RCODE_COMPLETE) { in sbp2_send_management_orb()
620 orb->base.rcode); in sbp2_send_management_orb()
624 if (STATUS_GET_RESPONSE(orb->status) != 0 || in sbp2_send_management_orb()
625 STATUS_GET_SBP_STATUS(orb->status) != 0) { in sbp2_send_management_orb()
627 STATUS_GET_RESPONSE(orb->status), in sbp2_send_management_orb()
628 STATUS_GET_SBP_STATUS(orb->status)); in sbp2_send_management_orb()
634 dma_unmap_single(device->card->device, orb->base.request_bus, in sbp2_send_management_orb()
635 sizeof(orb->request), DMA_TO_DEVICE); in sbp2_send_management_orb()
637 dma_unmap_single(device->card->device, orb->response_bus, in sbp2_send_management_orb()
638 sizeof(orb->response), DMA_FROM_DEVICE); in sbp2_send_management_orb()
641 memcpy(response, orb->response, sizeof(orb->response)); in sbp2_send_management_orb()
642 kref_put(&orb->base.kref, free_orb); in sbp2_send_management_orb()
649 struct fw_device *device = target_parent_device(lu->tgt); in sbp2_agent_reset()
652 fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, in sbp2_agent_reset()
653 lu->tgt->node_id, lu->generation, device->max_speed, in sbp2_agent_reset()
654 lu->command_block_agent_address + SBP2_AGENT_RESET, in sbp2_agent_reset()
666 struct fw_device *device = target_parent_device(lu->tgt); in sbp2_agent_reset_no_wait()
674 fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST, in sbp2_agent_reset_no_wait()
675 lu->tgt->node_id, lu->generation, device->max_speed, in sbp2_agent_reset_no_wait()
676 lu->command_block_agent_address + SBP2_AGENT_RESET, in sbp2_agent_reset_no_wait()
682 spin_lock_irq(&tgt->lock); in sbp2_allow_block()
683 --tgt->dont_block; in sbp2_allow_block()
684 spin_unlock_irq(&tgt->lock); in sbp2_allow_block()
688 * Blocks lu->tgt if all of the following conditions are met:
689 * - Login, INQUIRY, and high-level SCSI setup of all of the target's
691 * - lu->generation is stale.
693 * Note, scsi_block_requests() must be called while holding tgt->lock,
699 struct sbp2_target *tgt = lu->tgt; in sbp2_conditionally_block()
700 struct fw_card *card = target_parent_device(tgt)->card; in sbp2_conditionally_block()
705 spin_lock_irqsave(&tgt->lock, flags); in sbp2_conditionally_block()
706 if (!tgt->dont_block && !lu->blocked && in sbp2_conditionally_block()
707 lu->generation != card->generation) { in sbp2_conditionally_block()
708 lu->blocked = true; in sbp2_conditionally_block()
709 if (++tgt->blocked == 1) in sbp2_conditionally_block()
712 spin_unlock_irqrestore(&tgt->lock, flags); in sbp2_conditionally_block()
716 * Unblocks lu->tgt as soon as all its logical units can be unblocked.
718 * tgt->lock protected section. On the other hand, running it inside
719 * the section might clash with shost->host_lock.
723 struct sbp2_target *tgt = lu->tgt; in sbp2_conditionally_unblock()
724 struct fw_card *card = target_parent_device(tgt)->card; in sbp2_conditionally_unblock()
729 spin_lock_irq(&tgt->lock); in sbp2_conditionally_unblock()
730 if (lu->blocked && lu->generation == card->generation) { in sbp2_conditionally_unblock()
731 lu->blocked = false; in sbp2_conditionally_unblock()
732 unblock = --tgt->blocked == 0; in sbp2_conditionally_unblock()
734 spin_unlock_irq(&tgt->lock); in sbp2_conditionally_unblock()
743 * tgt->lock protected section. On the other hand, running it inside
744 * the section might clash with shost->host_lock.
751 spin_lock_irq(&tgt->lock); in sbp2_unblock()
752 ++tgt->dont_block; in sbp2_unblock()
753 spin_unlock_irq(&tgt->lock); in sbp2_unblock()
771 * - The single-phase retry protocol is supported by all SBP-2 devices, but the
774 * - The dual-phase retry protocol is optional to implement, and if not
775 * supported, writes to the dual-phase portion of the register will be
776 * ignored. We try to write the original 1394-1995 default here.
777 * - In the case of devices that are also SBP-3-compliant, all writes are
778 * ignored, as the register is read-only, but contains single-phase retry of
779 * 15, which is what we're trying to set for all SBP-2 device anyway, so this
782 * See section 8.3.2.3.5 of the 1394-1995 spec, section 6.2 of the SBP-2 spec,
783 * and section 6.4 of the SBP-3 spec for further details.
787 struct fw_device *device = target_parent_device(lu->tgt); in sbp2_set_busy_timeout()
790 fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, in sbp2_set_busy_timeout()
791 lu->tgt->node_id, lu->generation, device->max_speed, in sbp2_set_busy_timeout()
801 struct sbp2_target *tgt = lu->tgt; in sbp2_login()
811 generation = device->generation; in sbp2_login()
813 node_id = device->node_id; in sbp2_login()
814 local_node_id = device->card->node_id; in sbp2_login()
816 /* If this is a re-login attempt, log out, or we might be rejected. */ in sbp2_login()
817 if (lu->has_sdev) in sbp2_login()
818 sbp2_send_management_orb(lu, device->node_id, generation, in sbp2_login()
819 SBP2_LOGOUT_REQUEST, lu->login_id, NULL); in sbp2_login()
822 SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) { in sbp2_login()
823 if (lu->retries++ < 5) { in sbp2_login()
827 lu->lun); in sbp2_login()
829 sbp2_unblock(lu->tgt); in sbp2_login()
834 tgt->node_id = node_id; in sbp2_login()
835 tgt->address_high = local_node_id << 16; in sbp2_login()
837 lu->generation = generation; in sbp2_login()
839 lu->command_block_agent_address = in sbp2_login()
842 lu->login_id = be32_to_cpu(response.misc) & 0xffff; in sbp2_login()
844 dev_notice(tgt_dev(tgt), "logged in to LUN %04x (%d retries)\n", in sbp2_login()
845 lu->lun, lu->retries); in sbp2_login()
850 lu->workfn = sbp2_reconnect; in sbp2_login()
853 /* This was a re-login. */ in sbp2_login()
854 if (lu->has_sdev) { in sbp2_login()
861 if (lu->tgt->workarounds & SBP2_WORKAROUND_DELAY_INQUIRY) in sbp2_login()
865 sdev = __scsi_add_device(shost, 0, 0, sbp2_lun2int(lu->lun), lu); in sbp2_login()
880 if (generation != device->card->generation) { in sbp2_login()
887 lu->has_sdev = true; in sbp2_login()
895 generation = device->generation; in sbp2_login()
898 sbp2_send_management_orb(lu, device->node_id, generation, in sbp2_login()
899 SBP2_LOGOUT_REQUEST, lu->login_id, NULL); in sbp2_login()
902 * lu->work already. Reset the work from reconnect to login. in sbp2_login()
904 lu->workfn = sbp2_login; in sbp2_login()
911 struct sbp2_target *tgt = lu->tgt; in sbp2_reconnect()
918 generation = device->generation; in sbp2_reconnect()
920 node_id = device->node_id; in sbp2_reconnect()
921 local_node_id = device->card->node_id; in sbp2_reconnect()
925 lu->login_id, NULL) < 0) { in sbp2_reconnect()
934 if (generation == device->card->generation || in sbp2_reconnect()
935 lu->retries++ >= 5) { in sbp2_reconnect()
937 lu->retries = 0; in sbp2_reconnect()
938 lu->workfn = sbp2_login; in sbp2_reconnect()
945 tgt->node_id = node_id; in sbp2_reconnect()
946 tgt->address_high = local_node_id << 16; in sbp2_reconnect()
948 lu->generation = generation; in sbp2_reconnect()
950 dev_notice(tgt_dev(tgt), "reconnected to LUN %04x (%d retries)\n", in sbp2_reconnect()
951 lu->lun, lu->retries); in sbp2_reconnect()
962 lu->workfn(work); in sbp2_lu_workfn()
971 return -ENOMEM; in sbp2_add_logical_unit()
973 lu->address_handler.length = 0x100; in sbp2_add_logical_unit()
974 lu->address_handler.address_callback = sbp2_status_write; in sbp2_add_logical_unit()
975 lu->address_handler.callback_data = lu; in sbp2_add_logical_unit()
977 if (fw_core_add_address_handler(&lu->address_handler, in sbp2_add_logical_unit()
980 return -ENOMEM; in sbp2_add_logical_unit()
983 lu->tgt = tgt; in sbp2_add_logical_unit()
984 lu->lun = lun_entry & 0xffff; in sbp2_add_logical_unit()
985 lu->login_id = INVALID_LOGIN_ID; in sbp2_add_logical_unit()
986 lu->retries = 0; in sbp2_add_logical_unit()
987 lu->has_sdev = false; in sbp2_add_logical_unit()
988 lu->blocked = false; in sbp2_add_logical_unit()
989 ++tgt->dont_block; in sbp2_add_logical_unit()
990 INIT_LIST_HEAD(&lu->orb_list); in sbp2_add_logical_unit()
991 lu->workfn = sbp2_login; in sbp2_add_logical_unit()
992 INIT_DELAYED_WORK(&lu->work, sbp2_lu_workfn); in sbp2_add_logical_unit()
994 list_add_tail(&lu->link, &tgt->lu_list); in sbp2_add_logical_unit()
1002 tgt->guid = (u64)leaf[1] << 32 | leaf[2]; in sbp2_get_unit_unique_id()
1015 return -ENOMEM; in sbp2_scan_logical_unit_dir()
1030 tgt->management_agent_address = in sbp2_scan_unit_dir()
1035 tgt->directory_id = value; in sbp2_scan_unit_dir()
1048 tgt->mgt_orb_timeout = (value >> 8 & 0xff) * 500; in sbp2_scan_unit_dir()
1053 return -ENOMEM; in sbp2_scan_unit_dir()
1057 sbp2_get_unit_unique_id(tgt, ci.p - 1 + value); in sbp2_scan_unit_dir()
1062 if (sbp2_scan_logical_unit_dir(tgt, ci.p - 1 + value) < 0) in sbp2_scan_unit_dir()
1063 return -ENOMEM; in sbp2_scan_unit_dir()
1071 * Per section 7.4.8 of the SBP-2 spec, a mgt_ORB_timeout value can be
1077 unsigned int timeout = tgt->mgt_orb_timeout; in sbp2_clamp_management_orb_timeout()
1083 tgt->mgt_orb_timeout = clamp_val(timeout, 5000, 40000); in sbp2_clamp_management_orb_timeout()
1094 "Please notify linux1394-devel@lists.sf.net " in sbp2_init_workarounds()
1118 tgt->workarounds = w; in sbp2_init_workarounds()
1133 if (device->is_local) in sbp2_probe()
1134 return -ENODEV; in sbp2_probe()
1138 return -ENOMEM; in sbp2_probe()
1140 tgt = (struct sbp2_target *)shost->hostdata; in sbp2_probe()
1141 dev_set_drvdata(&unit->device, tgt); in sbp2_probe()
1142 tgt->unit = unit; in sbp2_probe()
1143 INIT_LIST_HEAD(&tgt->lu_list); in sbp2_probe()
1144 spin_lock_init(&tgt->lock); in sbp2_probe()
1145 tgt->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4]; in sbp2_probe()
1150 shost->max_cmd_len = SBP2_MAX_CDB_SIZE; in sbp2_probe()
1152 if (scsi_add_host_with_dma(shost, &unit->device, in sbp2_probe()
1153 device->card->device) < 0) in sbp2_probe()
1157 tgt->directory_id = ((unit->directory - device->config_rom) * 4 in sbp2_probe()
1163 if (sbp2_scan_unit_dir(tgt, unit->directory, &model, in sbp2_probe()
1172 * and so on up to 4096 bytes. The SBP-2 max_payload field in sbp2_probe()
1173 * specifies the max payload size as 2 ^ (max_payload + 2), so in sbp2_probe()
1176 tgt->max_payload = min3(device->max_speed + 7, 10U, in sbp2_probe()
1177 device->card->max_receive - 1); in sbp2_probe()
1179 /* Do the login in a workqueue so we can easily reschedule retries. */ in sbp2_probe()
1180 list_for_each_entry(lu, &tgt->lu_list, link) in sbp2_probe()
1187 return -ENOMEM; in sbp2_probe()
1191 return -ENOMEM; in sbp2_probe()
1196 struct sbp2_target *tgt = dev_get_drvdata(&unit->device); in sbp2_update()
1202 * Fw-core serializes sbp2_update() against sbp2_remove(). in sbp2_update()
1203 * Iteration over tgt->lu_list is therefore safe here. in sbp2_update()
1205 list_for_each_entry(lu, &tgt->lu_list, link) { in sbp2_update()
1207 lu->retries = 0; in sbp2_update()
1215 struct sbp2_target *tgt = dev_get_drvdata(&unit->device); in sbp2_remove()
1224 list_for_each_entry_safe(lu, next, &tgt->lu_list, link) { in sbp2_remove()
1225 cancel_delayed_work_sync(&lu->work); in sbp2_remove()
1226 sdev = scsi_device_lookup(shost, 0, 0, sbp2_lun2int(lu->lun)); in sbp2_remove()
1231 if (lu->login_id != INVALID_LOGIN_ID) { in sbp2_remove()
1234 * tgt->node_id may be obsolete here if we failed in sbp2_remove()
1238 generation = device->generation; in sbp2_remove()
1240 node_id = device->node_id; in sbp2_remove()
1243 lu->login_id, NULL); in sbp2_remove()
1245 fw_core_remove_address_handler(&lu->address_handler); in sbp2_remove()
1246 list_del(&lu->link); in sbp2_remove()
1250 dev_notice(&unit->device, "released target %d:0:0\n", shost->host_no); in sbp2_remove()
1283 scsi_dma_unmap(orb->cmd); in sbp2_unmap_scatterlist()
1285 if (orb->request.misc & cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT)) in sbp2_unmap_scatterlist()
1286 dma_unmap_single(card_device, orb->page_table_bus, in sbp2_unmap_scatterlist()
1287 sizeof(orb->page_table), DMA_TO_DEVICE); in sbp2_unmap_scatterlist()
1298 * Status block format vendor-dependent (3) in sbp2_status_to_sense_data()
1341 struct fw_device *device = target_parent_device(base_orb->lu->tgt); in complete_command_orb()
1346 sbp2_agent_reset_no_wait(base_orb->lu); in complete_command_orb()
1364 orb->cmd->sense_buffer); in complete_command_orb()
1368 * went wrong, typically a bus reset happened mid-orb in complete_command_orb()
1372 sbp2_conditionally_block(base_orb->lu); in complete_command_orb()
1375 dma_unmap_single(device->card->device, orb->base.request_bus, in complete_command_orb()
1376 sizeof(orb->request), DMA_TO_DEVICE); in complete_command_orb()
1377 sbp2_unmap_scatterlist(device->card->device, orb); in complete_command_orb()
1379 orb->cmd->result = result; in complete_command_orb()
1380 scsi_done(orb->cmd); in complete_command_orb()
1386 struct scatterlist *sg = scsi_sglist(orb->cmd); in sbp2_map_scatterlist()
1389 n = scsi_dma_map(orb->cmd); in sbp2_map_scatterlist()
1401 orb->request.data_descriptor.high = in sbp2_map_scatterlist()
1402 cpu_to_be32(lu->tgt->address_high); in sbp2_map_scatterlist()
1403 orb->request.data_descriptor.low = in sbp2_map_scatterlist()
1405 orb->request.misc |= in sbp2_map_scatterlist()
1411 orb->page_table[i].high = cpu_to_be32(sg_dma_len(sg) << 16); in sbp2_map_scatterlist()
1412 orb->page_table[i].low = cpu_to_be32(sg_dma_address(sg)); in sbp2_map_scatterlist()
1415 orb->page_table_bus = in sbp2_map_scatterlist()
1416 dma_map_single(device->card->device, orb->page_table, in sbp2_map_scatterlist()
1417 sizeof(orb->page_table), DMA_TO_DEVICE); in sbp2_map_scatterlist()
1418 if (dma_mapping_error(device->card->device, orb->page_table_bus)) in sbp2_map_scatterlist()
1428 orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high); in sbp2_map_scatterlist()
1429 orb->request.data_descriptor.low = cpu_to_be32(orb->page_table_bus); in sbp2_map_scatterlist()
1430 orb->request.misc |= cpu_to_be32(COMMAND_ORB_PAGE_TABLE_PRESENT | in sbp2_map_scatterlist()
1436 scsi_dma_unmap(orb->cmd); in sbp2_map_scatterlist()
1438 return -ENOMEM; in sbp2_map_scatterlist()
1446 struct sbp2_logical_unit *lu = cmd->device->hostdata; in sbp2_scsi_queuecommand()
1447 struct fw_device *device = target_parent_device(lu->tgt); in sbp2_scsi_queuecommand()
1456 orb->base.rcode = -1; in sbp2_scsi_queuecommand()
1457 kref_init(&orb->base.kref); in sbp2_scsi_queuecommand()
1458 orb->cmd = cmd; in sbp2_scsi_queuecommand()
1459 orb->request.next.high = cpu_to_be32(SBP2_ORB_NULL); in sbp2_scsi_queuecommand()
1460 orb->request.misc = cpu_to_be32( in sbp2_scsi_queuecommand()
1461 COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) | in sbp2_scsi_queuecommand()
1462 COMMAND_ORB_SPEED(device->max_speed) | in sbp2_scsi_queuecommand()
1465 if (cmd->sc_data_direction == DMA_FROM_DEVICE) in sbp2_scsi_queuecommand()
1466 orb->request.misc |= cpu_to_be32(COMMAND_ORB_DIRECTION); in sbp2_scsi_queuecommand()
1468 generation = device->generation; in sbp2_scsi_queuecommand()
1469 smp_rmb(); /* sbp2_map_scatterlist looks at tgt->address_high */ in sbp2_scsi_queuecommand()
1474 memcpy(orb->request.command_block, cmd->cmnd, cmd->cmd_len); in sbp2_scsi_queuecommand()
1476 orb->base.callback = complete_command_orb; in sbp2_scsi_queuecommand()
1477 orb->base.request_bus = in sbp2_scsi_queuecommand()
1478 dma_map_single(device->card->device, &orb->request, in sbp2_scsi_queuecommand()
1479 sizeof(orb->request), DMA_TO_DEVICE); in sbp2_scsi_queuecommand()
1480 if (dma_mapping_error(device->card->device, orb->base.request_bus)) { in sbp2_scsi_queuecommand()
1481 sbp2_unmap_scatterlist(device->card->device, orb); in sbp2_scsi_queuecommand()
1485 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation, in sbp2_scsi_queuecommand()
1486 lu->command_block_agent_address + SBP2_ORB_POINTER); in sbp2_scsi_queuecommand()
1489 kref_put(&orb->base.kref, free_orb); in sbp2_scsi_queuecommand()
1495 struct sbp2_logical_unit *lu = sdev->hostdata; in sbp2_scsi_sdev_init()
1497 /* (Re-)Adding logical units via the SCSI stack is not supported. */ in sbp2_scsi_sdev_init()
1499 return -ENOSYS; in sbp2_scsi_sdev_init()
1501 sdev->allow_restart = 1; in sbp2_scsi_sdev_init()
1503 if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36) in sbp2_scsi_sdev_init()
1504 sdev->inquiry_len = 36; in sbp2_scsi_sdev_init()
1512 struct sbp2_logical_unit *lu = sdev->hostdata; in sbp2_scsi_sdev_configure()
1514 sdev->use_10_for_rw = 1; in sbp2_scsi_sdev_configure()
1517 sdev->manage_system_start_stop = 1; in sbp2_scsi_sdev_configure()
1518 sdev->manage_runtime_start_stop = 1; in sbp2_scsi_sdev_configure()
1519 sdev->manage_shutdown = 1; in sbp2_scsi_sdev_configure()
1522 if (sdev->type == TYPE_ROM) in sbp2_scsi_sdev_configure()
1523 sdev->use_10_for_ms = 1; in sbp2_scsi_sdev_configure()
1525 if (sdev->type == TYPE_DISK && in sbp2_scsi_sdev_configure()
1526 lu->tgt->workarounds & SBP2_WORKAROUND_MODE_SENSE_8) in sbp2_scsi_sdev_configure()
1527 sdev->skip_ms_page_8 = 1; in sbp2_scsi_sdev_configure()
1529 if (lu->tgt->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) in sbp2_scsi_sdev_configure()
1530 sdev->fix_capacity = 1; in sbp2_scsi_sdev_configure()
1532 if (lu->tgt->workarounds & SBP2_WORKAROUND_POWER_CONDITION) in sbp2_scsi_sdev_configure()
1533 sdev->start_stop_pwr_cond = 1; in sbp2_scsi_sdev_configure()
1535 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) in sbp2_scsi_sdev_configure()
1536 lim->max_hw_sectors = 128 * 1024 / 512; in sbp2_scsi_sdev_configure()
1543 * called when a command has timed-out for some reason.
1547 struct sbp2_logical_unit *lu = cmd->device->hostdata; in sbp2_scsi_abort()
1558 * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal)
1561 * identifier as per SAM-2...SAM-4 annex A.
1572 lu = sdev->hostdata; in sbp2_sysfs_ieee1394_id_show()
1575 (unsigned long long)lu->tgt->guid, in sbp2_sysfs_ieee1394_id_show()
1576 lu->tgt->directory_id, lu->lun); in sbp2_sysfs_ieee1394_id_show()
1590 .name = "SBP-2 IEEE-1394",
1596 .this_id = -1,
1608 /* Provide a module alias so root-on-sbp2 initrds don't break. */