From 2b5b60fe0db0f526fd3ff926593df6fc550174a7 Mon Sep 17 00:00:00 2001 From: Marcin Wojtas Date: Thu, 30 May 2019 13:22:12 +0000 Subject: [PATCH] Check for number of MSI-x upon partial allocation in ENA The ENA driver needs at least 2 MSI-x - one for admin queue, and one for IO queues pair. If there were not enough resources to allocate more than one MSI-x, the device should not be attached. Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc. --- sys/dev/ena/ena.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index a742bf51e13..d03db819f8e 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -1865,6 +1865,14 @@ ena_enable_msix(struct ena_adapter *adapter) } if (msix_vecs != msix_req) { + if (msix_vecs == ENA_ADMIN_MSIX_VEC) { + device_printf(dev, + "Not enough number of MSI-x allocated: %d\n", + msix_vecs); + pci_release_msi(dev); + rc = ENOSPC; + goto err_msix_free; + } device_printf(dev, "Enable only %d MSI-x (out of %d), reduce " "the number of queues\n", msix_vecs, msix_req); adapter->num_queues = msix_vecs - ENA_ADMIN_MSIX_VEC;