aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/sbp2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/sbp2.c')
-rw-r--r--drivers/ieee1394/sbp2.c137
1 files changed, 54 insertions, 83 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index eca92eb475a1..2c765ca5aa50 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -214,6 +214,7 @@ static u32 global_outstanding_dmas = 0;
214#endif 214#endif
215 215
216#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) 216#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
217#define SBP2_DEBUG_ENTER() SBP2_DEBUG("%s", __FUNCTION__)
217 218
218/* 219/*
219 * Globals 220 * Globals
@@ -535,7 +536,7 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb(
535 command->Current_SCpnt = Current_SCpnt; 536 command->Current_SCpnt = Current_SCpnt;
536 list_add_tail(&command->list, &scsi_id->sbp2_command_orb_inuse); 537 list_add_tail(&command->list, &scsi_id->sbp2_command_orb_inuse);
537 } else { 538 } else {
538 SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!"); 539 SBP2_ERR("%s: no orbs available", __FUNCTION__);
539 } 540 }
540 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 541 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
541 return command; 542 return command;
@@ -549,7 +550,7 @@ static void sbp2util_free_command_dma(struct sbp2_command_info *command)
549 struct hpsb_host *host; 550 struct hpsb_host *host;
550 551
551 if (!scsi_id) { 552 if (!scsi_id) {
552 printk(KERN_ERR "%s: scsi_id == NULL\n", __FUNCTION__); 553 SBP2_ERR("%s: scsi_id == NULL", __FUNCTION__);
553 return; 554 return;
554 } 555 }
555 556
@@ -610,7 +611,7 @@ static int sbp2_probe(struct device *dev)
610 struct unit_directory *ud; 611 struct unit_directory *ud;
611 struct scsi_id_instance_data *scsi_id; 612 struct scsi_id_instance_data *scsi_id;
612 613
613 SBP2_DEBUG("sbp2_probe"); 614 SBP2_DEBUG_ENTER();
614 615
615 ud = container_of(dev, struct unit_directory, device); 616 ud = container_of(dev, struct unit_directory, device);
616 617
@@ -635,7 +636,7 @@ static int sbp2_remove(struct device *dev)
635 struct scsi_id_instance_data *scsi_id; 636 struct scsi_id_instance_data *scsi_id;
636 struct scsi_device *sdev; 637 struct scsi_device *sdev;
637 638
638 SBP2_DEBUG("sbp2_remove"); 639 SBP2_DEBUG_ENTER();
639 640
640 ud = container_of(dev, struct unit_directory, device); 641 ud = container_of(dev, struct unit_directory, device);
641 scsi_id = ud->device.driver_data; 642 scsi_id = ud->device.driver_data;
@@ -667,7 +668,7 @@ static int sbp2_update(struct unit_directory *ud)
667{ 668{
668 struct scsi_id_instance_data *scsi_id = ud->device.driver_data; 669 struct scsi_id_instance_data *scsi_id = ud->device.driver_data;
669 670
670 SBP2_DEBUG("sbp2_update"); 671 SBP2_DEBUG_ENTER();
671 672
672 if (sbp2_reconnect_device(scsi_id)) { 673 if (sbp2_reconnect_device(scsi_id)) {
673 674
@@ -715,7 +716,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
715 struct Scsi_Host *scsi_host = NULL; 716 struct Scsi_Host *scsi_host = NULL;
716 struct scsi_id_instance_data *scsi_id = NULL; 717 struct scsi_id_instance_data *scsi_id = NULL;
717 718
718 SBP2_DEBUG("sbp2_alloc_device"); 719 SBP2_DEBUG_ENTER();
719 720
720 scsi_id = kzalloc(sizeof(*scsi_id), GFP_KERNEL); 721 scsi_id = kzalloc(sizeof(*scsi_id), GFP_KERNEL);
721 if (!scsi_id) { 722 if (!scsi_id) {
@@ -749,12 +750,22 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
749 750
750#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA 751#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
751 /* Handle data movement if physical dma is not 752 /* Handle data movement if physical dma is not
752 * enabled/supportedon host controller */ 753 * enabled or not supported on host controller */
753 hpsb_register_addrspace(&sbp2_highlevel, ud->ne->host, &sbp2_physdma_ops, 754 if (!hpsb_register_addrspace(&sbp2_highlevel, ud->ne->host,
754 0x0ULL, 0xfffffffcULL); 755 &sbp2_physdma_ops,
756 0x0ULL, 0xfffffffcULL)) {
757 SBP2_ERR("failed to register lower 4GB address range");
758 goto failed_alloc;
759 }
755#endif 760#endif
756 } 761 }
757 762
763 /* Prevent unloading of the 1394 host */
764 if (!try_module_get(hi->host->driver->owner)) {
765 SBP2_ERR("failed to get a reference on 1394 host driver");
766 goto failed_alloc;
767 }
768
758 scsi_id->hi = hi; 769 scsi_id->hi = hi;
759 770
760 list_add_tail(&scsi_id->scsi_list, &hi->scsi_ids); 771 list_add_tail(&scsi_id->scsi_list, &hi->scsi_ids);
@@ -816,7 +827,7 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
816 struct sbp2scsi_host_info *hi = scsi_id->hi; 827 struct sbp2scsi_host_info *hi = scsi_id->hi;
817 int error; 828 int error;
818 829
819 SBP2_DEBUG("sbp2_start_device"); 830 SBP2_DEBUG_ENTER();
820 831
821 /* Login FIFO DMA */ 832 /* Login FIFO DMA */
822 scsi_id->login_response = 833 scsi_id->login_response =
@@ -891,7 +902,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
891 * allows someone else to login instead. One second makes sense. */ 902 * allows someone else to login instead. One second makes sense. */
892 msleep_interruptible(1000); 903 msleep_interruptible(1000);
893 if (signal_pending(current)) { 904 if (signal_pending(current)) {
894 SBP2_WARN("aborting sbp2_start_device due to event");
895 sbp2_remove_device(scsi_id); 905 sbp2_remove_device(scsi_id);
896 return -EINTR; 906 return -EINTR;
897 } 907 }
@@ -944,7 +954,7 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
944{ 954{
945 struct sbp2scsi_host_info *hi; 955 struct sbp2scsi_host_info *hi;
946 956
947 SBP2_DEBUG("sbp2_remove_device"); 957 SBP2_DEBUG_ENTER();
948 958
949 if (!scsi_id) 959 if (!scsi_id)
950 return; 960 return;
@@ -1015,6 +1025,9 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
1015 1025
1016 scsi_id->ud->device.driver_data = NULL; 1026 scsi_id->ud->device.driver_data = NULL;
1017 1027
1028 if (hi)
1029 module_put(hi->host->driver->owner);
1030
1018 SBP2_DEBUG("SBP-2 device removed, SCSI ID = %d", scsi_id->ud->id); 1031 SBP2_DEBUG("SBP-2 device removed, SCSI ID = %d", scsi_id->ud->id);
1019 1032
1020 kfree(scsi_id); 1033 kfree(scsi_id);
@@ -1073,23 +1086,20 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1073 int max_logins; 1086 int max_logins;
1074 int active_logins; 1087 int active_logins;
1075 1088
1076 SBP2_DEBUG("sbp2_query_logins"); 1089 SBP2_DEBUG_ENTER();
1077 1090
1078 scsi_id->query_logins_orb->reserved1 = 0x0; 1091 scsi_id->query_logins_orb->reserved1 = 0x0;
1079 scsi_id->query_logins_orb->reserved2 = 0x0; 1092 scsi_id->query_logins_orb->reserved2 = 0x0;
1080 1093
1081 scsi_id->query_logins_orb->query_response_lo = scsi_id->query_logins_response_dma; 1094 scsi_id->query_logins_orb->query_response_lo = scsi_id->query_logins_response_dma;
1082 scsi_id->query_logins_orb->query_response_hi = ORB_SET_NODE_ID(hi->host->node_id); 1095 scsi_id->query_logins_orb->query_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
1083 SBP2_DEBUG("sbp2_query_logins: query_response_hi/lo initialized");
1084 1096
1085 scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST); 1097 scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST);
1086 scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1); 1098 scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1);
1087 scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); 1099 scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun);
1088 SBP2_DEBUG("sbp2_query_logins: lun_misc initialized");
1089 1100
1090 scsi_id->query_logins_orb->reserved_resp_length = 1101 scsi_id->query_logins_orb->reserved_resp_length =
1091 ORB_SET_QUERY_LOGINS_RESP_LENGTH(sizeof(struct sbp2_query_logins_response)); 1102 ORB_SET_QUERY_LOGINS_RESP_LENGTH(sizeof(struct sbp2_query_logins_response));
1092 SBP2_DEBUG("sbp2_query_logins: reserved_resp_length initialized");
1093 1103
1094 scsi_id->query_logins_orb->status_fifo_hi = 1104 scsi_id->query_logins_orb->status_fifo_hi =
1095 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id); 1105 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
@@ -1098,25 +1108,19 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1098 1108
1099 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb)); 1109 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb));
1100 1110
1101 SBP2_DEBUG("sbp2_query_logins: orb byte-swapped");
1102
1103 sbp2util_packet_dump(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb), 1111 sbp2util_packet_dump(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb),
1104 "sbp2 query logins orb", scsi_id->query_logins_orb_dma); 1112 "sbp2 query logins orb", scsi_id->query_logins_orb_dma);
1105 1113
1106 memset(scsi_id->query_logins_response, 0, sizeof(struct sbp2_query_logins_response)); 1114 memset(scsi_id->query_logins_response, 0, sizeof(struct sbp2_query_logins_response));
1107 memset(&scsi_id->status_block, 0, sizeof(struct sbp2_status_block)); 1115 memset(&scsi_id->status_block, 0, sizeof(struct sbp2_status_block));
1108 1116
1109 SBP2_DEBUG("sbp2_query_logins: query_logins_response/status FIFO memset");
1110
1111 data[0] = ORB_SET_NODE_ID(hi->host->node_id); 1117 data[0] = ORB_SET_NODE_ID(hi->host->node_id);
1112 data[1] = scsi_id->query_logins_orb_dma; 1118 data[1] = scsi_id->query_logins_orb_dma;
1113 sbp2util_cpu_to_be32_buffer(data, 8); 1119 sbp2util_cpu_to_be32_buffer(data, 8);
1114 1120
1115 atomic_set(&scsi_id->sbp2_login_complete, 0); 1121 atomic_set(&scsi_id->sbp2_login_complete, 0);
1116 1122
1117 SBP2_DEBUG("sbp2_query_logins: prepared to write");
1118 hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8); 1123 hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8);
1119 SBP2_DEBUG("sbp2_query_logins: written");
1120 1124
1121 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) { 1125 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) {
1122 SBP2_INFO("Error querying logins to SBP-2 device - timed out"); 1126 SBP2_INFO("Error querying logins to SBP-2 device - timed out");
@@ -1165,10 +1169,10 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1165 struct sbp2scsi_host_info *hi = scsi_id->hi; 1169 struct sbp2scsi_host_info *hi = scsi_id->hi;
1166 quadlet_t data[2]; 1170 quadlet_t data[2];
1167 1171
1168 SBP2_DEBUG("sbp2_login_device"); 1172 SBP2_DEBUG_ENTER();
1169 1173
1170 if (!scsi_id->login_orb) { 1174 if (!scsi_id->login_orb) {
1171 SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!"); 1175 SBP2_DEBUG("%s: login_orb not alloc'd!", __FUNCTION__);
1172 return -EIO; 1176 return -EIO;
1173 } 1177 }
1174 1178
@@ -1182,59 +1186,39 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1182 /* Set-up login ORB, assume no password */ 1186 /* Set-up login ORB, assume no password */
1183 scsi_id->login_orb->password_hi = 0; 1187 scsi_id->login_orb->password_hi = 0;
1184 scsi_id->login_orb->password_lo = 0; 1188 scsi_id->login_orb->password_lo = 0;
1185 SBP2_DEBUG("sbp2_login_device: password_hi/lo initialized");
1186 1189
1187 scsi_id->login_orb->login_response_lo = scsi_id->login_response_dma; 1190 scsi_id->login_orb->login_response_lo = scsi_id->login_response_dma;
1188 scsi_id->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id); 1191 scsi_id->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
1189 SBP2_DEBUG("sbp2_login_device: login_response_hi/lo initialized");
1190 1192
1191 scsi_id->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST); 1193 scsi_id->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST);
1192 scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0); /* One second reconnect time */ 1194 scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0); /* One second reconnect time */
1193 scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login); /* Exclusive access to device */ 1195 scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login); /* Exclusive access to device */
1194 scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1); /* Notify us of login complete */ 1196 scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1); /* Notify us of login complete */
1195 scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); 1197 scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun);
1196 SBP2_DEBUG("sbp2_login_device: lun_misc initialized");
1197 1198
1198 scsi_id->login_orb->passwd_resp_lengths = 1199 scsi_id->login_orb->passwd_resp_lengths =
1199 ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response)); 1200 ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response));
1200 SBP2_DEBUG("sbp2_login_device: passwd_resp_lengths initialized");
1201 1201
1202 scsi_id->login_orb->status_fifo_hi = 1202 scsi_id->login_orb->status_fifo_hi =
1203 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id); 1203 ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id);
1204 scsi_id->login_orb->status_fifo_lo = 1204 scsi_id->login_orb->status_fifo_lo =
1205 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr); 1205 ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
1206 1206
1207 /*
1208 * Byte swap ORB if necessary
1209 */
1210 sbp2util_cpu_to_be32_buffer(scsi_id->login_orb, sizeof(struct sbp2_login_orb)); 1207 sbp2util_cpu_to_be32_buffer(scsi_id->login_orb, sizeof(struct sbp2_login_orb));
1211 1208
1212 SBP2_DEBUG("sbp2_login_device: orb byte-swapped");
1213
1214 sbp2util_packet_dump(scsi_id->login_orb, sizeof(struct sbp2_login_orb), 1209 sbp2util_packet_dump(scsi_id->login_orb, sizeof(struct sbp2_login_orb),
1215 "sbp2 login orb", scsi_id->login_orb_dma); 1210 "sbp2 login orb", scsi_id->login_orb_dma);
1216 1211
1217 /*
1218 * Initialize login response and status fifo
1219 */
1220 memset(scsi_id->login_response, 0, sizeof(struct sbp2_login_response)); 1212 memset(scsi_id->login_response, 0, sizeof(struct sbp2_login_response));
1221 memset(&scsi_id->status_block, 0, sizeof(struct sbp2_status_block)); 1213 memset(&scsi_id->status_block, 0, sizeof(struct sbp2_status_block));
1222 1214
1223 SBP2_DEBUG("sbp2_login_device: login_response/status FIFO memset");
1224
1225 /*
1226 * Ok, let's write to the target's management agent register
1227 */
1228 data[0] = ORB_SET_NODE_ID(hi->host->node_id); 1215 data[0] = ORB_SET_NODE_ID(hi->host->node_id);
1229 data[1] = scsi_id->login_orb_dma; 1216 data[1] = scsi_id->login_orb_dma;
1230 sbp2util_cpu_to_be32_buffer(data, 8); 1217 sbp2util_cpu_to_be32_buffer(data, 8);
1231 1218
1232 atomic_set(&scsi_id->sbp2_login_complete, 0); 1219 atomic_set(&scsi_id->sbp2_login_complete, 0);
1233 1220
1234 SBP2_DEBUG("sbp2_login_device: prepared to write to %08x",
1235 (unsigned int)scsi_id->sbp2_management_agent_addr);
1236 hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8); 1221 hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8);
1237 SBP2_DEBUG("sbp2_login_device: written");
1238 1222
1239 /* 1223 /*
1240 * Wait for login status (up to 20 seconds)... 1224 * Wait for login status (up to 20 seconds)...
@@ -1298,7 +1282,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
1298 quadlet_t data[2]; 1282 quadlet_t data[2];
1299 int error; 1283 int error;
1300 1284
1301 SBP2_DEBUG("sbp2_logout_device"); 1285 SBP2_DEBUG_ENTER();
1302 1286
1303 /* 1287 /*
1304 * Set-up logout ORB 1288 * Set-up logout ORB
@@ -1362,7 +1346,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1362 quadlet_t data[2]; 1346 quadlet_t data[2];
1363 int error; 1347 int error;
1364 1348
1365 SBP2_DEBUG("sbp2_reconnect_device"); 1349 SBP2_DEBUG_ENTER();
1366 1350
1367 /* 1351 /*
1368 * Set-up reconnect ORB 1352 * Set-up reconnect ORB
@@ -1453,17 +1437,11 @@ static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id)
1453{ 1437{
1454 quadlet_t data; 1438 quadlet_t data;
1455 1439
1456 SBP2_DEBUG("sbp2_set_busy_timeout"); 1440 SBP2_DEBUG_ENTER();
1457 1441
1458 /*
1459 * Ok, let's write to the target's busy timeout register
1460 */
1461 data = cpu_to_be32(SBP2_BUSY_TIMEOUT_VALUE); 1442 data = cpu_to_be32(SBP2_BUSY_TIMEOUT_VALUE);
1462 1443 if (hpsb_node_write(scsi_id->ne, SBP2_BUSY_TIMEOUT_ADDRESS, &data, 4))
1463 if (hpsb_node_write(scsi_id->ne, SBP2_BUSY_TIMEOUT_ADDRESS, &data, 4)) { 1444 SBP2_ERR("%s error", __FUNCTION__);
1464 SBP2_ERR("sbp2_set_busy_timeout error");
1465 }
1466
1467 return 0; 1445 return 0;
1468} 1446}
1469 1447
@@ -1482,7 +1460,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1482 firmware_revision, workarounds; 1460 firmware_revision, workarounds;
1483 int i; 1461 int i;
1484 1462
1485 SBP2_DEBUG("sbp2_parse_unit_directory"); 1463 SBP2_DEBUG_ENTER();
1486 1464
1487 management_agent_addr = 0x0; 1465 management_agent_addr = 0x0;
1488 command_set_spec_id = 0x0; 1466 command_set_spec_id = 0x0;
@@ -1615,7 +1593,7 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
1615{ 1593{
1616 struct sbp2scsi_host_info *hi = scsi_id->hi; 1594 struct sbp2scsi_host_info *hi = scsi_id->hi;
1617 1595
1618 SBP2_DEBUG("sbp2_max_speed_and_size"); 1596 SBP2_DEBUG_ENTER();
1619 1597
1620 /* Initial setting comes from the hosts speed map */ 1598 /* Initial setting comes from the hosts speed map */
1621 scsi_id->speed_code = 1599 scsi_id->speed_code =
@@ -1652,11 +1630,8 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait)
1652 u64 addr; 1630 u64 addr;
1653 int retval; 1631 int retval;
1654 1632
1655 SBP2_DEBUG("sbp2_agent_reset"); 1633 SBP2_DEBUG_ENTER();
1656 1634
1657 /*
1658 * Ok, let's write to the target's management agent register
1659 */
1660 data = ntohl(SBP2_AGENT_RESET_DATA); 1635 data = ntohl(SBP2_AGENT_RESET_DATA);
1661 addr = scsi_id->sbp2_command_block_agent_addr + SBP2_AGENT_RESET_OFFSET; 1636 addr = scsi_id->sbp2_command_block_agent_addr + SBP2_AGENT_RESET_OFFSET;
1662 1637
@@ -2004,11 +1979,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2004 unsigned int request_bufflen = SCpnt->request_bufflen; 1979 unsigned int request_bufflen = SCpnt->request_bufflen;
2005 struct sbp2_command_info *command; 1980 struct sbp2_command_info *command;
2006 1981
2007 SBP2_DEBUG("sbp2_send_command"); 1982 SBP2_DEBUG_ENTER();
2008#if (CONFIG_IEEE1394_SBP2_DEBUG >= 2) || defined(CONFIG_IEEE1394_SBP2_PACKET_DUMP)
2009 printk("[scsi command]\n ");
2010 scsi_print_command(SCpnt);
2011#endif
2012 SBP2_DEBUG("SCSI transfer size = %x", request_bufflen); 1983 SBP2_DEBUG("SCSI transfer size = %x", request_bufflen);
2013 SBP2_DEBUG("SCSI s/g elements = %x", (unsigned int)SCpnt->use_sg); 1984 SBP2_DEBUG("SCSI s/g elements = %x", (unsigned int)SCpnt->use_sg);
2014 1985
@@ -2048,7 +2019,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2048 */ 2019 */
2049static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data) 2020static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data)
2050{ 2021{
2051 SBP2_DEBUG("sbp2_status_to_sense_data"); 2022 SBP2_DEBUG_ENTER();
2052 2023
2053 /* 2024 /*
2054 * Ok, it's pretty ugly... ;-) 2025 * Ok, it's pretty ugly... ;-)
@@ -2082,7 +2053,7 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
2082{ 2053{
2083 u8 *scsi_buf = SCpnt->request_buffer; 2054 u8 *scsi_buf = SCpnt->request_buffer;
2084 2055
2085 SBP2_DEBUG("sbp2_check_sbp2_response"); 2056 SBP2_DEBUG_ENTER();
2086 2057
2087 if (SCpnt->cmnd[0] == INQUIRY && (SCpnt->cmnd[1] & 3) == 0) { 2058 if (SCpnt->cmnd[0] == INQUIRY && (SCpnt->cmnd[1] & 3) == 0) {
2088 /* 2059 /*
@@ -2113,7 +2084,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2113 struct sbp2_command_info *command; 2084 struct sbp2_command_info *command;
2114 unsigned long flags; 2085 unsigned long flags;
2115 2086
2116 SBP2_DEBUG("sbp2_handle_status_write"); 2087 SBP2_DEBUG_ENTER();
2117 2088
2118 sbp2util_packet_dump(data, length, "sbp2 status write by device", (u32)addr); 2089 sbp2util_packet_dump(data, length, "sbp2 status write by device", (u32)addr);
2119 2090
@@ -2260,7 +2231,10 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
2260 struct sbp2scsi_host_info *hi; 2231 struct sbp2scsi_host_info *hi;
2261 int result = DID_NO_CONNECT << 16; 2232 int result = DID_NO_CONNECT << 16;
2262 2233
2263 SBP2_DEBUG("sbp2scsi_queuecommand"); 2234 SBP2_DEBUG_ENTER();
2235#if (CONFIG_IEEE1394_SBP2_DEBUG >= 2) || defined(CONFIG_IEEE1394_SBP2_PACKET_DUMP)
2236 scsi_print_command(SCpnt);
2237#endif
2264 2238
2265 if (!sbp2util_node_is_available(scsi_id)) 2239 if (!sbp2util_node_is_available(scsi_id))
2266 goto done; 2240 goto done;
@@ -2338,7 +2312,7 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id
2338 struct sbp2_command_info *command; 2312 struct sbp2_command_info *command;
2339 unsigned long flags; 2313 unsigned long flags;
2340 2314
2341 SBP2_DEBUG("sbp2scsi_complete_all_commands"); 2315 SBP2_DEBUG_ENTER();
2342 2316
2343 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 2317 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
2344 while (!list_empty(&scsi_id->sbp2_command_orb_inuse)) { 2318 while (!list_empty(&scsi_id->sbp2_command_orb_inuse)) {
@@ -2371,7 +2345,7 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2371 u32 scsi_status, struct scsi_cmnd *SCpnt, 2345 u32 scsi_status, struct scsi_cmnd *SCpnt,
2372 void (*done)(struct scsi_cmnd *)) 2346 void (*done)(struct scsi_cmnd *))
2373{ 2347{
2374 SBP2_DEBUG("sbp2scsi_complete_command"); 2348 SBP2_DEBUG_ENTER();
2375 2349
2376 /* 2350 /*
2377 * Sanity 2351 * Sanity
@@ -2397,7 +2371,7 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2397 */ 2371 */
2398 switch (scsi_status) { 2372 switch (scsi_status) {
2399 case SBP2_SCSI_STATUS_GOOD: 2373 case SBP2_SCSI_STATUS_GOOD:
2400 SCpnt->result = DID_OK; 2374 SCpnt->result = DID_OK << 16;
2401 break; 2375 break;
2402 2376
2403 case SBP2_SCSI_STATUS_BUSY: 2377 case SBP2_SCSI_STATUS_BUSY:
@@ -2407,16 +2381,11 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2407 2381
2408 case SBP2_SCSI_STATUS_CHECK_CONDITION: 2382 case SBP2_SCSI_STATUS_CHECK_CONDITION:
2409 SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION"); 2383 SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION");
2410 SCpnt->result = CHECK_CONDITION << 1; 2384 SCpnt->result = CHECK_CONDITION << 1 | DID_OK << 16;
2411
2412 /*
2413 * Debug stuff
2414 */
2415#if CONFIG_IEEE1394_SBP2_DEBUG >= 1 2385#if CONFIG_IEEE1394_SBP2_DEBUG >= 1
2416 scsi_print_command(SCpnt); 2386 scsi_print_command(SCpnt);
2417 scsi_print_sense("bh", SCpnt); 2387 scsi_print_sense(SBP2_DEVICE_NAME, SCpnt);
2418#endif 2388#endif
2419
2420 break; 2389 break;
2421 2390
2422 case SBP2_SCSI_STATUS_SELECTION_TIMEOUT: 2391 case SBP2_SCSI_STATUS_SELECTION_TIMEOUT:
@@ -2441,7 +2410,7 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2441 /* 2410 /*
2442 * Take care of any sbp2 response data mucking here (RBC stuff, etc.) 2411 * Take care of any sbp2 response data mucking here (RBC stuff, etc.)
2443 */ 2412 */
2444 if (SCpnt->result == DID_OK) { 2413 if (SCpnt->result == DID_OK << 16) {
2445 sbp2_check_sbp2_response(scsi_id, SCpnt); 2414 sbp2_check_sbp2_response(scsi_id, SCpnt);
2446 } 2415 }
2447 2416
@@ -2459,6 +2428,8 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2459 * If a unit attention occurs, return busy status so it gets 2428 * If a unit attention occurs, return busy status so it gets
2460 * retried... it could have happened because of a 1394 bus reset 2429 * retried... it could have happened because of a 1394 bus reset
2461 * or hot-plug... 2430 * or hot-plug...
2431 * XXX DID_BUS_BUSY is actually a bad idea because it will defy
2432 * the scsi layer's retry logic.
2462 */ 2433 */
2463#if 0 2434#if 0
2464 if ((scsi_status == SBP2_SCSI_STATUS_CHECK_CONDITION) && 2435 if ((scsi_status == SBP2_SCSI_STATUS_CHECK_CONDITION) &&
@@ -2624,7 +2595,7 @@ static int sbp2_module_init(void)
2624{ 2595{
2625 int ret; 2596 int ret;
2626 2597
2627 SBP2_DEBUG("sbp2_module_init"); 2598 SBP2_DEBUG_ENTER();
2628 2599
2629 /* Module load debug option to force one command at a time (serializing I/O) */ 2600 /* Module load debug option to force one command at a time (serializing I/O) */
2630 if (serialize_io) { 2601 if (serialize_io) {
@@ -2652,7 +2623,7 @@ static int sbp2_module_init(void)
2652 2623
2653static void __exit sbp2_module_exit(void) 2624static void __exit sbp2_module_exit(void)
2654{ 2625{
2655 SBP2_DEBUG("sbp2_module_exit"); 2626 SBP2_DEBUG_ENTER();
2656 2627
2657 hpsb_unregister_protocol(&sbp2_driver); 2628 hpsb_unregister_protocol(&sbp2_driver);
2658 2629