Lines Matching refs:tgt

119 	struct sbp2_target *tgt;
169 static struct fw_device *target_parent_device(struct sbp2_target *tgt)
171 return fw_parent_device(tgt->unit);
174 static const struct device *tgt_dev(const struct sbp2_target *tgt)
176 return &tgt->unit->device;
181 return &lu->tgt->unit->device;
435 spin_lock_irqsave(&lu->tgt->lock, flags);
445 spin_unlock_irqrestore(&lu->tgt->lock, flags);
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);
492 struct fw_device *device = target_parent_device(lu->tgt);
500 spin_lock_irqsave(&lu->tgt->lock, flags);
502 spin_unlock_irqrestore(&lu->tgt->lock, flags);
514 struct fw_device *device = target_parent_device(lu->tgt);
520 spin_lock_irq(&lu->tgt->lock);
522 spin_unlock_irq(&lu->tgt->lock);
552 struct fw_device *device = target_parent_device(lu->tgt);
591 timeout = lu->tgt->mgt_orb_timeout;
606 lu->tgt->management_agent_address);
648 struct fw_device *device = target_parent_device(lu->tgt);
652 lu->tgt->node_id, lu->generation, device->max_speed,
665 struct fw_device *device = target_parent_device(lu->tgt);
674 lu->tgt->node_id, lu->generation, device->max_speed,
679 static inline void sbp2_allow_block(struct sbp2_target *tgt)
681 spin_lock_irq(&tgt->lock);
682 --tgt->dont_block;
683 spin_unlock_irq(&tgt->lock);
687 * Blocks lu->tgt if all of the following conditions are met:
692 * Note, scsi_block_requests() must be called while holding tgt->lock,
698 struct sbp2_target *tgt = lu->tgt;
699 struct fw_card *card = target_parent_device(tgt)->card;
701 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
704 spin_lock_irqsave(&tgt->lock, flags);
705 if (!tgt->dont_block && !lu->blocked &&
708 if (++tgt->blocked == 1)
711 spin_unlock_irqrestore(&tgt->lock, flags);
715 * Unblocks lu->tgt as soon as all its logical units can be unblocked.
717 * tgt->lock protected section. On the other hand, running it inside
722 struct sbp2_target *tgt = lu->tgt;
723 struct fw_card *card = target_parent_device(tgt)->card;
725 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
728 spin_lock_irq(&tgt->lock);
731 unblock = --tgt->blocked == 0;
733 spin_unlock_irq(&tgt->lock);
740 * Prevents future blocking of tgt and unblocks it.
742 * tgt->lock protected section. On the other hand, running it inside
745 static void sbp2_unblock(struct sbp2_target *tgt)
748 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
750 spin_lock_irq(&tgt->lock);
751 ++tgt->dont_block;
752 spin_unlock_irq(&tgt->lock);
786 struct fw_device *device = target_parent_device(lu->tgt);
790 lu->tgt->node_id, lu->generation, device->max_speed,
800 struct sbp2_target *tgt = lu->tgt;
801 struct fw_device *device = target_parent_device(tgt);
825 dev_err(tgt_dev(tgt), "failed to login to LUN %04x\n",
828 sbp2_unblock(lu->tgt);
833 tgt->node_id = node_id;
834 tgt->address_high = local_node_id << 16;
843 dev_notice(tgt_dev(tgt), "logged in to LUN %04x (%d retries)\n",
860 if (lu->tgt->workarounds & SBP2_WORKAROUND_DELAY_INQUIRY)
863 shost = container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
888 sbp2_allow_block(tgt);
910 struct sbp2_target *tgt = lu->tgt;
911 struct fw_device *device = target_parent_device(tgt);
935 dev_err(tgt_dev(tgt), "failed to reconnect\n");
944 tgt->node_id = node_id;
945 tgt->address_high = local_node_id << 16;
949 dev_notice(tgt_dev(tgt), "reconnected to LUN %04x (%d retries)\n",
964 static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry)
982 lu->tgt = tgt;
988 ++tgt->dont_block;
993 list_add_tail(&lu->link, &tgt->lu_list);
997 static void sbp2_get_unit_unique_id(struct sbp2_target *tgt,
1001 tgt->guid = (u64)leaf[1] << 32 | leaf[2];
1004 static int sbp2_scan_logical_unit_dir(struct sbp2_target *tgt,
1013 sbp2_add_logical_unit(tgt, value) < 0)
1018 static int sbp2_scan_unit_dir(struct sbp2_target *tgt, const u32 *directory,
1029 tgt->management_agent_address =
1034 tgt->directory_id = value;
1047 tgt->mgt_orb_timeout = (value >> 8 & 0xff) * 500;
1051 if (sbp2_add_logical_unit(tgt, value) < 0)
1056 sbp2_get_unit_unique_id(tgt, ci.p - 1 + value);
1061 if (sbp2_scan_logical_unit_dir(tgt, ci.p - 1 + value) < 0)
1074 static void sbp2_clamp_management_orb_timeout(struct sbp2_target *tgt)
1076 unsigned int timeout = tgt->mgt_orb_timeout;
1079 dev_notice(tgt_dev(tgt), "%ds mgt_ORB_timeout limited to 40s\n",
1082 tgt->mgt_orb_timeout = clamp_val(timeout, 5000, 40000);
1085 static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
1092 dev_notice(tgt_dev(tgt),
1114 dev_notice(tgt_dev(tgt), "workarounds 0x%x "
1117 tgt->workarounds = w;
1126 struct sbp2_target *tgt;
1135 shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt));
1139 tgt = (struct sbp2_target *)shost->hostdata;
1140 dev_set_drvdata(&unit->device, tgt);
1141 tgt->unit = unit;
1142 INIT_LIST_HEAD(&tgt->lu_list);
1143 spin_lock_init(&tgt->lock);
1144 tgt->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4];
1156 tgt->directory_id = ((unit->directory - device->config_rom) * 4
1162 if (sbp2_scan_unit_dir(tgt, unit->directory, &model,
1166 sbp2_clamp_management_orb_timeout(tgt);
1167 sbp2_init_workarounds(tgt, model, firmware_revision);
1175 tgt->max_payload = min3(device->max_speed + 7, 10U,
1179 list_for_each_entry(lu, &tgt->lu_list, link)
1195 struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
1202 * Iteration over tgt->lu_list is therefore safe here.
1204 list_for_each_entry(lu, &tgt->lu_list, link) {
1214 struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
1217 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
1221 sbp2_unblock(tgt);
1223 list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
1233 * tgt->node_id may be obsolete here if we failed
1340 struct fw_device *device = target_parent_device(base_orb->lu->tgt);
1401 cpu_to_be32(lu->tgt->address_high);
1427 orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high);
1446 struct fw_device *device = target_parent_device(lu->tgt);
1460 COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) |
1468 smp_rmb(); /* sbp2_map_scatterlist looks at tgt->address_high */
1484 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
1508 if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36)
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)
1576 (unsigned long long)lu->tgt->guid,
1577 lu->tgt->directory_id, lu->lun);