* [PATCH RFC v4 06/11] scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV
[not found] <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com>
@ 2024-01-22 17:24 ` Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 07/11] scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H Andrew Halaney
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: Andrew Halaney @ 2024-01-22 17:24 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
Janek Kotas, Alim Akhtar, Avri Altman, Bart Van Assche, Can Guo
Cc: Andrew Halaney, Will Deacon, linux-arm-msm, linux-scsi,
linux-kernel, Manivannan Sadhasivam
Currently, HCLKDIV is written to and then completed with an mb().
mb() ensure that the write completes, but completion doesn't mean that
it isn't stored in a buffer somewhere. The recommendation for
ensuring this bit has taken effect on the device is to perform a read
back to force it to make it all the way to the device. This is
documented in device-io.rst and a talk by Will Deacon on this can
be seen over here:
https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678
Let's do that to ensure the bit hits the device. Because the mb()'s
purpose wasn't to add extra ordering (on top of the ordering guaranteed
by writel()/readl()), it can safely be removed.
Fixes: d90996dae8e4 ("scsi: ufs: Add UFS platform driver for Cadence UFS")
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
---
drivers/ufs/host/cdns-pltfrm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ufs/host/cdns-pltfrm.c b/drivers/ufs/host/cdns-pltfrm.c
index bb30267da471..66811d8d1929 100644
--- a/drivers/ufs/host/cdns-pltfrm.c
+++ b/drivers/ufs/host/cdns-pltfrm.c
@@ -136,7 +136,7 @@ static int cdns_ufs_set_hclkdiv(struct ufs_hba *hba)
* Make sure the register was updated,
* UniPro layer will not work with an incorrect value.
*/
- mb();
+ ufshcd_readl(hba, CDNS_UFS_REG_HCLKDIV);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RFC v4 07/11] scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H
[not found] <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com>
2024-01-22 17:24 ` [PATCH RFC v4 06/11] scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV Andrew Halaney
@ 2024-01-22 17:24 ` Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 08/11] scsi: ufs: core: Perform read back after disabling interrupts Andrew Halaney
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: Andrew Halaney @ 2024-01-22 17:24 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
Janek Kotas, Alim Akhtar, Avri Altman, Bart Van Assche, Can Guo
Cc: Andrew Halaney, Will Deacon, linux-arm-msm, linux-scsi,
linux-kernel, Manivannan Sadhasivam
Currently, the UTP_TASK_REQ_LIST_BASE_L/UTP_TASK_REQ_LIST_BASE_H regs
are written to and then completed with an mb().
mb() ensure that the write completes, but completion doesn't mean that
it isn't stored in a buffer somewhere. The recommendation for
ensuring these bits have taken effect on the device is to perform a read
back to force it to make it all the way to the device. This is
documented in device-io.rst and a talk by Will Deacon on this can
be seen over here:
https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678
Let's do that to ensure the bits hit the device. Because the mb()'s
purpose wasn't to add extra ordering (on top of the ordering guaranteed
by writel()/readl()), it can safely be removed.
Fixes: 88441a8d355d ("scsi: ufs: core: Add hibernation callbacks")
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
---
drivers/ufs/core/ufshcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 029d017fc1b6..e2e6002fe46a 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10347,7 +10347,7 @@ int ufshcd_system_restore(struct device *dev)
* are updated with the latest queue addresses. Only after
* updating these addresses, we can queue the new commands.
*/
- mb();
+ ufshcd_readl(hba, REG_UTP_TASK_REQ_LIST_BASE_H);
/* Resuming from hibernate, assume that link was OFF */
ufshcd_set_link_off(hba);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RFC v4 08/11] scsi: ufs: core: Perform read back after disabling interrupts
[not found] <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com>
2024-01-22 17:24 ` [PATCH RFC v4 06/11] scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 07/11] scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H Andrew Halaney
@ 2024-01-22 17:24 ` Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 09/11] scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL Andrew Halaney
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: Andrew Halaney @ 2024-01-22 17:24 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
Janek Kotas, Alim Akhtar, Avri Altman, Bart Van Assche, Can Guo
Cc: Andrew Halaney, Will Deacon, linux-arm-msm, linux-scsi,
linux-kernel, Manivannan Sadhasivam
Currently, interrupts are cleared and disabled prior to registering the
interrupt. An mb() is used to complete the clear/disable writes before
the interrupt is registered.
mb() ensure that the write completes, but completion doesn't mean that
it isn't stored in a buffer somewhere. The recommendation for
ensuring these bits have taken effect on the device is to perform a read
back to force it to make it all the way to the device. This is
documented in device-io.rst and a talk by Will Deacon on this can
be seen over here:
https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678
Let's do that to ensure these bits hit the device. Because the mb()'s
purpose wasn't to add extra ordering (on top of the ordering guaranteed
by writel()/readl()), it can safely be removed.
Fixes: 199ef13cac7d ("scsi: ufs: avoid spurious UFS host controller interrupts")
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
---
drivers/ufs/core/ufshcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index e2e6002fe46a..9b6355555897 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10564,7 +10564,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
* Make sure that UFS interrupts are disabled and any pending interrupt
* status is cleared before registering UFS interrupt handler.
*/
- mb();
+ ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
/* IRQ registration */
err = devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RFC v4 09/11] scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL
[not found] <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com>
` (2 preceding siblings ...)
2024-01-22 17:24 ` [PATCH RFC v4 08/11] scsi: ufs: core: Perform read back after disabling interrupts Andrew Halaney
@ 2024-01-22 17:24 ` Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 10/11] scsi: ufs: core: Remove unnecessary wmb() after ringing doorbell Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 11/11] scsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs Andrew Halaney
5 siblings, 0 replies; 6+ messages in thread
From: Andrew Halaney @ 2024-01-22 17:24 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
Janek Kotas, Alim Akhtar, Avri Altman, Bart Van Assche, Can Guo
Cc: Andrew Halaney, Will Deacon, linux-arm-msm, linux-scsi,
linux-kernel, Manivannan Sadhasivam
Currently, the UIC_COMMAND_COMPL interrupt is disabled and a wmb() is
used to complete the register write before any following writes.
wmb() ensures the writes complete in that order, but completion doesn't
mean that it isn't stored in a buffer somewhere. The recommendation for
ensuring this bit has taken effect on the device is to perform a read
back to force it to make it all the way to the device. This is
documented in device-io.rst and a talk by Will Deacon on this can
be seen over here:
https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678
Let's do that to ensure the bit hits the device. Because the wmb()'s
purpose wasn't to add extra ordering (on top of the ordering guaranteed
by writel()/readl()), it can safely be removed.
Fixes: d75f7fe495cf ("scsi: ufs: reduce the interrupts for power mode change requests")
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
---
drivers/ufs/core/ufshcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9b6355555897..9bf490bb8eed 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4240,7 +4240,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
* Make sure UIC command completion interrupt is disabled before
* issuing UIC command.
*/
- wmb();
+ ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
reenable_intr = true;
}
spin_unlock_irqrestore(hba->host->host_lock, flags);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RFC v4 10/11] scsi: ufs: core: Remove unnecessary wmb() after ringing doorbell
[not found] <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com>
` (3 preceding siblings ...)
2024-01-22 17:24 ` [PATCH RFC v4 09/11] scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL Andrew Halaney
@ 2024-01-22 17:24 ` Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 11/11] scsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs Andrew Halaney
5 siblings, 0 replies; 6+ messages in thread
From: Andrew Halaney @ 2024-01-22 17:24 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
Janek Kotas, Alim Akhtar, Avri Altman, Bart Van Assche, Can Guo
Cc: Andrew Halaney, Will Deacon, linux-arm-msm, linux-scsi,
linux-kernel
Currently, the doorbell is written to and a wmb() is used to commit it
immediately.
wmb() ensures that the write completes before following writes occur,
but completion doesn't mean that it isn't stored in a buffer somewhere.
The recommendation for ensuring this bit has taken effect on the device
is to perform a read back to force it to make it all the way to the
device. This is documented in device-io.rst and a talk by Will Deacon on
this can be seen over here:
https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678
But, completion and taking effect aren't necessary to guarantee here.
There's already other examples of the doorbell being rung that don't do
this. The writel() of the doorbell guarantees prior writes by this
thread (to the request being setup for example) complete prior to the
ringing of the doorbell, and the following
wait_for_completion_io_timeout() doesn't require any special memory
barriers either.
With that in mind, just remove the wmb() altogether here.
Fixes: ad1a1b9cd67a ("scsi: ufs: commit descriptors before setting the doorbell")
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
---
drivers/ufs/core/ufshcd.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9bf490bb8eed..21f93d8e5818 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -7047,10 +7047,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba,
/* send command to the controller */
__set_bit(task_tag, &hba->outstanding_tasks);
-
ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL);
- /* Make sure that doorbell is committed immediately */
- wmb();
spin_unlock_irqrestore(host->host_lock, flags);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RFC v4 11/11] scsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs
[not found] <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com>
` (4 preceding siblings ...)
2024-01-22 17:24 ` [PATCH RFC v4 10/11] scsi: ufs: core: Remove unnecessary wmb() after ringing doorbell Andrew Halaney
@ 2024-01-22 17:24 ` Andrew Halaney
5 siblings, 0 replies; 6+ messages in thread
From: Andrew Halaney @ 2024-01-22 17:24 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
Janek Kotas, Alim Akhtar, Avri Altman, Bart Van Assche, Can Guo
Cc: Andrew Halaney, Will Deacon, linux-arm-msm, linux-scsi,
linux-kernel
Currently a wmb() is used to ensure that writes to the
UTP_TASK_REQ_LIST_BASE* regs are completed prior to following writes to
the run/stop registers.
wmb() ensure that the write completes, but completion doesn't mean that
it isn't stored in a buffer somewhere. The recommendation for
ensuring the bits have taken effect on the device is to perform a read
back to force it to make it all the way to the device. This is
documented in device-io.rst and a talk by Will Deacon on this can
be seen over here:
https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678
But, none of that is necessary here. All of the writel()/readl()'s here
are to the same endpoint, so they will be ordered. There's no subsequent
delay() etc that requires it to have taken effect already, so no
readback is necessary here.
For that reason just drop the wmb() altogether.
Fixes: 897efe628d7e ("scsi: ufs: add missing memory barriers")
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
---
drivers/ufs/core/ufshcd.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 21f93d8e5818..358857ea9ff6 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -4722,12 +4722,6 @@ int ufshcd_make_hba_operational(struct ufs_hba *hba)
ufshcd_writel(hba, upper_32_bits(hba->utmrdl_dma_addr),
REG_UTP_TASK_REQ_LIST_BASE_H);
- /*
- * Make sure base address and interrupt setup are updated before
- * enabling the run/stop registers below.
- */
- wmb();
-
/*
* UCRDY, UTMRLDY and UTRLRDY bits must be 1
*/
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-01-22 17:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com>
2024-01-22 17:24 ` [PATCH RFC v4 06/11] scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 07/11] scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 08/11] scsi: ufs: core: Perform read back after disabling interrupts Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 09/11] scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 10/11] scsi: ufs: core: Remove unnecessary wmb() after ringing doorbell Andrew Halaney
2024-01-22 17:24 ` [PATCH RFC v4 11/11] scsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs Andrew Halaney
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).