Skip to contentSkip to conversation

qedf: fix wrong le16 conversion

PATCH In review Arnd Bergmann 4 participants 5 messages Mar 20, 2017 – Mar 23, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qedf: fix wrong le16 conversion

gcc points out that we are converting a 16-bit integer into a 32-bit little-endian type and assigning that to 16-bit little-endian will end up with a zero:

drivers/scsi/qedf/drv_fcoe_fw_funcs.c: In function 'init_initiator_rw_fcoe_task':
include/uapi/linux/byteorder/big_endian.h:32:26: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);

The correct solution appears to be to just use a 16-bit byte swap instead.

Fixes be086e7c53f1 ("qed*: Utilize Firmware 8.15.3.0")
---
 drivers/scsi/qedf/drv_fcoe_fw_funcs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/qedf/drv_fcoe_fw_funcs.c +3 -3
index bb812db48da6..8c65e3b034dc 100644
@@ -8,7 +8,7 @@
 #include "drv_fcoe_fw_funcs.h"
 #include "drv_scsi_fw_funcs.h"
 
-#define FCOE_RX_ID ((u32)0x0000FFFF)
+#define FCOE_RX_ID (0xFFFFu)
 
 static inline void init_common_sqe(struct fcoe_task_params *task_params,
 				   enum fcoe_sqe_request_type request_type)
@@ -59,7 +59,7 @@ int init_initiator_rw_fcoe_task(struct fcoe_task_params *task_params,
 	t_st_ctx->read_only.task_type = task_params->task_type;
 	SET_FIELD(t_st_ctx->read_write.flags,
 		  FCOE_TSTORM_FCOE_TASK_ST_CTX_READ_WRITE_EXP_FIRST_FRAME, 1);
-	t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);
+	t_st_ctx->read_write.rx_id = cpu_to_le16(FCOE_RX_ID);
 
 	/* Ustorm ctx */
 	u_ag_ctx = &ctx->ustorm_ag_context;
@@ -151,7 +151,7 @@ int init_initiator_midpath_unsolicited_fcoe_task(
 	t_st_ctx->read_only.task_type = task_params->task_type;
 	SET_FIELD(t_st_ctx->read_write.flags,
 		  FCOE_TSTORM_FCOE_TASK_ST_CTX_READ_WRITE_EXP_FIRST_FRAME, 1);
-	t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);
+	t_st_ctx->read_write.rx_id = cpu_to_le16(FCOE_RX_ID);
 
 	/* Init Ustorm */
 	u_ag_ctx = &ctx->ustorm_ag_context;
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 40 lines · Arnd Bergmann

gcc points out that we are converting a 16-bit integer into a 32-bit little-endian type and assigning that to 16-bit little-endian will end up with a zero:

drivers/scsi/qedf/drv_fcoe_fw_funcs.c: In function 'init_initiator_rw_fcoe_task':
include/uapi/linux/byteorder/big_endian.h:32:26: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);

The correct solution appears to be to just use a 16-bit byte swap instead.

Fixes be086e7c53f1 ("qed*: Utilize Firmware 8.15.3.0")
---
 drivers/scsi/qedf/drv_fcoe_fw_funcs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/qedf/drv_fcoe_fw_funcs.c +2 -2
index bb812db48da6..8c65e3b034dc 100644
@@ -8,7 +8,7 @@
 #include "drv_fcoe_fw_funcs.h"
 #include "drv_scsi_fw_funcs.h"
 
-#define FCOE_RX_ID ((u32)0x0000FFFF)
+#define FCOE_RX_ID (0xFFFFu)
 
 static inline void init_common_sqe(struct fcoe_task_params *task_params,
 				   enum fcoe_sqe_request_type request_type)
@@ -59,7 +59,7 @@ int init_initiator_rw_fcoe_task(struct fcoe_task_params *task_params,
 	t_st_ctx->read_only.task_type = task_params->task_type;
 	SET_FIELD(t_st_ctx->read_write.flags,
 		  FCOE_TSTORM_FCOE_TASK_ST_CTX_READ_WRITE_EXP_FIRST_FRAME, 1);
-	t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);
+	t_st_ctx->read_write.rx_id = cpu_to_le16(FCOE_RX_ID);
 
 	/* Ustorm ctx */
 	u_ag_ctx = &ctx->ustorm_ag_context;

drivers/scsi/qedf/drv_fcoe_fw_funcs.c int init_initiator_midpath_unsolicited_fcoe_task( · line 157

Quoted 8 lines
drivers/scsi/qedf/drv_fcoe_fw_funcs.c +1 -1
@@ -151,7 +151,7 @@ int init_initiator_midpath_unsolicited_fcoe_task(
 	t_st_ctx->read_only.task_type = task_params->task_type;
 	SET_FIELD(t_st_ctx->read_write.flags,
 		  FCOE_TSTORM_FCOE_TASK_ST_CTX_READ_WRITE_EXP_FIRST_FRAME, 1);
-	t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);
+	t_st_ctx->read_write.rx_id = cpu_to_le16(FCOE_RX_ID);
 
 	/* Init Ustorm */
 	u_ag_ctx = &ctx->ustorm_ag_context;

Arnd, thanks for fixing this up.

#2 lore raw
In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

gcc points out that we are converting a 16-bit integer into a 32-bit little-endian type and assigning that to 16-bit little-endian will end up with a zero:

drivers/scsi/qedf/drv_fcoe_fw_funcs.c: In function 'init_initiator_rw_fcoe_task':
include/uapi/linux/byteorder/big_endian.h:32:26: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);

Quoted 7 lines

The correct solution appears to be to just use a 16-bit byte swap instead.

Fixes be086e7c53f1 ("qed*: Utilize Firmware 8.15.3.0")
---
 drivers/scsi/qedf/drv_fcoe_fw_funcs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Dave: Since you queued the firmware patch, mind taking this fix through your tree?

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#3 lore raw

From: "Martin K. Petersen" <[email protected]>
Date: Thu, 23 Mar 2017 10:19:03 -0400

Quoted 12 lines
Quoted 10 lines · Arnd Bergmann

gcc points out that we are converting a 16-bit integer into a 32-bit little-endian type and assigning that to 16-bit little-endian will end up with a zero:

drivers/scsi/qedf/drv_fcoe_fw_funcs.c: In function 'init_initiator_rw_fcoe_task':
include/uapi/linux/byteorder/big_endian.h:32:26: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);

The correct solution appears to be to just use a 16-bit byte swap instead.

Quoted 8 lines
Quoted 5 lines
Fixes be086e7c53f1 ("qed*: Utilize Firmware 8.15.3.0")
---
 drivers/scsi/qedf/drv_fcoe_fw_funcs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Dave: Since you queued the firmware patch, mind taking this fix through your tree?

Ok, applied to net-next, thanks.

#4 lore raw
Quoted 4 lines · David Miller
Quoted 2 lines

Dave: Since you queued the firmware patch, mind taking this fix through your tree?

Ok, applied to net-next, thanks.

Great, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering