Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dave Marquardt" <davemarq@linux.ibm.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v16 09/12] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ
Date: Mon, 26 Oct 2026 16:24:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-185515@kernel.org> (raw)
In-Reply-To: <20261026-ibmvfc-fpin-support-v16-9-a900aa657ed5@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: ibmvfc: same-class q_lock nesting in ibmvfc_drain_async_subq()
--

commit d3f6ce8f09b129387eea8b24d92aacbad8e6f279
Author: Dave Marquardt <davemarq@linux.ibm.com>

scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ

This commit adds ibmvfc_interrupt_async_subq(), ibmvfc_drain_async_subq(),
and ibmvfc_next_async_scrq() to handle and drain asynchronous sub-CRQ events
from the adapter.

> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> index 64981a5a39fbf..2cb38757333a4 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> @@ -4387,6 +4387,72 @@ static struct ibmvfc_crq *ibmvfc_next_scrq(struct ibmvfc_queue *scrq)
>  	return crq;
>  }
>  
> +static struct ibmvfc_async_sub_crq *ibmvfc_next_async_scrq(struct ibmvfc_queue *scrq)
> +{
> +	struct ibmvfc_async_sub_crq *crq;
> +
> +	crq = &scrq->msgs.async_scrq[scrq->cur];
> +	if (crq->valid & 0x80) {
> +		if (++scrq->cur == scrq->size)
> +			scrq->cur = 0;
> +		rmb();
> +	} else
> +		crq = NULL;
> +
> +	return crq;
> +}
> +
> +static void ibmvfc_drain_async_subq(struct ibmvfc_queue *scrq)
> +{
> +	struct ibmvfc_host *vhost = scrq->vhost;
> +	struct ibmvfc_async_crq_event ae = {
> +		.type = IBMVFC_ASYNC_CRQ_SUB,
> +	};
> +	struct ibmvfc_async_sub_crq *crq;
> +	unsigned long flags;
> +	int done = 0;
> +
> +	spin_lock_irqsave(&vhost->host->host_lock, flags);
> +	spin_lock(scrq->q_lock);
> +	while (!done) {
> +		while ((crq = ibmvfc_next_async_scrq(scrq)) != NULL) {
> +			ae.subq = *crq;
> +			ibmvfc_handle_async(&ae, scrq->vhost);

[Severity: High]
Can calling ibmvfc_handle_async() while holding scrq->q_lock trigger a
lockdep recursive locking warning?

Every struct ibmvfc_queue (including async_scrqs, scsi_scrqs, and nvme_scrqs)
initializes queue->_lock at the same call site in ibmvfc_alloc_queue():

	spin_lock_init(&queue->_lock);
	queue->q_lock = &queue->_lock;

This places scrq->q_lock, scsi_q[i].q_lock, and nvme_q[i].q_lock into the
same lockdep class.

When ibmvfc_drain_async_subq() processes a reset-triggering async event
(such as IBMVFC_AE_RESUME, IBMVFC_AE_LINK_UP, IBMVFC_AE_SCN_FABRIC, or
IBMVFC_AE_SCN_DOMAIN) while vhost->action is IBMVFC_HOST_ACTION_LOGO_WAIT
(for example, if a second async event arrives while NPIV logout is in flight
with vhost->using_channels set) or vhost->state is IBMVFC_HOST_OFFLINE, the
call chain reaches ibmvfc_purge_requests():

  ibmvfc_drain_async_subq()
    spin_lock(scrq->q_lock)
    ibmvfc_handle_async()
      __ibmvfc_reset_host()
        ibmvfc_hard_reset_host()
          ibmvfc_purge_requests()

In ibmvfc_purge_requests(), the loops over active SCSI and NVMe sub-queues
acquire scsi_q[i].q_lock and nvme_q[i].q_lock at subclass 0 while
scrq->q_lock of the same lockdep class is still held:

	for (i = 0; i < shwqs; i++) {
		spin_lock_irqsave(scsi_q[i].q_lock, flags);
		spin_lock(&scsi_q[i].l_lock);
		...
	}

	for (i = 0; i < nhwqs; i++) {
		spin_lock_irqsave(nvme_q[i].q_lock, flags);
		spin_lock(&nvme_q[i].l_lock);
		...
	}

Should async sub-queue locks use a separate lockdep class or subclass, or
should ibmvfc_handle_async() be called without holding scrq->q_lock?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261026-ibmvfc-fpin-support-v16-0-a900aa657ed5@linux.ibm.com?part=9

  reply	other threads:[~2026-10-26 16:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 16:12 [PATCH v16 00/12] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-10-26 16:12 ` [PATCH v16 01/12] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Dave Marquardt via B4 Relay
2026-10-26 16:12 ` [PATCH v16 02/12] scsi: ibmvfc: fix potential clobbering of rc after failed irq setup Dave Marquardt via B4 Relay
2026-10-26 16:12 ` [PATCH v16 03/12] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation Dave Marquardt via B4 Relay
2026-10-26 16:26   ` sashiko-bot
2026-10-26 21:17     ` Dave Marquardt
2026-10-26 16:12 ` [PATCH v16 04/12] scsi: ibmvfc: fix unguarded dma_unmap_single() in ibmvfc_free_queue() Dave Marquardt via B4 Relay
2026-10-26 16:12 ` [PATCH v16 05/12] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-10-26 16:24   ` sashiko-bot
2026-10-26 22:11     ` Dave Marquardt
2026-10-26 16:12 ` [PATCH v16 06/12] scsi: ibmvfc: add NOOP command support Dave Marquardt via B4 Relay
2026-10-26 16:12 ` [PATCH v16 07/12] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Dave Marquardt via B4 Relay
2026-10-26 16:12 ` [PATCH v16 08/12] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Dave Marquardt via B4 Relay
2026-10-26 16:12 ` [PATCH v16 09/12] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-10-26 16:24   ` sashiko-bot [this message]
2026-10-27 14:08     ` Dave Marquardt
2026-10-26 16:12 ` [PATCH v16 10/12] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Dave Marquardt via B4 Relay
2026-10-26 16:12 ` [PATCH v16 11/12] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-10-26 16:31   ` sashiko-bot
2026-10-27 15:00     ` Dave Marquardt
2026-10-26 16:12 ` [PATCH v16 12/12] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay

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=sashiko-outbox-185515@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=davemarq@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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