linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: Jitendra Bhivare <jitendra.bhivare@avagotech.com>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH 03/15] be2iscsi: Fix to use atomic operations for tag_state
Date: Sun, 20 Dec 2015 04:13:58 -0600	[thread overview]
Message-ID: <56767F66.8070302@cs.wisc.edu> (raw)
In-Reply-To: <56766E5E.1030605@cs.wisc.edu>

On 12/20/15 3:01 AM, Mike Christie wrote:
> On 12/20/2015 01:44 AM, Mike Christie wrote:
>
>>> diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
>>> index 6fabded..21c806f 100644
>>> --- a/drivers/scsi/be2iscsi/be_cmds.c
>>> +++ b/drivers/scsi/be2iscsi/be_cmds.c
>>> @@ -164,9 +164,8 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
>>>   	}
>>>
>>>   	/* Set MBX Tag state to Active */
>>> -	mutex_lock(&phba->ctrl.mbox_lock);
>>> -	phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_RUNNING;
>>> -	mutex_unlock(&phba->ctrl.mbox_lock);
>>> +	atomic_set(&phba->ctrl.ptag_state[tag].tag_state,
>>> +			MCC_TAG_STATE_RUNNING);
>>>
>
>
> Is it possible for be_mcc_compl_process_isr to run before we have set
> the state to MCC_TAG_STATE_RUNNING, so the
> wait_event_interruptible_timeout call timesout?
>
>
>>>   	/* wait for the mccq completion */
>>>   	rc = wait_event_interruptible_timeout(
>>> @@ -178,9 +177,8 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
>>>   	if (rc <= 0) {
>>>   		struct be_dma_mem *tag_mem;
>>>   		/* Set MBX Tag state to timeout */
>>> -		mutex_lock(&phba->ctrl.mbox_lock);
>>> -		phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_TIMEOUT;
>>> -		mutex_unlock(&phba->ctrl.mbox_lock);
>>> +		atomic_set(&phba->ctrl.ptag_state[tag].tag_state,
>>> +				MCC_TAG_STATE_TIMEOUT);
>>>
>>>   		/* Store resource addr to be freed later */
>>>   		tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state;
>>> @@ -199,9 +197,8 @@ int beiscsi_mccq_compl(struct beiscsi_hba *phba,
>>>   	} else {
>>>   		rc = 0;
>>>   		/* Set MBX Tag state to completed */
>>> -		mutex_lock(&phba->ctrl.mbox_lock);
>>> -		phba->ctrl.ptag_state[tag].tag_state = MCC_TAG_STATE_COMPLETED;
>>> -		mutex_unlock(&phba->ctrl.mbox_lock);
>>> +		atomic_set(&phba->ctrl.ptag_state[tag].tag_state,
>>> +				MCC_TAG_STATE_COMPLETED);
>>>   	}
>>>
>>>   	mcc_tag_response = phba->ctrl.mcc_numtag[tag];
>>> @@ -373,9 +370,11 @@ int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
>>>   	ctrl->mcc_numtag[tag] |= (extd_status & 0x000000FF) << 8;
>>>   	ctrl->mcc_numtag[tag] |= (compl_status & 0x000000FF);
>>>
>>> -	if (ctrl->ptag_state[tag].tag_state == MCC_TAG_STATE_RUNNING) {
>>> +	if (atomic_read(&ctrl->ptag_state[tag].tag_state) ==
>>> +		MCC_TAG_STATE_RUNNING) {
>>>   		wake_up_interruptible(&ctrl->mcc_wait[tag]);
>>> -	} else if (ctrl->ptag_state[tag].tag_state == MCC_TAG_STATE_TIMEOUT) {
>>> +	} else if (atomic_read(&ctrl->ptag_state[tag].tag_state) ==
>>> +			MCC_TAG_STATE_TIMEOUT) {
>>>   		struct be_dma_mem *tag_mem;
>>>   		tag_mem = &ctrl->ptag_state[tag].tag_mem_state;
>>>
>>> @@ -390,9 +389,8 @@ int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
>>>   					    tag_mem->va, tag_mem->dma);
>>>
>>>   		/* Change tag state */
>>> -		mutex_lock(&phba->ctrl.mbox_lock);
>>> -		ctrl->ptag_state[tag].tag_state = MCC_TAG_STATE_COMPLETED;
>>> -		mutex_unlock(&phba->ctrl.mbox_lock);
>>> +		atomic_set(&ctrl->ptag_state[tag].tag_state,
>>> +				MCC_TAG_STATE_COMPLETED);
>>>
>>>   		/* Free MCC Tag */
>>>   		free_mcc_tag(ctrl, tag);
>>>
>>
>> I think if you only need to get and set a u8 then you can just use a u8
>> since the operation will be atomic. No need for a atomic_t.
>
> I think you can ignore this. I think you would need some barriers in
> there too and it might be more complicated for no gain.
>

Ughhh. Sorry.

The atomic_ops.txt doc says atomic_read/atomic_set use still needs 
barriers, so I guess they do not do anything for you and a u8 is ok.

The memory-barrier.txt doc says wake_up/wait calls have barriers if the 
wake_up path is hit, so you are ok there.

However, besides the timeout issue in the previous mail, can 
beiscsi_mccq_compl set the tag_mem_state to MCC_TAG_STATE_TIMEOUT and 
be_mcc_compl_process_isr does not see the tag_mem values updated?




  reply	other threads:[~2015-12-20 10:14 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-15 15:54 [PATCH 00/15] be2iscsi: driver update 11.0.0.0 Jitendra Bhivare
2015-12-15 15:54 ` [PATCH 01/15] be2iscsi: Fix soft lockup in mgmt_get_all_if_id path using bmbx Jitendra Bhivare
2015-12-18  8:58   ` Hannes Reinecke
2015-12-15 15:54 ` [PATCH 02/15] be2iscsi: Fix mbox synchronization replacing spinlock with mutex Jitendra Bhivare
2015-12-18  8:59   ` Hannes Reinecke
2015-12-20  7:35   ` Mike Christie
2015-12-20  7:47     ` Mike Christie
2015-12-15 15:54 ` [PATCH 03/15] be2iscsi: Fix to use atomic operations for tag_state Jitendra Bhivare
2015-12-18  8:59   ` Hannes Reinecke
2015-12-20  7:44   ` Mike Christie
2015-12-20  9:01     ` Mike Christie
2015-12-20 10:13       ` Mike Christie [this message]
2015-12-21  4:47         ` Jitendra Bhivare
2015-12-15 15:54 ` [PATCH 04/15] be2iscsi: Fix to synchronize tag allocation using spin_lock Jitendra Bhivare
2015-12-18  8:59   ` Hannes Reinecke
2015-12-15 15:54 ` [PATCH 05/15] be2iscsi: Set mbox timeout to 30s Jitendra Bhivare
2015-12-18  9:00   ` Hannes Reinecke
2015-12-15 15:54 ` [PATCH 06/15] be2iscsi: Added return value check for mgmt_get_all_if_id Jitendra Bhivare
2015-12-18  9:00   ` Hannes Reinecke
2015-12-15 15:54 ` [PATCH 07/15] be2iscsi: Fix to remove shutdown entry point Jitendra Bhivare
2015-12-18  9:01   ` Hannes Reinecke
2015-12-15 15:54 ` [PATCH 08/15] be2iscsi: Fix VLAN support for IPv6 network Jitendra Bhivare
2015-12-18  9:01   ` Hannes Reinecke
2015-12-15 15:55 ` [PATCH 09/15] be2iscsi: Fix to handle misconfigured optics events Jitendra Bhivare
2015-12-18  9:02   ` Hannes Reinecke
2015-12-15 15:55 ` [PATCH 10/15] be2iscsi: Add FW config validation Jitendra Bhivare
2015-12-18  9:03   ` Hannes Reinecke
2015-12-21  2:57     ` Jitendra Bhivare
2015-12-21  3:59     ` Jitendra Bhivare
2015-12-15 15:55 ` [PATCH 11/15] be2iscsi: Fix return value for MCC completion Jitendra Bhivare
2015-12-18  9:04   ` Hannes Reinecke
2015-12-15 15:55 ` [PATCH 12/15] be2iscsi: Fix IOPOLL implementation Jitendra Bhivare
2015-12-18  9:04   ` Hannes Reinecke
2015-12-15 15:55 ` [PATCH 13/15] be2iscsi: Fix to process 25G link speed info from FW Jitendra Bhivare
2015-12-18  9:07   ` Hannes Reinecke
     [not found]     ` <CAOA9gs36+ozeo=ZtqHYMvznwMSG6wKnG_zLOp__=wnKMkKv0CA@mail.gmail.com>
2015-12-21  7:13       ` Hannes Reinecke
2015-12-15 15:55 ` [PATCH 14/15] be2iscsi: Fix WRB leak in login/logout path Jitendra Bhivare
2015-12-18  9:08   ` Hannes Reinecke
2015-12-15 15:55 ` [PATCH 15/15] be2iscsi: Update the driver version Jitendra Bhivare
2015-12-18  9:08   ` Hannes Reinecke
2015-12-18  9:11 ` [PATCH 00/15] be2iscsi: driver update 11.0.0.0 Hannes Reinecke

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=56767F66.8070302@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=jitendra.bhivare@avagotech.com \
    --cc=linux-scsi@vger.kernel.org \
    /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 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).