mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: core: Fix PM QoS mutex initialization
       [not found] <CGME20250929112740eucas1p284c5c49f54fec23c55260edf07aa1138@eucas1p2.samsung.com>
@ 2025-09-29 11:27 ` Marek Szyprowski
  2025-09-29 16:41   ` Bart Van Assche
  2025-09-29 21:00   ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Marek Szyprowski @ 2025-09-29 11:27 UTC (permalink / raw)
  To: linux-scsi, linux-kernel
  Cc: Marek Szyprowski, Alim Akhtar, Avri Altman, Bart Van Assche,
	James E.J. Bottomley, Martin K. Petersen, Zhongqiu Han

hba->pm_qos_mutex is used very early as a part of ufshcd_init(), so it
need to be initialized before that call. This fixes the following
warning:
------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(lock->magic != lock)
WARNING: kernel/locking/mutex.c:577 at __mutex_lock+0x268/0x894, CPU#4: kworker/u32:4/72
Modules linked in:
CPU: 4 UID: 0 PID: 72 Comm: kworker/u32:4 Not tainted 6.17.0-rc7-next-20250926+ #11223 PREEMPT
Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
Workqueue: events_unbound deferred_probe_work_func
pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : __mutex_lock+0x268/0x894
lr : __mutex_lock+0x268/0x894
...
Call trace:
 __mutex_lock+0x268/0x894 (P)
 mutex_lock_nested+0x24/0x30
 ufshcd_pm_qos_update+0x30/0x78
 ufshcd_setup_clocks+0x2d4/0x3c4
 ufshcd_init+0x234/0x126c
 ufshcd_pltfrm_init+0x62c/0x82c
 ufs_qcom_probe+0x20/0x58
 platform_probe+0x5c/0xac
 really_probe+0xbc/0x298
 __driver_probe_device+0x78/0x12c
 driver_probe_device+0x40/0x164
 __device_attach_driver+0xb8/0x138
 bus_for_each_drv+0x80/0xdc
 __device_attach+0xa8/0x1b0
 device_initial_probe+0x14/0x20
 bus_probe_device+0xb0/0xb4
 deferred_probe_work_func+0x8c/0xc8
 process_one_work+0x208/0x60c
 worker_thread+0x244/0x388
 kthread+0x150/0x228
 ret_from_fork+0x10/0x20
irq event stamp: 57267
hardirqs last  enabled at (57267): [<ffffd761485e868c>] _raw_spin_unlock_irqrestore+0x74/0x78
hardirqs last disabled at (57266): [<ffffd76147b13c44>] clk_enable_lock+0x7c/0xf0
softirqs last  enabled at (56270): [<ffffd7614734446c>] handle_softirqs+0x4c4/0x4dc
softirqs last disabled at (56265): [<ffffd76147290690>] __do_softirq+0x14/0x20
---[ end trace 0000000000000000 ]---

Fixes: 79dde5f7dc7c ("scsi: ufs: core: Fix data race in CPU latency PM QoS request handling")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/ufs/core/ufshcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index d9632d7c5f01..b3b14af4a726 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10677,6 +10677,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	 */
 	spin_lock_init(&hba->clk_gating.lock);
 
+	/* Initialize mutex for PM QoS request synchronization */
+	mutex_init(&hba->pm_qos_mutex);
+
 	/*
 	 * Set the default power management level for runtime and system PM.
 	 * Host controller drivers can override them in their
@@ -10765,9 +10768,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 
 	mutex_init(&hba->wb_mutex);
 
-	/* Initialize mutex for PM QoS request synchronization */
-	mutex_init(&hba->pm_qos_mutex);
-
 	init_rwsem(&hba->clk_scaling_lock);
 
 	ufshcd_init_clk_gating(hba);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: ufs: core: Fix PM QoS mutex initialization
  2025-09-29 11:27 ` [PATCH] scsi: ufs: core: Fix PM QoS mutex initialization Marek Szyprowski
@ 2025-09-29 16:41   ` Bart Van Assche
  2025-09-29 21:00   ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2025-09-29 16:41 UTC (permalink / raw)
  To: Marek Szyprowski, linux-scsi, linux-kernel
  Cc: Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Zhongqiu Han

On 9/29/25 4:27 AM, Marek Szyprowski wrote:
> hba->pm_qos_mutex is used very early as a part of ufshcd_init(), so it
> need to be initialized before that call.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: ufs: core: Fix PM QoS mutex initialization
  2025-09-29 11:27 ` [PATCH] scsi: ufs: core: Fix PM QoS mutex initialization Marek Szyprowski
  2025-09-29 16:41   ` Bart Van Assche
@ 2025-09-29 21:00   ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2025-09-29 21:00 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: linux-scsi, linux-kernel, Alim Akhtar, Avri Altman,
	Bart Van Assche, James E.J. Bottomley, Martin K. Petersen,
	Zhongqiu Han


Marek,

> hba->pm_qos_mutex is used very early as a part of ufshcd_init(), so it
> need to be initialized before that call. This fixes the following
> warning:

Applied to 6.18/scsi-staging, thanks!

-- 
Martin K. Petersen

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-29 21:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20250929112740eucas1p284c5c49f54fec23c55260edf07aa1138@eucas1p2.samsung.com>
2025-09-29 11:27 ` [PATCH] scsi: ufs: core: Fix PM QoS mutex initialization Marek Szyprowski
2025-09-29 16:41   ` Bart Van Assche
2025-09-29 21:00   ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®