All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomas Henzl <thenzl@redhat.com>
To: Sumit Saxena <sumit.saxena@avagotech.com>,
	jbottomley@parallels.com, hch@infradead.org,
	martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, kashyap.desai@avagotech.com
Subject: Re: [PATCH 12/15] megaraid_sas: MFI adapter's OCR changes
Date: Tue, 19 Jan 2016 15:22:57 +0100	[thread overview]
Message-ID: <569E46C1.7060104@redhat.com> (raw)
In-Reply-To: <1450445228-26571-13-git-send-email-Sumit.Saxena@avagotech.com>

On 18.12.2015 14:27, Sumit Saxena wrote:
> Optimized MFI adapters' OCR path, particularly megasas_wait_for_outstanding() function.
>
> Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
> Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c |  104 +++++++++++++++--------------
>  1 files changed, 54 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> index 5eaf6fd..cc843d6 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -2456,15 +2456,19 @@ void megasas_sriov_heartbeat_handler(unsigned long instance_addr)
>   */
>  static int megasas_wait_for_outstanding(struct megasas_instance *instance)
>  {
> -	int i;
> +	int i, sl, outstanding;
>  	u32 reset_index;
>  	u32 wait_time = MEGASAS_RESET_WAIT_TIME;
>  	unsigned long flags;
>  	struct list_head clist_local;
>  	struct megasas_cmd *reset_cmd;
>  	u32 fw_state;
> -	u8 kill_adapter_flag;
>  
> +	if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
> +		dev_info(&instance->pdev->dev, "%s:%d HBA is killed.\n",
> +		__func__, __LINE__);
> +		return FAILED;
> +	}
>  
>  	if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
>  
> @@ -2521,7 +2525,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
>  	}
>  
>  	for (i = 0; i < resetwaittime; i++) {
> -		int outstanding = atomic_read(&instance->fw_outstanding);
> +		outstanding = atomic_read(&instance->fw_outstanding);
>  
>  		if (!outstanding)
>  			break;
> @@ -2540,65 +2544,65 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
>  	}
>  
>  	i = 0;
> -	kill_adapter_flag = 0;
> +	outstanding = atomic_read(&instance->fw_outstanding);
> +	fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK;
> +
> +	if ((!outstanding && (fw_state == MFI_STATE_OPERATIONAL)))
> +		goto no_outstanding;
> +
> +	if (instance->disableOnlineCtrlReset)
> +		goto kill_hba_and_failed;
>  	do {
> -		fw_state = instance->instancet->read_fw_status_reg(
> -					instance->reg_set) & MFI_STATE_MASK;
> -		if ((fw_state == MFI_STATE_FAULT) &&
> -			(instance->disableOnlineCtrlReset == 0)) {
> -			if (i == 3) {
> -				kill_adapter_flag = 2;
> -				break;
> -			}
> +		if ((fw_state == MFI_STATE_FAULT) || atomic_read(&instance->fw_outstanding)) {
> +			dev_info(&instance->pdev->dev,
> +				"%s:%d waiting_for_outstanding: before issue OCR. FW state = 0x%x, oustanding 0x%x\n",
> +				__func__, __LINE__, fw_state, atomic_read(&instance->fw_outstanding));
> +			if (i == 3)
> +				goto kill_hba_and_failed;
>  			megasas_do_ocr(instance);
> -			kill_adapter_flag = 1;
>  
> -			/* wait for 1 secs to let FW finish the pending cmds */
> -			msleep(1000);
> +			if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
> +				dev_info(&instance->pdev->dev, "%s:%d OCR failed and HBA is killed.\n",
> +				__func__, __LINE__);
> +				return FAILED;
> +			}
> +			dev_info(&instance->pdev->dev, "%s:%d waiting_for_outstanding: after issue OCR.\n",
> +				__func__, __LINE__);
> +
> +			for (sl = 0; sl < 10; sl++)
> +				msleep(500);

		ssleep(5); ?

> +
> +			outstanding = atomic_read(&instance->fw_outstanding);
> +
> +			fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK;
> +			if ((!outstanding && (fw_state == MFI_STATE_OPERATIONAL)))
> +				goto no_outstanding;
>  		}
>  		i++;
>  	} while (i <= 3);
>  
> -	if (atomic_read(&instance->fw_outstanding) && !kill_adapter_flag) {
> -		if (instance->disableOnlineCtrlReset == 0) {
> -			megasas_do_ocr(instance);
> +no_outstanding:
>  
> -			/* wait for 5 secs to let FW finish the pending cmds */
> -			for (i = 0; i < wait_time; i++) {
> -				int outstanding =
> -					atomic_read(&instance->fw_outstanding);
> -				if (!outstanding)
> -					return SUCCESS;
> -				msleep(1000);
> -			}
> -		}
> -	}
> +	dev_info(&instance->pdev->dev, "%s:%d no more pending commands remain after reset handling.\n",
> +		__func__, __LINE__);
> +	return SUCCESS;
>  
> -	if (atomic_read(&instance->fw_outstanding) ||
> -					(kill_adapter_flag == 2)) {
> -		dev_notice(&instance->pdev->dev, "pending cmds after reset\n");
> -		/*
> -		 * Send signal to FW to stop processing any pending cmds.
> -		 * The controller will be taken offline by the OS now.
> -		 */
> -		if ((instance->pdev->device ==
> -			PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
> -			(instance->pdev->device ==
> -			PCI_DEVICE_ID_LSI_SAS0071SKINNY)) {
> -			writel(MFI_STOP_ADP,
> -				&instance->reg_set->doorbell);
> -		} else {
> -			writel(MFI_STOP_ADP,
> -				&instance->reg_set->inbound_doorbell);
> -		}
> +kill_hba_and_failed:
> +
> +	fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK;
> +	if (instance->disableOnlineCtrlReset ||
> +		atomic_read(&instance->fw_outstanding) ||
> +		(fw_state == MFI_STATE_FAULT)) {

You have tested all that many times before (fw_state etc.), so when you after all that
have arrived at kill_hba_and_failed: please just kill the HBA and return FAILED.

> +		/* Reset not supported, kill adapter */
> +		dev_info(&instance->pdev->dev, "%s:%d killing adapter scsi%d"
> +			" disableOnlineCtrlReset %d fw_outstanding %d \n",
> +			__func__, __LINE__, instance->host->host_no, instance->disableOnlineCtrlReset,
> +			atomic_read(&instance->fw_outstanding));
>  		megasas_dump_pending_frames(instance);
> -		atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR);
> -		return FAILED;
> +		megaraid_sas_kill_hba(instance);
>  	}
>  
> -	dev_notice(&instance->pdev->dev, "no pending cmds after reset\n");
> -
> -	return SUCCESS;
> +	return FAILED;
>  }
>  
>  /**


  reply	other threads:[~2016-01-19 14:23 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 13:26 [PATCH 00/15] megaraid_sas: Updates for scsi-next Sumit Saxena
2015-12-18 13:26 ` [PATCH 01/15] megaraid_sas: Do not allow PCI access during OCR Sumit Saxena
2016-01-11 17:02   ` Tomas Henzl
2015-12-18 13:26 ` [PATCH 02/15] megaraid_sas: MFI IO timeout handling Sumit Saxena
2016-01-11 17:02   ` Tomas Henzl
2015-12-18 13:26 ` [PATCH 03/15] megaraid_sas: Syncing request flags macro names with firmware Sumit Saxena
2016-01-11 17:03   ` Tomas Henzl
2015-12-18 13:26 ` [PATCH 04/15] megaraid_sas: Task management support Sumit Saxena
2016-01-11 17:03   ` Tomas Henzl
2016-01-14 12:04     ` Sumit Saxena
2015-12-18 13:26 ` [PATCH 05/15] megaraid_sas: Update device Queue depth based on interface type Sumit Saxena
2016-01-12 14:16   ` Tomas Henzl
2016-01-14 11:48     ` Sumit Saxena
2015-12-18 13:26 ` [PATCH 06/15] megaraid_sas: Fastpath region lock bypass Sumit Saxena
2016-01-12 14:44   ` Tomas Henzl
2015-12-18 13:27 ` [PATCH 07/15] megaraid_sas: Reply Descriptor Post Queue(RDPQ) support Sumit Saxena
2015-12-18 14:49   ` [PATCH] megaraid_sas: fix kzalloc-simple.cocci warnings kbuild test robot
2015-12-18 14:49   ` [PATCH 07/15] megaraid_sas: Reply Descriptor Post Queue(RDPQ) support kbuild test robot
2016-01-14 17:38   ` Tomas Henzl
2016-01-27 18:15     ` Sumit Saxena
2015-12-18 13:27 ` [PATCH 08/15] megaraid_sas: Code optimization build_and_issue_cmd return-type Sumit Saxena
2016-01-14 18:05   ` Tomas Henzl
2015-12-18 13:27 ` [PATCH 09/15] megaraid_sas: Dual Queue depth support Sumit Saxena
2016-01-19 13:34   ` Tomas Henzl
2016-01-19 13:44     ` Sumit Saxena
2016-01-20 13:55       ` Tomas Henzl
2016-01-20 14:09         ` Sumit Saxena
2016-01-20 14:16           ` Tomas Henzl
2016-01-20 15:08             ` Sumit Saxena
2016-01-20 16:00               ` Tomas Henzl
2016-01-27  2:02             ` Martin K. Petersen
2016-01-27  7:09               ` Sumit Saxena
2015-12-18 13:27 ` [PATCH 10/15] megaraid_sas: IO throttling support Sumit Saxena
2016-01-19 13:38   ` Tomas Henzl
2016-01-28  7:18     ` Sumit Saxena
2015-12-18 13:27 ` [PATCH 11/15] megaraid_sas: Make adprecovery variable atomic Sumit Saxena
2016-01-19 13:52   ` Tomas Henzl
2016-01-28  8:30     ` Sumit Saxena
2015-12-18 13:27 ` [PATCH 12/15] megaraid_sas: MFI adapter's OCR changes Sumit Saxena
2016-01-19 14:22   ` Tomas Henzl [this message]
2016-01-28 11:12     ` Sumit Saxena
2015-12-18 13:27 ` [PATCH 13/15] megaraid_sas: Introduce module parameter for SCSI command-timeout Sumit Saxena
2016-01-19 14:57   ` Tomas Henzl
2016-01-28 11:17     ` Sumit Saxena
2015-12-18 13:27 ` [PATCH 14/15] megaraid_sas: SPERC OCR changes Sumit Saxena
2016-01-19 15:14   ` Tomas Henzl
2015-12-18 13:27 ` [PATCH 15/15] megaraid_sas: SPERC boot driver reorder Sumit Saxena
2015-12-18 14:05   ` Christoph Hellwig
2016-01-08  7:07     ` Sumit Saxena
2016-01-12  5:26     ` Sumit Saxena

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=569E46C1.7060104@redhat.com \
    --to=thenzl@redhat.com \
    --cc=hch@infradead.org \
    --cc=jbottomley@parallels.com \
    --cc=kashyap.desai@avagotech.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sumit.saxena@avagotech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.