]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
VT-d: have set_msi_source_id() return a success indicator
authorJan Beulich <jbeulich@suse.com>
Fri, 14 Mar 2025 09:18:34 +0000 (10:18 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 14 Mar 2025 09:18:34 +0000 (10:18 +0100)
Handling possible internal errors by just emitting a (debug-build-only)
log message can't be quite enough. Return error codes in those cases,
and have the caller propagate those up.

Drop a pointless return path, rather than "inventing" an error code for
it.

While touching the function declarator anyway also constify its first
parameter.

Fixes: 476bbccc811c ("VT-d: fix MSI source-id of interrupt remapping")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/drivers/passthrough/vtd/intremap.c

index b2f5b4a65acfeb9d5098ee57da0ed86e4a101c6f..81394ef4529908f97e2a9a1b2cfff6b8aacacdcf 100644 (file)
@@ -436,15 +436,13 @@ void cf_check io_apic_write_remap_rte(
     __ioapic_write_entry(apic, pin, true, old_rte);
 }
 
-static void set_msi_source_id(struct pci_dev *pdev, struct iremap_entry *ire)
+static int set_msi_source_id(const struct pci_dev *pdev,
+                             struct iremap_entry *ire)
 {
     u16 seg;
     u8 bus, devfn, secbus;
     int ret;
 
-    if ( !pdev || !ire )
-        return;
-
     seg = pdev->seg;
     bus = pdev->bus;
     devfn = pdev->devfn;
@@ -485,16 +483,21 @@ static void set_msi_source_id(struct pci_dev *pdev, struct iremap_entry *ire)
                             PCI_BDF(bus, devfn));
         }
         else
+        {
             dprintk(XENLOG_WARNING VTDPREFIX,
                     "d%d: no upstream bridge for %pp\n",
                     pdev->domain->domain_id, &pdev->sbdf);
+            return -ENXIO;
+        }
         break;
 
     default:
         dprintk(XENLOG_WARNING VTDPREFIX, "d%d: unknown(%u): %pp\n",
                 pdev->domain->domain_id, pdev->type, &pdev->sbdf);
-        break;
-   }
+        return -EOPNOTSUPP;
+    }
+
+    return 0;
 }
 
 static int msi_msg_to_remap_entry(
@@ -509,7 +512,12 @@ static int msi_msg_to_remap_entry(
     bool alloc = false;
 
     if ( pdev )
-        set_msi_source_id(pdev, &new_ire);
+    {
+        int rc = set_msi_source_id(pdev, &new_ire);
+
+        if ( rc )
+            return rc;
+    }
     else
         set_hpet_source_id(msi_desc->hpet_id, &new_ire);