Print this page
8626 make pcplusmp and apix warning-free
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

@@ -18,10 +18,11 @@
  *
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2017 Joyent, Inc.
  */
 /*
  * Copyright (c) 2010, Intel Corporation.
  * All rights reserved.
  */

@@ -642,11 +643,11 @@
                         hwpri -= (APIC_BASE_VECT >> APIC_IPL_SHIFT);
 
                         ASSERT(hwpri >= 0);
                         ASSERT(hwpri < MAXIPL);
                         max_ipl = apic_vectortoipl[hwpri];
-                        apic_ipls[apic_ipls_index] = max_ipl;
+                        apic_ipls[apic_ipls_index] = (uchar_t)max_ipl;
 
                         irqp = irqheadptr;
                         while (irqp) {
                                 irqp->airq_ipl = (uchar_t)max_ipl;
                                 irqp = irqp->airq_next;

@@ -1048,23 +1049,26 @@
  */
 static int
 apic_setup_irq_table(dev_info_t *dip, int irqno, struct apic_io_intr *intrp,
     struct intrspec *ispec, iflag_t *intr_flagp, int type)
 {
-        int origirq = ispec->intrspec_vec;
-        uchar_t ipl = ispec->intrspec_pri;
+        int origirq;
+        uchar_t ipl;
         int     newirq, intr_index;
         uchar_t ipin, ioapic, ioapicindex, vector;
         apic_irq_t *irqptr;
         major_t major;
         dev_info_t      *sdip;
 
+        ASSERT(ispec != NULL);
+
+        origirq = ispec->intrspec_vec;
+        ipl = ispec->intrspec_pri;
+
         DDI_INTR_IMPLDBG((CE_CONT, "apic_setup_irq_table: dip=0x%p type=%d "
             "irqno=0x%x origirq=0x%x\n", (void *)dip, type, irqno, origirq));
 
-        ASSERT(ispec != NULL);
-
         major =  (dip != NULL) ? ddi_driver_major(dip) : 0;
 
         if (DDI_INTR_IS_MSI_OR_MSIX(type)) {
                 /* MSI/X doesn't need to setup ioapic stuffs */
                 ioapicindex = 0xff;

@@ -1119,14 +1123,11 @@
                 ioapic = apic_io_id[ioapicindex];
                 ipin = (uchar_t)irqno;
                 intr_index = DEFAULT_INDEX;
         }
 
-        if (ispec == NULL) {
-                APIC_VERBOSE_IOAPIC((CE_WARN, "No intrspec for irqno = %x\n",
-                    irqno));
-        } else if ((vector = apic_allocate_vector(ipl, irqno, 0)) == 0) {
+        if ((vector = apic_allocate_vector(ipl, irqno, 0)) == 0) {
                 if ((newirq = apic_share_vector(irqno, intr_flagp, intr_index,
                     ipl, ioapicindex, ipin, &irqptr)) != -1) {
                         irqptr->airq_ipl = ipl;
                         irqptr->airq_origirq = (uchar_t)origirq;
                         irqptr->airq_dip = dip;

@@ -1226,31 +1227,39 @@
                 return (IRQ_UNBOUND);
 
         if (apic_nproc == 1)
                 return (0);
 
-        drv_name = NULL;
-        rc = DDI_PROP_NOT_FOUND;
-        major = (major_t)-1;
-        if (dip != NULL) {
+        if (dip == NULL) {
+                iflag = intr_clear();
+                lock_set(&apic_ioapic_lock);
+                bind_cpu = apic_get_next_bind_cpu();
+                lock_clear(&apic_ioapic_lock);
+                intr_restore(iflag);
+
+                cmn_err(CE_CONT, "!%s: irq 0x%x "
+                    "vector 0x%x ioapic 0x%x intin 0x%x is bound to cpu %d\n",
+                    psm_name, irq, apic_irq_table[irq]->airq_vector, ioapicid,
+                    intin, bind_cpu & ~IRQ_USER_BOUND);
+
+                return ((uint32_t)bind_cpu);
+        }
+
                 name = ddi_get_name(dip);
                 major = ddi_name_to_major(name);
                 drv_name = ddi_major_to_name(major);
                 instance = ddi_get_instance(dip);
                 if (apic_intr_policy == INTR_ROUND_ROBIN_WITH_AFFINITY) {
                         i = apic_min_device_irq;
                         for (; i <= apic_max_device_irq; i++) {
-
                                 if ((i == irq) || (apic_irq_table[i] == NULL) ||
                                     (apic_irq_table[i]->airq_mps_intr_index
                                     == FREE_INDEX))
                                         continue;
 
                                 if ((apic_irq_table[i]->airq_major == major) &&
-                                    (!(apic_irq_table[i]->airq_cpu &
-                                    IRQ_USER_BOUND))) {
-
+                            (!(apic_irq_table[i]->airq_cpu & IRQ_USER_BOUND))) {
                                         cpu = apic_irq_table[i]->airq_cpu;
 
                                         cmn_err(CE_CONT,
                                             "!%s: %s (%s) instance #%d "
                                             "irq 0x%x vector 0x%x ioapic 0x%x "

@@ -1280,11 +1289,10 @@
                     (caddr_t)&prop_val, &prop_len);
                 if (rc != DDI_PROP_SUCCESS) {
                         rc = ddi_getlongprop(DDI_DEV_T_ANY, dip, 0,
                             "intpt_bind_cpus", (caddr_t)&prop_val, &prop_len);
                 }
-        }
         if (rc == DDI_PROP_SUCCESS) {
                 for (i = count = 0; i < (prop_len - 1); i++)
                         if (prop_val[i] == ',')
                                 count++;
                 if (prop_val[i-1] != ',')

@@ -1315,29 +1323,24 @@
                 /*
                  * no need to check apic_cpus[].aci_status, if specific CPU is
                  * not up, then post_cpu_start will handle it.
                  */
         }
+
         if (rc != DDI_PROP_SUCCESS) {
                 iflag = intr_clear();
                 lock_set(&apic_ioapic_lock);
                 bind_cpu = apic_get_next_bind_cpu();
                 lock_clear(&apic_ioapic_lock);
                 intr_restore(iflag);
         }
 
-        if (drv_name != NULL)
                 cmn_err(CE_CONT, "!%s: %s (%s) instance %d irq 0x%x "
                     "vector 0x%x ioapic 0x%x intin 0x%x is bound to cpu %d\n",
                     psm_name, name, drv_name, instance, irq,
                     apic_irq_table[irq]->airq_vector, ioapicid, intin,
                     bind_cpu & ~IRQ_USER_BOUND);
-        else
-                cmn_err(CE_CONT, "!%s: irq 0x%x "
-                    "vector 0x%x ioapic 0x%x intin 0x%x is bound to cpu %d\n",
-                    psm_name, irq, apic_irq_table[irq]->airq_vector, ioapicid,
-                    intin, bind_cpu & ~IRQ_USER_BOUND);
 
         return ((uint32_t)bind_cpu);
 }
 
 /*