From: John Garry <john.g.garry@oracle.com>
To: Bart Van Assche <bvanassche@acm.org>,
"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>
Subject: Re: [PATCH v2] scsi: core: Rework the DEF_SCSI_QCMD() implementation
Date: Tue, 1 Sep 2026 09:04:47 +0100 [thread overview]
Message-ID: <b003c0c1-ba99-403d-b3c9-3670dd7d027c@oracle.com> (raw)
In-Reply-To: <7d904551041c58fd2cda31f82cf3e7b246e6550a.1788214709.git.bvanassche@acm.org>
On 31/08/2026 23:19, Bart Van Assche wrote:
> In DEF_SCSI_QCMD(), make the following changes:
> - Assign cmd->device->host to shost because func_name##_lck()
> implementations will be annotated with
> __must_hold(&cmd->device->host->host_lock). This change prepares for
Why not annotate with __must_hold(&host->host_lock)? That is what we do
in scsi_host_set_state().
> enabling lock context annotations for SCSI drivers.
> - Do not save and restore the IRQ flags. Since support for the legacy
> block layer has been removed, .queue_rq() implementations are always
> called from thread context and with interrupts enabled. Hence, saving
> and restoring the interrupt state is not necessary.
That is really a separate change.
>
> Signed-off-by: Bart Van Assche<bvanassche@acm.org>
It would help the maintainer to mention that this conflicts with my
host_lock patch
> ---
>
> Changes compared to v1:
> - Fixed a use-after-free bug.
> - Added __maybe_unused to the shost argument.
>
> include/scsi/scsi_host.h | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 16243ec376cd..d62f1e1fbd0c 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -528,15 +528,22 @@ struct scsi_host_template {
> *
> */
> #define DEF_SCSI_QCMD(func_name) \
> - enum scsi_qc_status func_name(struct Scsi_Host *shost, \
> + enum scsi_qc_status func_name(struct Scsi_Host *shost \
> + __maybe_unused, \
> struct scsi_cmnd *cmd) \
> { \
> - unsigned long irq_flags; \
> enum scsi_qc_status rc; \
> \
> - spin_lock_irqsave(shost->host_lock, irq_flags); \
> + /* \
> + * Help compiler context analysis by using \
> + * cmd->device->host instead of the shost argument \
> + * for the func_name##_lck() implementations annotated \
> + * with __must_hold(cmd->device->host->host_lock). \
> + */ \
> + shost = cmd->device->host; \
> + spin_lock_irq(shost->host_lock); \
> rc = func_name##_lck(cmd); \
> - spin_unlock_irqrestore(shost->host_lock, irq_flags); \
> + spin_unlock_irq(shost->host_lock); \
> return rc; \
> }
>
next prev parent reply other threads:[~2026-09-01 8:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 22:19 [PATCH v2] scsi: core: Rework the DEF_SCSI_QCMD() implementation Bart Van Assche
2026-09-01 8:04 ` John Garry [this message]
2026-09-01 18:17 ` Bart Van Assche
2026-09-02 8:21 ` John Garry
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=b003c0c1-ba99-403d-b3c9-3670dd7d027c@oracle.com \
--to=john.g.garry@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mkp@kernel.org \
/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