diff options
Diffstat (limited to 'drivers/ieee1394/sbp2.c')
-rw-r--r-- | drivers/ieee1394/sbp2.c | 126 |
1 files changed, 64 insertions, 62 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 18d7eda38851..eca92eb475a1 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c | |||
@@ -137,15 +137,15 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device (default = 1)" | |||
137 | /* | 137 | /* |
138 | * SCSI inquiry hack for really badly behaved sbp2 devices. Turn this on | 138 | * SCSI inquiry hack for really badly behaved sbp2 devices. Turn this on |
139 | * if your sbp2 device is not properly handling the SCSI inquiry command. | 139 | * if your sbp2 device is not properly handling the SCSI inquiry command. |
140 | * This hack makes the inquiry look more like a typical MS Windows | 140 | * This hack makes the inquiry look more like a typical MS Windows inquiry |
141 | * inquiry. | 141 | * by enforcing 36 byte inquiry and avoiding access to mode_sense page 8. |
142 | * | 142 | * |
143 | * If force_inquiry_hack=1 is required for your device to work, | 143 | * If force_inquiry_hack=1 is required for your device to work, |
144 | * please submit the logged sbp2_firmware_revision value of this device to | 144 | * please submit the logged sbp2_firmware_revision value of this device to |
145 | * the linux1394-devel mailing list. | 145 | * the linux1394-devel mailing list. |
146 | */ | 146 | */ |
147 | static int force_inquiry_hack; | 147 | static int force_inquiry_hack; |
148 | module_param(force_inquiry_hack, int, 0444); | 148 | module_param(force_inquiry_hack, int, 0644); |
149 | MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); | 149 | MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); |
150 | 150 | ||
151 | /* | 151 | /* |
@@ -264,18 +264,17 @@ static struct hpsb_protocol_driver sbp2_driver = { | |||
264 | }, | 264 | }, |
265 | }; | 265 | }; |
266 | 266 | ||
267 | 267 | /* | |
268 | /* List of device firmware's that require a forced 36 byte inquiry. */ | 268 | * List of device firmwares that require the inquiry hack. |
269 | * Yields a few false positives but did not break other devices so far. | ||
270 | */ | ||
269 | static u32 sbp2_broken_inquiry_list[] = { | 271 | static u32 sbp2_broken_inquiry_list[] = { |
270 | 0x00002800, /* Stefan Richter <richtest@bauwesen.tu-cottbus.de> */ | 272 | 0x00002800, /* Stefan Richter <stefanr@s5r6.in-berlin.de> */ |
271 | /* DViCO Momobay CX-1 */ | 273 | /* DViCO Momobay CX-1 */ |
272 | 0x00000200 /* Andreas Plesch <plesch@fas.harvard.edu> */ | 274 | 0x00000200 /* Andreas Plesch <plesch@fas.harvard.edu> */ |
273 | /* QPS Fire DVDBurner */ | 275 | /* QPS Fire DVDBurner */ |
274 | }; | 276 | }; |
275 | 277 | ||
276 | #define NUM_BROKEN_INQUIRY_DEVS \ | ||
277 | (sizeof(sbp2_broken_inquiry_list)/sizeof(*sbp2_broken_inquiry_list)) | ||
278 | |||
279 | /************************************** | 278 | /************************************** |
280 | * General utility functions | 279 | * General utility functions |
281 | **************************************/ | 280 | **************************************/ |
@@ -643,9 +642,15 @@ static int sbp2_remove(struct device *dev) | |||
643 | if (!scsi_id) | 642 | if (!scsi_id) |
644 | return 0; | 643 | return 0; |
645 | 644 | ||
646 | /* Trigger shutdown functions in scsi's highlevel. */ | 645 | if (scsi_id->scsi_host) { |
647 | if (scsi_id->scsi_host) | 646 | /* Get rid of enqueued commands if there is no chance to |
647 | * send them. */ | ||
648 | if (!sbp2util_node_is_available(scsi_id)) | ||
649 | sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT); | ||
650 | /* scsi_remove_device() will trigger shutdown functions of SCSI | ||
651 | * highlevel drivers which would deadlock if blocked. */ | ||
648 | scsi_unblock_requests(scsi_id->scsi_host); | 652 | scsi_unblock_requests(scsi_id->scsi_host); |
653 | } | ||
649 | sdev = scsi_id->sdev; | 654 | sdev = scsi_id->sdev; |
650 | if (sdev) { | 655 | if (sdev) { |
651 | scsi_id->sdev = NULL; | 656 | scsi_id->sdev = NULL; |
@@ -742,11 +747,6 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud | |||
742 | hi->host = ud->ne->host; | 747 | hi->host = ud->ne->host; |
743 | INIT_LIST_HEAD(&hi->scsi_ids); | 748 | INIT_LIST_HEAD(&hi->scsi_ids); |
744 | 749 | ||
745 | /* Register our sbp2 status address space... */ | ||
746 | hpsb_register_addrspace(&sbp2_highlevel, ud->ne->host, &sbp2_ops, | ||
747 | SBP2_STATUS_FIFO_ADDRESS, | ||
748 | SBP2_STATUS_FIFO_ADDRESS + | ||
749 | SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(SBP2_MAX_UDS_PER_NODE+1)); | ||
750 | #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA | 750 | #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA |
751 | /* Handle data movement if physical dma is not | 751 | /* Handle data movement if physical dma is not |
752 | * enabled/supportedon host controller */ | 752 | * enabled/supportedon host controller */ |
@@ -759,6 +759,18 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud | |||
759 | 759 | ||
760 | list_add_tail(&scsi_id->scsi_list, &hi->scsi_ids); | 760 | list_add_tail(&scsi_id->scsi_list, &hi->scsi_ids); |
761 | 761 | ||
762 | /* Register the status FIFO address range. We could use the same FIFO | ||
763 | * for targets at different nodes. However we need different FIFOs per | ||
764 | * target in order to support multi-unit devices. */ | ||
765 | scsi_id->status_fifo_addr = hpsb_allocate_and_register_addrspace( | ||
766 | &sbp2_highlevel, ud->ne->host, &sbp2_ops, | ||
767 | sizeof(struct sbp2_status_block), sizeof(quadlet_t), | ||
768 | ~0ULL, ~0ULL); | ||
769 | if (!scsi_id->status_fifo_addr) { | ||
770 | SBP2_ERR("failed to allocate status FIFO address range"); | ||
771 | goto failed_alloc; | ||
772 | } | ||
773 | |||
762 | /* Register our host with the SCSI stack. */ | 774 | /* Register our host with the SCSI stack. */ |
763 | scsi_host = scsi_host_alloc(&scsi_driver_template, | 775 | scsi_host = scsi_host_alloc(&scsi_driver_template, |
764 | sizeof(unsigned long)); | 776 | sizeof(unsigned long)); |
@@ -997,6 +1009,10 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id) | |||
997 | SBP2_DMA_FREE("single query logins data"); | 1009 | SBP2_DMA_FREE("single query logins data"); |
998 | } | 1010 | } |
999 | 1011 | ||
1012 | if (scsi_id->status_fifo_addr) | ||
1013 | hpsb_unregister_addrspace(&sbp2_highlevel, hi->host, | ||
1014 | scsi_id->status_fifo_addr); | ||
1015 | |||
1000 | scsi_id->ud->device.driver_data = NULL; | 1016 | scsi_id->ud->device.driver_data = NULL; |
1001 | 1017 | ||
1002 | SBP2_DEBUG("SBP-2 device removed, SCSI ID = %d", scsi_id->ud->id); | 1018 | SBP2_DEBUG("SBP-2 device removed, SCSI ID = %d", scsi_id->ud->id); |
@@ -1075,11 +1091,10 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) | |||
1075 | ORB_SET_QUERY_LOGINS_RESP_LENGTH(sizeof(struct sbp2_query_logins_response)); | 1091 | ORB_SET_QUERY_LOGINS_RESP_LENGTH(sizeof(struct sbp2_query_logins_response)); |
1076 | SBP2_DEBUG("sbp2_query_logins: reserved_resp_length initialized"); | 1092 | SBP2_DEBUG("sbp2_query_logins: reserved_resp_length initialized"); |
1077 | 1093 | ||
1078 | scsi_id->query_logins_orb->status_FIFO_lo = SBP2_STATUS_FIFO_ADDRESS_LO + | 1094 | scsi_id->query_logins_orb->status_fifo_hi = |
1079 | SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(scsi_id->ud->id); | 1095 | ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id); |
1080 | scsi_id->query_logins_orb->status_FIFO_hi = (ORB_SET_NODE_ID(hi->host->node_id) | | 1096 | scsi_id->query_logins_orb->status_fifo_lo = |
1081 | SBP2_STATUS_FIFO_ADDRESS_HI); | 1097 | ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr); |
1082 | SBP2_DEBUG("sbp2_query_logins: status FIFO initialized"); | ||
1083 | 1098 | ||
1084 | sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb)); | 1099 | sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_orb, sizeof(struct sbp2_query_logins_orb)); |
1085 | 1100 | ||
@@ -1184,11 +1199,10 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) | |||
1184 | ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response)); | 1199 | ORB_SET_LOGIN_RESP_LENGTH(sizeof(struct sbp2_login_response)); |
1185 | SBP2_DEBUG("sbp2_login_device: passwd_resp_lengths initialized"); | 1200 | SBP2_DEBUG("sbp2_login_device: passwd_resp_lengths initialized"); |
1186 | 1201 | ||
1187 | scsi_id->login_orb->status_FIFO_lo = SBP2_STATUS_FIFO_ADDRESS_LO + | 1202 | scsi_id->login_orb->status_fifo_hi = |
1188 | SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(scsi_id->ud->id); | 1203 | ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id); |
1189 | scsi_id->login_orb->status_FIFO_hi = (ORB_SET_NODE_ID(hi->host->node_id) | | 1204 | scsi_id->login_orb->status_fifo_lo = |
1190 | SBP2_STATUS_FIFO_ADDRESS_HI); | 1205 | ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr); |
1191 | SBP2_DEBUG("sbp2_login_device: status FIFO initialized"); | ||
1192 | 1206 | ||
1193 | /* | 1207 | /* |
1194 | * Byte swap ORB if necessary | 1208 | * Byte swap ORB if necessary |
@@ -1301,10 +1315,10 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) | |||
1301 | scsi_id->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1); | 1315 | scsi_id->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1); |
1302 | 1316 | ||
1303 | scsi_id->logout_orb->reserved5 = 0x0; | 1317 | scsi_id->logout_orb->reserved5 = 0x0; |
1304 | scsi_id->logout_orb->status_FIFO_lo = SBP2_STATUS_FIFO_ADDRESS_LO + | 1318 | scsi_id->logout_orb->status_fifo_hi = |
1305 | SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(scsi_id->ud->id); | 1319 | ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id); |
1306 | scsi_id->logout_orb->status_FIFO_hi = (ORB_SET_NODE_ID(hi->host->node_id) | | 1320 | scsi_id->logout_orb->status_fifo_lo = |
1307 | SBP2_STATUS_FIFO_ADDRESS_HI); | 1321 | ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr); |
1308 | 1322 | ||
1309 | /* | 1323 | /* |
1310 | * Byte swap ORB if necessary | 1324 | * Byte swap ORB if necessary |
@@ -1366,10 +1380,10 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) | |||
1366 | scsi_id->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1); | 1380 | scsi_id->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1); |
1367 | 1381 | ||
1368 | scsi_id->reconnect_orb->reserved5 = 0x0; | 1382 | scsi_id->reconnect_orb->reserved5 = 0x0; |
1369 | scsi_id->reconnect_orb->status_FIFO_lo = SBP2_STATUS_FIFO_ADDRESS_LO + | 1383 | scsi_id->reconnect_orb->status_fifo_hi = |
1370 | SBP2_STATUS_FIFO_ENTRY_TO_OFFSET(scsi_id->ud->id); | 1384 | ORB_SET_STATUS_FIFO_HI(scsi_id->status_fifo_addr, hi->host->node_id); |
1371 | scsi_id->reconnect_orb->status_FIFO_hi = | 1385 | scsi_id->reconnect_orb->status_fifo_lo = |
1372 | (ORB_SET_NODE_ID(hi->host->node_id) | SBP2_STATUS_FIFO_ADDRESS_HI); | 1386 | ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr); |
1373 | 1387 | ||
1374 | /* | 1388 | /* |
1375 | * Byte swap ORB if necessary | 1389 | * Byte swap ORB if necessary |
@@ -1560,7 +1574,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, | |||
1560 | /* Check for a blacklisted set of devices that require us to force | 1574 | /* Check for a blacklisted set of devices that require us to force |
1561 | * a 36 byte host inquiry. This can be overriden as a module param | 1575 | * a 36 byte host inquiry. This can be overriden as a module param |
1562 | * (to force all hosts). */ | 1576 | * (to force all hosts). */ |
1563 | for (i = 0; i < NUM_BROKEN_INQUIRY_DEVS; i++) { | 1577 | for (i = 0; i < ARRAY_SIZE(sbp2_broken_inquiry_list); i++) { |
1564 | if ((firmware_revision & 0xffff00) == | 1578 | if ((firmware_revision & 0xffff00) == |
1565 | sbp2_broken_inquiry_list[i]) { | 1579 | sbp2_broken_inquiry_list[i]) { |
1566 | SBP2_WARN("Node " NODE_BUS_FMT ": Using 36byte inquiry workaround", | 1580 | SBP2_WARN("Node " NODE_BUS_FMT ": Using 36byte inquiry workaround", |
@@ -2007,18 +2021,6 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, | |||
2007 | } | 2021 | } |
2008 | 2022 | ||
2009 | /* | 2023 | /* |
2010 | * The scsi stack sends down a request_bufflen which does not match the | ||
2011 | * length field in the scsi cdb. This causes some sbp2 devices to | ||
2012 | * reject this inquiry command. Fix the request_bufflen. | ||
2013 | */ | ||
2014 | if (*cmd == INQUIRY) { | ||
2015 | if (force_inquiry_hack || scsi_id->workarounds & SBP2_BREAKAGE_INQUIRY_HACK) | ||
2016 | request_bufflen = cmd[4] = 0x24; | ||
2017 | else | ||
2018 | request_bufflen = cmd[4]; | ||
2019 | } | ||
2020 | |||
2021 | /* | ||
2022 | * Now actually fill in the comamnd orb and sbp2 s/g list | 2024 | * Now actually fill in the comamnd orb and sbp2 s/g list |
2023 | */ | 2025 | */ |
2024 | sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg, | 2026 | sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg, |
@@ -2082,9 +2084,7 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, | |||
2082 | 2084 | ||
2083 | SBP2_DEBUG("sbp2_check_sbp2_response"); | 2085 | SBP2_DEBUG("sbp2_check_sbp2_response"); |
2084 | 2086 | ||
2085 | switch (SCpnt->cmnd[0]) { | 2087 | if (SCpnt->cmnd[0] == INQUIRY && (SCpnt->cmnd[1] & 3) == 0) { |
2086 | |||
2087 | case INQUIRY: | ||
2088 | /* | 2088 | /* |
2089 | * Make sure data length is ok. Minimum length is 36 bytes | 2089 | * Make sure data length is ok. Minimum length is 36 bytes |
2090 | */ | 2090 | */ |
@@ -2097,13 +2097,7 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, | |||
2097 | */ | 2097 | */ |
2098 | scsi_buf[2] |= 2; | 2098 | scsi_buf[2] |= 2; |
2099 | scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2; | 2099 | scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2; |
2100 | |||
2101 | break; | ||
2102 | |||
2103 | default: | ||
2104 | break; | ||
2105 | } | 2100 | } |
2106 | return; | ||
2107 | } | 2101 | } |
2108 | 2102 | ||
2109 | /* | 2103 | /* |
@@ -2114,7 +2108,6 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest | |||
2114 | { | 2108 | { |
2115 | struct sbp2scsi_host_info *hi; | 2109 | struct sbp2scsi_host_info *hi; |
2116 | struct scsi_id_instance_data *scsi_id = NULL, *scsi_id_tmp; | 2110 | struct scsi_id_instance_data *scsi_id = NULL, *scsi_id_tmp; |
2117 | u32 id; | ||
2118 | struct scsi_cmnd *SCpnt = NULL; | 2111 | struct scsi_cmnd *SCpnt = NULL; |
2119 | u32 scsi_status = SBP2_SCSI_STATUS_GOOD; | 2112 | u32 scsi_status = SBP2_SCSI_STATUS_GOOD; |
2120 | struct sbp2_command_info *command; | 2113 | struct sbp2_command_info *command; |
@@ -2137,12 +2130,12 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest | |||
2137 | } | 2130 | } |
2138 | 2131 | ||
2139 | /* | 2132 | /* |
2140 | * Find our scsi_id structure by looking at the status fifo address written to by | 2133 | * Find our scsi_id structure by looking at the status fifo address |
2141 | * the sbp2 device. | 2134 | * written to by the sbp2 device. |
2142 | */ | 2135 | */ |
2143 | id = SBP2_STATUS_FIFO_OFFSET_TO_ENTRY((u32)(addr - SBP2_STATUS_FIFO_ADDRESS)); | ||
2144 | list_for_each_entry(scsi_id_tmp, &hi->scsi_ids, scsi_list) { | 2136 | list_for_each_entry(scsi_id_tmp, &hi->scsi_ids, scsi_list) { |
2145 | if (scsi_id_tmp->ne->nodeid == nodeid && scsi_id_tmp->ud->id == id) { | 2137 | if (scsi_id_tmp->ne->nodeid == nodeid && |
2138 | scsi_id_tmp->status_fifo_addr == addr) { | ||
2146 | scsi_id = scsi_id_tmp; | 2139 | scsi_id = scsi_id_tmp; |
2147 | break; | 2140 | break; |
2148 | } | 2141 | } |
@@ -2483,7 +2476,16 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, | |||
2483 | 2476 | ||
2484 | static int sbp2scsi_slave_alloc(struct scsi_device *sdev) | 2477 | static int sbp2scsi_slave_alloc(struct scsi_device *sdev) |
2485 | { | 2478 | { |
2486 | ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev; | 2479 | struct scsi_id_instance_data *scsi_id = |
2480 | (struct scsi_id_instance_data *)sdev->host->hostdata[0]; | ||
2481 | |||
2482 | scsi_id->sdev = sdev; | ||
2483 | |||
2484 | if (force_inquiry_hack || | ||
2485 | scsi_id->workarounds & SBP2_BREAKAGE_INQUIRY_HACK) { | ||
2486 | sdev->inquiry_len = 36; | ||
2487 | sdev->skip_ms_page_8 = 1; | ||
2488 | } | ||
2487 | return 0; | 2489 | return 0; |
2488 | } | 2490 | } |
2489 | 2491 | ||