All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sumit Saxena <sumit.saxena@avagotech.com>
To: Tomas Henzl <thenzl@redhat.com>,
	jbottomley@parallels.com, hch@infradead.org,
	martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, Kashyap Desai <kashyap.desai@avagotech.com>
Subject: RE: [PATCH 11/15] megaraid_sas: Make adprecovery variable atomic
Date: Thu, 28 Jan 2016 14:00:22 +0530	[thread overview]
Message-ID: <cf54fde696f7c6a7950b7a55b6d3ad76@mail.gmail.com> (raw)
In-Reply-To: <569E3FA7.80004@redhat.com>

> -----Original Message-----
> From: Tomas Henzl [mailto:thenzl@redhat.com]
> Sent: Tuesday, January 19, 2016 7:23 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 11/15] megaraid_sas: Make adprecovery variable
atomic
>
> On 18.12.2015 14:27, Sumit Saxena wrote:
> > Make instance->adprecovery variable atomic and removes hba_lock
spinlock
> while accessing instance->adprecovery.
>
> adprecovery is a 8bit int, you don't do any arithmetic with it, the
newly set
> values do not depend on previous values - I think that an atomic
variable is not
> needed.

I agree that this adprecovery can be made uint8_t but the purpose of
making "adprecovery"  atomic was to remove "hba_lock" while reading and
setting adprecovery. hba_lock around reading/setting adprecovery was added
when OCR was implemented for MFI adapters. Here is the old patch which had
done this- http://www.spinics.net/lists/linux-scsi/msg43496.html

The reason of adding "hba_lock" around reading/setting adprecovery is
unknown so the intent was to keep the flow of original code same and make
it less costly by making adprecovery atomic instead of using "hba_lock" .
MFI adapters' support is EOL and we may not get test coverage if we do
major changes in MFI adapters' code path so keep this less riskier this
approach of making variable atomic was adopted.
>
> -tm
>
> >
> > Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
> > Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
> > ---
> >  drivers/scsi/megaraid/megaraid_sas.h        |    2 +-
> >  drivers/scsi/megaraid/megaraid_sas_base.c   |   95
++++++++++-----------------
> >  drivers/scsi/megaraid/megaraid_sas_fusion.c |   27 ++++----
> >  3 files changed, 50 insertions(+), 74 deletions(-)
> >
> > diff --git a/drivers/scsi/megaraid/megaraid_sas.h
> > b/drivers/scsi/megaraid/megaraid_sas.h
> > index 9d2b3da..ac19d53 100644
> > --- a/drivers/scsi/megaraid/megaraid_sas.h
> > +++ b/drivers/scsi/megaraid/megaraid_sas.h
> > @@ -2101,7 +2101,7 @@ struct megasas_instance {
> >  	u16 drv_supported_vd_count;
> >  	u16 drv_supported_pd_count;
> >
> > -	u8 adprecovery;
> > +	atomic_t adprecovery;
> >  	unsigned long last_time;
> >  	u32 mfiStatus;
> >  	u32 last_seq_num;'
> > diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
> > b/drivers/scsi/megaraid/megaraid_sas_base.c
> > index edc26fb..5eaf6fd 100644
> > --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> > +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> > @@ -483,7 +483,7 @@ static int
> >  megasas_check_reset_xscale(struct megasas_instance *instance,
> >  		struct megasas_register_set __iomem *regs)  {
> > -	if ((instance->adprecovery != MEGASAS_HBA_OPERATIONAL) &&
> > +	if ((atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> > +&&
> >  	    (le32_to_cpu(*instance->consumer) ==
> >  		MEGASAS_ADPRESET_INPROG_SIGN))
> >  		return 1;
> > @@ -619,7 +619,7 @@ static int
> >  megasas_check_reset_ppc(struct megasas_instance *instance,
> >  			struct megasas_register_set __iomem *regs)  {
> > -	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL)
> > +	if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> >  		return 1;
> >
> >  	return 0;
> > @@ -756,7 +756,7 @@ static int
> >  megasas_check_reset_skinny(struct megasas_instance *instance,
> >  				struct megasas_register_set __iomem *regs)
{
> > -	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL)
> > +	if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> >  		return 1;
> >
> >  	return 0;
> > @@ -950,9 +950,8 @@ static int
> >  megasas_check_reset_gen2(struct megasas_instance *instance,
> >  		struct megasas_register_set __iomem *regs)  {
> > -	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
> > +	if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> >  		return 1;
> > -	}
> >
> >  	return 0;
> >  }
> > @@ -998,7 +997,7 @@ megasas_issue_polled(struct megasas_instance
> *instance, struct megasas_cmd *cmd)
> >  	frame_hdr->cmd_status = MFI_STAT_INVALID_STATUS;
> >  	frame_hdr->flags |=
> cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE);
> >
> > -	if ((instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) ||
> > +	if ((atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR) ||
> >  		(instance->instancet->issue_dcmd(instance, cmd))) {
> >  		dev_err(&instance->pdev->dev, "Failed from %s %d\n",
> >  			__func__, __LINE__);
> > @@ -1026,7 +1025,7 @@ megasas_issue_blocked_cmd(struct
> megasas_instance *instance,
> >  	int ret = 0;
> >  	cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS;
> >
> > -	if ((instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) ||
> > +	if ((atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR) ||
> >  		(instance->instancet->issue_dcmd(instance, cmd))) {
> >  		dev_err(&instance->pdev->dev, "Failed from %s %d\n",
> >  			__func__, __LINE__);
> > @@ -1090,7 +1089,7 @@ megasas_issue_blocked_abort_cmd(struct
> megasas_instance *instance,
> >  	cmd->sync_cmd = 1;
> >  	cmd->cmd_status_drv = MFI_STAT_INVALID_STATUS;
> >
> > -	if ((instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) ||
> > +	if ((atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR) ||
> >  		(instance->instancet->issue_dcmd(instance, cmd))) {
> >  		dev_err(&instance->pdev->dev, "Failed from %s %d\n",
> >  			__func__, __LINE__);
> > @@ -1653,7 +1652,6 @@ static int
> >  megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd
> > *scmd)  {
> >  	struct megasas_instance *instance;
> > -	unsigned long flags;
> >  	struct MR_PRIV_DEVICE *mr_device_priv_data;
> >
> >  	instance = (struct megasas_instance *) @@ -1668,24 +1666,20 @@
> > megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
> >  	if (instance->issuepend_done == 0)
> >  		return SCSI_MLQUEUE_HOST_BUSY;
> >
> > -	spin_lock_irqsave(&instance->hba_lock, flags);
> >
> >  	/* Check for an mpio path and adjust behavior */
> > -	if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) {
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_ADPRESET_SM_INFAULT) {
> >  		if (megasas_check_mpio_paths(instance, scmd) ==
> >  		    (DID_RESET << 16)) {
> > -			spin_unlock_irqrestore(&instance->hba_lock,
flags);
> >  			return SCSI_MLQUEUE_HOST_BUSY;
> >  		} else {
> > -			spin_unlock_irqrestore(&instance->hba_lock,
flags);
> >  			scmd->result = DID_NO_CONNECT << 16;
> >  			scmd->scsi_done(scmd);
> >  			return 0;
> >  		}
> >  	}
> >
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
> > -		spin_unlock_irqrestore(&instance->hba_lock, flags);
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR) {
> >  		scmd->result = DID_NO_CONNECT << 16;
> >  		scmd->scsi_done(scmd);
> >  		return 0;
> > @@ -1693,23 +1687,17 @@ megasas_queue_command(struct Scsi_Host
> *shost,
> > struct scsi_cmnd *scmd)
> >
> >  	mr_device_priv_data = scmd->device->hostdata;
> >  	if (!mr_device_priv_data) {
> > -		spin_unlock_irqrestore(&instance->hba_lock, flags);
> >  		scmd->result = DID_NO_CONNECT << 16;
> >  		scmd->scsi_done(scmd);
> >  		return 0;
> >  	}
> >
> > -	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
> > -		spin_unlock_irqrestore(&instance->hba_lock, flags);
> > +	if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> >  		return SCSI_MLQUEUE_HOST_BUSY;
> > -	}
> >
> > -	if (mr_device_priv_data->tm_busy) {
> > -		spin_unlock_irqrestore(&instance->hba_lock, flags);
> > +	if (mr_device_priv_data->tm_busy)
> >  		return SCSI_MLQUEUE_DEVICE_BUSY;
> > -	}
> >
> > -	spin_unlock_irqrestore(&instance->hba_lock, flags);
> >
> >  	scmd->result = 0;
> >
> > @@ -1943,7 +1931,7 @@ static void
> > megasas_complete_outstanding_ioctls(struct megasas_instance *instanc
> > void megaraid_sas_kill_hba(struct megasas_instance *instance)  {
> >  	/* Set critical error to block I/O & ioctls in case caller didn't
*/
> > -	instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR;
> > +	atomic_set(&instance->adprecovery, MEGASAS_HW_CRITICAL_ERROR);
> >  	/* Wait 1 second to ensure IO or ioctls in build have posted */
> >  	msleep(1000);
> >  	if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
> > @@ -2003,7 +1991,7 @@ static void megasas_complete_cmd_dpc(unsigned
> long instance_addr)
> >  	unsigned long flags;
> >
> >  	/* If we have already declared adapter dead, donot complete cmds
*/
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR)
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR)
> >  		return;
> >
> >  	spin_lock_irqsave(&instance->completion_lock, flags); @@ -2072,7
> > +2060,7 @@ void megasas_do_ocr(struct megasas_instance *instance)
> >  		*instance->consumer =
> cpu_to_le32(MEGASAS_ADPRESET_INPROG_SIGN);
> >  	}
> >  	instance->instancet->disable_intr(instance);
> > -	instance->adprecovery   = MEGASAS_ADPRESET_SM_INFAULT;
> > +	atomic_set(&instance->adprecovery,
> MEGASAS_ADPRESET_SM_INFAULT);
> >  	instance->issuepend_done = 0;
> >
> >  	atomic_set(&instance->fw_outstanding, 0); @@ -2471,18 +2459,14
> @@
> > static int megasas_wait_for_outstanding(struct megasas_instance
*instance)
> >  	int i;
> >  	u32 reset_index;
> >  	u32 wait_time = MEGASAS_RESET_WAIT_TIME;
> > -	u8 adprecovery;
> >  	unsigned long flags;
> >  	struct list_head clist_local;
> >  	struct megasas_cmd *reset_cmd;
> >  	u32 fw_state;
> >  	u8 kill_adapter_flag;
> >
> > -	spin_lock_irqsave(&instance->hba_lock, flags);
> > -	adprecovery = instance->adprecovery;
> > -	spin_unlock_irqrestore(&instance->hba_lock, flags);
> >
> > -	if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
> > +	if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> > +{
> >
> >  		INIT_LIST_HEAD(&clist_local);
> >  		spin_lock_irqsave(&instance->hba_lock, flags); @@ -2493,18
> +2477,13
> > @@ static int megasas_wait_for_outstanding(struct megasas_instance
> *instance)
> >  		dev_notice(&instance->pdev->dev, "HBA reset wait ...\n");
> >  		for (i = 0; i < wait_time; i++) {
> >  			msleep(1000);
> > -			spin_lock_irqsave(&instance->hba_lock, flags);
> > -			adprecovery = instance->adprecovery;
> > -			spin_unlock_irqrestore(&instance->hba_lock,
flags);
> > -			if (adprecovery == MEGASAS_HBA_OPERATIONAL)
> > +			if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HBA_OPERATIONAL)
> >  				break;
> >  		}
> >
> > -		if (adprecovery != MEGASAS_HBA_OPERATIONAL) {
> > +		if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> > +{
> >  			dev_notice(&instance->pdev->dev, "reset: Stopping
> HBA.\n");
> > -			spin_lock_irqsave(&instance->hba_lock, flags);
> > -			instance->adprecovery =
> MEGASAS_HW_CRITICAL_ERROR;
> > -			spin_unlock_irqrestore(&instance->hba_lock,
flags);
> > +			atomic_set(&instance->adprecovery,
> MEGASAS_HW_CRITICAL_ERROR);
> >  			return FAILED;
> >  		}
> >
> > @@ -2613,9 +2592,7 @@ static int megasas_wait_for_outstanding(struct
> megasas_instance *instance)
> >  				&instance->reg_set->inbound_doorbell);
> >  		}
> >  		megasas_dump_pending_frames(instance);
> > -		spin_lock_irqsave(&instance->hba_lock, flags);
> > -		instance->adprecovery = MEGASAS_HW_CRITICAL_ERROR;
> > -		spin_unlock_irqrestore(&instance->hba_lock, flags);
> > +		atomic_set(&instance->adprecovery,
> MEGASAS_HW_CRITICAL_ERROR);
> >  		return FAILED;
> >  	}
> >
> > @@ -2642,7 +2619,7 @@ static int megasas_generic_reset(struct
scsi_cmnd
> *scmd)
> >  	scmd_printk(KERN_NOTICE, scmd, "megasas: RESET cmd=%x
> retries=%x\n",
> >  		 scmd->cmnd[0], scmd->retries);
> >
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR) {
> >  		dev_err(&instance->pdev->dev, "cannot recover from
previous
> reset failures\n");
> >  		return FAILED;
> >  	}
> > @@ -3386,13 +3363,13 @@ process_fw_state_change_wq(struct work_struct
> *work)
> >  	u32 wait;
> >  	unsigned long flags;
> >
> > -	if (instance->adprecovery != MEGASAS_ADPRESET_SM_INFAULT) {
> > +    if (atomic_read(&instance->adprecovery) !=
> > + MEGASAS_ADPRESET_SM_INFAULT) {
> >  		dev_notice(&instance->pdev->dev, "error, recovery st
%x\n",
> > -				instance->adprecovery);
> > +				atomic_read(&instance->adprecovery));
> >  		return ;
> >  	}
> >
> > -	if (instance->adprecovery == MEGASAS_ADPRESET_SM_INFAULT) {
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_ADPRESET_SM_INFAULT) {
> >  		dev_notice(&instance->pdev->dev, "FW detected to be in
fault"
> >  					"state, restarting it...\n");
> >
> > @@ -3435,7 +3412,7 @@ process_fw_state_change_wq(struct work_struct
> *work)
> >  		megasas_issue_init_mfi(instance);
> >
> >  		spin_lock_irqsave(&instance->hba_lock, flags);
> > -		instance->adprecovery	= MEGASAS_HBA_OPERATIONAL;
> > +		atomic_set(&instance->adprecovery,
> MEGASAS_HBA_OPERATIONAL);
> >  		spin_unlock_irqrestore(&instance->hba_lock, flags);
> >  		instance->instancet->enable_intr(instance);
> >
> > @@ -3500,14 +3477,14 @@ megasas_deplete_reply_queue(struct
> > megasas_instance *instance,
> >
> >
> >  			instance->instancet->disable_intr(instance);
> > -			instance->adprecovery	=
> MEGASAS_ADPRESET_SM_INFAULT;
> > +			atomic_set(&instance->adprecovery,
> MEGASAS_ADPRESET_SM_INFAULT);
> >  			instance->issuepend_done = 0;
> >
> >  			atomic_set(&instance->fw_outstanding, 0);
> >  			megasas_internal_reset_defer_cmds(instance);
> >
> >  			dev_notice(&instance->pdev->dev, "fwState=%x,
> stage:%d\n",
> > -					fw_state, instance->adprecovery);
> > +					fw_state, atomic_read(&instance-
> >adprecovery));
> >
> >  			schedule_work(&instance->work_init);
> >  			return IRQ_HANDLED;
> > @@ -5796,7 +5773,7 @@ static int megasas_probe_one(struct pci_dev
*pdev,
> >  	instance->flag_ieee = 0;
> >  	instance->ev = NULL;
> >  	instance->issuepend_done = 1;
> > -	instance->adprecovery = MEGASAS_HBA_OPERATIONAL;
> > +	atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL);
> >  	instance->is_imr = 0;
> >
> >  	instance->evt_detail = pci_alloc_consistent(pdev, @@ -5975,7
+5952,7
> > @@ static void megasas_flush_cache(struct megasas_instance *instance)
> >  	struct megasas_cmd *cmd;
> >  	struct megasas_dcmd_frame *dcmd;
> >
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR)
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR)
> >  		return;
> >
> >  	cmd = megasas_get_cmd(instance);
> > @@ -6018,7 +5995,7 @@ static void megasas_shutdown_controller(struct
> megasas_instance *instance,
> >  	struct megasas_cmd *cmd;
> >  	struct megasas_dcmd_frame *dcmd;
> >
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR)
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR)
> >  		return;
> >
> >  	cmd = megasas_get_cmd(instance);
> > @@ -6463,7 +6440,7 @@ static int
> megasas_set_crash_dump_params_ioctl(struct megasas_cmd *cmd)
> >  	for (i = 0; i < megasas_mgmt_info.max_index; i++) {
> >  		local_instance = megasas_mgmt_info.instance[i];
> >  		if (local_instance &&
local_instance->crash_dump_drv_support)
> {
> > -			if ((local_instance->adprecovery ==
> > +			if ((atomic_read(&local_instance->adprecovery) ==
> >  				MEGASAS_HBA_OPERATIONAL) &&
> >
> 	!megasas_set_crash_dump_params(local_instance,
> >  					crash_support)) {
> > @@ -6711,7 +6688,7 @@ static int megasas_mgmt_ioctl_fw(struct file
*file,
> unsigned long arg)
> >  		goto out_kfree_ioc;
> >  	}
> >
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR) {
> >  		dev_err(&instance->pdev->dev, "Controller in crit
error\n");
> >  		error = -ENODEV;
> >  		goto out_kfree_ioc;
> > @@ -6730,7 +6707,7 @@ static int megasas_mgmt_ioctl_fw(struct file
*file,
> unsigned long arg)
> >  	for (i = 0; i < wait_time; i++) {
> >
> >  		spin_lock_irqsave(&instance->hba_lock, flags);
> > -		if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) {
> > +		if (atomic_read(&instance->adprecovery) ==
> MEGASAS_HBA_OPERATIONAL)
> > +{
> >  			spin_unlock_irqrestore(&instance->hba_lock,
flags);
> >  			break;
> >  		}
> > @@ -6745,7 +6722,7 @@ static int megasas_mgmt_ioctl_fw(struct file
*file,
> unsigned long arg)
> >  	}
> >
> >  	spin_lock_irqsave(&instance->hba_lock, flags);
> > -	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
> > +	if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> > +{
> >  		spin_unlock_irqrestore(&instance->hba_lock, flags);
> >
> >  		dev_err(&instance->pdev->dev, "timed out while"
> > @@ -6787,7 +6764,7 @@ static int megasas_mgmt_ioctl_aen(struct file
*file,
> unsigned long arg)
> >  	if (!instance)
> >  		return -ENODEV;
> >
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR) {
> >  		return -ENODEV;
> >  	}
> >
> > @@ -6798,7 +6775,7 @@ static int megasas_mgmt_ioctl_aen(struct file
*file,
> unsigned long arg)
> >  	for (i = 0; i < wait_time; i++) {
> >
> >  		spin_lock_irqsave(&instance->hba_lock, flags);
> > -		if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) {
> > +		if (atomic_read(&instance->adprecovery) ==
> MEGASAS_HBA_OPERATIONAL)
> > +{
> >  			spin_unlock_irqrestore(&instance->hba_lock,
> >  						flags);
> >  			break;
> > @@ -6815,7 +6792,7 @@ static int megasas_mgmt_ioctl_aen(struct file
*file,
> unsigned long arg)
> >  	}
> >
> >  	spin_lock_irqsave(&instance->hba_lock, flags);
> > -	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
> > +	if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> > +{
> >  		spin_unlock_irqrestore(&instance->hba_lock, flags);
> >  		dev_err(&instance->pdev->dev, "timed out while waiting"
> >  				"for HBA to recover\n");
> > diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > index 1248c7a..96e8d80 100644
> > --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> > @@ -2251,7 +2251,7 @@ complete_cmd_fusion(struct megasas_instance
> > *instance, u32 MSIxIndex)
> >
> >  	fusion = instance->ctrl_context;
> >
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR)
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR)
> >  		return IRQ_HANDLED;
> >
> >  	desc = fusion->reply_frames_desc[MSIxIndex] + @@ -2418,7 +2418,7
> @@
> > megasas_complete_cmd_dpc_fusion(unsigned long instance_addr)
> >
> >  	/* If we have already declared adapter dead, donot complete cmds
*/
> >  	spin_lock_irqsave(&instance->hba_lock, flags);
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR) {
> >  		spin_unlock_irqrestore(&instance->hba_lock, flags);
> >  		return;
> >  	}
> > @@ -3200,7 +3200,7 @@ int megasas_task_abort_fusion(struct scsi_cmnd
> *scmd)
> >  	instance = (struct megasas_instance
*)scmd->device->host->hostdata;
> >  	fusion = instance->ctrl_context;
> >
> > -	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
> > +	if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> > +{
> >  		dev_err(&instance->pdev->dev, "Controller is not
> OPERATIONAL,"
> >  		"SCSI host:%d\n", instance->host->host_no);
> >  		ret = FAILED;
> > @@ -3284,7 +3284,7 @@ int megasas_reset_target_fusion(struct scsi_cmnd
> *scmd)
> >  	instance = (struct megasas_instance
*)scmd->device->host->hostdata;
> >  	fusion = instance->ctrl_context;
> >
> > -	if (instance->adprecovery != MEGASAS_HBA_OPERATIONAL) {
> > +	if (atomic_read(&instance->adprecovery) !=
> MEGASAS_HBA_OPERATIONAL)
> > +{
> >  		dev_err(&instance->pdev->dev, "Controller is not
> OPERATIONAL,"
> >  		"SCSI host:%d\n", instance->host->host_no);
> >  		ret = FAILED;
> > @@ -3376,7 +3376,7 @@ int megasas_reset_fusion(struct Scsi_Host
> > *shost, int reason)
> >
> >  	mutex_lock(&instance->reset_mutex);
> >
> > -	if (instance->adprecovery == MEGASAS_HW_CRITICAL_ERROR) {
> > +	if (atomic_read(&instance->adprecovery) ==
> > +MEGASAS_HW_CRITICAL_ERROR) {
> >  		dev_warn(&instance->pdev->dev, "Hardware critical error, "
> >  		       "returning FAILED for scsi%d.\n",
> >  			instance->host->host_no);
> > @@ -3391,7 +3391,7 @@ int megasas_reset_fusion(struct Scsi_Host
*shost,
> int reason)
> >  		instance->crash_dump_app_support && reason) {
> >  		dev_info(&instance->pdev->dev, "IO/DCMD timeout is
> detected, "
> >  			"forcibly FAULT Firmware\n");
> > -		instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT;
> > +		atomic_set(&instance->adprecovery,
> MEGASAS_ADPRESET_SM_INFAULT);
> >  		status_reg = readl(&instance->reg_set->doorbell);
> >  		writel(status_reg | MFI_STATE_FORCE_OCR,
> >  			&instance->reg_set->doorbell);
> > @@ -3403,10 +3403,10 @@ int megasas_reset_fusion(struct Scsi_Host
> *shost, int reason)
> >  			dev_dbg(&instance->pdev->dev, "waiting for [%d] "
> >  				"seconds for crash dump collection and OCR
"
> >  				"to be done\n", (io_timeout_in_crash_mode
*
> 3));
> > -		} while ((instance->adprecovery !=
> MEGASAS_HBA_OPERATIONAL) &&
> > +		} while ((atomic_read(&instance->adprecovery) !=
> > +MEGASAS_HBA_OPERATIONAL) &&
> >  			(io_timeout_in_crash_mode < 80));
> >
> > -		if (instance->adprecovery == MEGASAS_HBA_OPERATIONAL) {
> > +		if (atomic_read(&instance->adprecovery) ==
> MEGASAS_HBA_OPERATIONAL)
> > +{
> >  			dev_info(&instance->pdev->dev, "OCR done for IO "
> >  				"timeout case\n");
> >  			retval = SUCCESS;
> > @@ -3423,14 +3423,14 @@ int megasas_reset_fusion(struct Scsi_Host
> *shost, int reason)
> >  	if (instance->requestorId && !instance->skip_heartbeat_timer_del)
> >  		del_timer_sync(&instance->sriov_heartbeat_timer);
> >  	set_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags);
> > -	instance->adprecovery = MEGASAS_ADPRESET_SM_POLLING;
> > +	atomic_set(&instance->adprecovery,
> MEGASAS_ADPRESET_SM_POLLING);
> >  	instance->instancet->disable_intr(instance);
> >  	msleep(1000);
> >
> >  	/* First try waiting for commands to complete */
> >  	if (megasas_wait_for_outstanding_fusion(instance, reason,
> >  						&convert)) {
> > -		instance->adprecovery = MEGASAS_ADPRESET_SM_INFAULT;
> > +		atomic_set(&instance->adprecovery,
> MEGASAS_ADPRESET_SM_INFAULT);
> >  		dev_warn(&instance->pdev->dev, "resetting fusion "
> >  		       "adapter scsi%d.\n", instance->host->host_no);
> >  		if (convert)
> > @@ -3513,8 +3513,7 @@ int megasas_reset_fusion(struct Scsi_Host
*shost,
> int reason)
> >  					       status_reg);
> >  					megaraid_sas_kill_hba(instance);
> >  					instance->skip_heartbeat_timer_del
=
> 1;
> > -					instance->adprecovery =
> > -
> 	MEGASAS_HW_CRITICAL_ERROR;
> > +					atomic_set(&instance->adprecovery,
> MEGASAS_HW_CRITICAL_ERROR);
> >  					retval = FAILED;
> >  					goto out;
> >  				}
> > @@ -3573,7 +3572,7 @@ int megasas_reset_fusion(struct Scsi_Host
*shost,
> int reason)
> >  			clear_bit(MEGASAS_FUSION_IN_RESET,
> >  				  &instance->reset_flags);
> >  			instance->instancet->enable_intr(instance);
> > -			instance->adprecovery =
> MEGASAS_HBA_OPERATIONAL;
> > +			atomic_set(&instance->adprecovery,
> MEGASAS_HBA_OPERATIONAL);
> >
> >  			/* Restart SR-IOV heartbeat */
> >  			if (instance->requestorId) {
> > @@ -3618,7 +3617,7 @@ int megasas_reset_fusion(struct Scsi_Host
*shost,
> int reason)
> >  		}
> >  		clear_bit(MEGASAS_FUSION_IN_RESET, &instance-
> >reset_flags);
> >  		instance->instancet->enable_intr(instance);
> > -		instance->adprecovery = MEGASAS_HBA_OPERATIONAL;
> > +		atomic_set(&instance->adprecovery,
> MEGASAS_HBA_OPERATIONAL);
> >  	}
> >  out:
> >  	clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags);

  reply	other threads:[~2016-01-28  8:30 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 [this message]
2015-12-18 13:27 ` [PATCH 12/15] megaraid_sas: MFI adapter's OCR changes Sumit Saxena
2016-01-19 14:22   ` Tomas Henzl
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=cf54fde696f7c6a7950b7a55b6d3ad76@mail.gmail.com \
    --to=sumit.saxena@avagotech.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=thenzl@redhat.com \
    --subject='RE: [PATCH 11/15] megaraid_sas: Make adprecovery variable atomic' \
    /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

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.