From: Bart Van Assche <bvanassche@acm.org>
To: "Bao D. Nguyen" <quic_nguyenb@quicinc.com>,
quic_asutoshd@quicinc.com, quic_cang@quicinc.com,
mani@kernel.org, stanley.chu@mediatek.com,
adrian.hunter@intel.com, beanhuo@micron.com, avri.altman@wdc.com,
martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, Alim Akhtar <alim.akhtar@samsung.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
Alice Chao <alice.chao@mediatek.com>,
Arthur Simchaev <Arthur.Simchaev@wdc.com>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
Eric Biggers <ebiggers@google.com>,
Kiwoong Kim <kwmad.kim@samsung.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 3/7] ufs: mcq: Add supporting functions for mcq abort
Date: Wed, 10 May 2023 14:50:16 -0700 [thread overview]
Message-ID: <9022430e-a50b-7744-d8f5-d5953b5460e2@acm.org> (raw)
In-Reply-To: <d58b5c068bdc03d5fe6d0219bb211370ae681ed2.1683688693.git.quic_nguyenb@quicinc.com>
On 5/9/23 22:24, Bao D. Nguyen wrote:
> +/**
> + * ufshcd_mcq_sq_cleanup - Clean up submission queue resources
> + * associated with the pending command.
> + * @hba - per adapter instance.
> + * @task_tag - The command's task tag.
> + * @result - Result of the clean up operation.
> + *
> + * Returns 0 and result on completion. Returns error code if
> + * the operation fails.
> + */
> +int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag, int *result)
> +{
> + struct ufshcd_lrb *lrbp = &hba->lrb[task_tag];
> + struct scsi_cmnd *cmd = lrbp->cmd;
> + struct ufs_hw_queue *hwq;
> + void __iomem *reg, *opr_sqd_base;
> + u32 nexus, id, val;
> + int err;
> +
> + if (task_tag != hba->nutrs - UFSHCD_NUM_RESERVED) {
> + if (!cmd)
> + return FAILED;
> + hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd));
> + } else {
> + hwq = hba->dev_cmd_queue;
> + }
> +
> + id = hwq->id;
> +
> + mutex_lock(&hwq->sq_mutex);
> +
> + /* stop the SQ fetching before working on it */
> + err = ufshcd_mcq_sq_stop(hba, hwq);
> + if (err)
> + goto unlock;
> +
> + /* SQCTI = EXT_IID, IID, LUN, Task Tag */
> + nexus = lrbp->lun << 8 | task_tag;
> + opr_sqd_base = mcq_opr_base(hba, OPR_SQD, id);
> + writel(nexus, opr_sqd_base + REG_SQCTI);
> +
> + /* SQRTCy.ICU = 1 */
> + writel(SQ_ICU, opr_sqd_base + REG_SQRTC);
> +
> + /* Poll SQRTSy.CUS = 1. Return result from SQRTSy.RTC */
> + reg = opr_sqd_base + REG_SQRTS;
> + err = read_poll_timeout(readl, val, val & SQ_CUS, 20,
> + MCQ_POLL_US, false, reg);
> + if (err)
> + dev_err(hba->dev, "%s: failed. hwq=%d, lun=0x%x, tag=%d\n",
> + __func__, id, lrbp->lun, task_tag);
> +
> + *result = FIELD_GET(SQ_ICU_ERR_CODE_MASK, readl(reg));
> +
> + if (ufshcd_mcq_sq_start(hba, hwq))
> + err = FAILED;
> +
> +unlock:
> + mutex_unlock(&hwq->sq_mutex);
> + return err;
> +}
Please do not use the FAILED / SUCCESS return values in this function.
These values should only be returned by functions related to SCSI error
handling. Please do the following:
* Return a negative Unix error code in case of failure.
* Return zero upon success.
* Return the FIELD_GET() result as a positive value.
* Remove the 'int *result' argument.
> + /* prevent concurrent access to sq hw */
> + struct mutex sq_mutex;
Hmm ... a submission queue (SQ) exists in host memory so I'm not sure
the "hw" part of the above comment is correct.
Thanks,
Bart.
next prev parent reply other threads:[~2023-05-10 21:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1683688692.git.quic_nguyenb@quicinc.com>
2023-05-10 5:24 ` [PATCH v3 1/7] ufs: core: Combine 32-bit command_desc_base_addr_lo/hi Bao D. Nguyen
2023-05-10 21:20 ` Bart Van Assche
2023-05-10 5:24 ` [PATCH v3 2/7] ufs: core: Update the ufshcd_clear_cmds() functionality Bao D. Nguyen
2023-05-10 21:25 ` Bart Van Assche
2023-05-10 21:57 ` Bart Van Assche
2023-05-10 5:24 ` [PATCH v3 3/7] ufs: mcq: Add supporting functions for mcq abort Bao D. Nguyen
2023-05-10 21:50 ` Bart Van Assche [this message]
2023-05-10 5:24 ` [PATCH v3 4/7] ufs: mcq: Add support for clean up mcq resources Bao D. Nguyen
2023-05-10 22:00 ` Bart Van Assche
2023-05-10 5:24 ` [PATCH v3 5/7] ufs: mcq: Added ufshcd_mcq_abort() Bao D. Nguyen
2023-05-10 5:24 ` [PATCH v3 6/7] ufs: mcq: Use ufshcd_mcq_poll_cqe_lock() in mcq mode Bao D. Nguyen
2023-05-10 5:24 ` [PATCH v3 7/7] ufs: core: Add error handling for MCQ mode Bao D. Nguyen
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=9022430e-a50b-7744-d8f5-d5953b5460e2@acm.org \
--to=bvanassche@acm.org \
--cc=Arthur.Simchaev@wdc.com \
--cc=adrian.hunter@intel.com \
--cc=alice.chao@mediatek.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=ebiggers@google.com \
--cc=jejb@linux.ibm.com \
--cc=kwmad.kim@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mani@kernel.org \
--cc=martin.petersen@oracle.com \
--cc=quic_asutoshd@quicinc.com \
--cc=quic_cang@quicinc.com \
--cc=quic_nguyenb@quicinc.com \
--cc=stanley.chu@mediatek.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/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
all inboxes | Powered by JetHome®