diff options
| author | Martin K. Petersen <martin.petersen@oracle.com> | 2024-12-04 13:13:00 -0500 |
|---|---|---|
| committer | Martin K. Petersen <martin.petersen@oracle.com> | 2024-12-04 13:13:00 -0500 |
| commit | 91e11129b9894ef709f3faf13a41ea60d46e7a44 (patch) | |
| tree | cb0ea915789f360db6f0db2afefa2012fde7c080 /include | |
| parent | cdb03e598750e7ebc222571aa96653e9b5a59dbe (diff) | |
| parent | be769e5cf53b8a45eedcc7354bacf939ae16f72c (diff) | |
Merge patch series "Untie the host lock entanglement - part 2"
Avri Altman <avri.altman@wdc.com> says:
Here is the 2nd part in the sequel, watering down the scsi host lock
usage in the ufs driver. This work is motivated by a comment made by
Bart [1], of the abuse of the scsi host lock in the ufs driver. Its
Precursor [2] removed the host lock around some of the host register
accesses.
This part replaces the scsi host lock by dedicated locks serializing
access to the clock gating and clock scaling members.
Changes compared to v4:
- split patch 1 into 2 parts (Bart)
- use scoped_guard() for the host_lock as well (Bart)
- remove irrelevant comment and use lockdep_assert_held instead (Bart)
- improve @lock documentation (Bart)
Changes compared to v3:
- Keep the host lock when checking ufshcd_state (Bean)
Changes compared to v2:
- Use clang-format to fix formating (Bart)
- Use guard() in ufshcd_clkgate_enable_store (Bart)
- Elaborate commit log (Bart)
Changes compared to v1:
- use the guard() & scoped_guard() macros (Bart)
- re-order struct ufs_clk_scaling and struct ufs_clk_gating (Bart)
[1] https://lore.kernel.org/linux-scsi/0b031b8f-c07c-42ef-af93-7336439d3c37@acm.org/
[2] https://lore.kernel.org/linux-scsi/20241024075033.562562-1-avri.altman@wdc.com/
Link: https://lore.kernel.org/r/20241124070808.194860-1-avri.altman@wdc.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/ufs/ufshcd.h | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index d7aca9e61684..ce7667b020e2 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -403,6 +403,9 @@ enum clk_gating_state { * delay_ms * @ungate_work: worker to turn on clocks that will be used in case of * interrupt context + * @clk_gating_workq: workqueue for clock gating work. + * @lock: serialize access to some struct ufs_clk_gating members. An outer lock + * relative to the host lock * @state: the current clocks state * @delay_ms: gating delay in ms * @is_suspended: clk gating is suspended when set to 1 which can be used @@ -413,11 +416,14 @@ enum clk_gating_state { * @is_initialized: Indicates whether clock gating is initialized or not * @active_reqs: number of requests that are pending and should be waited for * completion before gating clocks. - * @clk_gating_workq: workqueue for clock gating work. */ struct ufs_clk_gating { struct delayed_work gate_work; struct work_struct ungate_work; + struct workqueue_struct *clk_gating_workq; + + spinlock_t lock; + enum clk_gating_state state; unsigned long delay_ms; bool is_suspended; @@ -426,11 +432,14 @@ struct ufs_clk_gating { bool is_enabled; bool is_initialized; int active_reqs; - struct workqueue_struct *clk_gating_workq; }; /** * struct ufs_clk_scaling - UFS clock scaling related data + * @workq: workqueue to schedule devfreq suspend/resume work + * @suspend_work: worker to suspend devfreq + * @resume_work: worker to resume devfreq + * @lock: serialize access to some struct ufs_clk_scaling members * @active_reqs: number of requests that are pending. If this is zero when * devfreq ->target() function is called then schedule "suspend_work" to * suspend devfreq. @@ -440,9 +449,6 @@ struct ufs_clk_gating { * @enable_attr: sysfs attribute to enable/disable clock scaling * @saved_pwr_info: UFS power mode may also be changed during scaling and this * one keeps track of previous power mode. - * @workq: workqueue to schedule devfreq suspend/resume work - * @suspend_work: worker to suspend devfreq - * @resume_work: worker to resume devfreq * @target_freq: frequency requested by devfreq framework * @min_gear: lowest HS gear to scale down to * @is_enabled: tracks if scaling is currently enabled or not, controlled by @@ -454,15 +460,18 @@ struct ufs_clk_gating { * @is_suspended: tracks if devfreq is suspended or not */ struct ufs_clk_scaling { + struct workqueue_struct *workq; + struct work_struct suspend_work; + struct work_struct resume_work; + + spinlock_t lock; + int active_reqs; unsigned long tot_busy_t; ktime_t window_start_t; ktime_t busy_start_t; struct device_attribute enable_attr; struct ufs_pa_layer_attr saved_pwr_info; - struct workqueue_struct *workq; - struct work_struct suspend_work; - struct work_struct resume_work; unsigned long target_freq; u32 min_gear; bool is_enabled; |
