qla2xxx: Fix endianness of task management response code
Subsystems (2)
PATCH 1/1 qla2xxx: Fix endianness of task management response code
From: Roland Dreier <[email protected]>
The qla2xxx firmware actually expects the task management response code in a CTIO IOCB with SCSI status mode 1 to be in little-endian byte order, ie the response code should be the first byte in the sense_data[] array. The old code erroneously byte-swapped the response code, which puts it in the wrong place on the wire and leads to initiators thinking every task management request succeeds (since they see 0 in the byte where they look for the response code).
--- drivers/scsi/qla2xxx/qla_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_target.c +1 -1
@@ -1403,7 +1403,7 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha, ctio->u.status1.scsi_status =__constant_cpu_to_le16 (SS_RESPONSE_INFO_LEN_VALID ); ctio->u.status1.response_len =__constant_cpu_to_le16 (8 ); - ((uint32_t *)ctio->u.status1.sense_data)[0 ] =cpu_to_be32 (resp_code); + ctio->u.status1.sense_data[0 ] = resp_code;qla2x00_start_iocbs (ha, ha->req); }
Signature · 1 line
1.7.10.4
Quoted 10 lines · Roland Dreier
From: Roland Dreier <[email protected]>
The qla2xxx firmware actually expects the task management response code in a CTIO IOCB with SCSI status mode 1 to be in little-endian byte order, ie the response code should be the first byte in the sense_data[] array. The old code erroneously byte-swapped the response code, which puts it in the wrong place on the wire and leads to initiators thinking every task management request succeeds (since they see 0 in the byte where they look for the response code).
Quoted 4 lines
Cc Chad Dupuis <[email protected]>Cc Arun Easi <[email protected]>Signed-off-by Roland Dreier <[email protected]>---
Very nice catch here Roland!
Quoted 8 lines
drivers/scsi/qla2xxx/qla_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/qla2xxx/qla_target.c +0
-0
drivers/scsi/qla2xxx/qla_target.c static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha, · line 1409
Quoted 8 lines
drivers/scsi/qla2xxx/qla_target.c +1
-1@@ -1403,7 +1403,7 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha, ctio->u.status1.scsi_status =__constant_cpu_to_le16 (SS_RESPONSE_INFO_LEN_VALID ); ctio->u.status1.response_len =__constant_cpu_to_le16 (8 ); - ((uint32_t *)ctio->u.status1.sense_data)[0 ] =cpu_to_be32 (resp_code); + ctio->u.status1.sense_data[0 ] = resp_code;qla2x00_start_iocbs (ha, ha->req); }
Dropping this into queue for the moment, and will CC' to stable -> move into for-next once Chad & Co. have a chance to give their ACK.
Thank you!
Saurav Kashyap
Acked-byThanks,
~Saurav
Quoted 40 lines · Roland Dreier
Quoted 10 lines
From: Roland Dreier <[email protected]>
The qla2xxx firmware actually expects the task management response code in a CTIO IOCB with SCSI status mode 1 to be in little-endian byte order, ie the response code should be the first byte in the sense_data[] array. The old code erroneously byte-swapped the response code, which puts it in the wrong place on the wire and leads to initiators thinking every task management request succeeds (since they see 0 in the byte where they look for the response code).
Quoted 4 lines
Cc Chad Dupuis <[email protected]>Cc Arun Easi <[email protected]>Signed-off-by Roland Dreier <[email protected]>---
Very nice catch here Roland!
Quoted 17 lines
drivers/scsi/qla2xxx/qla_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/qla2xxx/qla_target.c +1
-1@@ -1403,7 +1403,7 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha, ctio->u.status1.scsi_status =__constant_cpu_to_le16 (SS_RESPONSE_INFO_LEN_VALID ); ctio->u.status1.response_len =__constant_cpu_to_le16 (8 ); - ((uint32_t *)ctio->u.status1.sense_data)[0 ] =cpu_to_be32 (resp_code); + ctio->u.status1.sense_data[0 ] = resp_code;qla2x00_start_iocbs (ha, ha->req);Quoted 1 line
}
Dropping this into queue for the moment, and will CC' to stable -> move into for-next once Chad & Co. have a chance to give their ACK.
Quoted 7 lines
Thank you!
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.
Quoted 33 lines
From: Roland Dreier <[email protected]>
The qla2xxx firmware actually expects the task management response code in a CTIO IOCB with SCSI status mode 1 to be in little-endian byte order, ie the response code should be the first byte in the sense_data[] array. The old code erroneously byte-swapped the response code, which puts it in the wrong place on the wire and leads to initiators thinking every task management request succeeds (since they see 0 in the byte where they look for the response code).
Cc Chad Dupuis <[email protected]>Cc Arun Easi <[email protected]>Signed-off-by Roland Dreier <[email protected]>---
drivers/scsi/qla2xxx/qla_target.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/qla2xxx/qla_target.c +1
-1@@ -1403,7 +1403,7 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha, ctio->u.status1.scsi_status =__constant_cpu_to_le16 (SS_RESPONSE_INFO_LEN_VALID ); ctio->u.status1.response_len =__constant_cpu_to_le16 (8 ); - ((uint32_t *)ctio->u.status1.sense_data)[0 ] =cpu_to_be32 (resp_code); + ctio->u.status1.sense_data[0 ] = resp_code;qla2x00_start_iocbs (ha, ha->req);
Quoted 3 lines
}
--
1.7.10.4
Thanks,
~Saurav
This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.
Nicholas A. Bellinger
AppliedQuoted 31 lines · Saurav Kashyap
Quoted 31 lines
From: Roland Dreier <[email protected]>
The qla2xxx firmware actually expects the task management response code in a CTIO IOCB with SCSI status mode 1 to be in little-endian byte order, ie the response code should be the first byte in the sense_data[] array. The old code erroneously byte-swapped the response code, which puts it in the wrong place on the wire and leads to initiators thinking every task management request succeeds (since they see 0 in the byte where they look for the response code).
Cc Chad Dupuis <[email protected]>Cc Arun Easi <[email protected]>Signed-off-by Roland Dreier <[email protected]>---
drivers/scsi/qla2xxx/qla_target.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/qla2xxx/qla_target.c +1
-1@@ -1403,7 +1403,7 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha, ctio->u.status1.scsi_status =__constant_cpu_to_le16 (SS_RESPONSE_INFO_LEN_VALID ); ctio->u.status1.response_len =__constant_cpu_to_le16 (8 ); - ((uint32_t *)ctio->u.status1.sense_data)[0 ] =cpu_to_be32 (resp_code); + ctio->u.status1.sense_data[0 ] = resp_code;
Quoted 7 lines
Quoted 4 lines
drivers/scsi/qla2xxx/qla_target.c +0
-0qla2x00_start_iocbs (ha, ha->req);}
--
1.7.10.4Acked-by Saurav Kashyap <[email protected]>
Applied to target-pending/for-next with CC' to stable
Thanks Roland & Co!
James Bottomley
maintainerQuoted 6 lines · Roland Dreier
From: Roland Dreier <[email protected]>
The qla2xxx firmware actually expects the task management response code in a CTIO IOCB with SCSI status mode 1 to be in little-endian byte order, ie the response code should be the first byte in the sense_data[] array.
Is this also true on Big Endian Hardware? Because the fix you have assumes that the TIO IOCB with SCSI status mode 1 should be CPU endian ... that doesn't look right since this is passed directly over the PCI bus (and the PCI bus is little endian), so shouldn't the correct fix be to replace cpu_to_be32 with cpu_to_le32?
James
Quoted 25 lines
The old code erroneously byte-swapped the
response code, which puts it in the wrong place on the wire and leads to initiators thinking every task management request succeeds (since they see 0 in the byte where they look for the response code).Cc Chad Dupuis <[email protected]>Cc Arun Easi <[email protected]>Signed-off-by Roland Dreier <[email protected]>--- drivers/scsi/qla2xxx/qla_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/qla2xxx/qla_target.c +1
-1@@ -1403,7 +1403,7 @@ static void qlt_24xx_send_task_mgmt_ctio(struct scsi_qla_host *ha, ctio->u.status1.scsi_status =__constant_cpu_to_le16 (SS_RESPONSE_INFO_LEN_VALID ); ctio->u.status1.response_len =__constant_cpu_to_le16 (8 ); - ((uint32_t *)ctio->u.status1.sense_data)[0 ] =cpu_to_be32 (resp_code); + ctio->u.status1.sense_data[0 ] = resp_code;qla2x00_start_iocbs (ha, ha->req); }
Quoted 5 lines · James Bottomley
Is this also true on Big Endian Hardware? Because the fix you have assumes that the TIO IOCB with SCSI status mode 1 should be CPU endian ... that doesn't look right since this is passed directly over the PCI bus (and the PCI bus is little endian), so shouldn't the correct fix be to replace
cpu_to_be32withcpu_to_le32?
After my patch the assignment is to a u8, and that byte is in the right place in memory. So I don't think there's any endianness bug.
- R.
James Bottomley
maintainerQuoted 10 lines · Roland Dreier
Quoted 5 lines · James Bottomley
Is this also true on Big Endian Hardware? Because the fix you have assumes that the TIO IOCB with SCSI status mode 1 should be CPU endian ... that doesn't look right since this is passed directly over the PCI bus (and the PCI bus is little endian), so shouldn't the correct fix be to replace
cpu_to_be32withcpu_to_le32?After my patch the assignment is to a u8, and that byte is in the right place in memory. So I don't think there's any endianness bug.
The data in status1 appears to get used a word at a time ... what about the other three bytes you don't set; are they guaranteed to be zero? (in which case this works, it just looks wrong from the way the thing is used in the rest of the code).
James
Quoted 4 lines · James Bottomley
The data in status1 appears to get used a word at a time ... what about the other three bytes you don't set; are they guaranteed to be zero? (in which case this works, it just looks wrong from the way the thing is used in the rest of the code).
Yes, the structure comes from
ctio = (struct ctio7_to_24xx *)qla2x00_alloc_iocbs(ha, NULL);
a few lines earlier, and that does:
/* Prep packet */ memset(pkt, 0, REQUEST_ENTRY_SIZE);
before
return pkt;