From: Brian King <brking@linux.vnet.ibm.com>
To: "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,
"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>
Subject: Re: [PATCH v5] cxlflash: Base support for IBM CXL Flash Adapter
Date: Mon, 08 Jun 2015 17:56:47 -0500 [thread overview]
Message-ID: <55761DAF.9030203@linux.vnet.ibm.com> (raw)
In-Reply-To: <1433802653-7476-1-git-send-email-mrochs@linux.vnet.ibm.com>
On 06/08/2015 05:30 PM, Matthew R. Ochs wrote:
> +
> +/**
> + * cxlflash_send_cmd() - sends an AFU command
> + * @afu: AFU associated with the host.
> + * @cmd: AFU command to send.
> + *
> + * Return:
> + * 0 on success
> + * -1 on failure
> + */
> +int cxlflash_send_cmd(struct afu *afu, struct afu_cmd *cmd)
> +{
> + int nretry = 0;
> + int rc = 0;
> + u64 room;
> + long newval;
> +
> + /*
> + * This routine is used by critical users such an AFU sync and to
> + * send a task management function (TMF). Thus we want to retry a
> + * bit before returning an error. To avoid the performance penalty
> + * of MMIO, we spread the update of 'room' over multiple commands.
> + */
> +retry:
> + newval = atomic64_dec_if_positive(&afu->room);
> + if (!newval) {
> + do {
> + room = readq_be(&afu->host_map->cmd_room);
> + atomic64_set(&afu->room, room);
> + if (room)
> + goto write_ioarrin;
> + } while (nretry++ < MC_ROOM_RETRY_CNT);
It looks like you removed the udelay here. Was that intentional?
> +
> + pr_err("%s: no cmd_room to send 0x%X\n",
> + __func__, cmd->rcb.cdb[0]);
> + rc = SCSI_MLQUEUE_HOST_BUSY;
If you actually get here, how do you get out of this state? Since now afu->room is
zero and anyone that comes through here will go to the else if leg.
> + goto out;
> + } else if (unlikely(newval < 0)) {
> + /* This should be rare. i.e. Only if two threads race and
> + * decrement before the MMIO read is done. In this case
> + * just benefit from the other thread having updated
> + * afu->room.
> + */
> + if (nretry++ < MC_ROOM_RETRY_CNT)
I'm guessing you'd want the udelay here as well.
> + goto retry;
> + else {
> + rc = SCSI_MLQUEUE_HOST_BUSY;
> + goto out;
> + }
> + }
> +
> +write_ioarrin:
> + writeq_be((u64)&cmd->rcb, &afu->host_map->ioarrin);
> +out:
> + pr_debug("%s: cmd=%p len=%d ea=%p rc=%d\n", __func__, cmd,
> + cmd->rcb.data_len, (void *)cmd->rcb.data_ea, rc);
> + return rc;
> +}
> +
--
Brian King
Power Linux I/O
IBM Linux Technology Center
next prev parent reply other threads:[~2015-06-08 22:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-08 22:30 [PATCH v5] cxlflash: Base support for IBM CXL Flash Adapter Matthew R. Ochs
2015-06-08 22:56 ` Brian King [this message]
2015-06-08 23:24 ` Manoj Kumar
2015-06-09 11:29 ` Brian King
2015-06-09 14:37 ` Manoj Kumar
2015-06-09 16:01 ` Matthew R. Ochs
2015-06-09 18:30 ` Brian King
2015-06-09 18:52 ` Matthew R. Ochs
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=55761DAF.9030203@linux.vnet.ibm.com \
--to=brking@linux.vnet.ibm.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=hch@infradead.org \
--cc=imunsie@au1.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=manoj@linux.vnet.ibm.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox