diff mbox

[10/15] megaraid_sas: IO throttling support

Message ID 1450445228-26571-11-git-send-email-Sumit.Saxena@avagotech.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Sumit Saxena Dec. 18, 2015, 1:27 p.m. UTC
This patch will add capability in driver to tell firmware that it can throttle IOs in case Controller's Queue depth is downgraded post OFU
(Online firmware upgrade). This feature will ensure firmware can be downgraded from higher queue depth to lower queue depth without needing system reboot.
Added throttling code in IO path of driver, in case OS tries to send more IOs than post OFU firmware's queue depth.

Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
---
 drivers/scsi/megaraid/megaraid_sas.h        |    6 ++++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c |    7 +++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

Comments

Tomas Henzl Jan. 19, 2016, 1:38 p.m. UTC | #1
On 18.12.2015 14:27, Sumit Saxena wrote:
> This patch will add capability in driver to tell firmware that it can throttle IOs in case Controller's Queue depth is downgraded post OFU
> (Online firmware upgrade). This feature will ensure firmware can be downgraded from higher queue depth to lower queue depth without needing system reboot.
> Added throttling code in IO path of driver, in case OS tries to send more IOs than post OFU firmware's queue depth.
>
> Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
> Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
> ---
>  drivers/scsi/megaraid/megaraid_sas.h        |    6 ++++--
>  drivers/scsi/megaraid/megaraid_sas_fusion.c |    7 +++++++
>  2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
> index 4595ef4..9d2b3da 100644
> --- a/drivers/scsi/megaraid/megaraid_sas.h
> +++ b/drivers/scsi/megaraid/megaraid_sas.h
> @@ -1537,7 +1537,8 @@ union megasas_sgl_frame {
>  typedef union _MFI_CAPABILITIES {
>  	struct {
>  #if   defined(__BIG_ENDIAN_BITFIELD)
> -		u32     reserved:21;
> +		u32     reserved:20;
> +		u32     support_qd_throttling:1;
>  		u32     support_fp_rlbypass:1;
>  		u32     support_vfid_in_ioframe:1;
>  		u32     support_ext_io_size:1;
> @@ -1561,7 +1562,8 @@ typedef union _MFI_CAPABILITIES {
>  		u32     support_ext_io_size:1;
>  		u32     support_vfid_in_ioframe:1;
>  		u32     support_fp_rlbypass:1;
> -		u32     reserved:21;
> +		u32     support_qd_throttling:1;
> +		u32     reserved:20;
>  #endif
>  	} mfi_capabilities;
>  	__le32		reg;
> diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> index 7cc7806..1248c7a 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> @@ -801,6 +801,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
>  	if (!dual_qdepth_disable)
>  		drv_ops->mfi_capabilities.support_ext_queue_depth = 1;
>  
> +	drv_ops->mfi_capabilities.support_qd_throttling = 1;
>  	/* Convert capability to LE32 */
>  	cpu_to_le32s((u32 *)&init_frame->driver_operations.mfi_capabilities);
>  
> @@ -2182,6 +2183,12 @@ megasas_build_and_issue_cmd_fusion(struct megasas_instance *instance,
>  			atomic_inc(&instance->ldio_outstanding);
>  	}
>  
> +	if (atomic_read(&instance->fw_outstanding) >=
> +			instance->host->can_queue) {
> +		dev_err(&instance->pdev->dev, "Throttle IOs beyond Controller queue depth\n");
> +		return SCSI_MLQUEUE_HOST_BUSY;
> +	}

Same as in the previous patch, this this test above won't you protect when several
processes read the same value in parallel. In addition to that, when the scsi layer
knows the new smaller can_queue value it will not queue new commands above the limit.

> +
>  	cmd = megasas_get_cmd_fusion(instance, scmd->request->tag);
>  
>  	index = cmd->index;

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sumit Saxena Jan. 28, 2016, 7:18 a.m. UTC | #2
> -----Original Message-----
> From: Tomas Henzl [mailto:thenzl@redhat.com]
> Sent: Tuesday, January 19, 2016 7:08 PM
> To: Sumit Saxena; jbottomley@parallels.com; hch@infradead.org;
> martin.petersen@oracle.com
> Cc: linux-scsi@vger.kernel.org; kashyap.desai@avagotech.com
> Subject: Re: [PATCH 10/15] megaraid_sas: IO throttling support
>
> On 18.12.2015 14:27, Sumit Saxena wrote:
> > This patch will add capability in driver to tell firmware that it can
> > throttle IOs in case Controller's Queue depth is downgraded post OFU
(Online
> firmware upgrade). This feature will ensure firmware can be downgraded
from
> higher queue depth to lower queue depth without needing system reboot.
> > Added throttling code in IO path of driver, in case OS tries to send
more IOs
> than post OFU firmware's queue depth.
> >
> > Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
> > Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
> > ---
> >  drivers/scsi/megaraid/megaraid_sas.h        |    6 ++++--
> >  drivers/scsi/megaraid/megaraid_sas_fusion.c |    7 +++++++
> >  2 files changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/scsi/megaraid/megaraid_sas.h
> > b/drivers/scsi/megaraid/megaraid_sas.h
> > index 4595ef4..9d2b3da 100644
> > --- a/drivers/scsi/megaraid/megaraid_sas.h
> > +++ b/drivers/scsi/megaraid/megaraid_sas.h
> > @@ -1537,7 +1537,8 @@ union megasas_sgl_frame {  typedef union
> > _MFI_CAPABILITIES {
> >  	struct {
> >  #if   defined(__BIG_ENDIAN_BITFIELD)
> > -		u32     reserved:21;
> > +		u32     reserved:20;
> > +		u32     support_qd_throttling:1;
> >  		u32     support_fp_rlbypass:1;
> >  		u32     support_vfid_in_ioframe:1;
> >  		u32     support_ext_io_size:1;
> > @@ -1561,7 +1562,8 @@ typedef union _MFI_CAPABILITIES {
> >  		u32     support_ext_io_size:1;
> >  		u32     support_vfid_in_ioframe:1;
> >  		u32     support_fp_rlbypass:1;
> > -		u32     reserved:21;
> > +		u32     support_qd_throttling:1;
> > +		u32     reserved:20;
> >  #endif
> >  	} mfi_capabilities;
> >  	__le32		reg;
> > diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > index 7cc7806..1248c7a 100644
> > --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > @@ -801,6 +801,7 @@ megasas_ioc_init_fusion(struct megasas_instance
> *instance)
> >  	if (!dual_qdepth_disable)
> >  		drv_ops->mfi_capabilities.support_ext_queue_depth = 1;
> >
> > +	drv_ops->mfi_capabilities.support_qd_throttling = 1;
> >  	/* Convert capability to LE32 */
> >  	cpu_to_le32s((u32
> > *)&init_frame->driver_operations.mfi_capabilities);
> >
> > @@ -2182,6 +2183,12 @@ megasas_build_and_issue_cmd_fusion(struct
> megasas_instance *instance,
> >  			atomic_inc(&instance->ldio_outstanding);
> >  	}
> >
> > +	if (atomic_read(&instance->fw_outstanding) >=
> > +			instance->host->can_queue) {
> > +		dev_err(&instance->pdev->dev, "Throttle IOs beyond
Controller
> queue depth\n");
> > +		return SCSI_MLQUEUE_HOST_BUSY;
> > +	}
>
> Same as in the previous patch, this this test above won't you protect
when
> several processes read the same value in parallel. In addition to that,
when the
> scsi layer knows the new smaller can_queue value it will not queue new
> commands above the limit.

Agree that SCSI mid layer itself will not send IOs beyond can_queue value
and we can remove this code. This code was just extra check for older
kernels- if IOs returned to SCSI mid layer by driver with DID_RESET status
does not check updated can_queue value(not sure if it was always taken
care of so added this code).
>
> > +
> >  	cmd = megasas_get_cmd_fusion(instance, scmd->request->tag);
> >
> >  	index = cmd->index;
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index 4595ef4..9d2b3da 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1537,7 +1537,8 @@  union megasas_sgl_frame {
 typedef union _MFI_CAPABILITIES {
 	struct {
 #if   defined(__BIG_ENDIAN_BITFIELD)
-		u32     reserved:21;
+		u32     reserved:20;
+		u32     support_qd_throttling:1;
 		u32     support_fp_rlbypass:1;
 		u32     support_vfid_in_ioframe:1;
 		u32     support_ext_io_size:1;
@@ -1561,7 +1562,8 @@  typedef union _MFI_CAPABILITIES {
 		u32     support_ext_io_size:1;
 		u32     support_vfid_in_ioframe:1;
 		u32     support_fp_rlbypass:1;
-		u32     reserved:21;
+		u32     support_qd_throttling:1;
+		u32     reserved:20;
 #endif
 	} mfi_capabilities;
 	__le32		reg;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 7cc7806..1248c7a 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -801,6 +801,7 @@  megasas_ioc_init_fusion(struct megasas_instance *instance)
 	if (!dual_qdepth_disable)
 		drv_ops->mfi_capabilities.support_ext_queue_depth = 1;
 
+	drv_ops->mfi_capabilities.support_qd_throttling = 1;
 	/* Convert capability to LE32 */
 	cpu_to_le32s((u32 *)&init_frame->driver_operations.mfi_capabilities);
 
@@ -2182,6 +2183,12 @@  megasas_build_and_issue_cmd_fusion(struct megasas_instance *instance,
 			atomic_inc(&instance->ldio_outstanding);
 	}
 
+	if (atomic_read(&instance->fw_outstanding) >=
+			instance->host->can_queue) {
+		dev_err(&instance->pdev->dev, "Throttle IOs beyond Controller queue depth\n");
+		return SCSI_MLQUEUE_HOST_BUSY;
+	}
+
 	cmd = megasas_get_cmd_fusion(instance, scmd->request->tag);
 
 	index = cmd->index;