Linux-HyperV List
 help / color / mirror / Atom feed
From: Laurence Oberman <loberman@redhat.com>
To: Hamza Mahfooz <hamza@kernel.org>, linux-hyperv@vger.kernel.org
Cc: "Haiyang Zhang" <haiyangz@microsoft.com>,
	"Wei Liu" <wei.liu@kernel.org>,
	"Dexuan Cui" <decui@microsoft.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Jake Oshins" <jakeo@microsoft.com>,
	linux-pci@vger.kernel.org,
	"Michael Kelley" <mhklinux@outlook.com>,
	stable@vger.kernel.org, "Asher Kariv" <askariv@microsoft.com>,
	"Mukesh R" <mrathor@linux.microsoft.com>,
	njavali@marvell.com, GR-QLogic-Storage-Upstream@marvell.com,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3] PCI: hv: Hardwire PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN to 0
Date: Wed, 02 Dec 2026 16:06:19 -0500	[thread overview]
Message-ID: <5eb3294725c5b0be0d397aa830baec13341320ca.camel@redhat.com> (raw)
In-Reply-To: <20261202144345.275647-1-hamza@kernel.org>

On Wed, 2026-12-02 at 09:43 -0500, Hamza Mahfooz wrote:
> Hyper-V Discrete Device Assignment (DDA) does not support legacy
> (INTx)
> interrupts.
> 
> The current code recognizes PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN
> reads and forces a zero value, but only for 8 bit reads. If a 16 or
> 32
> bit read overlaps these fields, they may be returned as a non-zero
> value. Fix this by recognizing such overlap, and forcing the
> PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN bytes to zero while
> retaining
> the adjacent bytes returned by the host/HW.
> 
> Cc: stable@vger.kernel.org
> Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for
> Microsoft Hyper-V VMs")
> Co-developed-by: Asher Kariv <askariv@microsoft.com>
> Signed-off-by: Asher Kariv <askariv@microsoft.com>
> Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>
> Signed-off-by: Wei Liu <wei.liu@kernel.org>
> Signed-off-by: Hamza Mahfooz <hamza@kernel.org>
> ---
> v2:
> - Fix a compilation error
> v3:
> - Capitalize "Hardwire" in the subject. (Michael)
> - Add description/comment clarifications. (Michael)
> - Also hardwire PCI_INTERRUPT_LINE to 0 for 16 and 32 bit reads.
> (Michael)
> - Emulate 16 bit reads of PCI_INTERRUPT_LINE/PCI_INTERRUPT_PIN, and
> clear
>   the low 16 bits of 32 bit reads instead of writing through a char
>   pointer.
> ---
>  drivers/pci/controller/pci-hyperv.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/pci-hyperv.c
> b/drivers/pci/controller/pci-hyperv.c
> index 824cf27e85e6..05a528df7a51 100644
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -1213,8 +1213,7 @@ static void _hv_pcifront_read_config(struct
> hv_pci_dev *hpdev, int where,
>  		   PCI_CAPABILITY_LIST) {
>  		/* ROM BARs are unimplemented */
>  		*val = 0;
> -	} else if ((where >= PCI_INTERRUPT_LINE && where + size <=
> PCI_INTERRUPT_PIN) ||
> -		   (where >= PCI_INTERRUPT_PIN && where + size <=
> PCI_MIN_GNT)) {
> +	} else if (where >= PCI_INTERRUPT_LINE && where + size <=
> PCI_MIN_GNT) {
>  		/*
>  		 * Interrupt Line and Interrupt PIN are hard-wired
> to zero
>  		 * because this front-end only supports message-
> signaled
> @@ -1256,6 +1255,14 @@ static void _hv_pcifront_read_config(struct
> hv_pci_dev *hpdev, int where,
>  			mb();
>  		}
>  		spin_unlock_irqrestore(&hbus->config_lock, flags);
> +
> +		/*
> +		 * Make sure PCI_INTERRUPT_LINE and
> PCI_INTERRUPT_PIN are
> +		 * hard-wired to 0, since they may be included in a
> 32 bit
> +		 * read, which is skipped by the above emulation.
> +		 */
> +		if (where == PCI_INTERRUPT_LINE)
> +			*val &= ~0xffff;
>  	} else {
>  		dev_err(dev, "Attempt to read beyond a function's
> config space.\n");
>  	}
Hi Hamza,

No objection to this change.

For the record, it affects qla2xxx under DDA. The driver uses
PCI_INTERRUPT_PIN to identify the physical port of a multi-port HBA,
which selects that port's NVRAM and WWPN. With the pin reading 0 and
every function presented as function 0, all ports get port 0's WWPN.
I described this earlier in [1].

Nilesh (Marvell, Cc'd) has a qla2xxx fix that reads the physical port
from the ISP control/status register in the HBA's MMIO space instead of
from PCI config space, so it is not affected by this patch. I tested it
today on an ISP2281 with the DDA conditions simulated (pin and function
forced to 0): with the fix each port gets its own WWPN; without it both
ports report port 0's WWPN and the second port never comes up on the
fabric. Nilesh will post it to linux-scsi.

Since this patch is tagged for stable, the qla2xxx fix should go to
stable as well. Otherwise multi-port QLogic HBAs in DDA guests on
stable kernels will end up with duplicate WWPNs.

[1] https://lore.kernel.org/linux-hyperv/<your RFC message-id>/

Thanks,
Laurence

      reply	other threads:[~2026-12-02 21:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 14:43 [PATCH v3] PCI: hv: Hardwire PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN to 0 Hamza Mahfooz
2026-12-02 21:06 ` Laurence Oberman [this message]

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=5eb3294725c5b0be0d397aa830baec13341320ca.camel@redhat.com \
    --to=loberman@redhat.com \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=askariv@microsoft.com \
    --cc=bhelgaas@google.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hamza@kernel.org \
    --cc=jakeo@microsoft.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=mrathor@linux.microsoft.com \
    --cc=njavali@marvell.com \
    --cc=robh@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wei.liu@kernel.org \
    /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