Skip to contentSkip to conversation

x86/MSI: drop local cpumask_t variable from msi_compose_msg()

PATCH In review Jan Beulich 2 participants 4 messages Oct 14, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/MSI: drop local cpumask_t variable from msi_compose_msg()

The function gets called only during initialization/resume (when no other CPUs are running) or with the IRQ descriptor lock held, so there's no way for the CPU mask to change under its feet.

xen/arch/x86/msi.c +3 -5
@@ -123,18 +123,16 @@ static void msix_put_fixmap(struct pci_d
 void msi_compose_msg(struct irq_desc *desc, struct msi_msg *msg)
 {
     unsigned dest;
-    cpumask_t domain;
     struct irq_cfg *cfg = desc->chip_data;
     int vector = cfg->vector;
-    domain = cfg->cpu_mask;
 
-    if ( cpus_empty( domain ) ) {
+    if ( cpus_empty(cfg->cpu_mask) ) {
         dprintk(XENLOG_ERR,"%s, compose msi message error!!\n", __func__);
-	    return;
+        return;
     }
 
     if ( vector ) {
-        dest = cpu_mask_to_apicid(&domain);
+        dest = cpu_mask_to_apicid(&cfg->cpu_mask);
 
         msg->address_hi = MSI_ADDR_BASE_HI;
         msg->address_lo =
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jan Beulich

The function gets called only during initialization/resume (when no other CPUs are running) or with the IRQ descriptor lock held, so there's no way for the CPU mask to change under its feet.

I wonder whether the cpus_empty() check should be a BUG_ON. Or an ASSERT pushed into cpu_mask_to_apicid.

-- Keir

Quoted 32 lines
xen/arch/x86/msi.c +3 -5
@@ -123,18 +123,16 @@ static void msix_put_fixmap(struct pci_d
 void msi_compose_msg(struct irq_desc *desc, struct msi_msg *msg)
 {
     unsigned dest;
-    cpumask_t domain;
     struct irq_cfg *cfg = desc->chip_data;
     int vector = cfg->vector;
-    domain = cfg->cpu_mask;
 
-    if ( cpus_empty( domain ) ) {
+    if ( cpus_empty(cfg->cpu_mask) ) {
         dprintk(XENLOG_ERR,"%s, compose msi message error!!\n", __func__);
-     return;
+        return;
     }
 
     if ( vector ) {
-        dest = cpu_mask_to_apicid(&domain);
+        dest = cpu_mask_to_apicid(&cfg->cpu_mask);
 
         msg->address_hi = MSI_ADDR_BASE_HI;
         msg->address_lo =

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 4 lines · Jan Beulich

The function gets called only during initialization/resume (when no other CPUs are running) or with the IRQ descriptor lock held, so there's no way for the CPU mask to change under its feet.

Quoted 6 lines
Quoted 1 line

I wonder whether the cpus_empty() check should be a BUG_ON. Or an ASSERT pushed into cpu_mask_to_apicid.

An ASSERT may be reasonable, but simply dropping the check here may be too - no other code path invoking cpu_mask_to_apicid() has a similar check.

Jan

Quoted 34 lines

-- Keir

Quoted 32 lines
xen/arch/x86/msi.c +3 -5
@@ -123,18 +123,16 @@ static void msix_put_fixmap(struct pci_d
 void msi_compose_msg(struct irq_desc *desc, struct msi_msg *msg)
 {
     unsigned dest;
-    cpumask_t domain;
     struct irq_cfg *cfg = desc->chip_data;
     int vector = cfg->vector;
-    domain = cfg->cpu_mask;
 
-    if ( cpus_empty( domain ) ) {
+    if ( cpus_empty(cfg->cpu_mask) ) {
         dprintk(XENLOG_ERR,"%s, compose msi message error!!\n", __func__);
-     return;
+        return;
     }
 
     if ( vector ) {
-        dest = cpu_mask_to_apicid(&domain);
+        dest = cpu_mask_to_apicid(&cfg->cpu_mask);
 
         msg->address_hi = MSI_ADDR_BASE_HI;
         msg->address_lo =

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 6 lines · Jan Beulich
Quoted 2 lines

I wonder whether the cpus_empty() check should be a BUG_ON. Or an ASSERT pushed into cpu_mask_to_apicid.

An ASSERT may be reasonable, but simply dropping the check here may be too - no other code path invoking cpu_mask_to_apicid() has a similar check.

It is certainly not valid to call cpu_mask_to_apicid with an empty mask. Hence an ASSERT would check that precondition, and for all callers.

-- Keir