From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Marco Elver <elver@google.com>,
Bart Van Assche <bvanassche@acm.org>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Can Guo <can.guo@oss.qualcomm.com>, Bean Huo <beanhuo@micron.com>,
Avri Altman <avri.altman@sandisk.com>,
Peter Wang <peter.wang@mediatek.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Ajay Neeli <ajay.neeli@amd.com>,
Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
Subject: [PATCH v2 50/56] scsi: ufs: Enable lock context analysis
Date: Thu, 30 Apr 2026 11:20:20 -0700 [thread overview]
Message-ID: <20260430182130.1978347-51-bvanassche@acm.org> (raw)
In-Reply-To: <20260430182130.1978347-1-bvanassche@acm.org>
Annotate functions that modify the state of a synchronization object.
Remove the struct semaphore annotations because lock context annotations
are not supported for semaphores.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/Makefile | 2 ++
drivers/ufs/core/ufs-debugfs.c | 8 ++++++--
drivers/ufs/core/ufshcd.c | 14 ++++++++++++++
drivers/ufs/host/Makefile | 2 ++
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/core/Makefile b/drivers/ufs/core/Makefile
index ce7d16d2cf35..67ab9ffbdf5d 100644
--- a/drivers/ufs/core/Makefile
+++ b/drivers/ufs/core/Makefile
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
+CONTEXT_ANALYSIS := y
+
obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
ufshcd-core-y += ufshcd.o ufs-sysfs.o ufs-mcq.o ufs-txeq.o
ufshcd-core-$(CONFIG_RPMB) += ufs-rpmb.o
diff --git a/drivers/ufs/core/ufs-debugfs.c b/drivers/ufs/core/ufs-debugfs.c
index e3dd81d6fe82..814816810388 100644
--- a/drivers/ufs/core/ufs-debugfs.c
+++ b/drivers/ufs/core/ufs-debugfs.c
@@ -65,8 +65,10 @@ static int ee_usr_mask_get(void *data, u64 *val)
return 0;
}
+token_context_lock(ufs_debugfs);
+
static int ufs_debugfs_get_user_access(struct ufs_hba *hba)
-__acquires(&hba->host_sem)
+ __cond_acquires(0, ufs_debugfs)
{
down(&hba->host_sem);
if (!ufshcd_is_user_access_allowed(hba)) {
@@ -74,14 +76,16 @@ __acquires(&hba->host_sem)
return -EBUSY;
}
ufshcd_rpm_get_sync(hba);
+ __acquire(ufs_debugfs);
return 0;
}
static void ufs_debugfs_put_user_access(struct ufs_hba *hba)
-__releases(&hba->host_sem)
+ __releases(ufs_debugfs)
{
ufshcd_rpm_put_sync(hba);
up(&hba->host_sem);
+ __release(ufs_debugfs);
}
static int ee_usr_mask_set(void *data, u64 val)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 4805e40ed4d7..6fed3f38c010 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1376,6 +1376,8 @@ static int ufshcd_wait_for_pending_cmds(struct ufs_hba *hba,
* On failure, all acquired locks are released and the tagset is unquiesced.
*/
int ufshcd_pause_command_processing(struct ufs_hba *hba, u64 timeout_us)
+ __cond_acquires(0, &hba->host->scan_mutex)
+ __cond_acquires(0, &hba->clk_scaling_lock)
{
int ret = 0;
@@ -1400,6 +1402,8 @@ int ufshcd_pause_command_processing(struct ufs_hba *hba, u64 timeout_us)
* This function resumes command submissions.
*/
void ufshcd_resume_command_processing(struct ufs_hba *hba)
+ __releases(&hba->clk_scaling_lock)
+ __releases(&hba->host->scan_mutex)
{
up_write(&hba->clk_scaling_lock);
blk_mq_unquiesce_tagset(&hba->host->tag_set);
@@ -1469,6 +1473,9 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, u32 target_gear, bool scale_up
* Return: 0 upon success; -EBUSY upon timeout.
*/
static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)
+ __cond_acquires(0, &hba->host->scan_mutex)
+ __cond_acquires(0, &hba->wb_mutex)
+ __cond_acquires(0, &hba->clk_scaling_lock)
{
int ret = 0;
/*
@@ -1498,6 +1505,9 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us)
}
static void ufshcd_clock_scaling_unprepare(struct ufs_hba *hba, int err)
+ __releases(&hba->clk_scaling_lock)
+ __releases(&hba->wb_mutex)
+ __releases(&hba->host->scan_mutex)
{
up_write(&hba->clk_scaling_lock);
mutex_unlock(&hba->wb_mutex);
@@ -3301,6 +3311,8 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
}
static void ufshcd_dev_man_lock(struct ufs_hba *hba)
+ __acquires(&hba->dev_cmd.lock)
+ __acquires_shared(&hba->clk_scaling_lock)
{
ufshcd_hold(hba);
mutex_lock(&hba->dev_cmd.lock);
@@ -3308,6 +3320,8 @@ static void ufshcd_dev_man_lock(struct ufs_hba *hba)
}
static void ufshcd_dev_man_unlock(struct ufs_hba *hba)
+ __releases_shared(&hba->clk_scaling_lock)
+ __releases(&hba->dev_cmd.lock)
{
up_read(&hba->clk_scaling_lock);
mutex_unlock(&hba->dev_cmd.lock);
diff --git a/drivers/ufs/host/Makefile b/drivers/ufs/host/Makefile
index 65d8bb23ab7b..7d8db67eb23c 100644
--- a/drivers/ufs/host/Makefile
+++ b/drivers/ufs/host/Makefile
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
+CONTEXT_ANALYSIS := y
+
obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o tc-dwc-g210.o
obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o
obj-$(CONFIG_SCSI_UFS_CDNS_PLATFORM) += cdns-pltfrm.o
next prev parent reply other threads:[~2026-04-30 18:25 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 18:19 [PATCH v2 00/56] Enable lock context analysis for the SCSI subsystem Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 01/56] PCI: Convert to_pci_dev() into an inline function Bart Van Assche
2026-04-30 22:19 ` Bjorn Helgaas
2026-04-30 18:19 ` [PATCH v2 02/56] scsi: scsi_debug: Prepare for enabling lock context analysis Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 03/56] scsi: sg: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 04/56] scsi: st: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 05/56] scsi: BusLogic: Introduce a local variable Bart Van Assche
2026-05-01 18:01 ` Khalid Aziz
2026-04-30 18:19 ` [PATCH v2 06/56] scsi: BusLogic: Prepare for enabling lock context analysis Bart Van Assche
2026-05-01 18:02 ` Khalid Aziz
2026-04-30 18:19 ` [PATCH v2 07/56] scsi: NCR5380: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 08/56] scsi: aacraid: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 09/56] scsi: aic7xxx: Enable " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 10/56] scsi: aha152x: Prepare for enabling " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 11/56] scsi: aic7xxx: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 12/56] scsi: aic94xx: Enable " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 13/56] scsi: arcmsr: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 14/56] scsi: arm: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 15/56] scsi: be2iscsi: Prepare for enabling " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 16/56] scsi: be2iscsi: Enable " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 17/56] scsi: cxgbi: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 18/56] scsi: bfa: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 19/56] scsi: bnx2fc: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 20/56] scsi: bnx2i: Introduce a local variable Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 21/56] scsi: bnx2i: Enable lock context analysis Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 22/56] scsi: csiostor: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 23/56] scsi: elx: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 24/56] scsi: esas2r: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 25/56] scsi: fcoe: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 26/56] scsi: fnic: " Bart Van Assche
2026-05-04 17:45 ` Karan Tilak Kumar (kartilak)
2026-04-30 18:19 ` [PATCH v2 27/56] scsi: hisi_sas: " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 28/56] scsi: hpsa: Prepare for enabling " Bart Van Assche
2026-04-30 18:19 ` [PATCH v2 29/56] scsi: ibmvscsi: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 30/56] scsi: ibmvscsi_tgt: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 31/56] scsi: ipr: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 32/56] scsi: ips: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 33/56] scsi: isci: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 34/56] scsi: libfc: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 35/56] scsi: libiscsi: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 36/56] scsi: libsas: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 37/56] scsi: libsas: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 38/56] scsi: lpfc: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 39/56] scsi: megaraid_sas: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 40/56] scsi: megaraid: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 41/56] scsi: mpt3sas: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 42/56] scsi: mvsas: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 43/56] scsi: pcmcia: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 44/56] scsi: pm8001: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 45/56] scsi: qedf: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 46/56] scsi: qedi: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 47/56] scsi: qla1280: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 48/56] scsi: qla2xxx: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 49/56] scsi: qla4xxx: " Bart Van Assche
2026-04-30 18:20 ` Bart Van Assche [this message]
2026-04-30 18:20 ` [PATCH v2 51/56] scsi: iSCSI transport: Prepare for enabling " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 52/56] scsi: smartpqi: Enable " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 53/56] scsi: snic: " Bart Van Assche
2026-05-01 19:08 ` Narsimhulu Musini (nmusini)
2026-04-30 18:20 ` [PATCH v2 54/56] scsi: sym53c8xx_2: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 55/56] scsi: core: " Bart Van Assche
2026-04-30 18:20 ` [PATCH v2 56/56] scsi: core: Protect host state changes with the host lock Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260430182130.1978347-51-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=adrian.hunter@intel.com \
--cc=ajay.neeli@amd.com \
--cc=avri.altman@sandisk.com \
--cc=beanhuo@micron.com \
--cc=can.guo@oss.qualcomm.com \
--cc=elver@google.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=peter.wang@mediatek.com \
--cc=sai.krishna.potthuri@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox