All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manoj Kumar <manoj@linux.vnet.ibm.com>
To: Brian King <brking@linux.vnet.ibm.com>,
	"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
	linux-scsi@vger.kernel.org,
	James.Bottomley@HansenPartnership.com, nab@linux-iscsi.org,
	hch@infradead.org
Cc: mikey@neuling.org, imunsie@au1.ibm.com
Subject: Re: [PATCH v4] cxlflash: Base support for IBM CXL Flash Adapter
Date: Mon, 08 Jun 2015 14:47:31 -0500	[thread overview]
Message-ID: <5575F153.2080808@linux.vnet.ibm.com> (raw)
In-Reply-To: <5575D6C6.5080808@linux.vnet.ibm.com>

Brian:

Thank you for your review. Comments are inline.

- Manoj

On 6/8/2015 12:54 PM, Brian King wrote:
> Looking pretty good. A few more comments.
>
> Thanks,
>
> Brian
>
>> +	spin_lock_irqsave(&cfg->tmf_waitq.lock, lock_flags);
>> +	if (cfg->tmf_active)
>> +		wait_event_interruptible_locked_irq(cfg->tmf_waitq,
>> +						    !cfg->tmf_active);
>> +	spin_unlock_irqrestore(&cfg->tmf_waitq.lock, lock_flags);
>
> This needs to return SCSI_MLQUEUE_HOST_BUSY instead of sleeping. You can't sleep
> in queuecommand.
>

Okay, will revise in v5 to return an error instead of sleeping.

>> +	if (atomic64_dec_and_test(&afu->room)) {
>
> If you have two threads executing this code concurrently you could have a problem.
> If afu->room = 1 and thread 1 decrements it and the return value is 0, we go into this
> leg. If a second thread then comes in right after afu->room goes to zero, afu->room
> will then get decremented to -1, and you'll send the command, regardless of whether
> the AFU has room or not. Either the AFU will have room and afu->room will then
> end up being off by one, or it won't have room and you'll send a command when it
> does not have room.
>
> I think if you use atomic_dec_if_positive instead, you can get rid of this race condition.
> You'd then need to check the return value. If its positive, there is room, if it zero,
> you are out of room and you are the thread that will reset afu->room from the AFU. If
> it is negative, then you have to either return host busy, or wait for the other thread to
> reset afu->room and simply try the atomic_dec_if_positive again in the loop here
> instead of reading from the adapter and trying to set it from two threads.
>

Good catch. Will switch to atomic_dec_if_positive() in v5 to avoid the race.




  reply	other threads:[~2015-06-08 19:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-05 21:46 [PATCH v4] cxlflash: Base support for IBM CXL Flash Adapter Matthew R. Ochs
2015-06-08 10:05 ` Michael Neuling
2015-06-08 19:11   ` Matthew R. Ochs
2015-06-08 17:54 ` Brian King
2015-06-08 19:47   ` Manoj Kumar [this message]
2015-06-08 21:41   ` Manoj Kumar
2015-06-08 21:45     ` Brian King
2015-06-09  1:22 ` Stephen Bates

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=5575F153.2080808@linux.vnet.ibm.com \
    --to=manoj@linux.vnet.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=hch@infradead.org \
    --cc=imunsie@au1.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mikey@neuling.org \
    --cc=mrochs@linux.vnet.ibm.com \
    --cc=nab@linux-iscsi.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 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.