Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Tyrel Datwyler <tyreld@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v9 4/9] scsi: ibmvfc: extend async event handlers for async sub-CRQ events
Date: Thu, 10 Sep 2026 20:52:33 -0700	[thread overview]
Message-ID: <465e2b19-3886-410e-b9be-5a6810e44c33@linux.ibm.com> (raw)
In-Reply-To: <20260911023904.6A1FE1F000FF@smtp.kernel.org>

On 9/10/26 7:39 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
> - [High] ibmvfc_find_target() incorrectly skips targets unless they support BOTH SCSI and NVMe, causing FPIN events to be dropped.
> - [Medium] Missing scsi_id extraction for async sub-CRQ events.
> - [Medium] Incorrect WWPN populated in FPIN descriptor for async sub-CRQ events when subq->wwpn is 0.
> - [Low] Missing address-of operator '&' when passing host_lock to spin_lock_irqsave() and spin_unlock_irqrestore(), causing a build failure.
> --
> 
> commit 997e4bca2edfad65478e2c572b7c236ba500e1bb
> Author: Dave Marquardt <davemarq@linux.ibm.com>
> 
> scsi: ibmvfc: extend async event handlers for async sub-CRQ events
> 
> This patch refactors async event handling to support both traditional async
> CRQs and new asynchronous sub-queue CRQs using a tagged union. It also
> updates FPIN processing logic to extract identifiers from the appropriate
> event type.
> 
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index 6b2eb82ceb98d..daec81f48857d 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> [ ... ]
>> @@ -3426,6 +3426,45 @@ ibmvfc_basic_fpin_to_desc(struct ibmvfc_async_crq *crq, u64 wwpn)
>> +static struct fc_els_fpin *
>> +ibmvfc_full_fpin_to_desc(struct ibmvfc_async_sub_crq *ibmvfc_fpin)
>> +{
>> +	__be16 type;
> [ ... ]
>> +	return ibmvfc_common_fpin_to_desc(ibmvfc_fpin->fpin_status, ibmvfc_fpin->wwpn,
>> +					  type, cpu_to_be16(0),
>> +					  cpu_to_be32(IBMVFC_FPIN_DEFAULT_EVENT_THRESHOLD),
>> +					  cpu_to_be32(1));
>> +}
> 
> [Severity: Medium]
> If the async sub-CRQ event arrives with a WWPN of 0 but the target is
> successfully matched via node_name, will this embed a WWPN of 0 into the
> FPIN descriptor?
> 
> It looks like fc_host_fpin_rcv() would then fail to find the remote port by
> WWPN, silently dropping the FPIN and missing statistics updates. Would it be
> safer to pass in the matched tgt->wwpn here, similar to how it's done for
> standard CRQs?

The wwpn and node name should never be zero.

> 
>>  /**
>>   * ibmvfc_find_target - Search for a target in a target list
>>   * @target_list: list head of targets to search
>> @@ -3463,28 +3502,39 @@ static struct ibmvfc_target *ibmvfc_find_target(struct list_head *target_list,
>>   */
>>  static void ibmvfc_process_async_work(struct work_struct *work)
>>  {
>> +	struct ibmvfc_async_sub_crq *subq = NULL;
>>  	struct ibmvfc_async_work *aw;
>> -	struct ibmvfc_async_crq *crq;
>> +	struct ibmvfc_async_crq *crq = NULL;
>>  	struct ibmvfc_target *tgt;
>>  	struct ibmvfc_host *vhost;
>> -	struct fc_els_fpin *fpin;
>> +	struct fc_els_fpin *fpin = NULL;
>>  	unsigned long flags;
>> +	__be64 node_name;
>> +	__be64 scsi_id;
>> +	__be64 wwpn;
>>  
>>  	aw = container_of_const(work, struct ibmvfc_async_work, async_work_s);
>>  	vhost = aw->vhost;
>> -	crq = &aw->crq;
>> +	if (aw->event.type == IBMVFC_ASYNC_CRQ_SUB) {
>> +		subq = &aw->event.subq;
>> +		scsi_id = 0;
> 
> [Severity: Medium]
> The commit message states we "extract WWPN, node_name, and scsi_id from the
> appropriate union member based on event type."
> 
> However, for async sub-CRQ events here and in ibmvfc_handle_async(), scsi_id
> is hardcoded to 0 instead of extracting nport_id from the payload. Could this
> cause target lookup failures if WWPN and node_name happen to be 0?

Again wwpn and node_name should never be zero here.

> 
>> +		wwpn = subq->wwpn;
>> +		node_name = (subq->flags & IBMVFC_ASYNC_ID_IS_ASSOC_ID) ? 0 : subq->id.node_name;
>> +	} else {
>> +		crq = &aw->event.async_crq;
>> +		scsi_id = crq->scsi_id;
>> +		wwpn = crq->wwpn;
>> +		node_name = crq->node_name;
>> +	}
>>  
>> -	if (!crq->scsi_id && !crq->wwpn && !crq->node_name)
>> +	if (!scsi_id && !wwpn && !node_name)
>>  		goto free;
>>  
>>  	spin_lock_irqsave(vhost->host->host_lock, flags);
>> -	tgt = ibmvfc_find_target(&vhost->scsi_scrqs.targets, crq->scsi_id,
>> -				 crq->wwpn, crq->node_name);
>> +	tgt = ibmvfc_find_target(&vhost->scsi_scrqs.targets, scsi_id, wwpn, node_name);
> 
> [Severity: High]
> Does ibmvfc_find_target() incorrectly skip targets unless they support BOTH
> SCSI and NVMe?
> 
> Looking at the implementation of ibmvfc_find_target():
> 
>     if (!tgt->rport || !tgt->nvme_remote_port)
>         continue;
> 
> Because a target represents a single endpoint for a specific protocol (SCSI or
> NVMe), it will only ever have either tgt->rport or tgt->nvme_remote_port,
> never both.
> 
> Because of the logical OR, this condition always evaluates to true. Could this
> effectively break FPIN event handling by causing every target to be skipped?

This was covered in patch 1 and will be fixed in v10.

> 
> [ ... ]
>> @@ -3512,25 +3566,51 @@ static void ibmvfc_process_async_work(struct work_struct *work)
>>  
>>  /**
>>   * ibmvfc_handle_async - Handle an async event from the adapter
> [ ... ]
>>  	if (ae->type == IBMVFC_ASYNC_CRQ_SUB) {
>> -	switch (be64_to_cpu(crq->event)) {
>> +		subq = &ae->subq;
>> +		event = be16_to_cpu(subq->event);
>> +		link_state = subq->link_state;
>> +		scsi_id = 0;
> 
> [Severity: Medium]
> Similarly, this hardcodes scsi_id to 0 for async sub-CRQ events instead of
> extracting it from the event payload.
>

scsi_id is not part of a subq event payload. We set it to zero to ensure we
don't pass junk  to ibmvfc_find_target.

-Tyrel


  reply	other threads:[~2026-09-11  3:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  2:19 [PATCH v9 0/9] scsi: ibmvfc: make ibmvfc support FPIN messages Tyrel Datwyler
2026-09-11  2:19 ` [PATCH v9 1/9] scsi: ibmvfc: add basic FPIN support Tyrel Datwyler
2026-09-11  2:38   ` sashiko-bot
2026-09-11  3:40     ` Tyrel Datwyler
2026-09-11  2:19 ` [PATCH v9 2/9] scsi: ibmvfc: add NOOP command support Tyrel Datwyler
2026-09-11  2:31   ` sashiko-bot
2026-09-11  3:41     ` Tyrel Datwyler
2026-09-11  2:19 ` [PATCH v9 3/9] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Tyrel Datwyler
2026-09-11  2:19 ` [PATCH v9 4/9] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Tyrel Datwyler
2026-09-11  2:39   ` sashiko-bot
2026-09-11  3:52     ` Tyrel Datwyler [this message]
2026-09-11  2:19 ` [PATCH v9 5/9] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Tyrel Datwyler
2026-09-11  2:44   ` sashiko-bot
2026-09-11  3:53     ` Tyrel Datwyler
2026-09-11  2:19 ` [PATCH v9 6/9] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Tyrel Datwyler
2026-09-11  2:19 ` [PATCH v9 7/9] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Tyrel Datwyler
2026-09-11  2:34   ` sashiko-bot
2026-09-11  2:19 ` [PATCH v9 8/9] scsi: ibmvfc: register and use asynchronous sub CRQ for events Tyrel Datwyler
2026-09-11  2:40   ` sashiko-bot
2026-09-11  2:19 ` [PATCH v9 9/9] scsi: ibmvfc: handle extended FPIN events Tyrel Datwyler
2026-09-11  2:40   ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-09-09 19:07 [PATCH v8 0/9] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-09-11  2:08 ` [PATCH v9 4/9] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Tyrel Datwyler
2026-09-11  2:40   ` sashiko-bot

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=465e2b19-3886-410e-b9be-5a6810e44c33@linux.ibm.com \
    --to=tyreld@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