Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: "Peter Wang (王信友)" <peter.wang@mediatek.com>
To: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"bvanassche@acm.org" <bvanassche@acm.org>,
	"avri.altman@wdc.com" <avri.altman@wdc.com>,
	"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>
Cc: "linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Jiajie Hao (郝加节)" <jiajie.hao@mediatek.com>,
	"CC Chou (周志杰)" <cc.chou@mediatek.com>,
	"Eddie Huang (黃智傑)" <eddie.huang@mediatek.com>,
	"Alice Chao (趙珮均)" <Alice.Chao@mediatek.com>,
	"quic_nguyenb@quicinc.com" <quic_nguyenb@quicinc.com>,
	wsd_upstream <wsd_upstream@mediatek.com>,
	"Ed Tsai (蔡宗軒)" <Ed.Tsai@mediatek.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	"Lin Gui (桂林)" <Lin.Gui@mediatek.com>,
	"Chun-Hung Wu (巫駿宏)" <Chun-hung.Wu@mediatek.com>,
	"Tun-yu Yu (游敦聿)" <Tun-yu.Yu@mediatek.com>,
	"Chaotian Jing (井朝天)" <Chaotian.Jing@mediatek.com>,
	"Powen Kao (高伯文)" <Powen.Kao@mediatek.com>,
	"Naomi Chu (朱詠田)" <Naomi.Chu@mediatek.com>,
	"Qilin Tan (谭麒麟)" <Qilin.Tan@mediatek.com>
Subject: Re: [PATCH v4 2/2] ufs: core: requeue aborted request
Date: Thu, 12 Sep 2024 13:31:29 +0000	[thread overview]
Message-ID: <524e9da9196cc0acf497ff87eba3a8043b780332.camel@mediatek.com> (raw)
In-Reply-To: <858c4b6b-fcbc-4d51-8641-051aeda387c5@acm.org>

On Wed, 2024-09-11 at 12:11 -0700, Bart Van Assche wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  On 9/10/24 11:03 PM, Peter Wang (王信友) wrote:
> > This statement is not quite accurate becasue in UFSHIC2.1, SDB mode
> > specification already have OCS: ABORTED (0x6) define.
> > And it is used in below UTRLCLR description:
> > 'which means a Transfer Request was "aborted"'
> > Therefore, the host controller should follow the
> > specification and fill the OCS field with OCS: ABORTED.
> > If not so, at what point does your host controller use the
> > OCS: ABORTED status?
> 
> Hmm ... I have not been able to find any explanation in the UFSHCI
> 2.1
> specification that says when the OCS status is set to aborted. Did I
> perhaps overlook something?
> 
> This is what I found in the UTRLCLR description: "The host software 
> shall use this field only when a UTP Transfer Request is expected to
> not be completed, e.g., when the host software receives a “FUNCTION
> COMPLETE” Task Management response which means a Transfer Request was
> aborted." This does not mean that the host controller is expected to
> set the OCS status to "ABORTED". I will send an email to the JC-64
> mailing list to request clarification.
> 

Hi Bart,


Yes, you're right, just as I mentioned earlier, I also think
the spec does not explicitly state that UTRLC should have 
corresponding behavior for OCS. This might lead to inconsistencies
in how host controllers operate. 


> >>> +/*
> >>> + * When the host software receives a "FUNCTION COMPLETE", set
> flag
> >>> + * to requeue command after receive response with OCS_ABORTED
> >>> + * SDB mode: UTRLCLR Task Management response which means a
> >> Transfer
> >>> + *           Request was aborted.
> >>> + * MCQ mode: Host will post to CQ with OCS_ABORTED after SQ
> >> cleanup
> >>> + * This flag is set because ufshcd_abort_all forcibly aborts all
> >>> + * commands, and the host will automatically fill in the OCS
> field
> >>> + * of the corresponding response with OCS_ABORTED.
> >>> + * Therefore, upon receiving this response, it needs to be
> >> requeued.
> >>> + */
> >>> +if (!err)
> >>> +lrbp->abort_initiated_by_err = true;
> >>> +
> >>>    err = ufshcd_clear_cmd(hba, tag);
> >>>    if (err)
> >>>    dev_err(hba->dev, "%s: Failed clearing cmd at tag %d, err
> %d\n",
> >>
> >> The above change is misplaced. ufshcd_try_to_abort_task() can be
> >> called
> >> when the SCSI core decides to abort a command while
> >> abort_initiated_by_err must not be set in that case. Please move
> the
> >> above code block into ufshcd_abort_one().
> > 
> > But move to ufshcd_abort_one may have race condition, beacause we
> > need set this flag before ufshcd_clear_cmd host controller fill
> > OCS_ABORTED to response. I will add check ufshcd_eh_in_progress.
> 
> Calling ufshcd_clear_cmd() does not affect the OCS status as far as I
> know. Did I perhaps overlook something?
> 

Because after ufshcd_clear_cmd,

in MCQ mode: 
ufshcd_mcq_sq_cleanup, host controller will post CQ response with OCS
ABORTED.

in SDB mode: 
ufshcd_utrl_clear set UTRLC, Mediatek host controller 
(may not all host controller) will post response with OCS ABORTED.

In both cases, we have an interrupt sent to the host, and there 
may be a race condition before we set this flag for requeue.
So I need to set this flag before ufshcd_clear_cmd.


Thanks.
Peter


> Thanks,
> 
> Bart.

  reply	other threads:[~2024-09-12 13:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240910073035.25974-1-peter.wang@mediatek.com>
2024-09-10  7:30 ` [PATCH v4 1/2] ufs: core: fix the issue of ICU failure peter.wang
2024-09-10  7:30 ` [PATCH v4 2/2] ufs: core: requeue aborted request peter.wang
2024-09-10 17:59   ` Bart Van Assche
2024-09-11  6:03     ` Peter Wang (王信友)
2024-09-11 19:11       ` Bart Van Assche
2024-09-12 13:31         ` Peter Wang (王信友) [this message]
2024-09-12 21:17           ` Bart Van Assche
2024-09-13  7:10             ` Peter Wang (王信友)
2024-09-13 17:41               ` Bart Van Assche
2024-09-18 13:29                 ` Peter Wang (王信友)
2024-09-18 18:29                   ` Bart Van Assche
2024-09-19 12:16                     ` Peter Wang (王信友)
2024-09-19 18:49                       ` Bart Van Assche
2024-09-20  2:02                         ` Peter Wang (王信友)
2024-09-20 18:39                           ` Bart Van Assche
2024-09-23  7:06                             ` Peter Wang (王信友)
2024-09-14 16:13       ` Bart Van Assche
2024-09-18 13:30         ` Peter Wang (王信友)

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=524e9da9196cc0acf497ff87eba3a8043b780332.camel@mediatek.com \
    --to=peter.wang@mediatek.com \
    --cc=Alice.Chao@mediatek.com \
    --cc=Chaotian.Jing@mediatek.com \
    --cc=Chun-hung.Wu@mediatek.com \
    --cc=Ed.Tsai@mediatek.com \
    --cc=Lin.Gui@mediatek.com \
    --cc=Naomi.Chu@mediatek.com \
    --cc=Powen.Kao@mediatek.com \
    --cc=Qilin.Tan@mediatek.com \
    --cc=Tun-yu.Yu@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=bvanassche@acm.org \
    --cc=cc.chou@mediatek.com \
    --cc=eddie.huang@mediatek.com \
    --cc=jejb@linux.ibm.com \
    --cc=jiajie.hao@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=quic_nguyenb@quicinc.com \
    --cc=stable@vger.kernel.org \
    --cc=wsd_upstream@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