kernel-ark/drivers/scsi/ufs
Subhash Jadavani 30fc33f1ef scsi: ufs: fix race between clock gating and devfreq scaling work
UFS devfreq clock scaling work may require clocks to be ON if it need to
execute some UFS commands hence it may request for clock hold before
issuing the command. But if UFS clock gating work is already running in
parallel, ungate work would end up waiting for the clock gating work to
finish and as clock gating work would also wait for the clock scaling
work to finish, we would enter in deadlock state. Here is the call trace
during this deadlock state:

Workqueue: devfreq_wq devfreq_monitor
	__switch_to
	__schedule
	schedule
	schedule_timeout
	wait_for_common
	wait_for_completion
	flush_work
	ufshcd_hold
	ufshcd_send_uic_cmd
	ufshcd_dme_get_attr
	ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div
	ufs_qcom_clk_scale_notify
	ufshcd_scale_clks
	ufshcd_devfreq_target
	update_devfreq
	devfreq_monitor
	process_one_work
	worker_thread
	kthread
	ret_from_fork

Workqueue: events ufshcd_gate_work
	__switch_to
	__schedule
	schedule
	schedule_preempt_disabled
	__mutex_lock_slowpath
	mutex_lock
	devfreq_monitor_suspend
	devfreq_simple_ondemand_handler
	devfreq_suspend_device
	ufshcd_gate_work
	process_one_work
	worker_thread
	kthread
	ret_from_fork

Workqueue: events ufshcd_ungate_work
	__switch_to
	__schedule
	schedule
	schedule_timeout
	wait_for_common
	wait_for_completion
	flush_work
	__cancel_work_timer
	cancel_delayed_work_sync
	ufshcd_ungate_work
	process_one_work
	worker_thread
	kthread
	ret_from_fork

This change fixes this deadlock by doing this in devfreq work (devfreq_wq):
Try cancelling clock gating work. If we are able to cancel gating work
or it wasn't scheduled, hold the clock reference count until scaling is
in progress. If gate work is already running in parallel, let's skip
the frequecy scaling at this time and it will be retried once next scaling
window expires.

Reviewed-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-11-08 17:30:00 -05:00
..
Kconfig scsi: ufs: Kconfig fix 2016-09-29 21:57:08 -04:00
Makefile ufs: add TC G210 pci driver 2016-07-12 23:16:31 -04:00
tc-dwc-g210-pci.c ufs: add TC G210 pci driver 2016-07-12 23:16:31 -04:00
tc-dwc-g210-pltfrm.c ufs: add TC G210 platform driver 2016-07-12 23:16:31 -04:00
tc-dwc-g210.c scsi: ufs: Add missing header dependencies for tc-dwc-g210 2016-09-04 01:28:08 -04:00
tc-dwc-g210.h ufs: add support for Synopsys G210 Test Chip 2016-07-12 23:16:31 -04:00
ufs_quirks.h scsi: ufs: Enable no vccq quirk for skhynix device 2016-09-28 01:08:05 -04:00
ufs-qcom.c scsi: ufshcd: Fix possible unclocked register access 2016-11-08 17:29:47 -05:00
ufs-qcom.h scsi: ufs-qcom: add printouts of testbus debug registers 2016-03-14 21:04:45 -04:00
ufs.h scsi: ufs: fix bugs related to null pointer access and array size 2016-11-08 17:29:58 -05:00
ufshcd-dwc.c ufs: Adding license info do tc-dwc-g210 and ufshcd-dwc to enable loadable module 2016-07-12 23:16:31 -04:00
ufshcd-dwc.h ufs: add support for DesignWare Controller 2016-07-12 23:16:31 -04:00
ufshcd-pci.c SCSI / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM 2014-12-15 15:11:06 +01:00
ufshcd-pltfrm.c ufs: fixed typo in ufshcd-pltfrm 2016-07-12 23:16:31 -04:00
ufshcd-pltfrm.h scsi: ufs: make the UFS variant a platform device 2015-11-09 18:00:02 -05:00
ufshcd.c scsi: ufs: fix race between clock gating and devfreq scaling work 2016-11-08 17:30:00 -05:00
ufshcd.h scsi: ufshcd: Fix possible unclocked register access 2016-11-08 17:29:47 -05:00
ufshci-dwc.h ufs: add support for DesignWare Controller 2016-07-12 23:16:31 -04:00
ufshci.h ufs: add link status to ufshci 2016-07-12 23:16:31 -04:00
unipro.h ufs: add unipro attributes 2016-07-12 23:16:31 -04:00