LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 3/6] scsi: megaraid_sas - throttle io if FW is busy
@ 2007-02-14 20:49 Sumant Patro
  2007-02-15  8:09 ` Richard Knutsson
  0 siblings, 1 reply; 3+ messages in thread
From: Sumant Patro @ 2007-02-14 20:49 UTC (permalink / raw)
  To: James.Bottomley, akpm
  Cc: linux-scsi, linux-kernel, neela.kolli, bo.yang, sumant.patro


Checks added in megasas_queue_command to know if FW is able to process
commands within the timeout period. If number of retries is 2 or more,
the driver stops sending cmd to FW. IO is resumed when pending cmd count 
reduces to 16 or 10 seconds has elapsed from the time cmds were last 
sent to FW.

Signed-off-by: Sumant Patro <sumant.patro@lsi.com>
---

 drivers/scsi/megaraid/megaraid_sas.c |   27 +++++++++++++++++++++++++
 drivers/scsi/megaraid/megaraid_sas.h |    3 ++
 2 files changed, 30 insertions(+)

diff -uprN linux-feb13-new-p2/drivers/scsi/megaraid/megaraid_sas.c linux-feb13-new-p3/drivers/scsi/megaraid/megaraid_sas.c
--- linux-feb13-new-p2/drivers/scsi/megaraid/megaraid_sas.c	2007-02-13 11:34:58.000000000 -0800
+++ linux-feb13-new-p3/drivers/scsi/megaraid/megaraid_sas.c	2007-02-13 11:45:38.000000000 -0800
@@ -839,6 +839,7 @@ megasas_queue_command(struct scsi_cmnd *
 	u32 frame_count;
 	struct megasas_cmd *cmd;
 	struct megasas_instance *instance;
+	unsigned long sec;
 
 	instance = (struct megasas_instance *)
 	    scmd->device->host->hostdata;
@@ -856,6 +857,23 @@ megasas_queue_command(struct scsi_cmnd *
 		goto out_done;
 	}
 
+	/* Check if we can accept cmds */
+	if (instance->is_busy) {
+		sec = (jiffies - instance->last_time) / HZ;
+		if (sec < 10)
+			return SCSI_MLQUEUE_HOST_BUSY;
+		else {
+			instance->is_busy = 0;
+			instance->last_time = 0;
+		}
+	}
+
+	if (scmd->retries > 1) {
+		/* FW is busy */
+		instance->is_busy = 1;
+		instance->last_time = jiffies;
+	}
+
 	cmd = megasas_get_cmd(instance);
 	if (!cmd)
 		return SCSI_MLQUEUE_HOST_BUSY;
@@ -1200,6 +1218,7 @@ megasas_complete_cmd(struct megasas_inst
 {
 	int exception = 0;
 	struct megasas_header *hdr = &cmd->frame->hdr;
+	int outstanding;
 
 	if (cmd->scmd) {
 		cmd->scmd->SCp.ptr = (char *)0;
@@ -1313,6 +1332,12 @@ megasas_complete_cmd(struct megasas_inst
 		       hdr->cmd);
 		break;
 	}
+
+	if (instance->is_busy) {
+		outstanding = atomic_read(&instance->fw_outstanding);
+		if (outstanding < 17)
+			instance->is_busy = 0;
+	}
 }
 
 /**
@@ -2384,6 +2409,8 @@ megasas_probe_one(struct pci_dev *pdev, 
 	instance->init_id = MEGASAS_DEFAULT_INIT_ID;
 
 	megasas_dbg_lvl = 0;
+	instance->is_busy = 0;
+	instance->last_time = 0;
 
 	/*
 	 * Initialize MFI Firmware
diff -uprN linux-feb13-new-p2/drivers/scsi/megaraid/megaraid_sas.h linux-feb13-new-p3/drivers/scsi/megaraid/megaraid_sas.h
--- linux-feb13-new-p2/drivers/scsi/megaraid/megaraid_sas.h	2007-02-13 07:22:40.000000000 -0800
+++ linux-feb13-new-p3/drivers/scsi/megaraid/megaraid_sas.h	2007-02-13 11:37:09.000000000 -0800
@@ -1102,6 +1102,9 @@ struct megasas_instance {
 	atomic_t fw_outstanding;
 	u32 hw_crit_error;
 
+	u8 is_busy;
+	unsigned long last_time;
+
 	struct megasas_instance_template *instancet;
 	struct tasklet_struct isr_tasklet;
 };




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

* Re: [PATCH 3/6] scsi: megaraid_sas - throttle io if FW is busy
  2007-02-14 20:49 [PATCH 3/6] scsi: megaraid_sas - throttle io if FW is busy Sumant Patro
@ 2007-02-15  8:09 ` Richard Knutsson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Knutsson @ 2007-02-15  8:09 UTC (permalink / raw)
  To: Sumant Patro
  Cc: James.Bottomley, akpm, linux-scsi, linux-kernel, neela.kolli,
	bo.yang, sumant.patro

Sumant Patro wrote:
> Checks added in megasas_queue_command to know if FW is able to process
> commands within the timeout period. If number of retries is 2 or more,
> the driver stops sending cmd to FW. IO is resumed when pending cmd count 
> reduces to 16 or 10 seconds has elapsed from the time cmds were last 
> sent to FW.
>
> Signed-off-by: Sumant Patro <sumant.patro@lsi.com>
> ---
>
>  drivers/scsi/megaraid/megaraid_sas.c |   27 +++++++++++++++++++++++++
>  drivers/scsi/megaraid/megaraid_sas.h |    3 ++
>  2 files changed, 30 insertions(+)
>
>   
[snip]
> diff -uprN linux-feb13-new-p2/drivers/scsi/megaraid/megaraid_sas.h linux-feb13-new-p3/drivers/scsi/megaraid/megaraid_sas.h
> --- linux-feb13-new-p2/drivers/scsi/megaraid/megaraid_sas.h	2007-02-13 07:22:40.000000000 -0800
> +++ linux-feb13-new-p3/drivers/scsi/megaraid/megaraid_sas.h	2007-02-13 11:37:09.000000000 -0800
> @@ -1102,6 +1102,9 @@ struct megasas_instance {
>  	atomic_t fw_outstanding;
>  	u32 hw_crit_error;
>  
> +	u8 is_busy;
>   
Why not "bool is_busy:8;"? It obviously is a boolean. I would also think 
false/true would be more descriptive then 0/1.

Richard Knutsson


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

* RE: [PATCH 3/6] scsi: megaraid_sas - throttle io if FW is busy
@ 2007-02-15 23:44 Patro, Sumant
  0 siblings, 0 replies; 3+ messages in thread
From: Patro, Sumant @ 2007-02-15 23:44 UTC (permalink / raw)
  To: Richard Knutsson
  Cc: James.Bottomley, akpm, linux-scsi, linux-kernel, Kolli, Neela, Yang, Bo

Yes I can make it boolean. 
Will change it in a future patch submission.

Thanks,
Sumant

-----Original Message-----
From: Richard Knutsson [mailto:ricknu-0@student.ltu.se] 
Sent: Thursday, February 15, 2007 12:10 AM
To: Patro, Sumant
Cc: James.Bottomley@SteelEye.com; akpm@osdl.org;
linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; Kolli, Neela;
Yang, Bo; Patro, Sumant
Subject: Re: [PATCH 3/6] scsi: megaraid_sas - throttle io if FW is busy

Sumant Patro wrote:
> Checks added in megasas_queue_command to know if FW is able to process

> commands within the timeout period. If number of retries is 2 or more,

> the driver stops sending cmd to FW. IO is resumed when pending cmd 
> count reduces to 16 or 10 seconds has elapsed from the time cmds were 
> last sent to FW.
>
> Signed-off-by: Sumant Patro <sumant.patro@lsi.com>
> ---
>
>  drivers/scsi/megaraid/megaraid_sas.c |   27 +++++++++++++++++++++++++
>  drivers/scsi/megaraid/megaraid_sas.h |    3 ++
>  2 files changed, 30 insertions(+)
>
>   
[snip]
> diff -uprN linux-feb13-new-p2/drivers/scsi/megaraid/megaraid_sas.h
linux-feb13-new-p3/drivers/scsi/megaraid/megaraid_sas.h
> --- linux-feb13-new-p2/drivers/scsi/megaraid/megaraid_sas.h
2007-02-13 07:22:40.000000000 -0800
> +++ linux-feb13-new-p3/drivers/scsi/megaraid/megaraid_sas.h
2007-02-13 11:37:09.000000000 -0800
> @@ -1102,6 +1102,9 @@ struct megasas_instance {
>  	atomic_t fw_outstanding;
>  	u32 hw_crit_error;
>  
> +	u8 is_busy;
>   
Why not "bool is_busy:8;"? It obviously is a boolean. I would also think
false/true would be more descriptive then 0/1.

Richard Knutsson


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

end of thread, other threads:[~2007-02-15 23:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 20:49 [PATCH 3/6] scsi: megaraid_sas - throttle io if FW is busy Sumant Patro
2007-02-15  8:09 ` Richard Knutsson
2007-02-15 23:44 Patro, Sumant

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).