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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/io/pcplusmp/apic_introp.c
          +++ new/usr/src/uts/i86pc/io/pcplusmp/apic_introp.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright 2013 Pluribus Networks, Inc.
       24 + * Copyright 2017 Joyent, Inc.
  24   25   */
  25   26  
  26   27  /*
  27   28   * apic_introp.c:
  28   29   *      Has code for Advanced DDI interrupt framework support.
  29   30   */
  30   31  
  31   32  #include <sys/cpuvar.h>
  32   33  #include <sys/psm.h>
  33   34  #include <sys/archsystm.h>
  34   35  #include <sys/apic.h>
  35   36  #include <sys/sunddi.h>
  36   37  #include <sys/ddi_impldefs.h>
  37   38  #include <sys/mach_intr.h>
  38   39  #include <sys/sysmacros.h>
  39   40  #include <sys/trap.h>
  40   41  #include <sys/pci.h>
  41   42  #include <sys/pci_intr_lib.h>
  42   43  #include <sys/apic_common.h>
  43   44  
       45 +#define UCHAR_MAX       UINT8_MAX
       46 +
  44   47  extern struct av_head autovect[];
  45   48  
  46   49  /*
  47   50   *      Local Function Prototypes
  48   51   */
  49   52  apic_irq_t      *apic_find_irq(dev_info_t *, struct intrspec *, int);
  50   53  
  51   54  /*
  52   55   * apic_pci_msi_enable_vector:
  53   56   *      Set the address/data fields in the MSI/X capability structure
↓ open down ↓ 165 lines elided ↑ open up ↑
 219  222                   * multiple MSIs
 220  223                   */
 221  224                  if (msibits)
 222  225                          i = (i + msibits) & ~msibits;
 223  226                  start = i;
 224  227                  while ((apic_vector_to_irq[i] == APIC_RESV_IRQ) &&
 225  228                      (i <= highest)) {
 226  229                          if (APIC_CHECK_RESERVE_VECTORS(i))
 227  230                                  break;
 228  231                          navail++;
 229      -                        if (navail >= count)
 230      -                                return (start);
      232 +                        if (navail >= count) {
      233 +                                ASSERT(start >= 0 && start <= UCHAR_MAX);
      234 +                                return ((uchar_t)start);
      235 +                        }
 231  236                          i++;
 232  237                  }
 233  238          }
 234  239          return (0);
 235  240  }
 236  241  
 237  242  
 238  243  /*
 239  244   * It finds the apic_irq_t associates with the dip, ispec and type.
 240  245   */
↓ open down ↓ 257 lines elided ↑ open up ↑
 498  503  
 499  504  static int
 500  505  apic_grp_set_cpu(int irqno, int new_cpu, int *result)
 501  506  {
 502  507          dev_info_t *orig_dip;
 503  508          uint32_t orig_cpu;
 504  509          ulong_t iflag;
 505  510          apic_irq_t *irqps[PCI_MSI_MAX_INTRS];
 506  511          int i;
 507  512          int cap_ptr;
 508      -        int msi_mask_off;
      513 +        int msi_mask_off = 0;
 509  514          ushort_t msi_ctrl;
 510      -        uint32_t msi_pvm;
      515 +        uint32_t msi_pvm = 0;
 511  516          ddi_acc_handle_t handle;
 512  517          int num_vectors = 0;
 513  518          uint32_t vector;
 514  519  
 515  520          DDI_INTR_IMPLDBG((CE_CONT, "APIC_GRP_SET_CPU\n"));
 516  521  
 517  522          /*
 518  523           * Take mutex to insure that table doesn't change out from underneath
 519  524           * us while we're playing with it.
 520  525           */
↓ open down ↓ 113 lines elided ↑ open up ↑
 634  639                  return (PSM_FAILURE);
 635  640  
 636  641          return (PSM_SUCCESS);
 637  642  }
 638  643  
 639  644  int
 640  645  apic_get_vector_intr_info(int vecirq, apic_get_intr_t *intr_params_p)
 641  646  {
 642  647          struct autovec *av_dev;
 643  648          uchar_t irqno;
 644      -        int i;
      649 +        uint i;
 645  650          apic_irq_t *irq_p;
 646  651  
 647  652          /* Sanity check the vector/irq argument. */
 648  653          ASSERT((vecirq >= 0) || (vecirq <= APIC_MAX_VECTOR));
 649  654  
 650  655          mutex_enter(&airq_mutex);
 651  656  
 652  657          /*
 653  658           * Convert the vecirq arg to an irq using vector_to_irq table
 654  659           * if the arg is a vector.  Pass thru if already an irq.
 655  660           */
 656  661          if ((intr_params_p->avgi_req_flags & PSMGI_INTRBY_FLAGS) ==
 657  662              PSMGI_INTRBY_VEC)
 658  663                  irqno = apic_vector_to_irq[vecirq];
 659  664          else
 660      -                irqno = vecirq;
      665 +                irqno = (uchar_t)vecirq;
 661  666  
 662  667          irq_p = apic_irq_table[irqno];
 663  668  
 664  669          if ((irq_p == NULL) ||
 665  670              ((irq_p->airq_mps_intr_index != RESERVE_INDEX) &&
 666  671              ((irq_p->airq_temp_cpu == IRQ_UNBOUND) ||
 667  672              (irq_p->airq_temp_cpu == IRQ_UNINIT)))) {
 668  673                  mutex_exit(&airq_mutex);
 669  674                  return (PSM_FAILURE);
 670  675          }
↓ open down ↓ 22 lines elided ↑ open up ↑
 693  698  
 694  699                  intr_params_p->avgi_req_flags  |= PSMGI_REQ_NUM_DEVS;
 695  700  
 696  701                  /* Some devices have NULL dip.  Don't count these. */
 697  702                  if (intr_params_p->avgi_num_devs > 0) {
 698  703                          for (i = 0, av_dev = autovect[irqno].avh_link;
 699  704                              av_dev; av_dev = av_dev->av_link)
 700  705                                  if (av_dev->av_vector && av_dev->av_dip)
 701  706                                          i++;
 702  707                          intr_params_p->avgi_num_devs =
 703      -                            MIN(intr_params_p->avgi_num_devs, i);
      708 +                            (uchar_t)MIN(intr_params_p->avgi_num_devs, i);
 704  709                  }
 705  710  
 706  711                  /* There are no viable dips to return. */
 707  712                  if (intr_params_p->avgi_num_devs == 0)
 708  713                          intr_params_p->avgi_dip_list = NULL;
 709  714  
 710  715                  else {  /* Return list of dips */
 711  716  
 712  717                          /* Allocate space in array for that number of devs. */
 713  718                          intr_params_p->avgi_dip_list = kmem_zalloc(
↓ open down ↓ 237 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX