Lines Matching refs:tgt

120 	struct sbp2_target *tgt;
170 static struct fw_device *target_parent_device(struct sbp2_target *tgt)
172 return fw_parent_device(tgt->unit);
175 static const struct device *tgt_dev(const struct sbp2_target *tgt)
177 return &tgt->unit->device;
182 return &lu->tgt->unit->device;
436 spin_lock_irqsave(&lu->tgt->lock, flags);
446 spin_unlock_irqrestore(&lu->tgt->lock, flags);
473 spin_lock_irqsave(&orb->lu->tgt->lock, flags);
479 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags);
484 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags);
493 struct fw_device *device = target_parent_device(lu->tgt);
501 spin_lock_irqsave(&lu->tgt->lock, flags);
503 spin_unlock_irqrestore(&lu->tgt->lock, flags);
515 struct fw_device *device = target_parent_device(lu->tgt);
521 spin_lock_irq(&lu->tgt->lock);
523 spin_unlock_irq(&lu->tgt->lock);
553 struct fw_device *device = target_parent_device(lu->tgt);
592 timeout = lu->tgt->mgt_orb_timeout;
607 lu->tgt->management_agent_address);
649 struct fw_device *device = target_parent_device(lu->tgt);
653 lu->tgt->node_id, lu->generation, device->max_speed,
666 struct fw_device *device = target_parent_device(lu->tgt);
675 lu->tgt->node_id, lu->generation, device->max_speed,
680 static inline void sbp2_allow_block(struct sbp2_target *tgt)
682 spin_lock_irq(&tgt->lock);
683 --tgt->dont_block;
684 spin_unlock_irq(&tgt->lock);
688 * Blocks lu->tgt if all of the following conditions are met:
693 * Note, scsi_block_requests() must be called while holding tgt->lock,
699 struct sbp2_target *tgt = lu->tgt;
700 struct fw_card *card = target_parent_device(tgt)->card;
702 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
705 spin_lock_irqsave(&tgt->lock, flags);
706 if (!tgt->dont_block && !lu->blocked &&
709 if (++tgt->blocked == 1)
712 spin_unlock_irqrestore(&tgt->lock, flags);
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
723 struct sbp2_target *tgt = lu->tgt;
724 struct fw_card *card = target_parent_device(tgt)->card;
726 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
729 spin_lock_irq(&tgt->lock);
732 unblock = --tgt->blocked == 0;
734 spin_unlock_irq(&tgt->lock);
741 * Prevents future blocking of tgt and unblocks it.
743 * tgt->lock protected section. On the other hand, running it inside
746 static void sbp2_unblock(struct sbp2_target *tgt)
749 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
751 spin_lock_irq(&tgt->lock);
752 ++tgt->dont_block;
753 spin_unlock_irq(&tgt->lock);
787 struct fw_device *device = target_parent_device(lu->tgt);
791 lu->tgt->node_id, lu->generation, device->max_speed,
801 struct sbp2_target *tgt = lu->tgt;
802 struct fw_device *device = target_parent_device(tgt);
826 dev_err(tgt_dev(tgt), "failed to login to LUN %04x\n",
829 sbp2_unblock(lu->tgt);
834 tgt->node_id = node_id;
835 tgt->address_high = local_node_id << 16;
844 dev_notice(tgt_dev(tgt), "logged in to LUN %04x (%d retries)\n",
861 if (lu->tgt->workarounds & SBP2_WORKAROUND_DELAY_INQUIRY)
864 shost = container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
889 sbp2_allow_block(tgt);
911 struct sbp2_target *tgt = lu->tgt;
912 struct fw_device *device = target_parent_device(tgt);
936 dev_err(tgt_dev(tgt), "failed to reconnect\n");
945 tgt->node_id = node_id;
946 tgt->address_high = local_node_id << 16;
950 dev_notice(tgt_dev(tgt), "reconnected to LUN %04x (%d retries)\n",
965 static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry)
983 lu->tgt = tgt;
989 ++tgt->dont_block;
994 list_add_tail(&lu->link, &tgt->lu_list);
998 static void sbp2_get_unit_unique_id(struct sbp2_target *tgt,
1002 tgt->guid = (u64)leaf[1] << 32 | leaf[2];
1005 static int sbp2_scan_logical_unit_dir(struct sbp2_target *tgt,
1014 sbp2_add_logical_unit(tgt, value) < 0)
1019 static int sbp2_scan_unit_dir(struct sbp2_target *tgt, const u32 *directory,
1030 tgt->management_agent_address =
1035 tgt->directory_id = value;
1048 tgt->mgt_orb_timeout = (value >> 8 & 0xff) * 500;
1052 if (sbp2_add_logical_unit(tgt, value) < 0)
1057 sbp2_get_unit_unique_id(tgt, ci.p - 1 + value);
1062 if (sbp2_scan_logical_unit_dir(tgt, ci.p - 1 + value) < 0)
1075 static void sbp2_clamp_management_orb_timeout(struct sbp2_target *tgt)
1077 unsigned int timeout = tgt->mgt_orb_timeout;
1080 dev_notice(tgt_dev(tgt), "%ds mgt_ORB_timeout limited to 40s\n",
1083 tgt->mgt_orb_timeout = clamp_val(timeout, 5000, 40000);
1086 static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
1093 dev_notice(tgt_dev(tgt),
1115 dev_notice(tgt_dev(tgt), "workarounds 0x%x "
1118 tgt->workarounds = w;
1127 struct sbp2_target *tgt;
1136 shost = scsi_host_alloc(&scsi_driver_template, sizeof(*tgt));
1140 tgt = (struct sbp2_target *)shost->hostdata;
1141 dev_set_drvdata(&unit->device, tgt);
1142 tgt->unit = unit;
1143 INIT_LIST_HEAD(&tgt->lu_list);
1144 spin_lock_init(&tgt->lock);
1145 tgt->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4];
1157 tgt->directory_id = ((unit->directory - device->config_rom) * 4
1163 if (sbp2_scan_unit_dir(tgt, unit->directory, &model,
1167 sbp2_clamp_management_orb_timeout(tgt);
1168 sbp2_init_workarounds(tgt, model, firmware_revision);
1176 tgt->max_payload = min3(device->max_speed + 7, 10U,
1180 list_for_each_entry(lu, &tgt->lu_list, link)
1196 struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
1203 * Iteration over tgt->lu_list is therefore safe here.
1205 list_for_each_entry(lu, &tgt->lu_list, link) {
1215 struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
1218 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
1222 sbp2_unblock(tgt);
1224 list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
1234 * tgt->node_id may be obsolete here if we failed
1341 struct fw_device *device = target_parent_device(base_orb->lu->tgt);
1402 cpu_to_be32(lu->tgt->address_high);
1428 orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high);
1447 struct fw_device *device = target_parent_device(lu->tgt);
1461 COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) |
1469 smp_rmb(); /* sbp2_map_scatterlist looks at tgt->address_high */
1485 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
1509 if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36)
1531 lu->tgt->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
1534 if (lu->tgt->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
1537 if (lu->tgt->workarounds & SBP2_WORKAROUND_POWER_CONDITION)
1540 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
1580 (unsigned long long)lu->tgt->guid,
1581 lu->tgt->directory_id, lu->lun);