All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Marquardt <davemarq@linux.ibm.com>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v16 11/12] scsi: ibmvfc: register and use asynchronous sub CRQ for events
Date: Tue, 27 Oct 2026 10:00:00 -0500	[thread overview]
Message-ID: <8733trfatr.fsf@linux.ibm.com> (raw)
In-Reply-To: <sashiko-outbox-185519@kernel.org> (sashiko-bot@kernel.org's message of "Mon, 26 Oct 2026 16:31:51 +0000")

sashiko-bot@kernel.org writes:

>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index af11726b76beb..4d4ebe5f6f123 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> [ ... ]
>> @@ -988,6 +989,7 @@ static int ibmvfc_reenable_crq_queue(struct ibmvfc_host *vhost)
>>  	spin_unlock(vhost->crq.q_lock);
>>  	spin_unlock_irqrestore(&vhost->host->host_lock, flags);
>>  
>> +	ibmvfc_reg_sub_crqs(vhost, &vhost->async_scrqs);
>>  	ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs);
>>  	ibmvfc_reg_sub_crqs(vhost, &vhost->nvme_scrqs);
>>  
> [ ... ]
>> @@ -1044,6 +1047,7 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost)
>>  	spin_unlock(vhost->crq.q_lock);
>>  	spin_unlock_irqrestore(&vhost->host->host_lock, flags);
>>  
>> +	ibmvfc_reg_sub_crqs(vhost, &vhost->async_scrqs);
>>  	ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs);
>>  	ibmvfc_reg_sub_crqs(vhost, &vhost->nvme_scrqs);
>>  
> [ ... ]
>> @@ -6976,25 +6994,45 @@ VISIBLE_IF_KUNIT void ibmvfc_deregister_channel(struct ibmvfc_host *vhost,
>>  }
>>  EXPORT_SYMBOL_IF_KUNIT(ibmvfc_deregister_channel);
>>  
>> -static void ibmvfc_reg_sub_crqs(struct ibmvfc_host *vhost,
> [ ... ]
>> +static int ibmvfc_reg_sub_crqs(struct ibmvfc_host *vhost,
>>  				struct ibmvfc_channels *channels)
>>  {
>> +	unsigned long flags;
>>  	int i, j;
>>  
>>  	ENTER;
>>  	if (!vhost->mq_enabled || !channels->scrqs)
>> -		return;
>> +		return 0;
>>  
>>  	for (i = 0; i < channels->max_queues; i++) {
>>  		if (ibmvfc_register_channel(vhost, channels, i)) {
>>  			for (j = i; j > 0; j--)
>>  				ibmvfc_deregister_channel(vhost, channels, j - 1);
>> +			spin_lock_irqsave(&vhost->host->host_lock, flags);
>>  			vhost->do_enquiry = 0;
>> -			return;
>> +			vhost->mq_enabled = 0;
>> +			spin_unlock_irqrestore(&vhost->host->host_lock, flags);
>> +			return -1;
>>  		}
>>  	}
>>  
>>  	LEAVE;
>> +	return 0;
>>  }
> [ ... ]
>> @@ -7083,9 +7102,74 @@ static void ibmvfc_release_channels(struct ibmvfc_host *vhost,
>>  	}
>>  }
>>  
> [ ... ]
>> +static void ibmvfc_init_sub_crqs(struct ibmvfc_host *vhost)
>> +{
>> +	unsigned long flags;
>> +
>> +	ENTER;
>> +	if (!vhost->mq_enabled)
>> +		return;
>> +
>> +	/* register async_sub_crq channel */
>> +	if (ibmvfc_alloc_channels(vhost, &vhost->async_scrqs))
>> +		goto out;
>> +
>> +	if (ibmvfc_reg_sub_crqs(vhost, &vhost->async_scrqs))
>> +		goto release_async_sub_crq;
>> +
>> +	if (ibmvfc_alloc_channels(vhost, &vhost->scsi_scrqs))
>> +		goto deregister_async_sub_crq;
>> +
>> +	if (ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs))
>> +		goto release_scsi_sub_crqs;
>> +
>> +	if (vhost->nvme_enabled) {
>> +		if (ibmvfc_alloc_channels(vhost, &vhost->nvme_scrqs)) {
>> +			spin_lock_irqsave(&vhost->host->host_lock, flags);
>> +			vhost->nvme_enabled = 0;
>> +			spin_unlock_irqrestore(&vhost->host->host_lock, flags);
>> +		} else if (ibmvfc_reg_sub_crqs(vhost, &vhost->nvme_scrqs)) {
>> +			ibmvfc_release_channels(vhost, &vhost->nvme_scrqs);
>> +			spin_lock_irqsave(&vhost->host->host_lock, flags);
>> +			vhost->nvme_enabled = 0;
>> +			spin_unlock_irqrestore(&vhost->host->host_lock, flags);
>> +		}
>> +	}
>
> [Severity: High]
> Does clearing vhost->do_enquiry and vhost->mq_enabled unconditionally inside
> ibmvfc_reg_sub_crqs() cause inconsistent state and leaked sub-CRQ
> registrations when a later channel set fails to register?
>
> In ibmvfc_init_sub_crqs(), vhost->async_scrqs and vhost->scsi_scrqs are
> allocated and registered first. When vhost->nvme_enabled is set and
> ibmvfc_reg_sub_crqs(vhost, &vhost->nvme_scrqs) fails, ibmvfc_init_sub_crqs()
> appears to intend to only disable NVMe by releasing vhost->nvme_scrqs and
> setting vhost->nvme_enabled = 0.
>
> However, because ibmvfc_reg_sub_crqs() has already set vhost->do_enquiry = 0
> and vhost->mq_enabled = 0, multi-queue and channel enquiry are disabled for
> the entire host while vhost->async_scrqs and vhost->scsi_scrqs remain
> allocated and registered with the hypervisor with active IRQ handlers.
>
> Similarly, in ibmvfc_reenable_crq_queue() and ibmvfc_reset_crq():
>
> 	ibmvfc_reg_sub_crqs(vhost, &vhost->async_scrqs);
> 	ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs);
> 	ibmvfc_reg_sub_crqs(vhost, &vhost->nvme_scrqs);
>
> If registering vhost->async_scrqs succeeds, and a subsequent call to
> ibmvfc_reg_sub_crqs() for vhost->scsi_scrqs or vhost->nvme_scrqs fails,
> vhost->mq_enabled and vhost->do_enquiry are cleared to 0, but the already
> registered channel sets are not deregistered via ibmvfc_dereg_sub_crqs().
>
> Should the caller handle clearing vhost->mq_enabled and vhost->do_enquiry (or
> unwinding previously registered channel sets) instead of clearing those flags
> unconditionally in ibmvfc_reg_sub_crqs()?

The callers will handle deregistering sub CRQs and clearing
vhost->mq_enabled and vhost->do_enquiry in the next revision.

-Dave

  reply	other threads:[~2026-10-27 15:00 UTC|newest]

Thread overview: 34+ 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 ` Dave Marquardt
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   ` Dave Marquardt
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   ` Dave Marquardt
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:12   ` Dave Marquardt
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   ` Dave Marquardt
2026-10-26 16:12 ` [PATCH v16 05/12] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-10-26 16:12   ` Dave Marquardt
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   ` Dave Marquardt
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   ` Dave Marquardt
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   ` Dave Marquardt
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:12   ` Dave Marquardt
2026-10-26 16:24   ` sashiko-bot
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   ` Dave Marquardt
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:12   ` Dave Marquardt
2026-10-26 16:31   ` sashiko-bot
2026-10-27 15:00     ` Dave Marquardt [this message]
2026-10-26 16:12 ` [PATCH v16 12/12] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-10-26 16:12   ` Dave Marquardt

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=8733trfatr.fsf@linux.ibm.com \
    --to=davemarq@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-bot@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.