From: "Asutosh Das (asd)" <asutoshd@codeaurora.org>
To: Bart Van Assche <bvanassche@acm.org>,
"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Jaegeuk Kim <jaegeuk@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Stanley Chu <stanley.chu@mediatek.com>,
Can Guo <cang@codeaurora.org>, Avri Altman <avri.altman@wdc.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Bean Huo <beanhuo@micron.com>
Subject: Re: [PATCH 13/21] ufs: Remove several wmb() calls
Date: Thu, 1 Jul 2021 15:26:47 -0700 [thread overview]
Message-ID: <a5770fbe-9bdc-444e-2093-aa3fd58d5638@codeaurora.org> (raw)
In-Reply-To: <20210701211224.17070-14-bvanassche@acm.org>
On 7/1/2021 2:12 PM, Bart Van Assche wrote:
> From arch/arm/include/asm/io.h
>
> #define __iowmb() wmb()
> [ ... ]
> #define writel(v,c) ({ __iowmb(); writel_relaxed(v,c); })
>
> From Documentation/memory-barriers.txt: "Note that, when using writel(), a
> prior wmb() is not needed to guarantee that the cache coherent memory
> writes have completed before writing to the MMIO region."
>
> In other words, calling wmb() before writel() is not necessary. Hence
> remove the wmb() calls that precede a writel() call. Remove the wmb()
> calls that precede a ufshcd_send_command() call since the latter function
> uses writel(). Remove the wmb() call from ufshcd_wait_for_dev_cmd()
> since the following chain of events guarantees that the CPU will see
> up-to-date LRB values:
> * UFS controller writes to host memory.
> * UFS controller posts completion interrupt after the memory writes from
> the previous step are visible to the CPU.
> * complete(hba->dev_cmd.complete) is called from the UFS interrupt handler.
> * The wait_for_completion(hba->dev_cmd.complete) call in
> ufshcd_wait_for_dev_cmd() returns.
>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Stanley Chu <stanley.chu@mediatek.com>
> Cc: Can Guo <cang@codeaurora.org>
> Cc: Asutosh Das <asutoshd@codeaurora.org>
> Cc: Avri Altman <avri.altman@wdc.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/scsi/ufs/ufshcd.c | 11 -----------
> 1 file changed, 11 deletions(-)
>
Hi Bart,
Did you verify this change? I think we've seen OCS errors which were
fixed with the wmb() in queuecommand.
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 7091798e6245..25ab603acad1 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -2768,8 +2768,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
> ufshcd_release(hba);
> goto out;
> }
> - /* Make sure descriptors are ready before ringing the doorbell */
> - wmb();
>
> ufshcd_send_command(hba, tag);
> out:
> @@ -2879,8 +2877,6 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba,
> time_left = wait_for_completion_timeout(hba->dev_cmd.complete,
> msecs_to_jiffies(max_timeout));
>
> - /* Make sure descriptors are ready before ringing the doorbell */
> - wmb();
> spin_lock_irqsave(hba->host->host_lock, flags);
> hba->dev_cmd.complete = NULL;
> if (likely(time_left)) {
> @@ -2955,8 +2951,6 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
> hba->dev_cmd.complete = &wait;
>
> ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr);
> - /* Make sure descriptors are ready before ringing the doorbell */
> - wmb();
>
> ufshcd_send_command(hba, tag);
> err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout);
> @@ -6514,9 +6508,6 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
> /* send command to the controller */
> __set_bit(task_tag, &hba->outstanding_tasks);
>
> - /* Make sure descriptors are ready before ringing the task doorbell */
> - wmb();
> -
> ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL);
> /* Make sure that doorbell is committed immediately */
> wmb();
> @@ -6687,8 +6678,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
> hba->dev_cmd.complete = &wait;
>
> ufshcd_add_query_upiu_trace(hba, UFS_QUERY_SEND, lrbp->ucd_req_ptr);
> - /* Make sure descriptors are ready before ringing the doorbell */
> - wmb();
>
> ufshcd_send_command(hba, tag);
> /*
>
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
Linux Foundation Collaborative Project
next prev parent reply other threads:[~2021-07-01 22:26 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-01 21:12 [PATCH 00/21] UFS patches for kernel v5.15 Bart Van Assche
2021-07-01 21:12 ` [PATCH 01/21] Fix the documentation of the scsi_execute() time parameter Bart Van Assche
2021-07-05 5:51 ` Avri Altman
2021-07-01 21:12 ` [PATCH 02/21] libsas: Only abort commands from inside the error handler Bart Van Assche
2021-07-03 2:32 ` Jason Yan
2021-07-04 23:52 ` Bart Van Assche
2021-07-05 7:16 ` Hannes Reinecke
2021-07-01 21:12 ` [PATCH 03/21] Clear host_eh_scheduled from inside the SCSI " Bart Van Assche
2021-07-01 21:12 ` [PATCH 04/21] libsas: Stop clearing host_eh_scheduled from the " Bart Van Assche
2021-07-01 21:12 ` [PATCH 05/21] ata: Stop clearing host_eh_scheduled from error handlers Bart Van Assche
2021-07-01 21:12 ` [PATCH 06/21] ufs: Reduce power management code duplication Bart Van Assche
2021-07-05 6:18 ` Avri Altman
2021-07-01 21:12 ` [PATCH 07/21] ufs: Only include power management code if necessary Bart Van Assche
2021-07-05 6:33 ` Avri Altman
2021-07-07 20:44 ` Bart Van Assche
2021-07-08 5:50 ` Avri Altman
2021-07-01 21:12 ` [PATCH 08/21] ufs: Rename the second ufshcd_probe_hba() argument Bart Van Assche
2021-07-01 21:12 ` [PATCH 09/21] ufs: Use DECLARE_COMPLETION_ONSTACK() where appropriate Bart Van Assche
2021-07-05 6:38 ` Avri Altman
2021-07-01 21:12 ` [PATCH 10/21] ufs: Remove ufshcd_valid_tag() Bart Van Assche
2021-07-05 6:46 ` Avri Altman
2021-07-05 18:08 ` Bart Van Assche
2021-07-05 19:01 ` Avri Altman
2021-07-05 19:02 ` Avri Altman
2021-07-01 21:12 ` [PATCH 11/21] ufs: Verify UIC locking requirements at runtime Bart Van Assche
2021-07-05 6:52 ` Avri Altman
2021-07-01 21:12 ` [PATCH 12/21] ufs: Improve static type checking for the host controller state Bart Van Assche
2021-07-01 21:12 ` [PATCH 13/21] ufs: Remove several wmb() calls Bart Van Assche
2021-07-01 22:26 ` Asutosh Das (asd) [this message]
2021-07-01 22:52 ` Bart Van Assche
2021-07-01 21:12 ` [PATCH 14/21] ufs: Inline ufshcd_outstanding_req_clear() Bart Van Assche
2021-07-05 7:03 ` Avri Altman
2021-07-01 21:12 ` [PATCH 15/21] ufs: Rename __ufshcd_transfer_req_compl() Bart Van Assche
2021-07-01 21:12 ` [PATCH 16/21] ufs: Fix the SCSI abort handler Bart Van Assche
2021-07-01 21:12 ` [PATCH 17/21] ufs: Fix a race in the completion path Bart Van Assche
2021-07-01 21:12 ` [PATCH 18/21] ufs: Use the doorbell register instead of the UTRLCNR register Bart Van Assche
2021-07-01 21:12 ` [PATCH 19/21] ufs: Request sense data asynchronously Bart Van Assche
2021-07-01 21:12 ` [PATCH 20/21] ufs: Synchronize SCSI and UFS error handling Bart Van Assche
2021-07-01 21:12 ` [PATCH 21/21] ufs: Retry aborted SCSI commands instead of completing these successfully Bart Van Assche
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=a5770fbe-9bdc-444e-2093-aa3fd58d5638@codeaurora.org \
--to=asutoshd@codeaurora.org \
--cc=adrian.hunter@intel.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=cang@codeaurora.org \
--cc=jaegeuk@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=matthias.bgg@gmail.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;
as well as URLs for NNTP newsgroup(s).