Lines Matching refs:lu
142 static void sbp2_queue_work(struct sbp2_logical_unit *lu, unsigned long delay)
144 queue_delayed_work(fw_workqueue, &lu->work, delay);
179 static const struct device *lu_dev(const struct sbp2_logical_unit *lu)
181 return &lu->tgt->unit->device;
261 struct sbp2_logical_unit *lu;
410 struct sbp2_logical_unit *lu = callback_data;
428 dev_notice(lu_dev(lu),
435 spin_lock_irqsave(&lu->tgt->lock, flags);
436 list_for_each_entry(iter, &lu->orb_list, link) {
445 spin_unlock_irqrestore(&lu->tgt->lock, flags);
451 dev_err(lu_dev(lu), "status write for unknown ORB\n");
472 spin_lock_irqsave(&orb->lu->tgt->lock, flags);
478 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags);
483 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags);
489 static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu,
492 struct fw_device *device = target_parent_device(lu->tgt);
499 orb->lu = lu;
500 spin_lock_irqsave(&lu->tgt->lock, flags);
501 list_add_tail(&orb->link, &lu->orb_list);
502 spin_unlock_irqrestore(&lu->tgt->lock, flags);
512 static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu)
514 struct fw_device *device = target_parent_device(lu->tgt);
520 spin_lock_irq(&lu->tgt->lock);
521 list_splice_init(&lu->orb_list, &list);
522 spin_unlock_irq(&lu->tgt->lock);
548 static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
552 struct fw_device *device = target_parent_device(lu->tgt);
582 cpu_to_be32(lu->address_handler.offset >> 32);
584 cpu_to_be32(lu->address_handler.offset);
591 timeout = lu->tgt->mgt_orb_timeout;
605 sbp2_send_orb(&orb->base, lu, node_id, generation,
606 lu->tgt->management_agent_address);
611 if (sbp2_cancel_orbs(lu) == 0) {
612 dev_err(lu_dev(lu), "ORB reply timed out, rcode 0x%02x\n",
618 dev_err(lu_dev(lu), "management write failed, rcode 0x%02x\n",
625 dev_err(lu_dev(lu), "error status: %d:%d\n",
646 static void sbp2_agent_reset(struct sbp2_logical_unit *lu)
648 struct fw_device *device = target_parent_device(lu->tgt);
652 lu->tgt->node_id, lu->generation, device->max_speed,
653 lu->command_block_agent_address + SBP2_AGENT_RESET,
663 static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu)
665 struct fw_device *device = target_parent_device(lu->tgt);
674 lu->tgt->node_id, lu->generation, device->max_speed,
675 lu->command_block_agent_address + SBP2_AGENT_RESET,
687 * Blocks lu->tgt if all of the following conditions are met:
690 * - lu->generation is stale.
696 static void sbp2_conditionally_block(struct sbp2_logical_unit *lu)
698 struct sbp2_target *tgt = lu->tgt;
705 if (!tgt->dont_block && !lu->blocked &&
706 lu->generation != card->generation) {
707 lu->blocked = true;
715 * Unblocks lu->tgt as soon as all its logical units can be unblocked.
720 static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu)
722 struct sbp2_target *tgt = lu->tgt;
729 if (lu->blocked && lu->generation == card->generation) {
730 lu->blocked = false;
784 static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
786 struct fw_device *device = target_parent_device(lu->tgt);
790 lu->tgt->node_id, lu->generation, device->max_speed,
798 struct sbp2_logical_unit *lu =
800 struct sbp2_target *tgt = lu->tgt;
816 if (lu->has_sdev)
817 sbp2_send_management_orb(lu, device->node_id, generation,
818 SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
820 if (sbp2_send_management_orb(lu, node_id, generation,
821 SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) {
822 if (lu->retries++ < 5) {
823 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
826 lu->lun);
828 sbp2_unblock(lu->tgt);
836 lu->generation = generation;
838 lu->command_block_agent_address =
841 lu->login_id = be32_to_cpu(response.misc) & 0xffff;
844 lu->lun, lu->retries);
847 sbp2_set_busy_timeout(lu);
849 lu->workfn = sbp2_reconnect;
850 sbp2_agent_reset(lu);
853 if (lu->has_sdev) {
854 sbp2_cancel_orbs(lu);
855 sbp2_conditionally_unblock(lu);
860 if (lu->tgt->workarounds & SBP2_WORKAROUND_DELAY_INQUIRY)
864 sdev = __scsi_add_device(shost, 0, 0, sbp2_lun2int(lu->lun), lu);
886 lu->has_sdev = true;
897 sbp2_send_management_orb(lu, device->node_id, generation,
898 SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
901 * lu->work already. Reset the work from reconnect to login.
903 lu->workfn = sbp2_login;
908 struct sbp2_logical_unit *lu =
910 struct sbp2_target *tgt = lu->tgt;
922 if (sbp2_send_management_orb(lu, node_id, generation,
924 lu->login_id, NULL) < 0) {
934 lu->retries++ >= 5) {
936 lu->retries = 0;
937 lu->workfn = sbp2_login;
939 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
947 lu->generation = generation;
950 lu->lun, lu->retries);
952 sbp2_agent_reset(lu);
953 sbp2_cancel_orbs(lu);
954 sbp2_conditionally_unblock(lu);
959 struct sbp2_logical_unit *lu = container_of(to_delayed_work(work),
961 lu->workfn(work);
966 struct sbp2_logical_unit *lu;
968 lu = kmalloc(sizeof(*lu), GFP_KERNEL);
969 if (!lu)
972 lu->address_handler.length = 0x100;
973 lu->address_handler.address_callback = sbp2_status_write;
974 lu->address_handler.callback_data = lu;
976 if (fw_core_add_address_handler(&lu->address_handler,
978 kfree(lu);
982 lu->tgt = tgt;
983 lu->lun = lun_entry & 0xffff;
984 lu->login_id = INVALID_LOGIN_ID;
985 lu->retries = 0;
986 lu->has_sdev = false;
987 lu->blocked = false;
989 INIT_LIST_HEAD(&lu->orb_list);
990 lu->workfn = sbp2_login;
991 INIT_DELAYED_WORK(&lu->work, sbp2_lu_workfn);
993 list_add_tail(&lu->link, &tgt->lu_list);
1127 struct sbp2_logical_unit *lu;
1179 list_for_each_entry(lu, &tgt->lu_list, link)
1180 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
1196 struct sbp2_logical_unit *lu;
1204 list_for_each_entry(lu, &tgt->lu_list, link) {
1205 sbp2_conditionally_block(lu);
1206 lu->retries = 0;
1207 sbp2_queue_work(lu, 0);
1215 struct sbp2_logical_unit *lu, *next;
1223 list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
1224 cancel_delayed_work_sync(&lu->work);
1225 sdev = scsi_device_lookup(shost, 0, 0, sbp2_lun2int(lu->lun));
1230 if (lu->login_id != INVALID_LOGIN_ID) {
1240 sbp2_send_management_orb(lu, node_id, generation,
1242 lu->login_id, NULL);
1244 fw_core_remove_address_handler(&lu->address_handler);
1245 list_del(&lu->link);
1246 kfree(lu);
1340 struct fw_device *device = target_parent_device(base_orb->lu->tgt);
1345 sbp2_agent_reset_no_wait(base_orb->lu);
1371 sbp2_conditionally_block(base_orb->lu);
1383 struct fw_device *device, struct sbp2_logical_unit *lu)
1401 cpu_to_be32(lu->tgt->address_high);
1427 orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high);
1445 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1446 struct fw_device *device = target_parent_device(lu->tgt);
1460 COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) |
1470 if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0)
1484 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
1485 lu->command_block_agent_address + SBP2_ORB_POINTER);
1494 struct sbp2_logical_unit *lu = sdev->hostdata;
1497 if (!lu)
1508 if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36)
1516 struct sbp2_logical_unit *lu = sdev->hostdata;
1527 lu->tgt->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
1530 if (lu->tgt->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
1533 if (lu->tgt->workarounds & SBP2_WORKAROUND_POWER_CONDITION)
1536 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
1548 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1550 dev_notice(lu_dev(lu), "sbp2_scsi_abort\n");
1551 sbp2_agent_reset(lu);
1552 sbp2_cancel_orbs(lu);
1568 struct sbp2_logical_unit *lu;
1573 lu = sdev->hostdata;
1576 (unsigned long long)lu->tgt->guid,
1577 lu->tgt->directory_id, lu->lun);