diff mbox

[v3,04/17] be2iscsi: Fix to synchronize tag allocation using spin_lock

Message ID 1450859676-22025-5-git-send-email-jitendra.bhivare@avagotech.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Jitendra Bhivare Dec. 23, 2015, 8:34 a.m. UTC
alloc_mcc_tag/free_mcc_tag is now done under mcc_lock spin_lock

Signed-off-by: Jitendra Bhivare <jitendra.bhivare@avagotech.com>
---
 drivers/scsi/be2iscsi/be_cmds.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Mike Christie Jan. 11, 2016, 9:06 p.m. UTC | #1
On 12/23/2015 02:34 AM, Jitendra Bhivare wrote:
> alloc_mcc_tag/free_mcc_tag is now done under mcc_lock spin_lock
> 
> Signed-off-by: Jitendra Bhivare <jitendra.bhivare@avagotech.com>
> ---
>  drivers/scsi/be2iscsi/be_cmds.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
> index 1913e9e..502c9b6 100644
> --- a/drivers/scsi/be2iscsi/be_cmds.c
> +++ b/drivers/scsi/be2iscsi/be_cmds.c
> @@ -121,6 +121,7 @@ unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
>  {
>  	unsigned int tag = 0;
>  
> +	spin_lock_bh(&phba->ctrl.mcc_lock);
>  	if (phba->ctrl.mcc_tag_available) {
>  		tag = phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index];
>  		phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index] = 0;
> @@ -134,6 +135,7 @@ unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
>  		else
>  			phba->ctrl.mcc_alloc_index++;
>  	}
> +	spin_unlock_bh(&phba->ctrl.mcc_lock);
>  	return tag;
>  }
>  
> @@ -254,7 +256,7 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
>  
>  void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag)
>  {
> -	spin_lock(&ctrl->mbox_lock);
> +	spin_lock_bh(&ctrl->mcc_lock);
>  	tag = tag & 0x000000FF;
>  	ctrl->mcc_tag[ctrl->mcc_free_index] = tag;
>  	if (ctrl->mcc_free_index == (MAX_MCC_CMD - 1))
> @@ -262,7 +264,7 @@ void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag)
>  	else
>  		ctrl->mcc_free_index++;
>  	ctrl->mcc_tag_available++;
> -	spin_unlock(&ctrl->mbox_lock);
> +	spin_unlock_bh(&ctrl->mcc_lock);
>  }
>  

What was the _bh change for?

--
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
Jitendra Bhivare Jan. 13, 2016, 3:08 a.m. UTC | #2
Thanks Mike.

It is not needed, will send the updated diff.

-----Original Message-----
From: Mike Christie [mailto:michaelc@cs.wisc.edu]
Sent: Tuesday, January 12, 2016 2:37 AM
To: Jitendra Bhivare; linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 04/17] be2iscsi: Fix to synchronize tag allocation
using spin_lock

On 12/23/2015 02:34 AM, Jitendra Bhivare wrote:
> alloc_mcc_tag/free_mcc_tag is now done under mcc_lock spin_lock
>
> Signed-off-by: Jitendra Bhivare <jitendra.bhivare@avagotech.com>
> ---
>  drivers/scsi/be2iscsi/be_cmds.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_cmds.c
> b/drivers/scsi/be2iscsi/be_cmds.c index 1913e9e..502c9b6 100644
> --- a/drivers/scsi/be2iscsi/be_cmds.c
> +++ b/drivers/scsi/be2iscsi/be_cmds.c
> @@ -121,6 +121,7 @@ unsigned int alloc_mcc_tag(struct beiscsi_hba
> *phba)  {
>  	unsigned int tag = 0;
>
> +	spin_lock_bh(&phba->ctrl.mcc_lock);
>  	if (phba->ctrl.mcc_tag_available) {
>  		tag = phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index];
>  		phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index] = 0; @@
-134,6
> +135,7 @@ unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
>  		else
>  			phba->ctrl.mcc_alloc_index++;
>  	}
> +	spin_unlock_bh(&phba->ctrl.mcc_lock);
>  	return tag;
>  }
>
> @@ -254,7 +256,7 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
>
>  void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag)  {
> -	spin_lock(&ctrl->mbox_lock);
> +	spin_lock_bh(&ctrl->mcc_lock);
>  	tag = tag & 0x000000FF;
>  	ctrl->mcc_tag[ctrl->mcc_free_index] = tag;
>  	if (ctrl->mcc_free_index == (MAX_MCC_CMD - 1)) @@ -262,7 +264,7 @@

> void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag)
>  	else
>  		ctrl->mcc_free_index++;
>  	ctrl->mcc_tag_available++;
> -	spin_unlock(&ctrl->mbox_lock);
> +	spin_unlock_bh(&ctrl->mcc_lock);
>  }
>

What was the _bh change for?
--
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/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 1913e9e..502c9b6 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -121,6 +121,7 @@  unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
 {
 	unsigned int tag = 0;
 
+	spin_lock_bh(&phba->ctrl.mcc_lock);
 	if (phba->ctrl.mcc_tag_available) {
 		tag = phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index];
 		phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index] = 0;
@@ -134,6 +135,7 @@  unsigned int alloc_mcc_tag(struct beiscsi_hba *phba)
 		else
 			phba->ctrl.mcc_alloc_index++;
 	}
+	spin_unlock_bh(&phba->ctrl.mcc_lock);
 	return tag;
 }
 
@@ -254,7 +256,7 @@  int beiscsi_mccq_compl(struct beiscsi_hba *phba,
 
 void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag)
 {
-	spin_lock(&ctrl->mbox_lock);
+	spin_lock_bh(&ctrl->mcc_lock);
 	tag = tag & 0x000000FF;
 	ctrl->mcc_tag[ctrl->mcc_free_index] = tag;
 	if (ctrl->mcc_free_index == (MAX_MCC_CMD - 1))
@@ -262,7 +264,7 @@  void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag)
 	else
 		ctrl->mcc_free_index++;
 	ctrl->mcc_tag_available++;
-	spin_unlock(&ctrl->mbox_lock);
+	spin_unlock_bh(&ctrl->mcc_lock);
 }
 
 bool is_link_state_evt(u32 trailer)