From 72bb75a360ce05bfc94ff0fbecda2e2d094e3d84 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Mon, 9 Aug 2021 17:02:27 +0200 Subject: [PATCH] pcie: msi: fix MSI-X fallback to MSI When enabling MSI & MSI-X, the code seemed to handle fallback to MSI when MSI-X is not available, but the logic uses MSI-X even if not available and the MSI path never gets used. Fixes: a2491b321e ("drivers/pcie: Add support for MSI-X") Signed-off-by: Neil Armstrong --- drivers/pcie/host/msi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pcie/host/msi.c b/drivers/pcie/host/msi.c index fae96c560ae..a19d7a364b6 100644 --- a/drivers/pcie/host/msi.c +++ b/drivers/pcie/host/msi.c @@ -125,11 +125,9 @@ uint8_t pcie_msi_vectors_allocate(pcie_bdf_t bdf, base_msix = pcie_get_cap(bdf, PCIE_MSIX_CAP_ID); if (base_msix != 0U) { + msi = false; base = base_msix; } - - msi = false; - base = base_msix; } if (IS_ENABLED(CONFIG_PCIE_MSI_X)) { @@ -279,9 +277,10 @@ bool pcie_msi_enable(pcie_bdf_t bdf, if ((base_msix != 0U) && (base != 0U)) { disable_msi(bdf, base); } - - msi = false; - base = base_msix; + if ((base_msix != 0U)) { + msi = false; + base = base_msix; + } } if (base == 0U) {