LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/2] scsi: qla1280: Resolve some compilation issues
@ 2021-08-18 13:53 John Garry
  2021-08-18 13:53 ` [PATCH 1/2] scsi: qla1280: Stop using scsi_cmnd.tag John Garry
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: John Garry @ 2021-08-18 13:53 UTC (permalink / raw)
  To: mdr, jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, bvanassche, John Garry

As another follow-up to removing scsi_cmnd.tag in [0], remove its usage in
the qla1280 driver lurking under a local build switch. Also fix
pre-existing compilation issues under the same switch.

Based on mkp-scsi 5.15 staging at 848ade90ba9c

[0] https://lore.kernel.org/linux-scsi/yq14kbppa42.fsf@ca-mkp.ca.oracle.com/T/#mb47909f38f35837686734369600051b278d124af

John Garry (2):
  scsi: qla1280: Stop using scsi_cmnd.tag
  scsi: qla1280: Fix DEBUG_QLA1280 compilation issues

 drivers/scsi/qla1280.c | 41 +++++++++--------------------------------
 1 file changed, 9 insertions(+), 32 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] scsi: qla1280: Stop using scsi_cmnd.tag
  2021-08-18 13:53 [PATCH 0/2] scsi: qla1280: Resolve some compilation issues John Garry
@ 2021-08-18 13:53 ` John Garry
  2021-08-18 13:53 ` [PATCH 2/2] scsi: qla1280: Fix DEBUG_QLA1280 compilation issues John Garry
  2021-08-28  2:32 ` [PATCH 0/2] scsi: qla1280: Resolve some " Martin K. Petersen
  2 siblings, 0 replies; 6+ messages in thread
From: John Garry @ 2021-08-18 13:53 UTC (permalink / raw)
  To: mdr, jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, bvanassche, John Garry

Use scsi_cmd_to_rq(cmd)->tag instead of scsi_cmnd.tag as preference.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/qla1280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index aec92471c5f2..b4f7d8d7a01c 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -3980,7 +3980,7 @@ __qla1280_print_scsi_cmd(struct scsi_cmnd *cmd)
 	   qla1280_dump_buffer(1, (char *)sg, (cmd->use_sg*sizeof(struct scatterlist)));
 	   } */
 	printk("  tag=%d, transfersize=0x%x \n",
-	       cmd->tag, cmd->transfersize);
+	       scsi_cmd_to_rq(cmd)->tag, cmd->transfersize);
 	printk("  SP=0x%p\n", CMD_SP(cmd));
 	printk(" underflow size = 0x%x, direction=0x%x\n",
 	       cmd->underflow, cmd->sc_data_direction);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] scsi: qla1280: Fix DEBUG_QLA1280 compilation issues
  2021-08-18 13:53 [PATCH 0/2] scsi: qla1280: Resolve some compilation issues John Garry
  2021-08-18 13:53 ` [PATCH 1/2] scsi: qla1280: Stop using scsi_cmnd.tag John Garry
@ 2021-08-18 13:53 ` John Garry
  2021-08-18 14:27   ` James Bottomley
  2021-08-28  2:32 ` [PATCH 0/2] scsi: qla1280: Resolve some " Martin K. Petersen
  2 siblings, 1 reply; 6+ messages in thread
From: John Garry @ 2021-08-18 13:53 UTC (permalink / raw)
  To: mdr, jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, bvanassche, John Garry

The driver does not compile under DEBUG_QLA1280 flag, so fix up with as
little fuss as possible some debug statements.

Also delete ql1280_dump_device(), which looks to have never been
referenced.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/qla1280.c | 39 ++++++++-------------------------------
 1 file changed, 8 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index b4f7d8d7a01c..27b16ec399cd 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -2807,7 +2807,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 
 	dprintk(2, "start: cmd=%p sp=%p CDB=%xm, handle %lx\n", cmd, sp,
 		cmd->cmnd[0], (long)CMD_HANDLE(sp->cmd));
-	dprintk(2, "             bus %i, target %i, lun %i\n",
+	dprintk(2, "             bus %i, target %i, lun %lld\n",
 		SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
 	qla1280_dump_buffer(2, cmd->cmnd, MAX_COMMAND_SIZE);
 
@@ -2879,7 +2879,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 			remseg--;
 		}
 		dprintk(5, "qla1280_64bit_start_scsi: Scatter/gather "
-			"command packet data - b %i, t %i, l %i \n",
+			"command packet data - b %i, t %i, l %lld \n",
 			SCSI_BUS_32(cmd), SCSI_TCN_32(cmd),
 			SCSI_LUN_32(cmd));
 		qla1280_dump_buffer(5, (char *)pkt,
@@ -2937,14 +2937,14 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 			remseg -= cnt;
 			dprintk(5, "qla1280_64bit_start_scsi: "
 				"continuation packet data - b %i, t "
-				"%i, l %i \n", SCSI_BUS_32(cmd),
+				"%i, l %lld \n", SCSI_BUS_32(cmd),
 				SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
 			qla1280_dump_buffer(5, (char *)pkt,
 					    REQUEST_ENTRY_SIZE);
 		}
 	} else {	/* No data transfer */
 		dprintk(5, "qla1280_64bit_start_scsi: No data, command "
-			"packet data - b %i, t %i, l %i \n",
+			"packet data - b %i, t %i, l %lld \n",
 			SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
 		qla1280_dump_buffer(5, (char *)pkt, REQUEST_ENTRY_SIZE);
 	}
@@ -3126,7 +3126,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 			*dword_ptr++ =
 				cpu_to_le32(lower_32_bits(sg_dma_address(s)));
 			*dword_ptr++ = cpu_to_le32(sg_dma_len(s));
-			dprintk(3, "S/G Segment phys_addr=0x%lx, len=0x%x\n",
+			dprintk(3, "S/G Segment phys_addr=0x%x, len=0x%x\n",
 				(lower_32_bits(sg_dma_address(s))),
 				(sg_dma_len(s)));
 			remseg--;
@@ -3182,7 +3182,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 			remseg -= cnt;
 			dprintk(5, "qla1280_32bit_start_scsi: "
 				"continuation packet data - "
-				"scsi(%i:%i:%i)\n", SCSI_BUS_32(cmd),
+				"scsi(%i:%i:%lld)\n", SCSI_BUS_32(cmd),
 				SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
 			qla1280_dump_buffer(5, (char *)pkt,
 					    REQUEST_ENTRY_SIZE);
@@ -3663,7 +3663,7 @@ qla1280_status_entry(struct scsi_qla_host *ha, struct response *pkt,
 
 			dprintk(2, "qla1280_status_entry: Check "
 				"condition Sense data, b %i, t %i, "
-				"l %i\n", SCSI_BUS_32(cmd), SCSI_TCN_32(cmd),
+				"l %lld\n", SCSI_BUS_32(cmd), SCSI_TCN_32(cmd),
 				SCSI_LUN_32(cmd));
 			if (sense_sz)
 				qla1280_dump_buffer(2,
@@ -3963,7 +3963,7 @@ __qla1280_print_scsi_cmd(struct scsi_cmnd *cmd)
 
 	sp = (struct srb *)CMD_SP(cmd);
 	printk("SCSI Command @= 0x%p, Handle=0x%p\n", cmd, CMD_HANDLE(cmd));
-	printk("  chan=%d, target = 0x%02x, lun = 0x%02x, cmd_len = 0x%02x\n",
+	printk("  chan=%d, target = 0x%02x, lun = 0x%02llx, cmd_len = 0x%02x\n",
 	       SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd),
 	       CMD_CDBLEN(cmd));
 	printk(" CDB = ");
@@ -3985,29 +3985,6 @@ __qla1280_print_scsi_cmd(struct scsi_cmnd *cmd)
 	printk(" underflow size = 0x%x, direction=0x%x\n",
 	       cmd->underflow, cmd->sc_data_direction);
 }
-
-/**************************************************************************
- *   ql1280_dump_device
- *
- **************************************************************************/
-static void
-ql1280_dump_device(struct scsi_qla_host *ha)
-{
-
-	struct scsi_cmnd *cp;
-	struct srb *sp;
-	int i;
-
-	printk(KERN_DEBUG "Outstanding Commands on controller:\n");
-
-	for (i = 0; i < MAX_OUTSTANDING_COMMANDS; i++) {
-		if ((sp = ha->outstanding_cmds[i]) == NULL)
-			continue;
-		if ((cp = sp->cmd) == NULL)
-			continue;
-		qla1280_print_scsi_cmd(1, cp);
-	}
-}
 #endif
 
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] scsi: qla1280: Fix DEBUG_QLA1280 compilation issues
  2021-08-18 13:53 ` [PATCH 2/2] scsi: qla1280: Fix DEBUG_QLA1280 compilation issues John Garry
@ 2021-08-18 14:27   ` James Bottomley
  2021-08-18 15:26     ` John Garry
  0 siblings, 1 reply; 6+ messages in thread
From: James Bottomley @ 2021-08-18 14:27 UTC (permalink / raw)
  To: John Garry, mdr, martin.petersen; +Cc: linux-scsi, linux-kernel, bvanassche

On Wed, 2021-08-18 at 21:53 +0800, John Garry wrote:
> The driver does not compile under DEBUG_QLA1280 flag, so fix up with
> as
> little fuss as possible some debug statements.
> 
> Also delete ql1280_dump_device(), which looks to have never been
> referenced.
> 
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
>  drivers/scsi/qla1280.c | 39 ++++++++-------------------------------
>  1 file changed, 8 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
> index b4f7d8d7a01c..27b16ec399cd 100644
> --- a/drivers/scsi/qla1280.c
> +++ b/drivers/scsi/qla1280.c
> @@ -2807,7 +2807,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host
> *ha, struct srb * sp)
>  
>  	dprintk(2, "start: cmd=%p sp=%p CDB=%xm, handle %lx\n", cmd,
> sp,
>  		cmd->cmnd[0], (long)CMD_HANDLE(sp->cmd));
> -	dprintk(2, "             bus %i, target %i, lun %i\n",
> +	dprintk(2, "             bus %i, target %i, lun %lld\n",
>  		SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
>  	qla1280_dump_buffer(2, cmd->cmnd, MAX_COMMAND_SIZE);
>  
> @@ -2879,7 +2879,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host
> *ha, struct srb * sp)
>  			remseg--;
>  		}
>  		dprintk(5, "qla1280_64bit_start_scsi: Scatter/gather "
> -			"command packet data - b %i, t %i, l %i \n",
> +			"command packet data - b %i, t %i, l %lld \n",
>  			SCSI_BUS_32(cmd), SCSI_TCN_32(cmd),
>  			SCSI_LUN_32(cmd));

These are the wrong fixes, I think.  The qla1280 can only cope with 32
bits, which is why all the macros have an _32.  Over the years we've
expanded the values in the SCSI command to be 64 bit but by and large,
the truncation in this driver is silent.  However, the correct fix
should be to make the truncation explicit in the macro, so

#define SCSI_LUN_32(Cmnd)	((int)Cmnd->device->lun)

And the same for all the other _32 macros.  This avoids the unexpected
outcome that the _32 macros are actually returning 64 bits and cause me
to do a WTF at your %lld change.

James



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] scsi: qla1280: Fix DEBUG_QLA1280 compilation issues
  2021-08-18 14:27   ` James Bottomley
@ 2021-08-18 15:26     ` John Garry
  0 siblings, 0 replies; 6+ messages in thread
From: John Garry @ 2021-08-18 15:26 UTC (permalink / raw)
  To: jejb, mdr, martin.petersen; +Cc: linux-scsi, linux-kernel, bvanassche

On 18/08/2021 15:27, James Bottomley wrote:
> On Wed, 2021-08-18 at 21:53 +0800, John Garry wrote:
>> The driver does not compile under DEBUG_QLA1280 flag, so fix up with
>> as
>> little fuss as possible some debug statements.
>>
>> Also delete ql1280_dump_device(), which looks to have never been
>> referenced.
>>
>> Signed-off-by: John Garry<john.garry@huawei.com>
>> ---
>>   drivers/scsi/qla1280.c | 39 ++++++++-------------------------------
>>   1 file changed, 8 insertions(+), 31 deletions(-)
>>
>> diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
>> index b4f7d8d7a01c..27b16ec399cd 100644
>> --- a/drivers/scsi/qla1280.c
>> +++ b/drivers/scsi/qla1280.c
>> @@ -2807,7 +2807,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host
>> *ha, struct srb * sp)
>>   
>>   	dprintk(2, "start: cmd=%p sp=%p CDB=%xm, handle %lx\n", cmd,
>> sp,
>>   		cmd->cmnd[0], (long)CMD_HANDLE(sp->cmd));
>> -	dprintk(2, "             bus %i, target %i, lun %i\n",
>> +	dprintk(2, "             bus %i, target %i, lun %lld\n",
>>   		SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
>>   	qla1280_dump_buffer(2, cmd->cmnd, MAX_COMMAND_SIZE);
>>   
>> @@ -2879,7 +2879,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host
>> *ha, struct srb * sp)
>>   			remseg--;
>>   		}
>>   		dprintk(5, "qla1280_64bit_start_scsi: Scatter/gather "
>> -			"command packet data - b %i, t %i, l %i \n",
>> +			"command packet data - b %i, t %i, l %lld \n",
>>   			SCSI_BUS_32(cmd), SCSI_TCN_32(cmd),
>>   			SCSI_LUN_32(cmd));

Hi James,

> These are the wrong fixes, I think.  The qla1280 can only cope with 32
> bits, which is why all the macros have an _32.

Looking structures like struct cmd_entry, mrk_entry, ecmd_entry, lun 
member is an 8-bit value. There is also this definition:
#define MAX_LUNS	8	/* 32 */
#define MAX_L_BITS	3	/* 5 */

But not sure on where 32/5 comes from - I suppose it's the size the 
driver uses to hold the lun. Or the 32 bits you mention.

>  Over the years we've
> expanded the values in the SCSI command to be 64 bit but by and large,
> the truncation in this driver is silent.  However, the correct fix
> should be to make the truncation explicit in the macro, so
> 
> #define SCSI_LUN_32(Cmnd)	((int)Cmnd->device->lun)

SCSI_LUN_32 is used outside the masked debug code, so I didn't want to 
mess with that.

> 
> And the same for all the other _32 macros.  This avoids the unexpected
> outcome that the _32 macros are actually returning 64 bits and cause me
> to do a WTF at your %lld change.

If a relevant scsi_device member really hold values > 32b in size for 
this driver then it's in trouble, as chopping off the top bits by 
casting won't help.

And if we only ever expect the bottom 32b to be used, using %lld as 
opposed to casting to an int and using %i should not really make a 
difference.

Anyway, I can change as you suggest. But I would rather do it only in 
SCSI_LUN_32().

Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] scsi: qla1280: Resolve some compilation issues
  2021-08-18 13:53 [PATCH 0/2] scsi: qla1280: Resolve some compilation issues John Garry
  2021-08-18 13:53 ` [PATCH 1/2] scsi: qla1280: Stop using scsi_cmnd.tag John Garry
  2021-08-18 13:53 ` [PATCH 2/2] scsi: qla1280: Fix DEBUG_QLA1280 compilation issues John Garry
@ 2021-08-28  2:32 ` Martin K. Petersen
  2 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2021-08-28  2:32 UTC (permalink / raw)
  To: mdr, John Garry, jejb
  Cc: Martin K . Petersen, linux-scsi, linux-kernel, bvanassche

On Wed, 18 Aug 2021 21:53:19 +0800, John Garry wrote:

> As another follow-up to removing scsi_cmnd.tag in [0], remove its usage in
> the qla1280 driver lurking under a local build switch. Also fix
> pre-existing compilation issues under the same switch.
> 
> Based on mkp-scsi 5.15 staging at 848ade90ba9c
> 
> [0] https://lore.kernel.org/linux-scsi/yq14kbppa42.fsf@ca-mkp.ca.oracle.com/T/#mb47909f38f35837686734369600051b278d124af
> 
> [...]

Applied to 5.15/scsi-queue, thanks!

[1/2] scsi: qla1280: Stop using scsi_cmnd.tag
      https://git.kernel.org/mkp/scsi/c/c563c126e293

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-28  2:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 13:53 [PATCH 0/2] scsi: qla1280: Resolve some compilation issues John Garry
2021-08-18 13:53 ` [PATCH 1/2] scsi: qla1280: Stop using scsi_cmnd.tag John Garry
2021-08-18 13:53 ` [PATCH 2/2] scsi: qla1280: Fix DEBUG_QLA1280 compilation issues John Garry
2021-08-18 14:27   ` James Bottomley
2021-08-18 15:26     ` John Garry
2021-08-28  2:32 ` [PATCH 0/2] scsi: qla1280: Resolve some " Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).