OSDN Git Service

scsi: ufs: Remove several wmb() calls
authorBart Van Assche <bvanassche@acm.org>
Thu, 22 Jul 2021 03:34:30 +0000 (20:34 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 3 Aug 2021 01:43:58 +0000 (21:43 -0400)
commit3d2ac73d13476fd996e3423863371805780a0663
tree643587fd93f56503179022f1bc454415274783ef
parent9c202090edd4c7679adf5bf040d7ee19966feae6
scsi: ufs: Remove several wmb() calls

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.

Link: https://lore.kernel.org/r/20210722033439.26550-10-bvanassche@acm.org
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>
Tested-by: Avri altman <avri.altman@wdc.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufshcd.c