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] scsi: qla2xxx: Take the port from ISP control/status
Date: Thu, 03 Dec 2026 09:40:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-247490@kernel.org> (raw)
In-Reply-To: <20261203091740.6044-1-njavali@marvell.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] scsi: qla2xxx: qla2x00_port_no_from_csrx() sets wrong portnum
  on ISP8031
- [Medium] scsi: qla2xxx: PCI_FUNC() gate in qla2x00_port_no_from_csrx()
  breaks VFIO
- [Low] scsi: qla2xxx: missing ISP_REG_DISCONNECT check in
  qla2x00_port_no_from_csrx()
- [Low] scsi: qla2xxx: reused ql_log message IDs in
  qla2x00_port_no_from_csrx()
--

commit 4028d2e2495092c9c8d80dc38a6aef6e800678b4
Author: Nilesh Javali <njavali@marvell.com>

scsi: qla2xxx: Take the port from ISP control/status

This commit adds qla2x00_port_no_from_csrx() to derive ha->port_no from
the ISP ctrl_status register after iospace_config() when PCI_INTERRUPT_PIN
and PCI_FUNC() are both zero, and drops the unused ha->portnum assignment
for 27xx/28xx/29xx.

> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index 3c412c7fb6fe7..4ca54bc09c58c 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -2704,6 +2704,66 @@ static struct isp_operations qla29xx_isp_ops = {
[ ... ]
> +static void
> +qla2x00_port_no_from_csrx(struct qla_hw_data *ha)
> +{
> +	struct device_reg_24xx __iomem *reg;
> +	u32 csr, port;
> +	u8 pin = 0;
> +
> +	if (!IS_FWI2_CAPABLE(ha) || IS_P3P_TYPE(ha) || !ha->iobase)
> +		return;
> +
> +	pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &pin);
> +	if (pin || PCI_FUNC(ha->pdev->devfn))
> +		return;

[Severity: Medium]
Can gating on PCI_FUNC(ha->pdev->devfn) cause port_no collisions under
multi-function VFIO passthrough?

When vfio_config_init() virtualizes PCI_INTERRUPT_PIN to 0, guest function
0 reads ctrl_status here while non-zero guest functions keep the virtual
PCI_FUNC() assigned in qla2x00_set_isp_flags().

If physical ports 1 and 0 are passed as guest .0 and .1, both get
ha->port_no == 1, read the same NVRAM/VPD, and log in with duplicate
WWPNs.  On ISP8031 FCoE functions (2 and 3), keeping PCI_FUNC() misses
FLT_REG_FCOE_NVRAM_0/1 in qla2xxx_get_flt_info().

Bare-metal adapters have a non-zero PCI_INTERRUPT_PIN, so checking only
if (pin) would preserve bare metal while resolving all VFIO functions from
ctrl_status consistently.

> +
> +	reg = &ha->iobase->isp24;
> +	csr = rd_reg_dword(&reg->ctrl_status);

[Severity: Low]
Should csr be checked against ISP_REG_DISCONNECT (0xffffffffU) before
decoding the port bits?

Under Hyper-V DDA, hv_pci_read_config() emulates PCI_INTERRUPT_PIN as 0,
so probe reaches rd_reg_dword(&reg->ctrl_status) even on a disconnected
link.  27xx/28xx/29xx reject 0xffffffffU as out of range, but other FWI2
adapters see CSRX_FUNCTION set and silently set ha->port_no/portnum to 1.

> +
> +	if (IS_QLA27XX(ha) || IS_QLA28XX(ha) || IS_QLA29XX(ha)) {
> +		port = (csr & CSRX_PORT_MASK) >> CSRX_PORT_SHIFT;
> +		if (port > 3) {
> +			ql_log_pci(ql_log_warn, ha->pdev, 0x00e2,
> +			    "port %u from ctrl_status=0x%x is out of range.\n",
> +			    port, csr);
> +			return;
> +		}
> +		ha->port_no = port;
> +		ql_log_pci(ql_log_info, ha->pdev, 0x00e1,
> +		    "port %u ctrl_status=0x%x replaces the INTx pin.\n",
> +		    port, csr);
> +		return;
> +	}
> +
> +	ha->port_no = (csr & CSRX_FUNCTION) ? 1 : 0;
> +	ha->portnum = ha->port_no;

[Severity: Medium]
Can setting ha->portnum = ha->port_no corrupt shared IDC state on ISP8031?

On ISP8031 CNAs, ha->portnum is the physical PCI function ID, not the 0/1
FCoE port index: functions 0 and 1 are NIC functions (qlcnic), while FCoE
uses higher functions in QLA83XX_DEV_PARTINFO1/2.  Setting ha->portnum = 1
collides with NIC function 1 in shared IDC presence and lock registers.

When both FCoE ports are passed through without NIC drivers, bits 0 and 1
are set in QLA83XX_IDC_DRV_PRESENCE while qla83xx_reset_ownership() masks
only ha->portnum and the real FCoE function, so neither port becomes
nic_core_reset_owner and NIC core reset times out into QLA8XXX_DEV_FAILED.

Only IS_QLA2031(ha) maps FC ports 0 and 1 to PCI functions 0 and 1, so
this assignment should exclude IS_QLA8031(ha).

> +	if (IS_QLA25XX(ha))
> +		ql_log_pci(ql_log_info, ha->pdev, 0x00e1,
> +		    "25xx port %u ctrl_status=0x%x replaces the INTx pin.\n",
> +		    ha->port_no, csr);
> +	else
> +		ql_log_pci(ql_log_info, ha->pdev, 0x00e1,
> +		    "pin and function are 0; ctrl_status=0x%x port=%u.\n",
> +		    csr, ha->port_no);
> +}

[Severity: Low]
Do these ql_log_pci() calls reuse already-allocated message IDs 0x00e1 and
0x00e2?

Both IDs are already used in drivers/scsi/qla2xxx/qla_mid.c
(qla25xx_create_rsp_que()), and the Module Init and Probe table in
drivers/scsi/qla2xxx/qla_dbg.c is allocated through 0x0199.  New probe
messages should use fresh IDs past 0x0199 and update that table.

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

  reply	other threads:[~2026-12-03  9:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  9:17 [PATCH] scsi: qla2xxx: Take the port from ISP control/status Nilesh Javali
2026-12-03  9:40 ` sashiko-bot [this message]
2026-12-03 13:24 ` Laurence Oberman

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-247490@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.