Skip to content

Commit c444cc3

Browse files
noaosgregkh
authored andcommitted
PCI: Support INTx masking on ConnectX-4 with firmware x.14.1100+
commit 1600f62 upstream. Mellanox devices were marked as having INTx masking ability broken. As a result, the VFIO driver fails to start when more than one device function is passed-through to a VM if both have the same INTx pin. Prior to Connect-IB, Mellanox devices exposed to the operating system one PCI function per all ports. Starting from Connect-IB, the devices are function-per-port. When passing the second function to a VM, VFIO will fail to start. Exclude ConnectX-4, ConnectX4-Lx and Connect-IB from the list of Mellanox devices marked as having broken INTx masking: - ConnectX-4 and ConnectX4-LX firmware version is checked. If INTx masking is supported, we unmark the broken INTx masking. - Connect-IB does not support INTx currently so will not cause any problem. [bhelgaas: call pci_disable_device() always, after iounmap()] Fixes: 11e4253 ("PCI: Assume all Mellanox devices have broken INTx masking") Signed-off-by: Noa Osherovich <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Or Gerlitz <[email protected]> Reviewed-by: Gavin Shan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e282290 commit c444cc3

File tree

1 file changed

+56
-3
lines changed

1 file changed

+56
-3
lines changed

drivers/pci/quirks.c

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3209,13 +3209,25 @@ static u16 mellanox_broken_intx_devs[] = {
32093209
PCI_DEVICE_ID_MELLANOX_CONNECTX2,
32103210
PCI_DEVICE_ID_MELLANOX_CONNECTX3,
32113211
PCI_DEVICE_ID_MELLANOX_CONNECTX3_PRO,
3212-
PCI_DEVICE_ID_MELLANOX_CONNECTIB,
3213-
PCI_DEVICE_ID_MELLANOX_CONNECTX4,
3214-
PCI_DEVICE_ID_MELLANOX_CONNECTX4_LX,
32153212
};
32163213

3214+
#define CONNECTX_4_CURR_MAX_MINOR 99
3215+
#define CONNECTX_4_INTX_SUPPORT_MINOR 14
3216+
3217+
/*
3218+
* Check ConnectX-4/LX FW version to see if it supports legacy interrupts.
3219+
* If so, don't mark it as broken.
3220+
* FW minor > 99 means older FW version format and no INTx masking support.
3221+
* FW minor < 14 means new FW version format and no INTx masking support.
3222+
*/
32173223
static void mellanox_check_broken_intx_masking(struct pci_dev *pdev)
32183224
{
3225+
__be32 __iomem *fw_ver;
3226+
u16 fw_major;
3227+
u16 fw_minor;
3228+
u16 fw_subminor;
3229+
u32 fw_maj_min;
3230+
u32 fw_sub_min;
32193231
int i;
32203232

32213233
for (i = 0; i < ARRAY_SIZE(mellanox_broken_intx_devs); i++) {
@@ -3224,6 +3236,47 @@ static void mellanox_check_broken_intx_masking(struct pci_dev *pdev)
32243236
return;
32253237
}
32263238
}
3239+
3240+
/* Getting here means Connect-IB cards and up. Connect-IB has no INTx
3241+
* support so shouldn't be checked further
3242+
*/
3243+
if (pdev->device == PCI_DEVICE_ID_MELLANOX_CONNECTIB)
3244+
return;
3245+
3246+
if (pdev->device != PCI_DEVICE_ID_MELLANOX_CONNECTX4 &&
3247+
pdev->device != PCI_DEVICE_ID_MELLANOX_CONNECTX4_LX)
3248+
return;
3249+
3250+
/* For ConnectX-4 and ConnectX-4LX, need to check FW support */
3251+
if (pci_enable_device_mem(pdev)) {
3252+
dev_warn(&pdev->dev, "Can't enable device memory\n");
3253+
return;
3254+
}
3255+
3256+
fw_ver = ioremap(pci_resource_start(pdev, 0), 4);
3257+
if (!fw_ver) {
3258+
dev_warn(&pdev->dev, "Can't map ConnectX-4 initialization segment\n");
3259+
goto out;
3260+
}
3261+
3262+
/* Reading from resource space should be 32b aligned */
3263+
fw_maj_min = ioread32be(fw_ver);
3264+
fw_sub_min = ioread32be(fw_ver + 1);
3265+
fw_major = fw_maj_min & 0xffff;
3266+
fw_minor = fw_maj_min >> 16;
3267+
fw_subminor = fw_sub_min & 0xffff;
3268+
if (fw_minor > CONNECTX_4_CURR_MAX_MINOR ||
3269+
fw_minor < CONNECTX_4_INTX_SUPPORT_MINOR) {
3270+
dev_warn(&pdev->dev, "ConnectX-4: FW %u.%u.%u doesn't support INTx masking, disabling. Please upgrade FW to %d.14.1100 and up for INTx support\n",
3271+
fw_major, fw_minor, fw_subminor, pdev->device ==
3272+
PCI_DEVICE_ID_MELLANOX_CONNECTX4 ? 12 : 14);
3273+
pdev->broken_intx_masking = 1;
3274+
}
3275+
3276+
iounmap(fw_ver);
3277+
3278+
out:
3279+
pci_disable_device(pdev);
32273280
}
32283281
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID,
32293282
mellanox_check_broken_intx_masking);

0 commit comments

Comments
 (0)