scsi: ufs: Allow async suspend/resume callbacks
PATCH 1/1 scsi: ufs: Allow async suspend/resume callbacks
Allow UFS suspend/resume callbacks to run in parallel with other suspend/resume callbacks. This can recoup dozens of milliseconds on the resume path if UFS hardware needs to be powered back on.
Suspending and resuming asynchronously is safe to do so long as the driver callbacks only depend on resources made available by either a) parent devices or b) devices explicitly marked as suppliers with device_link_add.
---
Are there any suspend/resume dependencies for UFS drivers not tracked by the device parent relationship?
drivers/scsi/ufs/ufshcd.c | 1 +
1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufshcd.c +1 -0
@@ -9625,6 +9625,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)async_schedule (ufshcd_async_scan, hba);ufs_sysfs_add_nodes (hba->dev); +device_enable_async_suspend (dev);return 0 ; free_tmf_queue:
Signature · 1 line
2.32.0.432.gabb21c7263-goog
Quoted 2 lines · Vincent Palomares
Are there any suspend/resume dependencies for UFS drivers not tracked by the device parent relationship?
Not that I know of. Since I like this patch:
Quoted 32 lines
Allow UFS suspend/resume callbacks to run in parallel with other suspend/resume callbacks. This can recoup dozens of milliseconds on the resume path if UFS hardware needs to be powered back on.
Suspending and resuming asynchronously is safe to do so long as the driver callbacks only depend on resources made available by either a) parent devices or b) devices explicitly marked as suppliers with
device_link_add.Cc Bjorn Helgaas <[email protected]>Cc Jaegeuk Kim <[email protected]>Cc Bart Van Assche <[email protected]>Cc Adrian Hunter <[email protected]>Cc Stanley Chu <[email protected]>Cc Can Guo <[email protected]>Cc Asutosh Das <[email protected]>Cc Avri Altman <[email protected]>Cc Martin K. Petersen <[email protected]>Signed-off-by Vincent Palomares <[email protected]>---
Are there any suspend/resume dependencies for UFS drivers not tracked by the device parent relationship?
drivers/scsi/ufs/ufshcd.c| 1 +1 file changed, 1 insertion(+)drivers/scsi/ufs/ufshcd.c +0
-0
drivers/scsi/ufs/ufshcd.c int ufshcd_init(struct ufs_hba *hba, void __iomem · line 9630
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +1
-0@@ -9625,6 +9625,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)async_schedule (ufshcd_async_scan ,hba );ufs_sysfs_add_nodes (hba->dev); +device_enable_async_suspend (dev);return 0 ;
Isn't device_enable_async_suspend is being called for each lun in scsi_sysfs_add_sdev Anyway?
Thanks,
Avri
Quoted 4 lines
drivers/scsi/ufs/ufshcd.c +0
-1free_tmf_queue: --2.32.0.432.gabb21c7263-goog
Quoted 10 lines · Avri Altman
Quoted 9 lines · Vincent
drivers/scsi/ufs/ufshcd.c +0
-0@@ -9625,6 +9625,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)async_schedule (ufshcd_async_scan ,hba );ufs_sysfs_add_nodes (hba->dev);
Quoted 3 lines
drivers/scsi/ufs/ufshcd.c int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · line 9629
Quoted 2 lines
drivers/scsi/ufs/ufshcd.c +1
-0+device_enable_async_suspend (dev);return 0 ;Isn't
device_enable_async_suspendis being called for each lun inscsi_sysfs_add_sdevAnyway?
Hi Avri,
Our measurements have shown that resume takes longer than it should with encryption enabled. While suspending we change the power mode of the UFS device to a mode in which it loses crypto keys. Restoring crypto keys during resume (blk_ksm_reprogram_all_keys()) takes about 31 ms. This is the long pole and takes much more time than resuming LUNs. This patch makes UFS resume happen concurrently with resuming other devices in the system instead of serializing it. Measurements have shown that this patch significantly improves the time needed to resume an Android device.
Bart.
Quoted 18 lines · Avri Altman
Quoted 10 lines
Quoted 9 lines · Vincent
drivers/scsi/ufs/ufshcd.c +0
-0@@ -9625,6 +9625,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)async_schedule (ufshcd_async_scan ,hba );ufs_sysfs_add_nodes (hba->dev);Quoted 3 lines
drivers/scsi/ufs/ufshcd.c int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · line 9629
Quoted 2 lines
drivers/scsi/ufs/ufshcd.c +1
-0+device_enable_async_suspend (dev);return 0 ;Isn't
device_enable_async_suspendis being called for each lun in
scsi_sysfs_add_sdevAnyway?Hi Avri,
Quoted 8 lines
Our measurements have shown that resume takes longer than it should with encryption enabled. While suspending we change the power mode of the UFS device to a mode in which it loses crypto keys. Restoring crypto keys during resume (
blk_ksm_reprogram_all_keys()) takes about 31 ms. This is the long pole and takes much more time than resuming LUNs. This patch makes UFS resume happen concurrently with resuming other devices in the system instead of serializing it. Measurements have shown that this patch significantly improves the time needed to resume an Android device.
OK.
Thanks for the extra info.
Thanks,
Avri
Quoted 2 lines
Bart.
Martin K. Petersen
AppliedVincent,
Quoted 3 lines
Allow UFS suspend/resume callbacks to run in parallel with other suspend/resume callbacks. This can recoup dozens of milliseconds on the resume path if UFS hardware needs to be powered back on.
Applied to 5.15/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering