]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
x86/msi: Extend per-domain/device warning mechanism
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Fri, 10 May 2024 03:53:21 +0000 (05:53 +0200)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 10 May 2024 23:13:43 +0000 (00:13 +0100)
The arch_msix struct had a single "warned" field with a domid for which
warning was issued. Upcoming patch will need similar mechanism for few
more warnings, so change it to save a bit field of issued warnings.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/include/asm/msi.h
xen/arch/x86/msi.c

index 997ccb87be0c9a925595eb11c0d2ed6abbc47ee2..b64cb93c0c3fc84432664efaad6864bfb888c836 100644 (file)
@@ -208,6 +208,16 @@ struct msg_address {
                                        PCI_MSIX_ENTRY_SIZE + \
                                        (~PCI_MSIX_BIRMASK & (PAGE_SIZE - 1)))
 
+#define MSIX_CHECK_WARN(msix, domid, which)                             \
+    ({                                                                  \
+        if ( (msix)->warned_domid != (domid) )                          \
+        {                                                               \
+            (msix)->warned_domid = (domid);                             \
+            (msix)->warned_kind.all = 0;                                \
+        }                                                               \
+        (msix)->warned_kind.which ? false : ((msix)->warned_kind.which = true); \
+    })
+
 struct arch_msix {
     unsigned int nr_entries, used_entries;
     struct {
@@ -217,7 +227,13 @@ struct arch_msix {
     int table_idx[MAX_MSIX_TABLE_PAGES];
     spinlock_t table_lock;
     bool host_maskall, guest_maskall;
-    domid_t warned;
+    domid_t warned_domid;
+    union {
+        uint8_t all;
+        struct {
+            bool maskall                   : 1;
+        };
+    } warned_kind;
 };
 
 void early_msi_init(void);
index 3009ce109f5e2750641b41abb9f4a59f937a5bb8..fb0fab60f14ee5f9dfaa4609113e3964c7758308 100644 (file)
@@ -364,13 +364,10 @@ static bool msi_set_mask_bit(struct irq_desc *desc, bool host, bool guest)
             domid_t domid = pdev->domain->domain_id;
 
             maskall = true;
-            if ( pdev->msix->warned != domid )
-            {
-                pdev->msix->warned = domid;
+            if ( MSIX_CHECK_WARN(pdev->msix, domid, maskall) )
                 printk(XENLOG_G_WARNING
                        "cannot mask IRQ %d: masking MSI-X on Dom%d's %pp\n",
                        desc->irq, domid, &pdev->sbdf);
-            }
         }
         pdev->msix->host_maskall = maskall;
         if ( maskall || pdev->msix->guest_maskall )