Skip to content

Commit 4e5483b

Browse files
ahunter6martinkpetersen
authored andcommitted
scsi: ufs: ufs-pci: Force a full restore after suspend-to-disk
Implement the ->restore() PM operation and set the link to off, which will force a full reset and restore. This ensures that Host Performance Booster is reset after suspend-to-disk. The Host Performance Booster feature caches logical-to-physical mapping information in the host memory. After suspend-to-disk, such information is not valid, so a full reset and restore is needed. A full reset and restore is done if the SPM level is 5 or 6, but not for other SPM levels, so this change fixes those cases. A full reset and restore also restores base address registers, so that code is removed. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Avri Altman <[email protected]> Signed-off-by: Adrian Hunter <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4a8f710 commit 4e5483b

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

drivers/scsi/ufs/ufshcd-pci.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,6 @@ static void ufs_intel_common_exit(struct ufs_hba *hba)
370370

371371
static int ufs_intel_resume(struct ufs_hba *hba, enum ufs_pm_op op)
372372
{
373-
/*
374-
* To support S4 (suspend-to-disk) with spm_lvl other than 5, the base
375-
* address registers must be restored because the restore kernel can
376-
* have used different addresses.
377-
*/
378-
ufshcd_writel(hba, lower_32_bits(hba->utrdl_dma_addr),
379-
REG_UTP_TRANSFER_REQ_LIST_BASE_L);
380-
ufshcd_writel(hba, upper_32_bits(hba->utrdl_dma_addr),
381-
REG_UTP_TRANSFER_REQ_LIST_BASE_H);
382-
ufshcd_writel(hba, lower_32_bits(hba->utmrdl_dma_addr),
383-
REG_UTP_TASK_REQ_LIST_BASE_L);
384-
ufshcd_writel(hba, upper_32_bits(hba->utmrdl_dma_addr),
385-
REG_UTP_TASK_REQ_LIST_BASE_H);
386-
387373
if (ufshcd_is_link_hibern8(hba)) {
388374
int ret = ufshcd_uic_hibern8_exit(hba);
389375

@@ -463,6 +449,18 @@ static struct ufs_hba_variant_ops ufs_intel_lkf_hba_vops = {
463449
.device_reset = ufs_intel_device_reset,
464450
};
465451

452+
#ifdef CONFIG_PM_SLEEP
453+
static int ufshcd_pci_restore(struct device *dev)
454+
{
455+
struct ufs_hba *hba = dev_get_drvdata(dev);
456+
457+
/* Force a full reset and restore */
458+
ufshcd_set_link_off(hba);
459+
460+
return ufshcd_system_resume(dev);
461+
}
462+
#endif
463+
466464
/**
467465
* ufshcd_pci_shutdown - main function to put the controller in reset state
468466
* @pdev: pointer to PCI device handle
@@ -546,9 +544,14 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
546544
}
547545

548546
static const struct dev_pm_ops ufshcd_pci_pm_ops = {
549-
SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
550547
SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
551548
#ifdef CONFIG_PM_SLEEP
549+
.suspend = ufshcd_system_suspend,
550+
.resume = ufshcd_system_resume,
551+
.freeze = ufshcd_system_suspend,
552+
.thaw = ufshcd_system_resume,
553+
.poweroff = ufshcd_system_suspend,
554+
.restore = ufshcd_pci_restore,
552555
.prepare = ufshcd_suspend_prepare,
553556
.complete = ufshcd_resume_complete,
554557
#endif

0 commit comments

Comments
 (0)