Commit a4a1d7c4 authored by Bart Van Assche's avatar Bart Van Assche Committed by Wentao Guan
Browse files

scsi: ufs: core: Start the RTC update work later

stable inclusion
from stable-v6.6.81
commit 6e34b9d7caa5a4c831b74bdfed5ef86fa0c03316
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBYZED

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6e34b9d7caa5a4c831b74bdfed5ef86fa0c03316



--------------------------------

commit 54c814c8b23bc7617be3d46abdb896937695dbfa upstream.

The RTC update work involves runtime resuming the UFS controller. Hence,
only start the RTC update work after runtime power management in the UFS
driver has been fully initialized. This patch fixes the following kernel
crash:

Internal error: Oops: 0000000096000006 [#1] PREEMPT SMP
Workqueue: events ufshcd_rtc_work
Call trace:
 _raw_spin_lock_irqsave+0x34/0x8c (P)
 pm_runtime_get_if_active+0x24/0x9c (L)
 pm_runtime_get_if_active+0x24/0x9c
 ufshcd_rtc_work+0x138/0x1b4
 process_one_work+0x148/0x288
 worker_thread+0x2cc/0x3d4
 kthread+0x110/0x114
 ret_from_fork+0x10/0x20

Reported-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Closes: https://lore.kernel.org/linux-scsi/0c0bc528-fdc2-4106-bc99-f23ae377f6f5@linaro.org/


Fixes: 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
Cc: Bean Huo <beanhuo@micron.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20241031212632.2799127-1-bvanassche@acm.org


Reviewed-by: default avatarPeter Wang <peter.wang@mediatek.com>
Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6e34b9d7caa5a4c831b74bdfed5ef86fa0c03316)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent da239d1e
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -8678,6 +8678,14 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
		ufshcd_init_clk_scaling_sysfs(hba);
	}

	/*
	 * The RTC update code accesses the hba->ufs_device_wlun->sdev_gendev
	 * pointer and hence must only be started after the WLUN pointer has
	 * been initialized by ufshcd_scsi_add_wlus().
	 */
	schedule_delayed_work(&hba->ufs_rtc_update_work,
			      msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS));

	ufs_bsg_probe(hba);
	scsi_scan_host(hba->host);

@@ -8837,8 +8845,6 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
	ufshcd_force_reset_auto_bkops(hba);

	ufshcd_set_timestamp_attr(hba);
	schedule_delayed_work(&hba->ufs_rtc_update_work,
			      msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS));

	/* Gear up to HS gear if supported */
	if (hba->max_pwr_info.is_valid) {