From 86eb94bf8006a85738f0ccf49e3ce894e03922a6 Mon Sep 17 00:00:00 2001 From: Adrien Thierry Date: Wed, 29 Mar 2023 16:54:25 -0400 Subject: scsi: Revert "scsi: ufs: core: Initialize devfreq synchronously" This reverts commit 7dafc3e007918384c8693ff8d70381b5c1e9c247. This patch introduced a regression [1] where hba->pwr_info is used before being initialized, which could create issues in ufshcd_scale_gear(). Revert it until a better solution is found. [1] https://lore.kernel.org/all/CAGaU9a_PMZhqv+YJ0r3w-hJMsR922oxW6Kg59vw+oen-NZ6Otw@mail.gmail.com Signed-off-by: Adrien Thierry Link: https://lore.kernel.org/r/20230329205426.46393-1-athierry@redhat.com Reviewed-by: Stanley Chu Signed-off-by: Martin K. Petersen --- include/ufs/ufshcd.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/ufs') diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 25aab8ec4f86..431c3afb2ce0 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -979,7 +979,6 @@ struct ufs_hba { struct completion *uic_async_done; enum ufshcd_state ufshcd_state; - bool logical_unit_scan_finished; u32 eh_flags; u32 intr_mask; u16 ee_ctrl_mask; -- cgit v1.2.3 From 543a827b1db3ef0a123dc7a48e8feb6585eae0a6 Mon Sep 17 00:00:00 2001 From: Stanley Chu Date: Thu, 30 Mar 2023 09:29:18 +0800 Subject: scsi: core: Clean up struct ufs_saved_pwr_info The "is_valid" field of the struct ufs_saved_pwr_info is no longer used, and this struct can be replaced by struct ufs_pa_layer_attr without any changes to the functionality. Signed-off-by: Stanley Chu Link: https://lore.kernel.org/r/20230330012918.13748-1-stanley.chu@mediatek.com Reviewed-by: Avri Altman Signed-off-by: Martin K. Petersen --- drivers/ufs/core/ufshcd.c | 7 +++---- include/ufs/ufshcd.h | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'include/ufs') diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index acae4e194ec4..03c47f9a2750 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -1269,7 +1269,7 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up) struct ufs_pa_layer_attr new_pwr_info; if (scale_up) { - memcpy(&new_pwr_info, &hba->clk_scaling.saved_pwr_info.info, + memcpy(&new_pwr_info, &hba->clk_scaling.saved_pwr_info, sizeof(struct ufs_pa_layer_attr)); } else { memcpy(&new_pwr_info, &hba->pwr_info, @@ -1278,7 +1278,7 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up) if (hba->pwr_info.gear_tx > hba->clk_scaling.min_gear || hba->pwr_info.gear_rx > hba->clk_scaling.min_gear) { /* save the current power mode */ - memcpy(&hba->clk_scaling.saved_pwr_info.info, + memcpy(&hba->clk_scaling.saved_pwr_info, &hba->pwr_info, sizeof(struct ufs_pa_layer_attr)); @@ -10349,10 +10349,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) /* Initialize devfreq */ if (ufshcd_is_clkscaling_supported(hba)) { - memcpy(&hba->clk_scaling.saved_pwr_info.info, + memcpy(&hba->clk_scaling.saved_pwr_info, &hba->pwr_info, sizeof(struct ufs_pa_layer_attr)); - hba->clk_scaling.saved_pwr_info.is_valid = true; hba->clk_scaling.is_allowed = true; err = ufshcd_devfreq_init(hba); diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 25aab8ec4f86..8b1046c21960 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -394,11 +394,6 @@ struct ufs_clk_gating { struct workqueue_struct *clk_gating_workq; }; -struct ufs_saved_pwr_info { - struct ufs_pa_layer_attr info; - bool is_valid; -}; - /** * struct ufs_clk_scaling - UFS clock scaling related data * @active_reqs: number of requests that are pending. If this is zero when @@ -428,7 +423,7 @@ struct ufs_clk_scaling { ktime_t window_start_t; ktime_t busy_start_t; struct device_attribute enable_attr; - struct ufs_saved_pwr_info saved_pwr_info; + struct ufs_pa_layer_attr saved_pwr_info; struct workqueue_struct *workq; struct work_struct suspend_work; struct work_struct resume_work; -- cgit v1.2.3 From 3c85f087faeca3ca9ec9e7b085e1eff370e3f0db Mon Sep 17 00:00:00 2001 From: Avri Altman Date: Wed, 29 Mar 2023 13:13:03 +0300 Subject: scsi: ufs: mcq: Use pointer arithmetic in ufshcd_send_command() Make sqe_base_addr the UTRD pointer it is, instead of an opaque void *. Signed-off-by: Avri Altman Link: https://lore.kernel.org/r/20230329101303.18377-3-avri.altman@wdc.com Signed-off-by: Martin K. Petersen --- drivers/ufs/core/ufshcd.c | 5 +++-- include/ufs/ufshcd.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'include/ufs') diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 03c47f9a2750..9434328ba323 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2242,10 +2242,11 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, if (is_mcq_enabled(hba)) { int utrd_size = sizeof(struct utp_transfer_req_desc); + struct utp_transfer_req_desc *src = lrbp->utr_descriptor_ptr; + struct utp_transfer_req_desc *dest = hwq->sqe_base_addr + hwq->sq_tail_slot; spin_lock(&hwq->sq_lock); - memcpy(hwq->sqe_base_addr + (hwq->sq_tail_slot * utrd_size), - lrbp->utr_descriptor_ptr, utrd_size); + memcpy(dest, src, utrd_size); ufshcd_inc_sq_tail(hwq); spin_unlock(&hwq->sq_lock); } else { diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 8b1046c21960..721ae4cd3702 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -1095,7 +1095,7 @@ struct ufs_hw_queue { void __iomem *mcq_cq_head; void __iomem *mcq_cq_tail; - void *sqe_base_addr; + struct utp_transfer_req_desc *sqe_base_addr; dma_addr_t sqe_dma_addr; struct cq_entry *cqe_base_addr; dma_addr_t cqe_dma_addr; -- cgit v1.2.3