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>,
Hannes Reinecke <hare@suse.de>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Subject: [PATCH v2 34/56] scsi: libfc: Enable lock context analysis
Date: Thu, 30 Apr 2026 11:20:04 -0700 [thread overview]
Message-ID: <20260430182130.1978347-35-bvanassche@acm.org> (raw)
In-Reply-To: <20260430182130.1978347-1-bvanassche@acm.org>
Document locking requirements with __must_hold().
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/libfc/Makefile | 2 ++
drivers/scsi/libfc/fc_disc.c | 6 +++++-
drivers/scsi/libfc/fc_exch.c | 6 ++++++
drivers/scsi/libfc/fc_fcp.c | 4 ++++
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/libfc/Makefile b/drivers/scsi/libfc/Makefile
index 65396f86c307..b265cf2a84a2 100644
--- a/drivers/scsi/libfc/Makefile
+++ b/drivers/scsi/libfc/Makefile
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: GPL-2.0
# $Id: Makefile
+CONTEXT_ANALYSIS := y
+
obj-$(CONFIG_LIBFC) += libfc.o
libfc-objs := \
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 7792724d5b97..e2fd076ee15b 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -37,7 +37,7 @@
#define FC_DISC_RETRY_LIMIT 3 /* max retries */
#define FC_DISC_RETRY_DELAY 500UL /* (msecs) delay */
-static void fc_disc_gpn_ft_req(struct fc_disc *);
+static void fc_disc_gpn_ft_req(struct fc_disc *disc) __must_hold(disc->disc_mutex);
static void fc_disc_gpn_ft_resp(struct fc_seq *, struct fc_frame *, void *);
static void fc_disc_done(struct fc_disc *, enum fc_disc_event);
static void fc_disc_timeout(struct work_struct *);
@@ -200,6 +200,7 @@ static void fc_disc_recv_req(struct fc_lport *lport, struct fc_frame *fp)
* @disc: The discovery object to be restarted
*/
static void fc_disc_restart(struct fc_disc *disc)
+ __must_hold(disc->disc_mutex)
{
lockdep_assert_held(&disc->disc_mutex);
@@ -250,6 +251,7 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
* @event: The discovery completion status
*/
static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
+ __must_hold(disc->disc_mutex)
{
struct fc_lport *lport = fc_disc_lport(disc);
struct fc_rport_priv *rdata;
@@ -294,6 +296,7 @@ static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
* @fp: The error code encoded as a frame pointer
*/
static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
+ __must_hold(disc->disc_mutex)
{
struct fc_lport *lport = fc_disc_lport(disc);
unsigned long delay = 0;
@@ -374,6 +377,7 @@ static void fc_disc_gpn_ft_req(struct fc_disc *disc)
* Goes through the list of IDs and names resulting from a request.
*/
static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
+ __must_hold(disc->disc_mutex)
{
struct fc_lport *lport;
struct fc_gpn_ft_resp *np;
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 9183a0e9568a..9057a95d8612 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -811,6 +811,7 @@ static void fc_exch_timeout(struct work_struct *work)
*/
static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
struct fc_exch_mgr *mp)
+ __context_unsafe(conditionally acquires &_res->ex_lock)
{
struct fc_exch *ep;
unsigned int cpu;
@@ -904,6 +905,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
*/
static struct fc_exch *fc_exch_alloc(struct fc_lport *lport,
struct fc_frame *fp)
+ __context_unsafe(conditionally acquires &_res->ex_lock)
{
struct fc_exch_mgr_anchor *ema;
struct fc_exch *ep;
@@ -996,6 +998,8 @@ static struct fc_exch *fc_exch_resp(struct fc_lport *lport,
ep = fc_exch_alloc(lport, fp);
if (ep) {
+ /* Acquired by fc_exch_alloc(). */
+ __acquire(&ep->ex_lock);
ep->class = fc_frame_class(fp);
/*
@@ -2191,6 +2195,8 @@ struct fc_seq *fc_exch_seq_send(struct fc_lport *lport,
fc_frame_free(fp);
return NULL;
}
+ /* Acquired by fc_exch_alloc(). */
+ __acquire(&ep->ex_lock);
ep->esb_stat |= ESB_ST_SEQ_INIT;
fh = fc_frame_header_get(fp);
fc_exch_set_addr(ep, ntoh24(fh->fh_s_id), ntoh24(fh->fh_d_id));
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index a5139e43ca4c..9ba31a8a5250 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -207,6 +207,7 @@ static void fc_fcp_pkt_destroy(struct fc_seq *seq, void *fsp)
* needed.
*/
static inline int fc_fcp_lock_pkt(struct fc_fcp_pkt *fsp)
+ __cond_acquires(0, &fsp->scsi_pkt_lock)
{
spin_lock_bh(&fsp->scsi_pkt_lock);
if (fsp->state & FC_SRB_COMPL) {
@@ -224,6 +225,7 @@ static inline int fc_fcp_lock_pkt(struct fc_fcp_pkt *fsp)
* @fsp: The FCP packet to be unlocked and decremented
*/
static inline void fc_fcp_unlock_pkt(struct fc_fcp_pkt *fsp)
+ __releases(&fsp->scsi_pkt_lock)
{
spin_unlock_bh(&fsp->scsi_pkt_lock);
fc_fcp_pkt_release(fsp);
@@ -1242,6 +1244,7 @@ static void fc_fcp_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
* Called to send an abort and then wait for abort completion
*/
static int fc_fcp_pkt_abort(struct fc_fcp_pkt *fsp)
+ __must_hold(&fsp->scsi_pkt_lock)
{
int rc = FAILED;
unsigned long ticks_left;
@@ -1950,6 +1953,7 @@ EXPORT_SYMBOL(fc_queuecommand);
* The fcp packet lock must be held when calling.
*/
static void fc_io_compl(struct fc_fcp_pkt *fsp)
+ __must_hold(&fsp->scsi_pkt_lock)
{
struct fc_fcp_internal *si;
struct scsi_cmnd *sc_cmd;
next prev parent reply other threads:[~2026-04-30 18:24 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 ` Bart Van Assche [this message]
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 ` [PATCH v2 50/56] scsi: ufs: " Bart Van Assche
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-35-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=elver@google.com \
--cc=hare@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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