diff options
author | Anton Blanchard <anton@samba.org> | 2013-09-02 20:04:47 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-09-06 14:38:19 -0400 |
commit | 72264eb6dbb9090265f6c87e49db78c4306bc1c3 (patch) | |
tree | fef44249d8db3c9f55e841efe962b1f2c138b84d /drivers | |
parent | 4079bc8b7d22c6ca24da7825c27c4b640ae61dc7 (diff) |
[SCSI] ibmvscsi: Fix little endian issues
The hypervisor is big endian, so little endian kernel builds need
to byteswap.
[jejb: fix checkpatch errors]
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/ibmvscsi/ibmvscsi.c | 154 | ||||
-rw-r--r-- | drivers/scsi/ibmvscsi/viosrp.h | 46 |
2 files changed, 109 insertions, 91 deletions
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index d0fa4b6c551f..fa764406df68 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c | |||
@@ -241,7 +241,7 @@ static void gather_partition_info(void) | |||
241 | struct device_node *rootdn; | 241 | struct device_node *rootdn; |
242 | 242 | ||
243 | const char *ppartition_name; | 243 | const char *ppartition_name; |
244 | const unsigned int *p_number_ptr; | 244 | const __be32 *p_number_ptr; |
245 | 245 | ||
246 | /* Retrieve information about this partition */ | 246 | /* Retrieve information about this partition */ |
247 | rootdn = of_find_node_by_path("/"); | 247 | rootdn = of_find_node_by_path("/"); |
@@ -255,7 +255,7 @@ static void gather_partition_info(void) | |||
255 | sizeof(partition_name)); | 255 | sizeof(partition_name)); |
256 | p_number_ptr = of_get_property(rootdn, "ibm,partition-no", NULL); | 256 | p_number_ptr = of_get_property(rootdn, "ibm,partition-no", NULL); |
257 | if (p_number_ptr) | 257 | if (p_number_ptr) |
258 | partition_number = *p_number_ptr; | 258 | partition_number = of_read_number(p_number_ptr, 1); |
259 | of_node_put(rootdn); | 259 | of_node_put(rootdn); |
260 | } | 260 | } |
261 | 261 | ||
@@ -270,10 +270,11 @@ static void set_adapter_info(struct ibmvscsi_host_data *hostdata) | |||
270 | strncpy(hostdata->madapter_info.partition_name, partition_name, | 270 | strncpy(hostdata->madapter_info.partition_name, partition_name, |
271 | sizeof(hostdata->madapter_info.partition_name)); | 271 | sizeof(hostdata->madapter_info.partition_name)); |
272 | 272 | ||
273 | hostdata->madapter_info.partition_number = partition_number; | 273 | hostdata->madapter_info.partition_number = |
274 | cpu_to_be32(partition_number); | ||
274 | 275 | ||
275 | hostdata->madapter_info.mad_version = 1; | 276 | hostdata->madapter_info.mad_version = cpu_to_be32(1); |
276 | hostdata->madapter_info.os_type = 2; | 277 | hostdata->madapter_info.os_type = cpu_to_be32(2); |
277 | } | 278 | } |
278 | 279 | ||
279 | /** | 280 | /** |
@@ -464,9 +465,9 @@ static int initialize_event_pool(struct event_pool *pool, | |||
464 | memset(&evt->crq, 0x00, sizeof(evt->crq)); | 465 | memset(&evt->crq, 0x00, sizeof(evt->crq)); |
465 | atomic_set(&evt->free, 1); | 466 | atomic_set(&evt->free, 1); |
466 | evt->crq.valid = 0x80; | 467 | evt->crq.valid = 0x80; |
467 | evt->crq.IU_length = sizeof(*evt->xfer_iu); | 468 | evt->crq.IU_length = cpu_to_be16(sizeof(*evt->xfer_iu)); |
468 | evt->crq.IU_data_ptr = pool->iu_token + | 469 | evt->crq.IU_data_ptr = cpu_to_be64(pool->iu_token + |
469 | sizeof(*evt->xfer_iu) * i; | 470 | sizeof(*evt->xfer_iu) * i); |
470 | evt->xfer_iu = pool->iu_storage + i; | 471 | evt->xfer_iu = pool->iu_storage + i; |
471 | evt->hostdata = hostdata; | 472 | evt->hostdata = hostdata; |
472 | evt->ext_list = NULL; | 473 | evt->ext_list = NULL; |
@@ -588,7 +589,7 @@ static void init_event_struct(struct srp_event_struct *evt_struct, | |||
588 | evt_struct->cmnd_done = NULL; | 589 | evt_struct->cmnd_done = NULL; |
589 | evt_struct->sync_srp = NULL; | 590 | evt_struct->sync_srp = NULL; |
590 | evt_struct->crq.format = format; | 591 | evt_struct->crq.format = format; |
591 | evt_struct->crq.timeout = timeout; | 592 | evt_struct->crq.timeout = cpu_to_be16(timeout); |
592 | evt_struct->done = done; | 593 | evt_struct->done = done; |
593 | } | 594 | } |
594 | 595 | ||
@@ -659,8 +660,8 @@ static int map_sg_list(struct scsi_cmnd *cmd, int nseg, | |||
659 | 660 | ||
660 | scsi_for_each_sg(cmd, sg, nseg, i) { | 661 | scsi_for_each_sg(cmd, sg, nseg, i) { |
661 | struct srp_direct_buf *descr = md + i; | 662 | struct srp_direct_buf *descr = md + i; |
662 | descr->va = sg_dma_address(sg); | 663 | descr->va = cpu_to_be64(sg_dma_address(sg)); |
663 | descr->len = sg_dma_len(sg); | 664 | descr->len = cpu_to_be32(sg_dma_len(sg)); |
664 | descr->key = 0; | 665 | descr->key = 0; |
665 | total_length += sg_dma_len(sg); | 666 | total_length += sg_dma_len(sg); |
666 | } | 667 | } |
@@ -703,13 +704,14 @@ static int map_sg_data(struct scsi_cmnd *cmd, | |||
703 | } | 704 | } |
704 | 705 | ||
705 | indirect->table_desc.va = 0; | 706 | indirect->table_desc.va = 0; |
706 | indirect->table_desc.len = sg_mapped * sizeof(struct srp_direct_buf); | 707 | indirect->table_desc.len = cpu_to_be32(sg_mapped * |
708 | sizeof(struct srp_direct_buf)); | ||
707 | indirect->table_desc.key = 0; | 709 | indirect->table_desc.key = 0; |
708 | 710 | ||
709 | if (sg_mapped <= MAX_INDIRECT_BUFS) { | 711 | if (sg_mapped <= MAX_INDIRECT_BUFS) { |
710 | total_length = map_sg_list(cmd, sg_mapped, | 712 | total_length = map_sg_list(cmd, sg_mapped, |
711 | &indirect->desc_list[0]); | 713 | &indirect->desc_list[0]); |
712 | indirect->len = total_length; | 714 | indirect->len = cpu_to_be32(total_length); |
713 | return 1; | 715 | return 1; |
714 | } | 716 | } |
715 | 717 | ||
@@ -731,9 +733,10 @@ static int map_sg_data(struct scsi_cmnd *cmd, | |||
731 | 733 | ||
732 | total_length = map_sg_list(cmd, sg_mapped, evt_struct->ext_list); | 734 | total_length = map_sg_list(cmd, sg_mapped, evt_struct->ext_list); |
733 | 735 | ||
734 | indirect->len = total_length; | 736 | indirect->len = cpu_to_be32(total_length); |
735 | indirect->table_desc.va = evt_struct->ext_list_token; | 737 | indirect->table_desc.va = cpu_to_be64(evt_struct->ext_list_token); |
736 | indirect->table_desc.len = sg_mapped * sizeof(indirect->desc_list[0]); | 738 | indirect->table_desc.len = cpu_to_be32(sg_mapped * |
739 | sizeof(indirect->desc_list[0])); | ||
737 | memcpy(indirect->desc_list, evt_struct->ext_list, | 740 | memcpy(indirect->desc_list, evt_struct->ext_list, |
738 | MAX_INDIRECT_BUFS * sizeof(struct srp_direct_buf)); | 741 | MAX_INDIRECT_BUFS * sizeof(struct srp_direct_buf)); |
739 | return 1; | 742 | return 1; |
@@ -849,7 +852,7 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, | |||
849 | struct ibmvscsi_host_data *hostdata, | 852 | struct ibmvscsi_host_data *hostdata, |
850 | unsigned long timeout) | 853 | unsigned long timeout) |
851 | { | 854 | { |
852 | u64 *crq_as_u64 = (u64 *) &evt_struct->crq; | 855 | __be64 *crq_as_u64 = (__be64 *)&evt_struct->crq; |
853 | int request_status = 0; | 856 | int request_status = 0; |
854 | int rc; | 857 | int rc; |
855 | int srp_req = 0; | 858 | int srp_req = 0; |
@@ -920,8 +923,9 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, | |||
920 | add_timer(&evt_struct->timer); | 923 | add_timer(&evt_struct->timer); |
921 | } | 924 | } |
922 | 925 | ||
923 | if ((rc = | 926 | rc = ibmvscsi_send_crq(hostdata, be64_to_cpu(crq_as_u64[0]), |
924 | ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) { | 927 | be64_to_cpu(crq_as_u64[1])); |
928 | if (rc != 0) { | ||
925 | list_del(&evt_struct->list); | 929 | list_del(&evt_struct->list); |
926 | del_timer(&evt_struct->timer); | 930 | del_timer(&evt_struct->timer); |
927 | 931 | ||
@@ -987,15 +991,16 @@ static void handle_cmd_rsp(struct srp_event_struct *evt_struct) | |||
987 | if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION) | 991 | if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION) |
988 | memcpy(cmnd->sense_buffer, | 992 | memcpy(cmnd->sense_buffer, |
989 | rsp->data, | 993 | rsp->data, |
990 | rsp->sense_data_len); | 994 | be32_to_cpu(rsp->sense_data_len)); |
991 | unmap_cmd_data(&evt_struct->iu.srp.cmd, | 995 | unmap_cmd_data(&evt_struct->iu.srp.cmd, |
992 | evt_struct, | 996 | evt_struct, |
993 | evt_struct->hostdata->dev); | 997 | evt_struct->hostdata->dev); |
994 | 998 | ||
995 | if (rsp->flags & SRP_RSP_FLAG_DOOVER) | 999 | if (rsp->flags & SRP_RSP_FLAG_DOOVER) |
996 | scsi_set_resid(cmnd, rsp->data_out_res_cnt); | 1000 | scsi_set_resid(cmnd, |
1001 | be32_to_cpu(rsp->data_out_res_cnt)); | ||
997 | else if (rsp->flags & SRP_RSP_FLAG_DIOVER) | 1002 | else if (rsp->flags & SRP_RSP_FLAG_DIOVER) |
998 | scsi_set_resid(cmnd, rsp->data_in_res_cnt); | 1003 | scsi_set_resid(cmnd, be32_to_cpu(rsp->data_in_res_cnt)); |
999 | } | 1004 | } |
1000 | 1005 | ||
1001 | if (evt_struct->cmnd_done) | 1006 | if (evt_struct->cmnd_done) |
@@ -1037,7 +1042,7 @@ static int ibmvscsi_queuecommand_lck(struct scsi_cmnd *cmnd, | |||
1037 | memset(srp_cmd, 0x00, SRP_MAX_IU_LEN); | 1042 | memset(srp_cmd, 0x00, SRP_MAX_IU_LEN); |
1038 | srp_cmd->opcode = SRP_CMD; | 1043 | srp_cmd->opcode = SRP_CMD; |
1039 | memcpy(srp_cmd->cdb, cmnd->cmnd, sizeof(srp_cmd->cdb)); | 1044 | memcpy(srp_cmd->cdb, cmnd->cmnd, sizeof(srp_cmd->cdb)); |
1040 | srp_cmd->lun = ((u64) lun) << 48; | 1045 | srp_cmd->lun = cpu_to_be64(((u64)lun) << 48); |
1041 | 1046 | ||
1042 | if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { | 1047 | if (!map_data_for_srp_cmd(cmnd, evt_struct, srp_cmd, hostdata->dev)) { |
1043 | if (!firmware_has_feature(FW_FEATURE_CMO)) | 1048 | if (!firmware_has_feature(FW_FEATURE_CMO)) |
@@ -1062,9 +1067,10 @@ static int ibmvscsi_queuecommand_lck(struct scsi_cmnd *cmnd, | |||
1062 | if ((in_fmt == SRP_DATA_DESC_INDIRECT || | 1067 | if ((in_fmt == SRP_DATA_DESC_INDIRECT || |
1063 | out_fmt == SRP_DATA_DESC_INDIRECT) && | 1068 | out_fmt == SRP_DATA_DESC_INDIRECT) && |
1064 | indirect->table_desc.va == 0) { | 1069 | indirect->table_desc.va == 0) { |
1065 | indirect->table_desc.va = evt_struct->crq.IU_data_ptr + | 1070 | indirect->table_desc.va = |
1071 | cpu_to_be64(be64_to_cpu(evt_struct->crq.IU_data_ptr) + | ||
1066 | offsetof(struct srp_cmd, add_data) + | 1072 | offsetof(struct srp_cmd, add_data) + |
1067 | offsetof(struct srp_indirect_buf, desc_list); | 1073 | offsetof(struct srp_indirect_buf, desc_list)); |
1068 | } | 1074 | } |
1069 | 1075 | ||
1070 | return ibmvscsi_send_srp_event(evt_struct, hostdata, 0); | 1076 | return ibmvscsi_send_srp_event(evt_struct, hostdata, 0); |
@@ -1158,7 +1164,7 @@ static void login_rsp(struct srp_event_struct *evt_struct) | |||
1158 | * request_limit could have been set to -1 by this client. | 1164 | * request_limit could have been set to -1 by this client. |
1159 | */ | 1165 | */ |
1160 | atomic_set(&hostdata->request_limit, | 1166 | atomic_set(&hostdata->request_limit, |
1161 | evt_struct->xfer_iu->srp.login_rsp.req_lim_delta); | 1167 | be32_to_cpu(evt_struct->xfer_iu->srp.login_rsp.req_lim_delta)); |
1162 | 1168 | ||
1163 | /* If we had any pending I/Os, kick them */ | 1169 | /* If we had any pending I/Os, kick them */ |
1164 | scsi_unblock_requests(hostdata->host); | 1170 | scsi_unblock_requests(hostdata->host); |
@@ -1184,8 +1190,9 @@ static int send_srp_login(struct ibmvscsi_host_data *hostdata) | |||
1184 | login = &evt_struct->iu.srp.login_req; | 1190 | login = &evt_struct->iu.srp.login_req; |
1185 | memset(login, 0, sizeof(*login)); | 1191 | memset(login, 0, sizeof(*login)); |
1186 | login->opcode = SRP_LOGIN_REQ; | 1192 | login->opcode = SRP_LOGIN_REQ; |
1187 | login->req_it_iu_len = sizeof(union srp_iu); | 1193 | login->req_it_iu_len = cpu_to_be32(sizeof(union srp_iu)); |
1188 | login->req_buf_fmt = SRP_BUF_FORMAT_DIRECT | SRP_BUF_FORMAT_INDIRECT; | 1194 | login->req_buf_fmt = cpu_to_be16(SRP_BUF_FORMAT_DIRECT | |
1195 | SRP_BUF_FORMAT_INDIRECT); | ||
1189 | 1196 | ||
1190 | spin_lock_irqsave(hostdata->host->host_lock, flags); | 1197 | spin_lock_irqsave(hostdata->host->host_lock, flags); |
1191 | /* Start out with a request limit of 0, since this is negotiated in | 1198 | /* Start out with a request limit of 0, since this is negotiated in |
@@ -1214,12 +1221,13 @@ static void capabilities_rsp(struct srp_event_struct *evt_struct) | |||
1214 | dev_err(hostdata->dev, "error 0x%X getting capabilities info\n", | 1221 | dev_err(hostdata->dev, "error 0x%X getting capabilities info\n", |
1215 | evt_struct->xfer_iu->mad.capabilities.common.status); | 1222 | evt_struct->xfer_iu->mad.capabilities.common.status); |
1216 | } else { | 1223 | } else { |
1217 | if (hostdata->caps.migration.common.server_support != SERVER_SUPPORTS_CAP) | 1224 | if (hostdata->caps.migration.common.server_support != |
1225 | cpu_to_be16(SERVER_SUPPORTS_CAP)) | ||
1218 | dev_info(hostdata->dev, "Partition migration not supported\n"); | 1226 | dev_info(hostdata->dev, "Partition migration not supported\n"); |
1219 | 1227 | ||
1220 | if (client_reserve) { | 1228 | if (client_reserve) { |
1221 | if (hostdata->caps.reserve.common.server_support == | 1229 | if (hostdata->caps.reserve.common.server_support == |
1222 | SERVER_SUPPORTS_CAP) | 1230 | cpu_to_be16(SERVER_SUPPORTS_CAP)) |
1223 | dev_info(hostdata->dev, "Client reserve enabled\n"); | 1231 | dev_info(hostdata->dev, "Client reserve enabled\n"); |
1224 | else | 1232 | else |
1225 | dev_info(hostdata->dev, "Client reserve not supported\n"); | 1233 | dev_info(hostdata->dev, "Client reserve not supported\n"); |
@@ -1251,9 +1259,9 @@ static void send_mad_capabilities(struct ibmvscsi_host_data *hostdata) | |||
1251 | req = &evt_struct->iu.mad.capabilities; | 1259 | req = &evt_struct->iu.mad.capabilities; |
1252 | memset(req, 0, sizeof(*req)); | 1260 | memset(req, 0, sizeof(*req)); |
1253 | 1261 | ||
1254 | hostdata->caps.flags = CAP_LIST_SUPPORTED; | 1262 | hostdata->caps.flags = cpu_to_be32(CAP_LIST_SUPPORTED); |
1255 | if (hostdata->client_migrated) | 1263 | if (hostdata->client_migrated) |
1256 | hostdata->caps.flags |= CLIENT_MIGRATED; | 1264 | hostdata->caps.flags |= cpu_to_be32(CLIENT_MIGRATED); |
1257 | 1265 | ||
1258 | strncpy(hostdata->caps.name, dev_name(&hostdata->host->shost_gendev), | 1266 | strncpy(hostdata->caps.name, dev_name(&hostdata->host->shost_gendev), |
1259 | sizeof(hostdata->caps.name)); | 1267 | sizeof(hostdata->caps.name)); |
@@ -1264,22 +1272,31 @@ static void send_mad_capabilities(struct ibmvscsi_host_data *hostdata) | |||
1264 | strncpy(hostdata->caps.loc, location, sizeof(hostdata->caps.loc)); | 1272 | strncpy(hostdata->caps.loc, location, sizeof(hostdata->caps.loc)); |
1265 | hostdata->caps.loc[sizeof(hostdata->caps.loc) - 1] = '\0'; | 1273 | hostdata->caps.loc[sizeof(hostdata->caps.loc) - 1] = '\0'; |
1266 | 1274 | ||
1267 | req->common.type = VIOSRP_CAPABILITIES_TYPE; | 1275 | req->common.type = cpu_to_be32(VIOSRP_CAPABILITIES_TYPE); |
1268 | req->buffer = hostdata->caps_addr; | 1276 | req->buffer = cpu_to_be64(hostdata->caps_addr); |
1269 | 1277 | ||
1270 | hostdata->caps.migration.common.cap_type = MIGRATION_CAPABILITIES; | 1278 | hostdata->caps.migration.common.cap_type = |
1271 | hostdata->caps.migration.common.length = sizeof(hostdata->caps.migration); | 1279 | cpu_to_be32(MIGRATION_CAPABILITIES); |
1272 | hostdata->caps.migration.common.server_support = SERVER_SUPPORTS_CAP; | 1280 | hostdata->caps.migration.common.length = |
1273 | hostdata->caps.migration.ecl = 1; | 1281 | cpu_to_be16(sizeof(hostdata->caps.migration)); |
1282 | hostdata->caps.migration.common.server_support = | ||
1283 | cpu_to_be16(SERVER_SUPPORTS_CAP); | ||
1284 | hostdata->caps.migration.ecl = cpu_to_be32(1); | ||
1274 | 1285 | ||
1275 | if (client_reserve) { | 1286 | if (client_reserve) { |
1276 | hostdata->caps.reserve.common.cap_type = RESERVATION_CAPABILITIES; | 1287 | hostdata->caps.reserve.common.cap_type = |
1277 | hostdata->caps.reserve.common.length = sizeof(hostdata->caps.reserve); | 1288 | cpu_to_be32(RESERVATION_CAPABILITIES); |
1278 | hostdata->caps.reserve.common.server_support = SERVER_SUPPORTS_CAP; | 1289 | hostdata->caps.reserve.common.length = |
1279 | hostdata->caps.reserve.type = CLIENT_RESERVE_SCSI_2; | 1290 | cpu_to_be16(sizeof(hostdata->caps.reserve)); |
1280 | req->common.length = sizeof(hostdata->caps); | 1291 | hostdata->caps.reserve.common.server_support = |
1292 | cpu_to_be16(SERVER_SUPPORTS_CAP); | ||
1293 | hostdata->caps.reserve.type = | ||
1294 | cpu_to_be32(CLIENT_RESERVE_SCSI_2); | ||
1295 | req->common.length = | ||
1296 | cpu_to_be16(sizeof(hostdata->caps)); | ||
1281 | } else | 1297 | } else |
1282 | req->common.length = sizeof(hostdata->caps) - sizeof(hostdata->caps.reserve); | 1298 | req->common.length = cpu_to_be16(sizeof(hostdata->caps) - |
1299 | sizeof(hostdata->caps.reserve)); | ||
1283 | 1300 | ||
1284 | spin_lock_irqsave(hostdata->host->host_lock, flags); | 1301 | spin_lock_irqsave(hostdata->host->host_lock, flags); |
1285 | if (ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2)) | 1302 | if (ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2)) |
@@ -1297,7 +1314,7 @@ static void send_mad_capabilities(struct ibmvscsi_host_data *hostdata) | |||
1297 | static void fast_fail_rsp(struct srp_event_struct *evt_struct) | 1314 | static void fast_fail_rsp(struct srp_event_struct *evt_struct) |
1298 | { | 1315 | { |
1299 | struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; | 1316 | struct ibmvscsi_host_data *hostdata = evt_struct->hostdata; |
1300 | u8 status = evt_struct->xfer_iu->mad.fast_fail.common.status; | 1317 | u16 status = be16_to_cpu(evt_struct->xfer_iu->mad.fast_fail.common.status); |
1301 | 1318 | ||
1302 | if (status == VIOSRP_MAD_NOT_SUPPORTED) | 1319 | if (status == VIOSRP_MAD_NOT_SUPPORTED) |
1303 | dev_err(hostdata->dev, "fast_fail not supported in server\n"); | 1320 | dev_err(hostdata->dev, "fast_fail not supported in server\n"); |
@@ -1334,8 +1351,8 @@ static int enable_fast_fail(struct ibmvscsi_host_data *hostdata) | |||
1334 | 1351 | ||
1335 | fast_fail_mad = &evt_struct->iu.mad.fast_fail; | 1352 | fast_fail_mad = &evt_struct->iu.mad.fast_fail; |
1336 | memset(fast_fail_mad, 0, sizeof(*fast_fail_mad)); | 1353 | memset(fast_fail_mad, 0, sizeof(*fast_fail_mad)); |
1337 | fast_fail_mad->common.type = VIOSRP_ENABLE_FAST_FAIL; | 1354 | fast_fail_mad->common.type = cpu_to_be32(VIOSRP_ENABLE_FAST_FAIL); |
1338 | fast_fail_mad->common.length = sizeof(*fast_fail_mad); | 1355 | fast_fail_mad->common.length = cpu_to_be16(sizeof(*fast_fail_mad)); |
1339 | 1356 | ||
1340 | spin_lock_irqsave(hostdata->host->host_lock, flags); | 1357 | spin_lock_irqsave(hostdata->host->host_lock, flags); |
1341 | rc = ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2); | 1358 | rc = ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2); |
@@ -1362,15 +1379,15 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct) | |||
1362 | "host partition %s (%d), OS %d, max io %u\n", | 1379 | "host partition %s (%d), OS %d, max io %u\n", |
1363 | hostdata->madapter_info.srp_version, | 1380 | hostdata->madapter_info.srp_version, |
1364 | hostdata->madapter_info.partition_name, | 1381 | hostdata->madapter_info.partition_name, |
1365 | hostdata->madapter_info.partition_number, | 1382 | be32_to_cpu(hostdata->madapter_info.partition_number), |
1366 | hostdata->madapter_info.os_type, | 1383 | be32_to_cpu(hostdata->madapter_info.os_type), |
1367 | hostdata->madapter_info.port_max_txu[0]); | 1384 | be32_to_cpu(hostdata->madapter_info.port_max_txu[0])); |
1368 | 1385 | ||
1369 | if (hostdata->madapter_info.port_max_txu[0]) | 1386 | if (hostdata->madapter_info.port_max_txu[0]) |
1370 | hostdata->host->max_sectors = | 1387 | hostdata->host->max_sectors = |
1371 | hostdata->madapter_info.port_max_txu[0] >> 9; | 1388 | be32_to_cpu(hostdata->madapter_info.port_max_txu[0]) >> 9; |
1372 | 1389 | ||
1373 | if (hostdata->madapter_info.os_type == 3 && | 1390 | if (be32_to_cpu(hostdata->madapter_info.os_type) == 3 && |
1374 | strcmp(hostdata->madapter_info.srp_version, "1.6a") <= 0) { | 1391 | strcmp(hostdata->madapter_info.srp_version, "1.6a") <= 0) { |
1375 | dev_err(hostdata->dev, "host (Ver. %s) doesn't support large transfers\n", | 1392 | dev_err(hostdata->dev, "host (Ver. %s) doesn't support large transfers\n", |
1376 | hostdata->madapter_info.srp_version); | 1393 | hostdata->madapter_info.srp_version); |
@@ -1379,7 +1396,7 @@ static void adapter_info_rsp(struct srp_event_struct *evt_struct) | |||
1379 | hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS; | 1396 | hostdata->host->sg_tablesize = MAX_INDIRECT_BUFS; |
1380 | } | 1397 | } |
1381 | 1398 | ||
1382 | if (hostdata->madapter_info.os_type == 3) { | 1399 | if (be32_to_cpu(hostdata->madapter_info.os_type) == 3) { |
1383 | enable_fast_fail(hostdata); | 1400 | enable_fast_fail(hostdata); |
1384 | return; | 1401 | return; |
1385 | } | 1402 | } |
@@ -1414,9 +1431,9 @@ static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata) | |||
1414 | req = &evt_struct->iu.mad.adapter_info; | 1431 | req = &evt_struct->iu.mad.adapter_info; |
1415 | memset(req, 0x00, sizeof(*req)); | 1432 | memset(req, 0x00, sizeof(*req)); |
1416 | 1433 | ||
1417 | req->common.type = VIOSRP_ADAPTER_INFO_TYPE; | 1434 | req->common.type = cpu_to_be32(VIOSRP_ADAPTER_INFO_TYPE); |
1418 | req->common.length = sizeof(hostdata->madapter_info); | 1435 | req->common.length = cpu_to_be16(sizeof(hostdata->madapter_info)); |
1419 | req->buffer = hostdata->adapter_info_addr; | 1436 | req->buffer = cpu_to_be64(hostdata->adapter_info_addr); |
1420 | 1437 | ||
1421 | spin_lock_irqsave(hostdata->host->host_lock, flags); | 1438 | spin_lock_irqsave(hostdata->host->host_lock, flags); |
1422 | if (ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2)) | 1439 | if (ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2)) |
@@ -1501,7 +1518,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) | |||
1501 | /* Set up an abort SRP command */ | 1518 | /* Set up an abort SRP command */ |
1502 | memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt)); | 1519 | memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt)); |
1503 | tsk_mgmt->opcode = SRP_TSK_MGMT; | 1520 | tsk_mgmt->opcode = SRP_TSK_MGMT; |
1504 | tsk_mgmt->lun = ((u64) lun) << 48; | 1521 | tsk_mgmt->lun = cpu_to_be64(((u64) lun) << 48); |
1505 | tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK; | 1522 | tsk_mgmt->tsk_mgmt_func = SRP_TSK_ABORT_TASK; |
1506 | tsk_mgmt->task_tag = (u64) found_evt; | 1523 | tsk_mgmt->task_tag = (u64) found_evt; |
1507 | 1524 | ||
@@ -1624,7 +1641,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) | |||
1624 | /* Set up a lun reset SRP command */ | 1641 | /* Set up a lun reset SRP command */ |
1625 | memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt)); | 1642 | memset(tsk_mgmt, 0x00, sizeof(*tsk_mgmt)); |
1626 | tsk_mgmt->opcode = SRP_TSK_MGMT; | 1643 | tsk_mgmt->opcode = SRP_TSK_MGMT; |
1627 | tsk_mgmt->lun = ((u64) lun) << 48; | 1644 | tsk_mgmt->lun = cpu_to_be64(((u64) lun) << 48); |
1628 | tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET; | 1645 | tsk_mgmt->tsk_mgmt_func = SRP_TSK_LUN_RESET; |
1629 | 1646 | ||
1630 | evt->sync_srp = &srp_rsp; | 1647 | evt->sync_srp = &srp_rsp; |
@@ -1735,8 +1752,9 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, | |||
1735 | { | 1752 | { |
1736 | long rc; | 1753 | long rc; |
1737 | unsigned long flags; | 1754 | unsigned long flags; |
1755 | /* The hypervisor copies our tag value here so no byteswapping */ | ||
1738 | struct srp_event_struct *evt_struct = | 1756 | struct srp_event_struct *evt_struct = |
1739 | (struct srp_event_struct *)crq->IU_data_ptr; | 1757 | (__force struct srp_event_struct *)crq->IU_data_ptr; |
1740 | switch (crq->valid) { | 1758 | switch (crq->valid) { |
1741 | case 0xC0: /* initialization */ | 1759 | case 0xC0: /* initialization */ |
1742 | switch (crq->format) { | 1760 | switch (crq->format) { |
@@ -1792,18 +1810,18 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq, | |||
1792 | */ | 1810 | */ |
1793 | if (!valid_event_struct(&hostdata->pool, evt_struct)) { | 1811 | if (!valid_event_struct(&hostdata->pool, evt_struct)) { |
1794 | dev_err(hostdata->dev, "returned correlation_token 0x%p is invalid!\n", | 1812 | dev_err(hostdata->dev, "returned correlation_token 0x%p is invalid!\n", |
1795 | (void *)crq->IU_data_ptr); | 1813 | evt_struct); |
1796 | return; | 1814 | return; |
1797 | } | 1815 | } |
1798 | 1816 | ||
1799 | if (atomic_read(&evt_struct->free)) { | 1817 | if (atomic_read(&evt_struct->free)) { |
1800 | dev_err(hostdata->dev, "received duplicate correlation_token 0x%p!\n", | 1818 | dev_err(hostdata->dev, "received duplicate correlation_token 0x%p!\n", |
1801 | (void *)crq->IU_data_ptr); | 1819 | evt_struct); |
1802 | return; | 1820 | return; |
1803 | } | 1821 | } |
1804 | 1822 | ||
1805 | if (crq->format == VIOSRP_SRP_FORMAT) | 1823 | if (crq->format == VIOSRP_SRP_FORMAT) |
1806 | atomic_add(evt_struct->xfer_iu->srp.rsp.req_lim_delta, | 1824 | atomic_add(be32_to_cpu(evt_struct->xfer_iu->srp.rsp.req_lim_delta), |
1807 | &hostdata->request_limit); | 1825 | &hostdata->request_limit); |
1808 | 1826 | ||
1809 | del_timer(&evt_struct->timer); | 1827 | del_timer(&evt_struct->timer); |
@@ -1856,13 +1874,11 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata, | |||
1856 | 1874 | ||
1857 | /* Set up a lun reset SRP command */ | 1875 | /* Set up a lun reset SRP command */ |
1858 | memset(host_config, 0x00, sizeof(*host_config)); | 1876 | memset(host_config, 0x00, sizeof(*host_config)); |
1859 | host_config->common.type = VIOSRP_HOST_CONFIG_TYPE; | 1877 | host_config->common.type = cpu_to_be32(VIOSRP_HOST_CONFIG_TYPE); |
1860 | host_config->common.length = length; | 1878 | host_config->common.length = cpu_to_be16(length); |
1861 | host_config->buffer = addr = dma_map_single(hostdata->dev, buffer, | 1879 | addr = dma_map_single(hostdata->dev, buffer, length, DMA_BIDIRECTIONAL); |
1862 | length, | ||
1863 | DMA_BIDIRECTIONAL); | ||
1864 | 1880 | ||
1865 | if (dma_mapping_error(hostdata->dev, host_config->buffer)) { | 1881 | if (dma_mapping_error(hostdata->dev, addr)) { |
1866 | if (!firmware_has_feature(FW_FEATURE_CMO)) | 1882 | if (!firmware_has_feature(FW_FEATURE_CMO)) |
1867 | dev_err(hostdata->dev, | 1883 | dev_err(hostdata->dev, |
1868 | "dma_mapping error getting host config\n"); | 1884 | "dma_mapping error getting host config\n"); |
@@ -1870,6 +1886,8 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata, | |||
1870 | return -1; | 1886 | return -1; |
1871 | } | 1887 | } |
1872 | 1888 | ||
1889 | host_config->buffer = cpu_to_be64(addr); | ||
1890 | |||
1873 | init_completion(&evt_struct->comp); | 1891 | init_completion(&evt_struct->comp); |
1874 | spin_lock_irqsave(hostdata->host->host_lock, flags); | 1892 | spin_lock_irqsave(hostdata->host->host_lock, flags); |
1875 | rc = ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2); | 1893 | rc = ibmvscsi_send_srp_event(evt_struct, hostdata, info_timeout * 2); |
diff --git a/drivers/scsi/ibmvscsi/viosrp.h b/drivers/scsi/ibmvscsi/viosrp.h index 2cd735d1d196..116243087622 100644 --- a/drivers/scsi/ibmvscsi/viosrp.h +++ b/drivers/scsi/ibmvscsi/viosrp.h | |||
@@ -75,9 +75,9 @@ struct viosrp_crq { | |||
75 | u8 format; /* SCSI vs out-of-band */ | 75 | u8 format; /* SCSI vs out-of-band */ |
76 | u8 reserved; | 76 | u8 reserved; |
77 | u8 status; /* non-scsi failure? (e.g. DMA failure) */ | 77 | u8 status; /* non-scsi failure? (e.g. DMA failure) */ |
78 | u16 timeout; /* in seconds */ | 78 | __be16 timeout; /* in seconds */ |
79 | u16 IU_length; /* in bytes */ | 79 | __be16 IU_length; /* in bytes */ |
80 | u64 IU_data_ptr; /* the TCE for transferring data */ | 80 | __be64 IU_data_ptr; /* the TCE for transferring data */ |
81 | }; | 81 | }; |
82 | 82 | ||
83 | /* MADs are Management requests above and beyond the IUs defined in the SRP | 83 | /* MADs are Management requests above and beyond the IUs defined in the SRP |
@@ -124,10 +124,10 @@ enum viosrp_capability_flag { | |||
124 | * Common MAD header | 124 | * Common MAD header |
125 | */ | 125 | */ |
126 | struct mad_common { | 126 | struct mad_common { |
127 | u32 type; | 127 | __be32 type; |
128 | u16 status; | 128 | __be16 status; |
129 | u16 length; | 129 | __be16 length; |
130 | u64 tag; | 130 | __be64 tag; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | /* | 133 | /* |
@@ -139,23 +139,23 @@ struct mad_common { | |||
139 | */ | 139 | */ |
140 | struct viosrp_empty_iu { | 140 | struct viosrp_empty_iu { |
141 | struct mad_common common; | 141 | struct mad_common common; |
142 | u64 buffer; | 142 | __be64 buffer; |
143 | u32 port; | 143 | __be32 port; |
144 | }; | 144 | }; |
145 | 145 | ||
146 | struct viosrp_error_log { | 146 | struct viosrp_error_log { |
147 | struct mad_common common; | 147 | struct mad_common common; |
148 | u64 buffer; | 148 | __be64 buffer; |
149 | }; | 149 | }; |
150 | 150 | ||
151 | struct viosrp_adapter_info { | 151 | struct viosrp_adapter_info { |
152 | struct mad_common common; | 152 | struct mad_common common; |
153 | u64 buffer; | 153 | __be64 buffer; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | struct viosrp_host_config { | 156 | struct viosrp_host_config { |
157 | struct mad_common common; | 157 | struct mad_common common; |
158 | u64 buffer; | 158 | __be64 buffer; |
159 | }; | 159 | }; |
160 | 160 | ||
161 | struct viosrp_fast_fail { | 161 | struct viosrp_fast_fail { |
@@ -164,27 +164,27 @@ struct viosrp_fast_fail { | |||
164 | 164 | ||
165 | struct viosrp_capabilities { | 165 | struct viosrp_capabilities { |
166 | struct mad_common common; | 166 | struct mad_common common; |
167 | u64 buffer; | 167 | __be64 buffer; |
168 | }; | 168 | }; |
169 | 169 | ||
170 | struct mad_capability_common { | 170 | struct mad_capability_common { |
171 | u32 cap_type; | 171 | __be32 cap_type; |
172 | u16 length; | 172 | __be16 length; |
173 | u16 server_support; | 173 | __be16 server_support; |
174 | }; | 174 | }; |
175 | 175 | ||
176 | struct mad_reserve_cap { | 176 | struct mad_reserve_cap { |
177 | struct mad_capability_common common; | 177 | struct mad_capability_common common; |
178 | u32 type; | 178 | __be32 type; |
179 | }; | 179 | }; |
180 | 180 | ||
181 | struct mad_migration_cap { | 181 | struct mad_migration_cap { |
182 | struct mad_capability_common common; | 182 | struct mad_capability_common common; |
183 | u32 ecl; | 183 | __be32 ecl; |
184 | }; | 184 | }; |
185 | 185 | ||
186 | struct capabilities{ | 186 | struct capabilities{ |
187 | u32 flags; | 187 | __be32 flags; |
188 | char name[SRP_MAX_LOC_LEN]; | 188 | char name[SRP_MAX_LOC_LEN]; |
189 | char loc[SRP_MAX_LOC_LEN]; | 189 | char loc[SRP_MAX_LOC_LEN]; |
190 | struct mad_migration_cap migration; | 190 | struct mad_migration_cap migration; |
@@ -208,10 +208,10 @@ union viosrp_iu { | |||
208 | struct mad_adapter_info_data { | 208 | struct mad_adapter_info_data { |
209 | char srp_version[8]; | 209 | char srp_version[8]; |
210 | char partition_name[96]; | 210 | char partition_name[96]; |
211 | u32 partition_number; | 211 | __be32 partition_number; |
212 | u32 mad_version; | 212 | __be32 mad_version; |
213 | u32 os_type; | 213 | __be32 os_type; |
214 | u32 port_max_txu[8]; /* per-port maximum transfer */ | 214 | __be32 port_max_txu[8]; /* per-port maximum transfer */ |
215 | }; | 215 | }; |
216 | 216 | ||
217 | #endif | 217 | #endif |