summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAvri Altman <avri.altman@wdc.com>2024-11-24 09:08:07 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-21 14:01:39 +0100
commitf453c4515208aba5265171e760642608ffebec36 (patch)
tree266e0359e0dc2761007002ef5d148489b9412f0c /include
parent9ece41a0d7d39590069093f056463e7771035a66 (diff)
downloadlinux-f453c4515208aba5265171e760642608ffebec36.tar.gz
linux-f453c4515208aba5265171e760642608ffebec36.tar.bz2
linux-f453c4515208aba5265171e760642608ffebec36.zip
scsi: ufs: core: Introduce a new clock_gating lock
[ Upstream commit 209f4e43b8068c24cde227f464111030430153fa ] Introduce a new clock gating lock to serialize access to some of the clock gating members instead of the host_lock. While at it, simplify the code with the guard() macro and co for automatic cleanup of the new lock. There are some explicit spin_lock_irqsave()/spin_unlock_irqrestore() snaking instances I left behind because I couldn't make heads or tails of it. Additionally, move the trace_ufshcd_clk_gating() call from inside the region protected by the lock as it doesn't needs protection. Signed-off-by: Avri Altman <avri.altman@wdc.com> Link: https://lore.kernel.org/r/20241124070808.194860-4-avri.altman@wdc.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Stable-dep-of: 839a74b5649c ("scsi: ufs: Fix toggling of clk_gating.state when clock gating is not allowed") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/ufs/ufshcd.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index d5e43a1dcff2..47cba116f87b 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -402,6 +402,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
@@ -412,11 +415,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;
@@ -425,7 +431,6 @@ struct ufs_clk_gating {
bool is_enabled;
bool is_initialized;
int active_reqs;
- struct workqueue_struct *clk_gating_workq;
};
/**