mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Bao D. Nguyen" <quic_nguyenb@quicinc.com>
To: Stanley Chu <chu.stanley@gmail.com>
Cc: <quic_asutoshd@quicinc.com>, <quic_cang@quicinc.com>,
	<bvanassche@acm.org>, <mani@kernel.org>,
	<stanley.chu@mediatek.com>, <adrian.hunter@intel.com>,
	<beanhuo@micron.com>, <avri.altman@wdc.com>,
	<martin.petersen@oracle.com>, <linux-scsi@vger.kernel.org>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 7/7] ufs: core: Add error handling for MCQ mode
Date: Tue, 23 May 2023 00:01:09 -0700	[thread overview]
Message-ID: <a9352709-b9c8-065e-cca8-33e4cde55ff1@quicinc.com> (raw)
In-Reply-To: <CAGaU9a8+mDgVu9-rmH944NhbSCGocADUhbdin5gQkrc_FD1xMQ@mail.gmail.com>

On 5/21/2023 11:56 PM, Stanley Chu wrote:
> On Mon, May 22, 2023 at 2:48 PM Stanley Chu <chu.stanley@gmail.com> wrote:
>>
>> Hi Bao,
>>
>> Bao D. Nguyen <quic_nguyenb@quicinc.com> 於 2023年5月12日 週五 下午2:34寫道:
>>>
>>> Add support for error handling for MCQ mode.
>>>
>>> Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
>>> ---
>>>   drivers/ufs/core/ufshcd.c | 85 +++++++++++++++++++++++++++++++++++++++++------
>>>   1 file changed, 74 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
>>> index ec07e49..9345118 100644
>>> --- a/drivers/ufs/core/ufshcd.c
>>> +++ b/drivers/ufs/core/ufshcd.c
>>> @@ -3148,6 +3148,16 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
>>>                  err = -ETIMEDOUT;
>>>                  dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n",
>>>                          __func__, lrbp->task_tag);
>>> +
>>> +               /* MCQ mode */
>>> +               if (is_mcq_enabled(hba)) {
>>> +                       err = ufshcd_clear_cmd(hba, lrbp->task_tag);
>>> +                       if (!err)
>>> +                               hba->dev_cmd.complete = NULL;
>>
>> How about always clearing hba->dev_cmd.complete? If ufshcd_clear_cmd()
>> fails (for example, times out), "complete" should be cleared, similar
>> to the "pending" case in the SDB path.
>>
>>> +                       return err;
>>> +               }
>>> +
>>> +               /* SDB mode */
>>>                  if (ufshcd_clear_cmd(hba, lrbp->task_tag) == 0) {
>>>                          /* successfully cleared the command, retry if needed */
>>>                          err = -EAGAIN;
>>> @@ -5581,6 +5591,10 @@ static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num)
>>>    */
>>>   static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba)
>>>   {
>>> +       struct ufshcd_lrb *lrbp;
>>> +       u32 hwq_num, utag;
>>> +       int tag;
>>> +
>>>          /* Resetting interrupt aggregation counters first and reading the
>>>           * DOOR_BELL afterward allows us to handle all the completed requests.
>>>           * In order to prevent other interrupts starvation the DB is read once
>>> @@ -5599,7 +5613,22 @@ static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba)
>>>           * Ignore the ufshcd_poll() return value and return IRQ_HANDLED since we
>>>           * do not want polling to trigger spurious interrupt complaints.
>>>           */
>>> -       ufshcd_poll(hba->host, UFSHCD_POLL_FROM_INTERRUPT_CONTEXT);
>>> +       if (!is_mcq_enabled(hba)) {
>>> +               ufshcd_poll(hba->host, UFSHCD_POLL_FROM_INTERRUPT_CONTEXT);
>>> +               goto out;
>>> +       }
>>> +
>>> +       /* MCQ mode */
>>> +       for (tag = 0; tag < hba->nutrs; tag++) {
>>> +               lrbp = &hba->lrb[tag];
>>> +               if (ufshcd_cmd_inflight(lrbp->cmd)) {
>>> +                       utag = blk_mq_unique_tag(scsi_cmd_to_rq(lrbp->cmd));
>>> +                       hwq_num = blk_mq_unique_tag_to_hwq(utag);
>>> +                       ufshcd_poll(hba->host, hwq_num);
>>> +               }
>>> +       }
>>
>> In SDB mode, the DOOR_BELL is reset by ufshcd_hba_stop(). All bits
>> that were previously set in DOOR_BELL are also set in "completed_reqs"
>> in ufshcd_poll(). This allows ufshcd_poll() to handle all outstanding
>> requests properly.
>>
>> However, in MCQ mode, the CQ tail registers cannot provide the same
>> information after they are reset. Hence, they cannot be properly
>> referenced by ufshcd_poll().
> 
> A fixed version sample is as follows and has been tested on our end.
Thank you Stanley. I will make the change.

> 
> struct scsi_cmnd *cmd;
> 
> for (tag = 0; tag < hba->nutrs; tag++) {
>          lrbp = &hba->lrb[tag];
>          cmd = lrbp->cmd;
>          if (ufshcd_cmd_inflight(cmd)) {
>                  set_host_byte(cmd, DID_ERROR);
>                  ufshcd_release_scsi_cmd(hba, lrbp);
>                  scsi_done(cmd);
>          }
> }
> 
> Thanks,
> Stanley Chu


      reply	other threads:[~2023-05-23  7:01 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1683872601.git.quic_nguyenb@quicinc.com>
2023-05-12  6:28 ` [PATCH v5 1/7] ufs: core: Combine 32-bit command_desc_base_addr_lo/hi Bao D. Nguyen
2023-05-19 22:46   ` Bart Van Assche
2023-05-12  6:28 ` [PATCH v5 2/7] ufs: core: Update the ufshcd_clear_cmds() functionality Bao D. Nguyen
2023-05-19 22:53   ` Bart Van Assche
2023-05-12  6:28 ` [PATCH v5 3/7] ufs: mcq: Add supporting functions for mcq abort Bao D. Nguyen
2023-05-19 22:56   ` Bart Van Assche
2023-05-12  6:28 ` [PATCH v5 4/7] ufs: mcq: Add support for clean up mcq resources Bao D. Nguyen
2023-05-19 22:58   ` Bart Van Assche
2023-05-12  6:28 ` [PATCH v5 5/7] ufs: mcq: Added ufshcd_mcq_abort() Bao D. Nguyen
2023-05-17  3:15   ` Stanley Chu
2023-05-17  3:25     ` Bao D. Nguyen
2023-05-12  6:28 ` [PATCH v5 6/7] ufs: mcq: Use ufshcd_mcq_poll_cqe_lock() in mcq mode Bao D. Nguyen
2023-05-19 22:59   ` Bart Van Assche
2023-05-12  6:28 ` [PATCH v5 7/7] ufs: core: Add error handling for MCQ mode Bao D. Nguyen
2023-05-19 23:03   ` Bart Van Assche
2023-05-20  0:11     ` Bao D. Nguyen
2023-05-23  6:58     ` Bao D. Nguyen
2023-05-22  6:48   ` Stanley Chu
2023-05-22  6:56     ` Stanley Chu
2023-05-23  7:01       ` Bao D. Nguyen [this message]

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=a9352709-b9c8-065e-cca8-33e4cde55ff1@quicinc.com \
    --to=quic_nguyenb@quicinc.com \
    --cc=adrian.hunter@intel.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=chu.stanley@gmail.com \
    --cc=jejb@linux.ibm.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=stanley.chu@mediatek.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®