All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nilesh Javali" <njavali@marvell.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 12/14] scsi: qla2xxx: Yield work_lock in fabric scan path
Date: Wed, 21 Oct 2026 10:37:38 +0000	[thread overview]
Message-ID: <sashiko-outbox-180108@kernel.org> (raw)
In-Reply-To: <20261021102310.3854868-13-njavali@marvell.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: qla2xxx: wrong lock targeted with trylock loop in qla_fab_scan_finish()
--

commit 97d6a044424099a02acc895f356a103166186107
Author: Nilesh Javali <njavali@marvell.com>

scsi: qla2xxx: Yield work_lock in fabric scan path

This commit replaces spin_lock_irqsave(&vha->work_lock, flags) in
qla_fab_scan_finish() with a spin_trylock_irqsave() and cond_resched() loop
to avoid a hard lockup observed during vport deletion.

> diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
> index efe98609c149d..31308a6148585 100644
> --- a/drivers/scsi/qla2xxx/qla_gs.c
> +++ b/drivers/scsi/qla2xxx/qla_gs.c
> @@ -3386,7 +3386,9 @@ void qla_fab_scan_finish(scsi_qla_host_t *vha, srb_t *sp)
>  	recheck = 1;
>  out:
>  	qla24xx_sp_unmap(vha, sp);
> -	spin_lock_irqsave(&vha->work_lock, flags);
> +	/* Avoid hard lockup: yield if work_lock is held instead of spinning */
> +	while (!spin_trylock_irqsave(&vha->work_lock, flags))
> +		cond_resched();
>  	vha->scan.scan_flags &= ~SF_SCANNING;
>  	spin_unlock_irqrestore(&vha->work_lock, flags);
>  

[Severity: High]
Is this targeting the right spinlock for the hard lockup shown in the commit
message, and is a trylock loop safe here?

In the qla2x00_iocb_work_fn() -> qla2x00_do_work() -> qla_fab_scan_finish()
path, the static helper qla2x00_is_a_vp() is inlined into the
max_fibre_devices scan loop in qla_fab_scan_finish():

drivers/scsi/qla2xxx/qla_gs.c:qla2x00_is_a_vp() {
	...
	spin_lock_irqsave(&ha->vport_slock, flags);
	list_for_each_entry(vp, &ha->vp_list, list) {
		twwn = wwn_to_u64(vp->port_name);
		if (wwn == twwn) {
			rc = 1;
			break;
		}
	}
	spin_unlock_irqrestore(&ha->vport_slock, flags);
	...
}

drivers/scsi/qla2xxx/qla_gs.c:qla_fab_scan_finish() {
	...
	for (i = 0; i < vha->hw->max_fibre_devices; i++) {
		...
		/* Bypass virtual ports of the same host. */
		if (qla2x00_is_a_vp(vha, wwn))
			continue;
		...
	}
}

Looking at the registers in the backtrace:
- rbp is 0xffff98b803e60a58, which is vha (at the shost_priv offset 0xa58),
  where &vha->work_lock at offset 0x30 would be 0xffff98b803e60a88.
- rdi (the lock pointer passed to _raw_spin_lock_irqsave) is
  0xffff98b149ff6488, which is at offset 0x488 of struct qla_hw_data *ha
  (0xffff98b149ff6000), matching &ha->vport_slock (as also seen in commits
  79b305e1e477, 0334585318b2, and 200e63c70fc1).
- r10 and r15 hold 0x2100000eddd08241 (the 64-bit port name wwn passed to
  qla2x00_is_a_vp(vha, wwn)), r13 holds 0xffffb9a8a4555000 (vha->scan.l),
  rcx holds 0x800 (vha->hw->max_fibre_devices), and r12 holds 0xc000
  (2048 * sizeof(struct fab_scan_rp)).

This indicates the worker was spinning on &ha->vport_slock inside
qla2x00_is_a_vp() rather than on &vha->work_lock at the out label.

In addition, vha->work_lock is not taken in the vport delete path
(qla24xx_vport_delete() -> qla24xx_disable_vp() ->
qla24xx_deallocate_vp_id()) and is only held across short, non-blocking flag
and list updates with interrupts disabled. By contrast, ha->vport_slock
protects ha->vp_list during vport deletion, where several
list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) loops (such as in
qla2x00_abort_isp_cleanup(), qla2x00_abort_isp(), qla2x00_quiesce_io(),
qla82xx_restart_isp(), and qla_pci_error_cleanup()) drop and re-acquire
ha->vport_slock without refreshing tvp if qla24xx_deallocate_vp_id() removes
an entry via list_del_init(&vha->list).

Could replacing spin_lock_irqsave(&vha->work_lock, flags) with a
spin_trylock_irqsave() + cond_resched() loop also introduce regressions by
bypassing queued spinlock fairness and realtime priority inheritance,
busy-looping without cpu_relax() while toggling interrupts when
need_resched() is false, or livelocking the qla2xxx_wq worker if the lock is
ever stuck (leaving scan_flags with SF_SCANNING set and hanging
flush_workqueue(vha->hw->wq) in qla2x00_wait_for_sess_deletion())?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021102310.3854868-1-njavali@marvell.com?part=12

  reply	other threads:[~2026-10-21 10:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 10:22 [PATCH 00/14] scsi: qla2xxx: Misc. Bug fixes Nilesh Javali
2026-10-21 10:22 ` [PATCH 01/14] scsi: qla2xxx: Update MAINTAINERS with new FC storage alias Nilesh Javali
2026-10-21 10:22 ` [PATCH 02/14] scsi: qla2xxx: Update few AENs for 29xx handling Nilesh Javali
2026-10-21 10:22 ` [PATCH 03/14] Revert "scsi: qla2xxx: Validate BSG request_len before reading vendor_cmd[]" Nilesh Javali
2026-10-21 10:39   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 04/14] scsi: qla2xxx: Wait for session deletion before full-login LIP Nilesh Javali
2026-10-21 10:23 ` [PATCH 05/14] scsi: qla2xxx: Fix double addition of fcport to gnl.fcport list Nilesh Javali
2026-10-21 10:43   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 06/14] scsi: qla2xxx: Fix scan state machine race and IRQ-unsafe sp_unmap Nilesh Javali
2026-10-21 10:39   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 07/14] scsi: qla2xxx: Skip vport DPC processing during vport deletion Nilesh Javali
2026-10-21 10:36   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 08/14] scsi: qla2xxx: Add validation check for base vport index during delete Nilesh Javali
2026-10-21 10:43   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 09/14] scsi: qla2xxx: Validate vport before deletion Nilesh Javali
2026-10-21 10:23 ` [PATCH 10/14] scsi: qla2xxx: Fix use-after-free races during vport deletion Nilesh Javali
2026-10-21 10:40   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 11/14] scsi: qla2xxx: Re-acquire vport_slock and refresh tvp during vport DPC Nilesh Javali
2026-10-21 10:43   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 12/14] scsi: qla2xxx: Yield work_lock in fabric scan path Nilesh Javali
2026-10-21 10:37   ` sashiko-bot [this message]
2026-10-21 10:23 ` [PATCH 13/14] scsi: qla2xxx: Fix purex IOCB copy size on non-29xx adapters Nilesh Javali
2026-10-21 10:23 ` [PATCH 14/14] scsi: qla2xxx: Update version to 12.00.00.2610b1 Nilesh Javali
2026-10-23 10:09 ` [PATCH 00/14] scsi: qla2xxx: Misc. Bug fixes Nilesh Javali

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-180108@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=njavali@marvell.com \
    --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.