Print this page


Split Close
Expand all
Collapse all
          --- old/./mr_sas.c
          +++ new/./mr_sas.c
↓ open down ↓ 4 lines elided ↑ open up ↑
   5    5   * Copyright (c) 2008-2012, LSI Logic Corporation.
   6    6   * All rights reserved.
   7    7   *
   8    8   * Version:
   9    9   * Author:
  10   10   *              Swaminathan K S
  11   11   *              Arun Chandrashekhar
  12   12   *              Manju R
  13   13   *              Rasheed
  14   14   *              Shakeel Bukhari
       15 + *
       16 + * Redistribution and use in source and binary forms, with or without
       17 + * modification, are permitted provided that the following conditions are met:
       18 + *
       19 + * 1. Redistributions of source code must retain the above copyright notice,
       20 + *    this list of conditions and the following disclaimer.
       21 + *
       22 + * 2. Redistributions in binary form must reproduce the above copyright notice,
       23 + *    this list of conditions and the following disclaimer in the documentation
       24 + *    and/or other materials provided with the distribution.
       25 + *
       26 + * 3. Neither the name of the author nor the names of its contributors may be
       27 + *    used to endorse or promote products derived from this software without
       28 + *    specific prior written permission.
       29 + *
       30 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
       31 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
       32 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
       33 + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
       34 + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
       35 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
       36 + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
       37 + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
       38 + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
       39 + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
       40 + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
       41 + * DAMAGE.
  15   42   */
  16   43  
       44 +/*
       45 + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
       46 + * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
       47 + * Copyright 2012 Nexenta System, Inc. All rights reserved.
       48 + */
       49 +
  17   50  #include <sys/types.h>
  18   51  #include <sys/param.h>
  19   52  #include <sys/file.h>
  20   53  #include <sys/errno.h>
  21   54  #include <sys/open.h>
  22   55  #include <sys/cred.h>
  23   56  #include <sys/modctl.h>
  24   57  #include <sys/conf.h>
  25   58  #include <sys/devops.h>
  26   59  #include <sys/cmn_err.h>
↓ open down ↓ 6 lines elided ↑ open up ↑
  33   66  #include <sys/sunddi.h>
  34   67  #include <sys/atomic.h>
  35   68  #include <sys/signal.h>
  36   69  #include <sys/byteorder.h>
  37   70  #include <sys/sdt.h>
  38   71  #include <sys/fs/dv_node.h>     /* devfs_clean */
  39   72  
  40   73  #include "mr_sas.h"
  41   74  
  42   75  /*
       76 + * FMA header files
       77 + */
       78 +#include <sys/ddifm.h>
       79 +#include <sys/fm/protocol.h>
       80 +#include <sys/fm/util.h>
       81 +#include <sys/fm/io/ddi.h>
       82 +
       83 +/*
  43   84   * Local static data
  44   85   */
  45   86  static void     *mrsas_state = NULL;
  46      -static volatile boolean_t       mrsas_relaxed_ordering = 0;
  47      -volatile int    debug_level_g = CL_NONE;
       87 +static volatile boolean_t       mrsas_relaxed_ordering = B_TRUE;
       88 +volatile int    debug_level_g = CL_NONE;
       89 +static volatile int     msi_enable = 1;
       90 +static volatile int     ctio_enable = 1;
  48   91  
  49      -static volatile int     msi_enable = 1;
  50      -
  51   92  /* Default Timeout value to issue online controller reset */
  52      -volatile int  debug_timeout_g  = 0xF0;          //0xB4;
       93 +volatile int  debug_timeout_g  = 0xF0;          /* 0xB4; */
  53   94  /* Simulate consecutive firmware fault */
  54   95  static volatile int  debug_fw_faults_after_ocr_g  = 0;
  55   96  #ifdef OCRDEBUG
  56   97  /* Simulate three consecutive timeout for an IO */
  57   98  static volatile int  debug_consecutive_timeout_after_ocr_g  = 0;
  58   99  #endif
  59  100  
  60      -/* Enable OCR on firmware fault */
  61      -static volatile int  debug_support_ocr_isr_g  = 0;
  62  101  #pragma weak scsi_hba_open
  63  102  #pragma weak scsi_hba_close
  64  103  #pragma weak scsi_hba_ioctl
  65  104  
      105 +/* Local static prototypes. */
      106 +static int      mrsas_getinfo(dev_info_t *, ddi_info_cmd_t,  void *, void **);
      107 +static int      mrsas_attach(dev_info_t *, ddi_attach_cmd_t);
      108 +#ifdef __sparc
      109 +static int      mrsas_reset(dev_info_t *, ddi_reset_cmd_t);
      110 +#else
      111 +static int      mrsas_quiesce(dev_info_t *);
      112 +#endif
      113 +static int      mrsas_detach(dev_info_t *, ddi_detach_cmd_t);
      114 +static int      mrsas_open(dev_t *, int, int, cred_t *);
      115 +static int      mrsas_close(dev_t, int, int, cred_t *);
      116 +static int      mrsas_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
  66  117  
      118 +static int      mrsas_tran_tgt_init(dev_info_t *, dev_info_t *,
      119 +                    scsi_hba_tran_t *, struct scsi_device *);
      120 +static struct scsi_pkt *mrsas_tran_init_pkt(struct scsi_address *, register
      121 +                    struct scsi_pkt *, struct buf *, int, int, int, int,
      122 +                    int (*)(), caddr_t);
      123 +static int      mrsas_tran_start(struct scsi_address *,
      124 +                    register struct scsi_pkt *);
      125 +static int      mrsas_tran_abort(struct scsi_address *, struct scsi_pkt *);
      126 +static int      mrsas_tran_reset(struct scsi_address *, int);
      127 +static int      mrsas_tran_getcap(struct scsi_address *, char *, int);
      128 +static int      mrsas_tran_setcap(struct scsi_address *, char *, int, int);
      129 +static void     mrsas_tran_destroy_pkt(struct scsi_address *,
      130 +                    struct scsi_pkt *);
      131 +static void     mrsas_tran_dmafree(struct scsi_address *, struct scsi_pkt *);
      132 +static void     mrsas_tran_sync_pkt(struct scsi_address *, struct scsi_pkt *);
      133 +static int      mrsas_tran_quiesce(dev_info_t *dip);
      134 +static int      mrsas_tran_unquiesce(dev_info_t *dip);
      135 +static uint_t   mrsas_isr();
      136 +static uint_t   mrsas_softintr();
      137 +static void     mrsas_undo_resources(dev_info_t *, struct mrsas_instance *);
      138 +static struct mrsas_cmd *get_mfi_pkt(struct mrsas_instance *);
      139 +static void     return_mfi_pkt(struct mrsas_instance *,
      140 +                    struct mrsas_cmd *);
  67  141  
      142 +static void     free_space_for_mfi(struct mrsas_instance *);
      143 +static uint32_t read_fw_status_reg_ppc(struct mrsas_instance *);
      144 +static void     issue_cmd_ppc(struct mrsas_cmd *, struct mrsas_instance *);
      145 +static int      issue_cmd_in_poll_mode_ppc(struct mrsas_instance *,
      146 +                    struct mrsas_cmd *);
      147 +static int      issue_cmd_in_sync_mode_ppc(struct mrsas_instance *,
      148 +                    struct mrsas_cmd *);
      149 +static void     enable_intr_ppc(struct mrsas_instance *);
      150 +static void     disable_intr_ppc(struct mrsas_instance *);
      151 +static int      intr_ack_ppc(struct mrsas_instance *);
      152 +static void     flush_cache(struct mrsas_instance *instance);
      153 +void    display_scsi_inquiry(caddr_t);
      154 +static int      start_mfi_aen(struct mrsas_instance *instance);
      155 +static int      handle_drv_ioctl(struct mrsas_instance *instance,
      156 +                    struct mrsas_ioctl *ioctl, int mode);
      157 +static int      handle_mfi_ioctl(struct mrsas_instance *instance,
      158 +                    struct mrsas_ioctl *ioctl, int mode);
      159 +static int      handle_mfi_aen(struct mrsas_instance *instance,
      160 +                    struct mrsas_aen *aen);
      161 +static struct mrsas_cmd *build_cmd(struct mrsas_instance *,
      162 +    struct scsi_address *, struct scsi_pkt *, uchar_t *);
      163 +static int      alloc_additional_dma_buffer(struct mrsas_instance *);
      164 +static void     complete_cmd_in_sync_mode(struct mrsas_instance *,
      165 +                struct mrsas_cmd *);
      166 +static int      mrsas_kill_adapter(struct mrsas_instance *);
      167 +static int      mrsas_issue_init_mfi(struct mrsas_instance *);
      168 +static int      mrsas_reset_ppc(struct mrsas_instance *);
      169 +static uint32_t mrsas_initiate_ocr_if_fw_is_faulty(struct mrsas_instance *);
      170 +static int      wait_for_outstanding(struct mrsas_instance *instance);
      171 +static int      register_mfi_aen(struct mrsas_instance *instance,
      172 +                    uint32_t seq_num, uint32_t class_locale_word);
      173 +static int      issue_mfi_pthru(struct mrsas_instance *instance, struct
      174 +                    mrsas_ioctl *ioctl, struct mrsas_cmd *cmd, int mode);
      175 +static int      issue_mfi_dcmd(struct mrsas_instance *instance, struct
      176 +                    mrsas_ioctl *ioctl, struct mrsas_cmd *cmd, int mode);
      177 +static int      issue_mfi_smp(struct mrsas_instance *instance, struct
      178 +                    mrsas_ioctl *ioctl, struct mrsas_cmd *cmd, int mode);
      179 +static int      issue_mfi_stp(struct mrsas_instance *instance, struct
      180 +                    mrsas_ioctl *ioctl, struct mrsas_cmd *cmd, int mode);
      181 +static int      abort_aen_cmd(struct mrsas_instance *instance,
      182 +                    struct mrsas_cmd *cmd_to_abort);
      183 +
      184 +static void     mrsas_rem_intrs(struct mrsas_instance *instance);
      185 +static int      mrsas_add_intrs(struct mrsas_instance *instance, int intr_type);
      186 +
      187 +static void     mrsas_tran_tgt_free(dev_info_t *, dev_info_t *,
      188 +                    scsi_hba_tran_t *, struct scsi_device *);
      189 +static int      mrsas_tran_bus_config(dev_info_t *, uint_t,
      190 +                    ddi_bus_config_op_t, void *, dev_info_t **);
      191 +static int      mrsas_parse_devname(char *, int *, int *);
      192 +static int      mrsas_config_all_devices(struct mrsas_instance *);
      193 +static int      mrsas_config_ld(struct mrsas_instance *, uint16_t,
      194 +                        uint8_t, dev_info_t **);
      195 +static int      mrsas_name_node(dev_info_t *, char *, int);
      196 +static void     mrsas_issue_evt_taskq(struct mrsas_eventinfo *);
      197 +static void     free_additional_dma_buffer(struct mrsas_instance *);
      198 +static void io_timeout_checker(void *);
      199 +static void mrsas_fm_init(struct mrsas_instance *);
      200 +static void mrsas_fm_fini(struct mrsas_instance *);
      201 +
  68  202  static struct mrsas_function_template mrsas_function_template_ppc = {
  69  203          .read_fw_status_reg = read_fw_status_reg_ppc,
  70  204          .issue_cmd = issue_cmd_ppc,
  71  205          .issue_cmd_in_sync_mode = issue_cmd_in_sync_mode_ppc,
  72  206          .issue_cmd_in_poll_mode = issue_cmd_in_poll_mode_ppc,
  73  207          .enable_intr = enable_intr_ppc,
  74  208          .disable_intr = disable_intr_ppc,
  75  209          .intr_ack = intr_ack_ppc,
  76  210          .init_adapter = mrsas_init_adapter_ppc
  77      -//      .reset_adapter = mrsas_reset_adapter_ppc
  78  211  };
  79  212  
  80  213  
  81  214  static struct mrsas_function_template mrsas_function_template_fusion = {
  82  215          .read_fw_status_reg = tbolt_read_fw_status_reg,
  83  216          .issue_cmd = tbolt_issue_cmd,
  84  217          .issue_cmd_in_sync_mode = tbolt_issue_cmd_in_sync_mode,
  85  218          .issue_cmd_in_poll_mode = tbolt_issue_cmd_in_poll_mode,
  86  219          .enable_intr = tbolt_enable_intr,
  87  220          .disable_intr = tbolt_disable_intr,
  88  221          .intr_ack = tbolt_intr_ack,
  89  222          .init_adapter = mrsas_init_adapter_tbolt
  90      -//      .reset_adapter = mrsas_reset_adapter_tbolt
  91  223  };
  92  224  
  93  225  
  94  226  ddi_dma_attr_t mrsas_generic_dma_attr = {
  95  227          DMA_ATTR_V0,            /* dma_attr_version */
  96  228          0,                      /* low DMA address range */
  97  229          0xFFFFFFFFU,            /* high DMA address range */
  98      -        0xFFFFFFFFU,            /* DMA counter register  */
      230 +        0xFFFFFFFFU,            /* DMA counter register  */
  99  231          8,                      /* DMA address alignment */
 100  232          0x07,                   /* DMA burstsizes  */
 101  233          1,                      /* min DMA size */
 102  234          0xFFFFFFFFU,            /* max DMA size */
 103  235          0xFFFFFFFFU,            /* segment boundary */
 104  236          MRSAS_MAX_SGE_CNT,      /* dma_attr_sglen */
 105  237          512,                    /* granularity of device */
 106  238          0                       /* bus specific DMA flags */
 107  239  };
 108  240  
 109  241  int32_t mrsas_max_cap_maxxfer = 0x1000000;
 110  242  
 111      -//Fix for: Thunderbolt controller IO timeout when IO write size is 1MEG, Limit size to 256K
      243 +/*
      244 + * Fix for: Thunderbolt controller IO timeout when IO write size is 1MEG,
      245 + * Limit size to 256K
      246 + */
 112  247  uint32_t mrsas_tbolt_max_cap_maxxfer = (512 * 512);
 113  248  
 114  249  /*
 115  250   * cb_ops contains base level routines
 116  251   */
 117  252  static struct cb_ops mrsas_cb_ops = {
 118  253          mrsas_open,             /* open */
 119  254          mrsas_close,            /* close */
 120  255          nodev,                  /* strategy */
 121  256          nodev,                  /* print */
↓ open down ↓ 17 lines elided ↑ open up ↑
 139  274   * dev_ops contains configuration routines
 140  275   */
 141  276  static struct dev_ops mrsas_ops = {
 142  277          DEVO_REV,               /* rev, */
 143  278          0,                      /* refcnt */
 144  279          mrsas_getinfo,          /* getinfo */
 145  280          nulldev,                /* identify */
 146  281          nulldev,                /* probe */
 147  282          mrsas_attach,           /* attach */
 148  283          mrsas_detach,           /* detach */
 149      -#if defined(__SunOS_5_11)
 150      -        nodev,
 151      -#else
      284 +#ifdef  __sparc
 152  285          mrsas_reset,            /* reset */
 153      -#endif  /* defined(__SunOS_5_11) */
      286 +#else   /* __sparc */
      287 +        nodev,
      288 +#endif  /* __sparc */
 154  289          &mrsas_cb_ops,          /* char/block ops */
 155  290          NULL,                   /* bus ops */
 156  291          NULL,                   /* power */
 157      -#ifdef __SunOS_5_11
      292 +#ifdef __sparc
      293 +        ddi_quiesce_not_needed
      294 +#else   /* __sparc */
 158  295          mrsas_quiesce   /* quiesce */
 159      -#endif /*__SunOS_5_11 */
 160      -
      296 +#endif  /* __sparc */
 161  297  };
 162  298  
 163      -char _depends_on[] = "misc/scsi";
 164      -
 165  299  static struct modldrv modldrv = {
 166  300          &mod_driverops,         /* module type - driver */
 167  301          MRSAS_VERSION,
 168  302          &mrsas_ops,             /* driver ops */
 169  303  };
 170  304  
 171  305  static struct modlinkage modlinkage = {
 172  306          MODREV_1,       /* ml_rev - must be MODREV_1 */
 173  307          &modldrv,       /* ml_linkage */
 174  308          NULL            /* end of driver linkage */
 175  309  };
 176  310  
 177  311  static struct ddi_device_acc_attr endian_attr = {
 178  312          DDI_DEVICE_ATTR_V1,
 179  313          DDI_STRUCTURE_LE_ACC,
 180  314          DDI_STRICTORDER_ACC,
 181  315          DDI_DEFAULT_ACC
 182  316  };
 183  317  
 184      -
      318 +/* Use the LSI Fast Path for the 2208 (tbolt) commands. */
 185  319  unsigned int enable_fp = 1;
 186  320  
 187  321  
 188  322  /*
 189  323   * ************************************************************************** *
 190      - *                                                                            *
 191      - *         common entry points - for loadable kernel modules                  *
 192      - *                                                                            *
      324 + *                                                                            *
      325 + *         common entry points - for loadable kernel modules                  *
      326 + *                                                                            *
 193  327   * ************************************************************************** *
 194  328   */
 195  329  
 196  330  /*
 197  331   * _init - initialize a loadable module
 198  332   * @void
 199  333   *
 200  334   * The driver should perform any one-time resource allocation or data
 201  335   * initialization during driver loading in _init(). For example, the driver
 202  336   * should initialize any mutexes global to the driver in this routine.
↓ open down ↓ 55 lines elided ↑ open up ↑
 258  392   * In _fini(), the driver should release any resources that were allocated in
 259  393   * _init(). The driver must remove itself from the system module list.
 260  394   */
 261  395  int
 262  396  _fini(void)
 263  397  {
 264  398          int ret;
 265  399  
 266  400          con_log(CL_ANN1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
 267  401  
 268      -        if ((ret = mod_remove(&modlinkage)) != DDI_SUCCESS)
 269      -        {
 270      -                con_log(CL_ANN1, (CE_WARN, "_fini: mod_remove() failed, error 0x%X", ret));
      402 +        if ((ret = mod_remove(&modlinkage)) != DDI_SUCCESS) {
      403 +                con_log(CL_ANN1,
      404 +                    (CE_WARN, "_fini: mod_remove() failed, error 0x%X", ret));
 271  405                  return (ret);
 272  406          }
 273  407  
 274  408          scsi_hba_fini(&modlinkage);
 275  409          con_log(CL_DLEVEL1, (CE_NOTE, "_fini: scsi_hba_fini() done."));
 276  410  
 277  411          ddi_soft_state_fini(&mrsas_state);
 278  412          con_log(CL_DLEVEL1, (CE_NOTE, "_fini: ddi_soft_state_fini() done."));
 279  413  
 280  414          return (ret);
 281  415  }
 282  416  
 283  417  
 284  418  /*
 285  419   * ************************************************************************** *
 286      - *                                                                            *
 287      - *               common entry points - for autoconfiguration                  *
 288      - *                                                                            *
      420 + *                                                                            *
      421 + *               common entry points - for autoconfiguration                  *
      422 + *                                                                            *
 289  423   * ************************************************************************** *
 290  424   */
 291  425  /*
 292  426   * attach - adds a device to the system as part of initialization
 293  427   * @dip:
 294  428   * @cmd:
 295  429   *
 296  430   * The kernel calls a driver's attach() entry point to attach an instance of
 297  431   * a device (for MegaRAID, it is instance of a controller) or to resume
 298  432   * operation for an instance of a device that has been suspended or has been
↓ open down ↓ 5 lines elided ↑ open up ↑
 304  438   * - initialize per-instance mutexes
 305  439   * - initialize condition variables
 306  440   * - register the device's interrupts (for MegaRAID, controller's interrupts)
 307  441   * - map the registers and memory of the device instance (for MegaRAID,
 308  442   *   controller instance)
 309  443   * - create minor device nodes for the device instance (for MegaRAID,
 310  444   *   controller instance)
 311  445   * - report that the device instance (for MegaRAID, controller instance) has
 312  446   *   attached
 313  447   */
 314      -#if       __SunOS_5_11
 315      -#define   DDI_PM_RESUME DDI_PM_RESUME_OBSOLETE
 316      -#define   DDI_PM_SUSPEND DDI_PM_SUSPEND_OBSOLETE
 317      -#endif // __SunOS_5_11
 318  448  static int
 319  449  mrsas_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
 320  450  {
 321  451          int             instance_no;
 322  452          int             nregs;
 323  453          int             i = 0;
 324      -        uint8_t         irq;
      454 +        uint8_t         irq;
 325  455          uint16_t        vendor_id;
 326  456          uint16_t        device_id;
 327  457          uint16_t        subsysvid;
 328  458          uint16_t        subsysid;
 329  459          uint16_t        command;
 330  460          off_t           reglength = 0;
 331  461          int             intr_types = 0;
 332  462          char            *data;
 333  463  
 334  464          scsi_hba_tran_t         *tran;
 335      -        ddi_dma_attr_t  tran_dma_attr;
      465 +        ddi_dma_attr_t  tran_dma_attr;
 336  466          struct mrsas_instance   *instance;
 337  467  
 338  468          con_log(CL_ANN1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
 339  469  
 340  470          /* CONSTCOND */
 341  471          ASSERT(NO_COMPETING_THREADS);
 342  472  
 343  473          instance_no = ddi_get_instance(dip);
 344  474  
 345  475          /*
 346  476           * check to see whether this device is in a DMA-capable slot.
 347  477           */
 348  478          if (ddi_slaveonly(dip) == DDI_SUCCESS) {
 349  479                  cmn_err(CE_WARN,
 350  480                      "mr_sas%d: Device in slave-only slot, unused",
 351  481                      instance_no);
 352  482                  return (DDI_FAILURE);
 353  483          }
 354  484  
 355  485          switch (cmd) {
 356      -                case DDI_ATTACH:
      486 +        case DDI_ATTACH:
      487 +                /* allocate the soft state for the instance */
      488 +                if (ddi_soft_state_zalloc(mrsas_state, instance_no)
      489 +                    != DDI_SUCCESS) {
      490 +                        cmn_err(CE_WARN,
      491 +                            "mr_sas%d: Failed to allocate soft state",
      492 +                            instance_no);
      493 +                        return (DDI_FAILURE);
      494 +                }
 357  495  
 358      -                        /* allocate the soft state for the instance */
 359      -                        if (ddi_soft_state_zalloc(mrsas_state, instance_no)
 360      -                            != DDI_SUCCESS) {
 361      -                                cmn_err(CE_WARN,
 362      -                                    "mr_sas%d: Failed to allocate soft state",
 363      -                                    instance_no);
      496 +                instance = (struct mrsas_instance *)ddi_get_soft_state
      497 +                    (mrsas_state, instance_no);
 364  498  
 365      -                                return (DDI_FAILURE);
 366      -                        }
      499 +                if (instance == NULL) {
      500 +                        cmn_err(CE_WARN,
      501 +                            "mr_sas%d: Bad soft state", instance_no);
      502 +                        ddi_soft_state_free(mrsas_state, instance_no);
      503 +                        return (DDI_FAILURE);
      504 +                }
 367  505  
 368      -                        instance = (struct mrsas_instance *)ddi_get_soft_state
 369      -                            (mrsas_state, instance_no);
      506 +                instance->unroll.softs  = 1;
 370  507  
 371      -                        if (instance == NULL) {
 372      -                                cmn_err(CE_WARN,
 373      -                                    "mr_sas%d: Bad soft state", instance_no);
      508 +                /* Setup the PCI configuration space handles */
      509 +                if (pci_config_setup(dip, &instance->pci_handle) !=
      510 +                    DDI_SUCCESS) {
      511 +                        cmn_err(CE_WARN,
      512 +                            "mr_sas%d: pci config setup failed ",
      513 +                            instance_no);
 374  514  
 375      -                                ddi_soft_state_free(mrsas_state, instance_no);
      515 +                        ddi_soft_state_free(mrsas_state, instance_no);
      516 +                        return (DDI_FAILURE);
      517 +                }
 376  518  
 377      -                                return (DDI_FAILURE);
 378      -                        }
      519 +                if (ddi_dev_nregs(dip, &nregs) != DDI_SUCCESS) {
      520 +                        cmn_err(CE_WARN,
      521 +                            "mr_sas: failed to get registers.");
 379  522  
 380      -                        bzero((caddr_t)instance,
 381      -                            sizeof (struct mrsas_instance));
      523 +                        pci_config_teardown(&instance->pci_handle);
      524 +                        ddi_soft_state_free(mrsas_state, instance_no);
      525 +                        return (DDI_FAILURE);
      526 +                }
 382  527  
 383      -                        instance->unroll.softs  = 1;
      528 +                vendor_id = pci_config_get16(instance->pci_handle,
      529 +                    PCI_CONF_VENID);
      530 +                device_id = pci_config_get16(instance->pci_handle,
      531 +                    PCI_CONF_DEVID);
 384  532  
 385      -                        /* Setup the PCI configuration space handles */
 386      -                        if (pci_config_setup(dip, &instance->pci_handle) !=
 387      -                            DDI_SUCCESS) {
 388      -                                cmn_err(CE_WARN,
 389      -                                    "mr_sas%d: pci config setup failed ",
 390      -                                    instance_no);
      533 +                subsysvid = pci_config_get16(instance->pci_handle,
      534 +                    PCI_CONF_SUBVENID);
      535 +                subsysid = pci_config_get16(instance->pci_handle,
      536 +                    PCI_CONF_SUBSYSID);
 391  537  
 392      -                                ddi_soft_state_free(mrsas_state, instance_no);
 393      -                                return (DDI_FAILURE);
 394      -                        }
 395      -                        if (instance->pci_handle == NULL) {
 396      -                                cmn_err(CE_WARN,
 397      -                                    "mr_sas%d: pci config setup failed ",
 398      -                                    instance_no);
 399      -                                ddi_soft_state_free(mrsas_state, instance_no);
 400      -                                return (DDI_FAILURE);
 401      -                        }
      538 +                pci_config_put16(instance->pci_handle, PCI_CONF_COMM,
      539 +                    (pci_config_get16(instance->pci_handle,
      540 +                    PCI_CONF_COMM) | PCI_COMM_ME));
      541 +                irq = pci_config_get8(instance->pci_handle,
      542 +                    PCI_CONF_ILINE);
 402  543  
      544 +                con_log(CL_DLEVEL1, (CE_CONT, "mr_sas%d: "
      545 +                    "0x%x:0x%x 0x%x:0x%x, irq:%d drv-ver:%s",
      546 +                    instance_no, vendor_id, device_id, subsysvid,
      547 +                    subsysid, irq, MRSAS_VERSION));
 403  548  
      549 +                /* enable bus-mastering */
      550 +                command = pci_config_get16(instance->pci_handle,
      551 +                    PCI_CONF_COMM);
 404  552  
 405      -                        if (ddi_dev_nregs(dip, &nregs) != DDI_SUCCESS) {
 406      -                                cmn_err(CE_WARN,
 407      -                                    "mr_sas: failed to get registers.");
      553 +                if (!(command & PCI_COMM_ME)) {
      554 +                        command |= PCI_COMM_ME;
 408  555  
 409      -                                pci_config_teardown(&instance->pci_handle);
 410      -                                ddi_soft_state_free(mrsas_state, instance_no);
 411      -                                return (DDI_FAILURE);
 412      -                        }
      556 +                        pci_config_put16(instance->pci_handle,
      557 +                            PCI_CONF_COMM, command);
 413  558  
 414      -                        vendor_id = pci_config_get16(instance->pci_handle,
 415      -                            PCI_CONF_VENID);
 416      -                        device_id = pci_config_get16(instance->pci_handle,
 417      -                            PCI_CONF_DEVID);
      559 +                        con_log(CL_ANN, (CE_CONT, "mr_sas%d: "
      560 +                            "enable bus-mastering", instance_no));
      561 +                } else {
      562 +                        con_log(CL_DLEVEL1, (CE_CONT, "mr_sas%d: "
      563 +                            "bus-mastering already set", instance_no));
      564 +                }
 418  565  
 419      -                        subsysvid = pci_config_get16(instance->pci_handle,
 420      -                            PCI_CONF_SUBVENID);
 421      -                        subsysid = pci_config_get16(instance->pci_handle,
 422      -                            PCI_CONF_SUBSYSID);
      566 +                /* initialize function pointers */
      567 +                switch (device_id) {
      568 +                case PCI_DEVICE_ID_LSI_TBOLT:
      569 +                case PCI_DEVICE_ID_LSI_INVADER:
      570 +                        con_log(CL_ANN, (CE_NOTE,
      571 +                            "mr_sas: 2208 T.B. device detected"));
 423  572  
 424      -                        pci_config_put16(instance->pci_handle, PCI_CONF_COMM,
 425      -                            (pci_config_get16(instance->pci_handle,
 426      -                            PCI_CONF_COMM) | PCI_COMM_ME));
 427      -                        irq = pci_config_get8(instance->pci_handle,
 428      -                            PCI_CONF_ILINE);
      573 +                        instance->func_ptr =
      574 +                            &mrsas_function_template_fusion;
      575 +                        instance->tbolt = 1;
      576 +                        break;
 429  577  
 430      -                        con_log(CL_DLEVEL1, (CE_CONT, "mr_sas%d: "
 431      -                            "0x%x:0x%x 0x%x:0x%x, irq:%d drv-ver:%s",
 432      -                            instance_no, vendor_id, device_id, subsysvid,
 433      -                            subsysid, irq, MRSAS_VERSION));
      578 +                case PCI_DEVICE_ID_LSI_2108VDE:
      579 +                case PCI_DEVICE_ID_LSI_2108V:
      580 +                        con_log(CL_ANN, (CE_NOTE,
      581 +                            "mr_sas: 2108 Liberator device detected"));
 434  582  
 435      -                        /* enable bus-mastering */
 436      -                        command = pci_config_get16(instance->pci_handle,
 437      -                            PCI_CONF_COMM);
      583 +                        instance->func_ptr =
      584 +                            &mrsas_function_template_ppc;
      585 +                        break;
 438  586  
 439      -                        if (!(command & PCI_COMM_ME)) {
 440      -                                command |= PCI_COMM_ME;
      587 +                default:
      588 +                        cmn_err(CE_WARN,
      589 +                            "mr_sas: Invalid device detected");
 441  590  
 442      -                                pci_config_put16(instance->pci_handle,
 443      -                                    PCI_CONF_COMM, command);
      591 +                        pci_config_teardown(&instance->pci_handle);
      592 +                        ddi_soft_state_free(mrsas_state, instance_no);
      593 +                        return (DDI_FAILURE);
      594 +                }
 444  595  
 445      -                                con_log(CL_ANN, (CE_CONT, "mr_sas%d: "
 446      -                                    "enable bus-mastering", instance_no));
 447      -                        } else {
 448      -                                con_log(CL_DLEVEL1, (CE_CONT, "mr_sas%d: "
 449      -                                "bus-mastering already set", instance_no));
 450      -                        }
      596 +                instance->baseaddress = pci_config_get32(
      597 +                    instance->pci_handle, PCI_CONF_BASE0);
      598 +                instance->baseaddress &= 0x0fffc;
 451  599  
 452      -                        /* initialize function pointers */
 453      -                       switch(device_id) {
 454      -                                case PCI_DEVICE_ID_LSI_TBOLT:
 455      -                                case PCI_DEVICE_ID_LSI_INVADER:
 456      -                                        con_log(CL_ANN, (CE_NOTE,
 457      -                                            "mr_sas: 2208 T.B. device detected"));
      600 +                instance->dip           = dip;
      601 +                instance->vendor_id     = vendor_id;
      602 +                instance->device_id     = device_id;
      603 +                instance->subsysvid     = subsysvid;
      604 +                instance->subsysid      = subsysid;
      605 +                instance->instance      = instance_no;
 458  606  
 459      -                                        instance->func_ptr = &mrsas_function_template_fusion;
 460      -                                        instance->tbolt = 1;
 461      -                                        break;
      607 +                /* Initialize FMA */
      608 +                instance->fm_capabilities = ddi_prop_get_int(
      609 +                    DDI_DEV_T_ANY, instance->dip, DDI_PROP_DONTPASS,
      610 +                    "fm-capable", DDI_FM_EREPORT_CAPABLE |
      611 +                    DDI_FM_ACCCHK_CAPABLE | DDI_FM_DMACHK_CAPABLE
      612 +                    | DDI_FM_ERRCB_CAPABLE);
 462  613  
 463      -                                case PCI_DEVICE_ID_LSI_2108VDE:
 464      -                                case PCI_DEVICE_ID_LSI_2108V:
 465      -                                        con_log(CL_ANN, (CE_NOTE,
 466      -                                            "mr_sas: 2108 Liberator device detected"));
      614 +                mrsas_fm_init(instance);
 467  615  
 468      -                                        instance->func_ptr = &mrsas_function_template_ppc;
 469      -                                        break;
      616 +                /* Setup register map */
      617 +                if ((ddi_dev_regsize(instance->dip,
      618 +                    REGISTER_SET_IO_2108, &reglength) != DDI_SUCCESS) ||
      619 +                    reglength < MINIMUM_MFI_MEM_SZ) {
      620 +                        goto fail_attach;
      621 +                }
      622 +                if (reglength > DEFAULT_MFI_MEM_SZ) {
      623 +                        reglength = DEFAULT_MFI_MEM_SZ;
      624 +                        con_log(CL_DLEVEL1, (CE_NOTE,
      625 +                            "mr_sas: register length to map is 0x%lx bytes",
      626 +                            reglength));
      627 +                }
      628 +                if (ddi_regs_map_setup(instance->dip,
      629 +                    REGISTER_SET_IO_2108, &instance->regmap, 0,
      630 +                    reglength, &endian_attr, &instance->regmap_handle)
      631 +                    != DDI_SUCCESS) {
      632 +                        cmn_err(CE_WARN,
      633 +                            "mr_sas: couldn't map control registers");
      634 +                        goto fail_attach;
      635 +                }
 470  636  
 471      -                                default:
 472      -                                        cmn_err(CE_WARN,
 473      -                                            "mr_sas: Invalid device detected");
      637 +                instance->unroll.regs = 1;
 474  638  
 475      -                                        pci_config_teardown(&instance->pci_handle);
 476      -                                        ddi_soft_state_free(mrsas_state, instance_no);
 477      -                                        return (DDI_FAILURE);
      639 +                /*
      640 +                 * Disable Interrupt Now.
      641 +                 * Setup Software interrupt
      642 +                 */
      643 +                instance->func_ptr->disable_intr(instance);
 478  644  
 479      -                        }
      645 +                if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, 0,
      646 +                    "mrsas-enable-msi", &data) == DDI_SUCCESS) {
      647 +                        if (strncmp(data, "no", 3) == 0) {
      648 +                                msi_enable = 0;
      649 +                                con_log(CL_ANN1, (CE_WARN,
      650 +                                    "msi_enable = %d disabled", msi_enable));
      651 +                        }
      652 +                        ddi_prop_free(data);
      653 +                }
 480  654  
 481      -                        instance->baseaddress = pci_config_get32(
 482      -                            instance->pci_handle, PCI_CONF_BASE0);
 483      -                        instance->baseaddress &= 0x0fffc;
      655 +                con_log(CL_DLEVEL1, (CE_NOTE, "msi_enable = %d", msi_enable));
 484  656  
 485      -                        instance->dip           = dip;
 486      -                        instance->vendor_id     = vendor_id;
 487      -                        instance->device_id     = device_id;
 488      -                        instance->subsysvid     = subsysvid;
 489      -                        instance->subsysid      = subsysid;
 490      -                        instance->instance      = instance_no;
      657 +                if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, 0,
      658 +                    "mrsas-enable-fp", &data) == DDI_SUCCESS) {
      659 +                        if (strncmp(data, "no", 3) == 0) {
      660 +                                enable_fp = 0;
      661 +                                cmn_err(CE_NOTE,
      662 +                                    "enable_fp = %d, Fast-Path disabled.\n",
      663 +                                    enable_fp);
      664 +                        }
 491  665  
      666 +                        ddi_prop_free(data);
      667 +                }
 492  668  
 493      -                        /* Setup register map */
 494      -                        if ((ddi_dev_regsize(instance->dip,
 495      -                            REGISTER_SET_IO_2108, &reglength) != DDI_SUCCESS) ||
 496      -                            reglength < MINIMUM_MFI_MEM_SZ) {
      669 +                con_log(CL_DLEVEL1, (CE_NOTE, "enable_fp = %d\n", enable_fp));
      670 +
      671 +                /* Check for all supported interrupt types */
      672 +                if (ddi_intr_get_supported_types(
      673 +                    dip, &intr_types) != DDI_SUCCESS) {
      674 +                        cmn_err(CE_WARN,
      675 +                            "ddi_intr_get_supported_types() failed");
      676 +                        goto fail_attach;
      677 +                }
      678 +
      679 +                con_log(CL_DLEVEL1, (CE_NOTE,
      680 +                    "ddi_intr_get_supported_types() ret: 0x%x", intr_types));
      681 +
      682 +                /* Initialize and Setup Interrupt handler */
      683 +                if (msi_enable && (intr_types & DDI_INTR_TYPE_MSIX)) {
      684 +                        if (mrsas_add_intrs(instance, DDI_INTR_TYPE_MSIX) !=
      685 +                            DDI_SUCCESS) {
      686 +                                cmn_err(CE_WARN,
      687 +                                    "MSIX interrupt query failed");
 497  688                                  goto fail_attach;
 498  689                          }
 499      -                        if (reglength > DEFAULT_MFI_MEM_SZ) {
 500      -                                reglength = DEFAULT_MFI_MEM_SZ;
 501      -                                con_log(CL_DLEVEL1, (CE_NOTE,
 502      -                                    "mr_sas: register length to map is "
 503      -                                    "0x%lx bytes", reglength));
 504      -                        }
 505      -                        if (ddi_regs_map_setup(instance->dip,
 506      -                            REGISTER_SET_IO_2108, &instance->regmap, 0,
 507      -                            reglength, &endian_attr, &instance->regmap_handle)
 508      -                            != DDI_SUCCESS) {
      690 +                        instance->intr_type = DDI_INTR_TYPE_MSIX;
      691 +                } else if (msi_enable && (intr_types & DDI_INTR_TYPE_MSI)) {
      692 +                        if (mrsas_add_intrs(instance, DDI_INTR_TYPE_MSI) !=
      693 +                            DDI_SUCCESS) {
 509  694                                  cmn_err(CE_WARN,
 510      -                                    "mr_sas: couldn't map control registers");
      695 +                                    "MSI interrupt query failed");
 511  696                                  goto fail_attach;
 512  697                          }
 513      -                        if (instance->regmap_handle == NULL) {
      698 +                        instance->intr_type = DDI_INTR_TYPE_MSI;
      699 +                } else if (intr_types & DDI_INTR_TYPE_FIXED) {
      700 +                        msi_enable = 0;
      701 +                        if (mrsas_add_intrs(instance, DDI_INTR_TYPE_FIXED) !=
      702 +                            DDI_SUCCESS) {
 514  703                                  cmn_err(CE_WARN,
 515      -                                    "mr_sas: couldn't map control registers");
      704 +                                    "FIXED interrupt query failed");
 516  705                                  goto fail_attach;
 517  706                          }
      707 +                        instance->intr_type = DDI_INTR_TYPE_FIXED;
      708 +                } else {
      709 +                        cmn_err(CE_WARN, "Device cannot "
      710 +                            "suppport either FIXED or MSI/X "
      711 +                            "interrupts");
      712 +                        goto fail_attach;
      713 +                }
 518  714  
 519      -                        instance->unroll.regs = 1;
      715 +                instance->unroll.intr = 1;
 520  716  
 521      -                        /*
 522      -                         * Disable Interrupt Now.
 523      -                         * Setup Software interrupt
 524      -                         */
 525      -                        instance->func_ptr->disable_intr(instance);
 526      -
 527      -                        if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, 0,
 528      -                            "mrsas-enable-msi", &data) == DDI_SUCCESS) {
 529      -                                if (strncmp(data, "no", 3) == 0) {
 530      -                                        msi_enable = 0;
 531      -                                        con_log(CL_ANN1, (CE_WARN,
 532      -                                            "msi_enable = %d disabled",
 533      -                                            msi_enable));
 534      -                                }
 535      -                                ddi_prop_free(data);
      717 +                if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, 0,
      718 +                    "mrsas-enable-ctio", &data) == DDI_SUCCESS) {
      719 +                        if (strncmp(data, "no", 3) == 0) {
      720 +                                ctio_enable = 0;
      721 +                                con_log(CL_ANN1, (CE_WARN,
      722 +                                    "ctio_enable = %d disabled", ctio_enable));
 536  723                          }
      724 +                        ddi_prop_free(data);
      725 +                }
 537  726  
 538      -                        con_log(CL_DLEVEL1, (CE_NOTE, "msi_enable = %d", msi_enable));
      727 +                con_log(CL_DLEVEL1, (CE_WARN, "ctio_enable = %d", ctio_enable));
 539  728  
 540      -                        if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, 0,
 541      -                            "mrsas-enable-fp", &data) == DDI_SUCCESS) {
 542      -                                if (strncmp(data, "no", 3) == 0) {
 543      -                                        enable_fp = 0;
 544      -                                        cmn_err(CE_NOTE,
 545      -                                            "enable_fp = %d, Fast-Path disabled.\n",
 546      -                                            enable_fp);
 547      -                                }
      729 +                /* setup the mfi based low level driver */
      730 +                if (mrsas_init_adapter(instance) != DDI_SUCCESS) {
      731 +                        cmn_err(CE_WARN, "mr_sas: "
      732 +                            "could not initialize the low level driver");
 548  733  
 549      -                                ddi_prop_free(data);
 550      -                        }
      734 +                        goto fail_attach;
      735 +                }
 551  736  
 552      -                        cmn_err(CE_NOTE, "enable_fp = %d\n", enable_fp);
      737 +                /* Initialize all Mutex */
      738 +                INIT_LIST_HEAD(&instance->completed_pool_list);
      739 +                mutex_init(&instance->completed_pool_mtx, NULL,
      740 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 553  741  
 554      -                        /* Check for all supported interrupt types */
 555      -                        if (ddi_intr_get_supported_types(
 556      -                            dip, &intr_types) != DDI_SUCCESS) {
 557      -                                cmn_err(CE_WARN,
 558      -                                    "ddi_intr_get_supported_types() failed");
 559      -                                goto fail_attach;
 560      -                        }
      742 +                mutex_init(&instance->sync_map_mtx, NULL,
      743 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 561  744  
 562      -                        con_log(CL_DLEVEL1, (CE_NOTE,
 563      -                            "ddi_intr_get_supported_types() ret: 0x%x",
 564      -                            intr_types));
      745 +                mutex_init(&instance->app_cmd_pool_mtx, NULL,
      746 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 565  747  
 566      -                        /* Initialize and Setup Interrupt handler */
 567      -                        if (msi_enable && (intr_types & DDI_INTR_TYPE_MSIX)) {
 568      -                                if (mrsas_add_intrs(instance,
 569      -                                    DDI_INTR_TYPE_MSIX) != DDI_SUCCESS) {
 570      -                                        cmn_err(CE_WARN,
 571      -                                            "MSIX interrupt query failed");
 572      -                                        goto fail_attach;
 573      -                                }
 574      -                                instance->intr_type = DDI_INTR_TYPE_MSIX;
 575      -                        } else if (msi_enable && (intr_types &
 576      -                            DDI_INTR_TYPE_MSI)) {
 577      -                                if (mrsas_add_intrs(instance,
 578      -                                    DDI_INTR_TYPE_MSI) != DDI_SUCCESS) {
 579      -                                        cmn_err(CE_WARN,
 580      -                                            "MSI interrupt query failed");
 581      -                                        goto fail_attach;
 582      -                                }
 583      -                                instance->intr_type = DDI_INTR_TYPE_MSI;
 584      -                        } else if (intr_types & DDI_INTR_TYPE_FIXED) {
 585      -                                msi_enable = 0;
 586      -                                if (mrsas_add_intrs(instance,
 587      -                                    DDI_INTR_TYPE_FIXED) != DDI_SUCCESS) {
 588      -                                        cmn_err(CE_WARN,
 589      -                                            "FIXED interrupt query failed");
 590      -                                        goto fail_attach;
 591      -                                }
 592      -                                instance->intr_type = DDI_INTR_TYPE_FIXED;
 593      -                        } else {
 594      -                                cmn_err(CE_WARN, "Device cannot "
 595      -                                    "suppport either FIXED or MSI/X "
 596      -                                    "interrupts");
 597      -                                goto fail_attach;
 598      -                        }
      748 +                mutex_init(&instance->config_dev_mtx, NULL,
      749 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 599  750  
 600      -                        instance->unroll.intr = 1;
      751 +                mutex_init(&instance->cmd_pend_mtx, NULL,
      752 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 601  753  
      754 +                mutex_init(&instance->ocr_flags_mtx, NULL,
      755 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 602  756  
 603      -                        /* setup the mfi based low level driver */
 604      -                        if (mrsas_init_adapter(instance) != DDI_SUCCESS) {
 605      -                                cmn_err(CE_WARN, "mr_sas: "
 606      -                                "could not initialize the low level driver");
      757 +                mutex_init(&instance->int_cmd_mtx, NULL,
      758 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
      759 +                cv_init(&instance->int_cmd_cv, NULL, CV_DRIVER, NULL);
 607  760  
 608      -                                goto fail_attach;
 609      -                        }
      761 +                mutex_init(&instance->cmd_pool_mtx, NULL,
      762 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 610  763  
 611      -                        /* Initialize all Mutex */
 612      -                        INIT_LIST_HEAD(&instance->completed_pool_list);
 613      -                        mutex_init(&instance->completed_pool_mtx,
 614      -                            "completed_pool_mtx", MUTEX_DRIVER,
 615      -                            DDI_INTR_PRI(instance->intr_pri));
 616      -                        
 617      -                        mutex_init(&instance->sync_map_mtx,
 618      -                            "sync_map_mtx", MUTEX_DRIVER,
 619      -                            DDI_INTR_PRI(instance->intr_pri));
 620      -                        
 621      -                        mutex_init(&instance->app_cmd_pool_mtx,
 622      -                            "app_cmd_pool_mtx", MUTEX_DRIVER,
 623      -                            DDI_INTR_PRI(instance->intr_pri));
      764 +                mutex_init(&instance->reg_write_mtx, NULL,
      765 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 624  766  
 625      -                        mutex_init(&instance->config_dev_mtx, "config_dev_mtx",
      767 +                if (instance->tbolt) {
      768 +                        mutex_init(&instance->cmd_app_pool_mtx, NULL,
 626  769                              MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 627  770  
 628      -                        mutex_init(&instance->cmd_pend_mtx, "cmd_pend_mtx",
      771 +                        mutex_init(&instance->chip_mtx, NULL,
 629  772                              MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 630  773  
 631      -                        mutex_init(&instance->ocr_flags_mtx, "ocr_flags_mtx",
 632      -                            MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
      774 +                }
 633  775  
 634      -                        mutex_init(&instance->int_cmd_mtx, "int_cmd_mtx",
 635      -                            MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 636      -                        cv_init(&instance->int_cmd_cv, NULL, CV_DRIVER, NULL);
      776 +                instance->unroll.mutexs = 1;
 637  777  
 638      -                        mutex_init(&instance->cmd_pool_mtx, "cmd_pool_mtx",
 639      -                            MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
      778 +                instance->timeout_id = (timeout_id_t)-1;
 640  779  
 641      -                        mutex_init(&instance->reg_write_mtx,"reg_write_mtx", 
 642      -                                MUTEX_DRIVER,DDI_INTR_PRI(instance->intr_pri));
      780 +                /* Register our soft-isr for highlevel interrupts. */
      781 +                instance->isr_level = instance->intr_pri;
      782 +                if (!(instance->tbolt)) {
      783 +                        if (instance->isr_level == HIGH_LEVEL_INTR) {
      784 +                                if (ddi_add_softintr(dip,
      785 +                                    DDI_SOFTINT_HIGH,
      786 +                                    &instance->soft_intr_id, NULL, NULL,
      787 +                                    mrsas_softintr, (caddr_t)instance) !=
      788 +                                    DDI_SUCCESS) {
      789 +                                        cmn_err(CE_WARN,
      790 +                                            "Software ISR did not register");
 643  791  
 644      -                        if (instance->tbolt) {
 645      -                                mutex_init(&instance->cmd_app_pool_mtx,
 646      -                                    "cmd_app_pool_mtx", MUTEX_DRIVER,
 647      -                                    DDI_INTR_PRI(instance->intr_pri));
      792 +                                        goto fail_attach;
      793 +                                }
 648  794  
 649      -                                mutex_init(&instance->chip_mtx,
 650      -                                    "chip_mtx", MUTEX_DRIVER,
 651      -                                    DDI_INTR_PRI(instance->intr_pri));
      795 +                                instance->unroll.soft_isr = 1;
 652  796  
 653  797                          }
      798 +                }
 654  799  
 655      -                        instance->unroll.mutexs = 1;
      800 +                instance->softint_running = 0;
 656  801  
 657      -                        instance->timeout_id = (timeout_id_t)-1;
      802 +                /* Allocate a transport structure */
      803 +                tran = scsi_hba_tran_alloc(dip, SCSI_HBA_CANSLEEP);
 658  804  
 659      -                        /* Register our soft-isr for highlevel interrupts. */
 660      -                        instance->isr_level = instance->intr_pri;
 661      -                        if (!(instance->tbolt)) {
 662      -                                if (instance->isr_level == HIGH_LEVEL_INTR) {
 663      -                                        if (ddi_add_softintr(dip,
 664      -                                            DDI_SOFTINT_HIGH,
 665      -                                            &instance->soft_intr_id,
 666      -                                            NULL, NULL, mrsas_softintr,
 667      -                                            (caddr_t)instance) !=
 668      -                                            DDI_SUCCESS) {
 669      -                                                cmn_err(CE_WARN,
 670      -                                                    "Software ISR "
 671      -                                                    "did not register");
      805 +                if (tran == NULL) {
      806 +                        cmn_err(CE_WARN,
      807 +                            "scsi_hba_tran_alloc failed");
      808 +                        goto fail_attach;
      809 +                }
 672  810  
 673      -                                                goto fail_attach;
 674      -                                        }
      811 +                instance->tran = tran;
      812 +                instance->unroll.tran = 1;
 675  813  
 676      -                                        instance->unroll.soft_isr = 1;
      814 +                tran->tran_hba_private  = instance;
      815 +                tran->tran_tgt_init     = mrsas_tran_tgt_init;
      816 +                tran->tran_tgt_probe    = scsi_hba_probe;
      817 +                tran->tran_tgt_free     = mrsas_tran_tgt_free;
      818 +                if (instance->tbolt) {
      819 +                        tran->tran_init_pkt     =
      820 +                            mrsas_tbolt_tran_init_pkt;
      821 +                        tran->tran_start        =
      822 +                            mrsas_tbolt_tran_start;
      823 +                } else {
      824 +                        tran->tran_init_pkt     = mrsas_tran_init_pkt;
      825 +                        tran->tran_start        = mrsas_tran_start;
      826 +                }
      827 +                tran->tran_abort        = mrsas_tran_abort;
      828 +                tran->tran_reset        = mrsas_tran_reset;
      829 +                tran->tran_getcap       = mrsas_tran_getcap;
      830 +                tran->tran_setcap       = mrsas_tran_setcap;
      831 +                tran->tran_destroy_pkt  = mrsas_tran_destroy_pkt;
      832 +                tran->tran_dmafree      = mrsas_tran_dmafree;
      833 +                tran->tran_sync_pkt     = mrsas_tran_sync_pkt;
      834 +                tran->tran_quiesce      = mrsas_tran_quiesce;
      835 +                tran->tran_unquiesce    = mrsas_tran_unquiesce;
      836 +                tran->tran_bus_config   = mrsas_tran_bus_config;
 677  837  
 678      -                                }
 679      -                        }
      838 +                if (mrsas_relaxed_ordering)
      839 +                        mrsas_generic_dma_attr.dma_attr_flags |=
      840 +                            DDI_DMA_RELAXED_ORDERING;
 680  841  
 681      -                        instance->softint_running = 0;
 682  842  
 683      -                        /* Allocate a transport structure */
 684      -                        tran = scsi_hba_tran_alloc(dip, SCSI_HBA_CANSLEEP);
      843 +                tran_dma_attr = mrsas_generic_dma_attr;
      844 +                tran_dma_attr.dma_attr_sgllen = instance->max_num_sge;
 685  845  
 686      -                        if (tran == NULL) {
 687      -                                cmn_err(CE_WARN,
 688      -                                    "scsi_hba_tran_alloc failed");
 689      -                                goto fail_attach;
 690      -                        }
      846 +                /* Attach this instance of the hba */
      847 +                if (scsi_hba_attach_setup(dip, &tran_dma_attr, tran, 0)
      848 +                    != DDI_SUCCESS) {
      849 +                        cmn_err(CE_WARN,
      850 +                            "scsi_hba_attach failed");
 691  851  
 692      -                        instance->tran = tran;
 693      -                        instance->unroll.tran = 1;
      852 +                        goto fail_attach;
      853 +                }
      854 +                instance->unroll.tranSetup = 1;
      855 +                con_log(CL_ANN1,
      856 +                    (CE_CONT, "scsi_hba_attach_setup()  done."));
 694  857  
 695      -                        tran->tran_hba_private  = instance;
 696      -                        tran->tran_tgt_init     = mrsas_tran_tgt_init;
 697      -                        tran->tran_tgt_probe    = scsi_hba_probe;
 698      -                        tran->tran_tgt_free     = mrsas_tran_tgt_free;
 699      -                        if (instance->tbolt) {
 700      -                                tran->tran_init_pkt     =
 701      -                                    mrsas_tbolt_tran_init_pkt;
 702      -                                tran->tran_start        =
 703      -                                    mrsas_tbolt_tran_start;
 704      -                        } else {
 705      -                                tran->tran_init_pkt     = mrsas_tran_init_pkt;
 706      -                                tran->tran_start        = mrsas_tran_start;
 707      -                        }
 708      -                        tran->tran_abort        = mrsas_tran_abort;
 709      -                        tran->tran_reset        = mrsas_tran_reset;
 710      -                        tran->tran_getcap       = mrsas_tran_getcap;
 711      -                        tran->tran_setcap       = mrsas_tran_setcap;
 712      -                        tran->tran_destroy_pkt  = mrsas_tran_destroy_pkt;
 713      -                        tran->tran_dmafree      = mrsas_tran_dmafree;
 714      -                        tran->tran_sync_pkt     = mrsas_tran_sync_pkt;
 715      -                        tran->tran_quiesce      = mrsas_tran_quiesce;
 716      -                        tran->tran_unquiesce    = mrsas_tran_unquiesce;
 717      -                        tran->tran_bus_config   = mrsas_tran_bus_config;
      858 +                /* create devctl node for cfgadm command */
      859 +                if (ddi_create_minor_node(dip, "devctl",
      860 +                    S_IFCHR, INST2DEVCTL(instance_no),
      861 +                    DDI_NT_SCSI_NEXUS, 0) == DDI_FAILURE) {
      862 +                        cmn_err(CE_WARN,
      863 +                            "mr_sas: failed to create devctl node.");
 718  864  
 719      -                        if (mrsas_relaxed_ordering)
 720      -                                mrsas_generic_dma_attr.dma_attr_flags |=
 721      -                                    DDI_DMA_RELAXED_ORDERING;
      865 +                        goto fail_attach;
      866 +                }
 722  867  
      868 +                instance->unroll.devctl = 1;
 723  869  
 724      -                        tran_dma_attr = mrsas_generic_dma_attr;
 725      -                        tran_dma_attr.dma_attr_sgllen = instance->max_num_sge;
      870 +                /* create scsi node for cfgadm command */
      871 +                if (ddi_create_minor_node(dip, "scsi", S_IFCHR,
      872 +                    INST2SCSI(instance_no), DDI_NT_SCSI_ATTACHMENT_POINT, 0) ==
      873 +                    DDI_FAILURE) {
      874 +                        cmn_err(CE_WARN,
      875 +                            "mr_sas: failed to create scsi node.");
 726  876  
 727      -                        /* Attach this instance of the hba */
 728      -                        if (scsi_hba_attach_setup(dip, &tran_dma_attr, tran, 0)
 729      -                            != DDI_SUCCESS) {
 730      -                                cmn_err(CE_WARN,
 731      -                                    "scsi_hba_attach failed");
      877 +                        goto fail_attach;
      878 +                }
 732  879  
 733      -                                goto fail_attach;
 734      -                        }
 735      -                        instance->unroll.tranSetup = 1;
 736      -                        con_log(CL_ANN1, (CE_CONT,
 737      -                                "scsi_hba_attach_setup()  done."));
      880 +                instance->unroll.scsictl = 1;
 738  881  
      882 +                (void) sprintf(instance->iocnode, "%d:lsirdctl",
      883 +                    instance_no);
 739  884  
 740      -                        /* create devctl node for cfgadm command */
 741      -                        if (ddi_create_minor_node(dip, "devctl",
 742      -                            S_IFCHR, INST2DEVCTL(instance_no),
 743      -                            DDI_NT_SCSI_NEXUS, 0) == DDI_FAILURE) {
 744      -                                cmn_err(CE_WARN,
 745      -                                    "mr_sas: failed to create devctl node.");
      885 +                /*
      886 +                 * Create a node for applications
      887 +                 * for issuing ioctl to the driver.
      888 +                 */
      889 +                if (ddi_create_minor_node(dip, instance->iocnode,
      890 +                    S_IFCHR, INST2LSIRDCTL(instance_no), DDI_PSEUDO, 0) ==
      891 +                    DDI_FAILURE) {
      892 +                        cmn_err(CE_WARN,
      893 +                            "mr_sas: failed to create ioctl node.");
 746  894  
 747      -                                goto fail_attach;
 748      -                        }
      895 +                        goto fail_attach;
      896 +                }
 749  897  
 750      -                        instance->unroll.devctl = 1;
      898 +                instance->unroll.ioctl = 1;
 751  899  
 752      -                        /* create scsi node for cfgadm command */
 753      -                        if (ddi_create_minor_node(dip, "scsi", S_IFCHR,
 754      -                            INST2SCSI(instance_no),
 755      -                            DDI_NT_SCSI_ATTACHMENT_POINT, 0) ==
 756      -                            DDI_FAILURE) {
 757      -                                cmn_err(CE_WARN,
 758      -                                    "mr_sas: failed to create scsi node.");
      900 +                /* Create a taskq to handle dr events */
      901 +                if ((instance->taskq = ddi_taskq_create(dip,
      902 +                    "mrsas_dr_taskq", 1, TASKQ_DEFAULTPRI, 0)) == NULL) {
      903 +                        cmn_err(CE_WARN,
      904 +                            "mr_sas: failed to create taskq ");
      905 +                        instance->taskq = NULL;
      906 +                        goto fail_attach;
      907 +                }
      908 +                instance->unroll.taskq = 1;
      909 +                con_log(CL_ANN1, (CE_CONT, "ddi_taskq_create()  done."));
 759  910  
 760      -                                goto fail_attach;
 761      -                        }
      911 +                /* enable interrupt */
      912 +                instance->func_ptr->enable_intr(instance);
 762  913  
 763      -                        instance->unroll.scsictl = 1;
      914 +                /* initiate AEN */
      915 +                if (start_mfi_aen(instance)) {
      916 +                        cmn_err(CE_WARN,
      917 +                            "mr_sas: failed to initiate AEN.");
      918 +                        goto fail_attach;
      919 +                }
      920 +                instance->unroll.aenPend = 1;
      921 +                con_log(CL_ANN1,
      922 +                    (CE_CONT, "AEN started for instance %d.", instance_no));
 764  923  
 765      -                        (void) sprintf(instance->iocnode, "%d:lsirdctl",
 766      -                            instance_no);
      924 +                /* Finally! We are on the air.  */
      925 +                ddi_report_dev(dip);
 767  926  
 768      -                        /*
 769      -                         * Create a node for applications
 770      -                         * for issuing ioctl to the driver.
 771      -                         */
 772      -                        if (ddi_create_minor_node(dip, instance->iocnode,
 773      -                            S_IFCHR, INST2LSIRDCTL(instance_no),
 774      -                            DDI_PSEUDO, 0) == DDI_FAILURE) {
 775      -                                cmn_err(CE_WARN,
 776      -                                    "mr_sas: failed to create ioctl node.");
      927 +                /* FMA handle checking. */
      928 +                if (mrsas_check_acc_handle(instance->regmap_handle) !=
      929 +                    DDI_SUCCESS) {
      930 +                        goto fail_attach;
      931 +                }
      932 +                if (mrsas_check_acc_handle(instance->pci_handle) !=
      933 +                    DDI_SUCCESS) {
      934 +                        goto fail_attach;
      935 +                }
 777  936  
 778      -                                goto fail_attach;
 779      -                        }
      937 +                instance->mr_ld_list =
      938 +                    kmem_zalloc(MRDRV_MAX_LD * sizeof (struct mrsas_ld),
      939 +                    KM_SLEEP);
      940 +                instance->unroll.ldlist_buff = 1;
 780  941  
 781      -                        instance->unroll.ioctl = 1;
 782      -
 783      -                        /* Create a taskq to handle dr events */
 784      -                        if ((instance->taskq = ddi_taskq_create(dip,
 785      -                            "mrsas_dr_taskq", 1,
 786      -                            TASKQ_DEFAULTPRI, 0)) == NULL) {
 787      -                                cmn_err(CE_WARN,
 788      -                                    "mr_sas: failed to create taskq ");
 789      -                                instance->taskq = NULL;
 790      -                                goto fail_attach;
      942 +#ifdef PDSUPPORT
      943 +                if (instance->tbolt) {
      944 +                        instance->mr_tbolt_pd_max = MRSAS_TBOLT_PD_TGT_MAX;
      945 +                        instance->mr_tbolt_pd_list =
      946 +                            kmem_zalloc(MRSAS_TBOLT_GET_PD_MAX(instance) *
      947 +                            sizeof (struct mrsas_tbolt_pd), KM_SLEEP);
      948 +                        ASSERT(instance->mr_tbolt_pd_list);
      949 +                        for (i = 0; i < instance->mr_tbolt_pd_max; i++) {
      950 +                                instance->mr_tbolt_pd_list[i].lun_type =
      951 +                                    MRSAS_TBOLT_PD_LUN;
      952 +                                instance->mr_tbolt_pd_list[i].dev_id =
      953 +                                    (uint8_t)i;
 791  954                          }
 792      -                        instance->unroll.taskq = 1;
 793      -                        con_log(CL_ANN1, (CE_CONT,
 794      -                                "ddi_taskq_create()  done."));
 795  955  
 796      -                        /* enable interrupt */
 797      -                        instance->func_ptr->enable_intr(instance);
 798      -
 799      -                        /* initiate AEN */
 800      -                        if (start_mfi_aen(instance)) {
 801      -                                        cmn_err(CE_WARN,
 802      -                                    "mr_sas: failed to initiate AEN.");
 803      -                                goto fail_attach;
 804      -                        }
 805      -                        instance->unroll.aenPend = 1;
 806      -                        con_log(CL_ANN1, (CE_CONT,
 807      -                            "AEN started for instance %d.", instance_no));
 808      -
 809      -                        /* Finally! We are on the air.  */
 810      -                        ddi_report_dev(dip);
 811      -                                                
 812      -                        instance->mr_ld_list =
 813      -                            kmem_zalloc(MRDRV_MAX_LD * sizeof (struct mrsas_ld),
 814      -                            KM_SLEEP);
 815      -                        if (instance->mr_ld_list == NULL) {
 816      -                                cmn_err(CE_WARN,
 817      -                                    "mr_sas attach(): failed to allocate ld_list array");
 818      -                                goto fail_attach;
 819      -                        }
 820      -                        instance->unroll.ldlist_buff = 1;
 821      -
 822      -#ifdef PDSUPPORT
 823      -                        if(instance->tbolt) {
 824      -                                instance->mr_tbolt_pd_max = MRSAS_TBOLT_PD_TGT_MAX;
 825      -                                instance->mr_tbolt_pd_list =
 826      -                                    kmem_zalloc(MRSAS_TBOLT_GET_PD_MAX(instance)
 827      -                                    * sizeof (struct mrsas_tbolt_pd), KM_SLEEP);
 828      -                                ASSERT(instance->mr_tbolt_pd_list);
 829      -                                for (i = 0; i < instance->mr_tbolt_pd_max; i++) {
 830      -                                        instance->mr_tbolt_pd_list[i].lun_type = 
 831      -                                            MRSAS_TBOLT_PD_LUN;
 832      -                                        instance->mr_tbolt_pd_list[i].dev_id = 
 833      -                                            (uint8_t)i;
 834      -                                }
 835      -
 836      -                                instance->unroll.pdlist_buff = 1;
 837      -                        }       
      956 +                        instance->unroll.pdlist_buff = 1;
      957 +                }
 838  958  #endif
 839      -                        break;
 840      -                case DDI_PM_RESUME:
 841      -                        con_log(CL_ANN, (CE_NOTE,
 842      -                            "mr_sas: DDI_PM_RESUME"));
 843      -                        break;
 844      -                case DDI_RESUME:
 845      -                        con_log(CL_ANN, (CE_NOTE,
 846      -                            "mr_sas: DDI_RESUME"));
 847      -                        break;
 848      -                default:
 849      -                        con_log(CL_ANN, (CE_WARN,
 850      -                            "mr_sas: invalid attach cmd=%x", cmd));
 851      -                        return (DDI_FAILURE);
      959 +                break;
      960 +        case DDI_PM_RESUME:
      961 +                con_log(CL_ANN, (CE_NOTE, "mr_sas: DDI_PM_RESUME"));
      962 +                break;
      963 +        case DDI_RESUME:
      964 +                con_log(CL_ANN, (CE_NOTE, "mr_sas: DDI_RESUME"));
      965 +                break;
      966 +        default:
      967 +                con_log(CL_ANN,
      968 +                    (CE_WARN, "mr_sas: invalid attach cmd=%x", cmd));
      969 +                return (DDI_FAILURE);
 852  970          }
 853  971  
 854  972  
 855      -        cmn_err(CE_NOTE, "mrsas_attach() return SUCCESS instance_num %d", instance_no);
      973 +        con_log(CL_DLEVEL1,
      974 +            (CE_NOTE, "mrsas_attach() return SUCCESS instance_num %d",
      975 +            instance_no));
 856  976          return (DDI_SUCCESS);
 857  977  
 858  978  fail_attach:
 859  979  
 860  980          mrsas_undo_resources(dip, instance);
 861  981  
      982 +        mrsas_fm_ereport(instance, DDI_FM_DEVICE_NO_RESPONSE);
      983 +        ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST);
      984 +
      985 +        mrsas_fm_fini(instance);
      986 +
 862  987          pci_config_teardown(&instance->pci_handle);
 863  988          ddi_soft_state_free(mrsas_state, instance_no);
 864  989  
 865      -        con_log(CL_ANN, (CE_WARN,
 866      -            "mr_sas: return failure from mrsas_attach"));
      990 +        con_log(CL_ANN, (CE_WARN, "mr_sas: return failure from mrsas_attach"));
 867  991  
 868      -        cmn_err(CE_WARN, "mrsas_attach() return FAILURE instance_num %d", instance_no);
      992 +        cmn_err(CE_WARN, "mrsas_attach() return FAILURE instance_num %d",
      993 +            instance_no);
 869  994  
 870  995          return (DDI_FAILURE);
 871  996  }
 872  997  
 873  998  /*
 874  999   * getinfo - gets device information
 875 1000   * @dip:
 876 1001   * @cmd:
 877 1002   * @arg:
 878 1003   * @resultp:
↓ open down ↓ 95 lines elided ↑ open up ↑
 974 1099                          mutex_enter(&instance->config_dev_mtx);
 975 1100                          if (instance->timeout_id != (timeout_id_t)-1) {
 976 1101                                  mutex_exit(&instance->config_dev_mtx);
 977 1102                                  (void) untimeout(instance->timeout_id);
 978 1103                                  instance->timeout_id = (timeout_id_t)-1;
 979 1104                                  mutex_enter(&instance->config_dev_mtx);
 980 1105                                  instance->unroll.timer = 0;
 981 1106                          }
 982 1107                          mutex_exit(&instance->config_dev_mtx);
 983 1108  
 984      -                        if(instance->unroll.tranSetup == 1) {
     1109 +                        if (instance->unroll.tranSetup == 1) {
 985 1110                                  if (scsi_hba_detach(dip) != DDI_SUCCESS) {
 986 1111                                          cmn_err(CE_WARN,
 987      -                                                "mr_sas2%d: failed to detach", instance_no);
     1112 +                                            "mr_sas2%d: failed to detach",
     1113 +                                            instance_no);
 988 1114                                          return (DDI_FAILURE);
 989 1115                                  }
 990 1116                                  instance->unroll.tranSetup = 0;
 991      -                                con_log(CL_ANN1, (CE_CONT, "scsi_hba_dettach()  done."));
     1117 +                                con_log(CL_ANN1,
     1118 +                                    (CE_CONT, "scsi_hba_dettach()  done."));
 992 1119                          }
 993 1120  
 994 1121                          flush_cache(instance);
 995 1122  
 996 1123                          mrsas_undo_resources(dip, instance);
 997 1124  
     1125 +                        mrsas_fm_fini(instance);
     1126 +
 998 1127                          pci_config_teardown(&instance->pci_handle);
 999 1128                          ddi_soft_state_free(mrsas_state, instance_no);
1000 1129                          break;
1001 1130  
1002 1131                  case DDI_PM_SUSPEND:
1003 1132                          con_log(CL_ANN, (CE_NOTE,
1004 1133                              "mrsas_detach: DDI_PM_SUSPEND"));
1005 1134  
1006 1135                          break;
1007 1136                  case DDI_SUSPEND:
↓ open down ↓ 4 lines elided ↑ open up ↑
1012 1141                  default:
1013 1142                          con_log(CL_ANN, (CE_WARN,
1014 1143                              "invalid detach command:0x%x", cmd));
1015 1144                          return (DDI_FAILURE);
1016 1145          }
1017 1146  
1018 1147          return (DDI_SUCCESS);
1019 1148  }
1020 1149  
1021 1150  
1022      -static int
1023      -mrsas_undo_resources (dev_info_t *dip, struct mrsas_instance *instance)
     1151 +static void
     1152 +mrsas_undo_resources(dev_info_t *dip, struct mrsas_instance *instance)
1024 1153  {
1025 1154          int     instance_no;
1026 1155  
1027 1156          con_log(CL_ANN, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
1028 1157  
1029 1158  
1030 1159          instance_no = ddi_get_instance(dip);
1031 1160  
1032 1161  
1033      -        if(instance->unroll.ioctl == 1)  {
     1162 +        if (instance->unroll.ioctl == 1) {
1034 1163                  ddi_remove_minor_node(dip, instance->iocnode);
1035 1164                  instance->unroll.ioctl = 0;
1036 1165          }
1037 1166  
1038      -        if(instance->unroll.scsictl == 1)  {
     1167 +        if (instance->unroll.scsictl == 1) {
1039 1168                  ddi_remove_minor_node(dip, "scsi");
1040 1169                  instance->unroll.scsictl = 0;
1041 1170          }
1042 1171  
1043      -        if(instance->unroll.devctl == 1)  {
     1172 +        if (instance->unroll.devctl == 1) {
1044 1173                  ddi_remove_minor_node(dip, "devctl");
1045 1174                  instance->unroll.devctl = 0;
1046 1175          }
1047 1176  
1048      -        if(instance->unroll.tranSetup == 1)  {
     1177 +        if (instance->unroll.tranSetup == 1) {
1049 1178                  if (scsi_hba_detach(dip) != DDI_SUCCESS) {
1050 1179                          cmn_err(CE_WARN,
1051      -                                "mr_sas2%d: failed to detach", instance_no);
1052      -                        return (DDI_FAILURE);
     1180 +                            "mr_sas2%d: failed to detach", instance_no);
     1181 +                        return;  /* DDI_FAILURE */
1053 1182                  }
1054 1183                  instance->unroll.tranSetup = 0;
1055      -                con_log(CL_ANN1, (CE_CONT, "scsi_hba_dettach()  done."));
     1184 +                con_log(CL_ANN1, (CE_CONT, "scsi_hba_dettach()  done."));
1056 1185          }
1057 1186  
1058      -        if(instance->unroll.tran == 1)  {
     1187 +        if (instance->unroll.tran == 1)  {
1059 1188                  scsi_hba_tran_free(instance->tran);
1060 1189                  instance->unroll.tran = 0;
1061 1190                  con_log(CL_ANN1, (CE_CONT, "scsi_hba_tran_free()  done."));
1062 1191          }
1063 1192  
1064      -        if(instance->unroll.syncCmd == 1)  {
1065      -                if(instance->tbolt) {
1066      -                        if (abort_syncmap_cmd(instance, instance->map_update_cmd))
     1193 +        if (instance->unroll.syncCmd == 1) {
     1194 +                if (instance->tbolt) {
     1195 +                        if (abort_syncmap_cmd(instance,
     1196 +                            instance->map_update_cmd)) {
1067 1197                                  cmn_err(CE_WARN, "mrsas_detach: "
1068      -                                        "failed to abort previous syncmap command");
     1198 +                                    "failed to abort previous syncmap command");
     1199 +                        }
1069 1200  
1070 1201                          instance->unroll.syncCmd = 0;
1071 1202                          con_log(CL_ANN1, (CE_CONT, "sync cmd aborted, done."));
1072 1203                  }
1073 1204          }
1074 1205  
1075      -        if(instance->unroll.aenPend == 1)  {
1076      -                if (abort_aen_cmd(instance, instance->aen_cmd)) 
     1206 +        if (instance->unroll.aenPend == 1) {
     1207 +                if (abort_aen_cmd(instance, instance->aen_cmd))
1077 1208                          cmn_err(CE_WARN, "mrsas_detach: "
1078      -                                        "failed to abort prevous AEN command");
     1209 +                            "failed to abort prevous AEN command");
1079 1210  
1080 1211                  instance->unroll.aenPend = 0;
1081 1212                  con_log(CL_ANN1, (CE_CONT, "aen cmd aborted, done."));
1082      -                 /*This means the controller is fully initialzed and running */
1083      -                 // shutdown_controller();Shutdown should be a last command to controller.
     1213 +                /* This means the controller is fully initialized and running */
     1214 +                /* Shutdown should be a last command to controller. */
     1215 +                /* shutdown_controller(); */
1084 1216          }
1085 1217  
1086 1218  
1087      -        if(instance->unroll.timer == 1)  {
1088      -                if (instance->timeout_id != (timeout_id_t)-1)  {
     1219 +        if (instance->unroll.timer == 1)         {
     1220 +                if (instance->timeout_id != (timeout_id_t)-1) {
1089 1221                          (void) untimeout(instance->timeout_id);
1090 1222                          instance->timeout_id = (timeout_id_t)-1;
1091 1223  
1092 1224                          instance->unroll.timer = 0;
1093 1225                  }
1094 1226          }
1095 1227  
1096 1228          instance->func_ptr->disable_intr(instance);
1097 1229  
1098 1230  
1099      -        if(instance->unroll.mutexs == 1)  {
     1231 +        if (instance->unroll.mutexs == 1) {
1100 1232                  mutex_destroy(&instance->cmd_pool_mtx);
1101 1233                  mutex_destroy(&instance->app_cmd_pool_mtx);
1102 1234                  mutex_destroy(&instance->cmd_pend_mtx);
1103 1235                  mutex_destroy(&instance->completed_pool_mtx);
1104 1236                  mutex_destroy(&instance->sync_map_mtx);
1105 1237                  mutex_destroy(&instance->int_cmd_mtx);
1106 1238                  cv_destroy(&instance->int_cmd_cv);
1107 1239                  mutex_destroy(&instance->config_dev_mtx);
1108 1240                  mutex_destroy(&instance->ocr_flags_mtx);
1109 1241                  mutex_destroy(&instance->reg_write_mtx);
1110 1242  
1111 1243                  if (instance->tbolt) {
1112 1244                          mutex_destroy(&instance->cmd_app_pool_mtx);
1113 1245                          mutex_destroy(&instance->chip_mtx);
1114 1246                  }
1115 1247  
1116 1248                  instance->unroll.mutexs = 0;
1117      -                con_log(CL_ANN1, (CE_CONT, "Destroy mutex & cv,  done."));
     1249 +                con_log(CL_ANN1, (CE_CONT, "Destroy mutex & cv,  done."));
1118 1250          }
1119 1251  
1120 1252  
1121 1253          if (instance->unroll.soft_isr == 1) {
1122 1254                  ddi_remove_softintr(instance->soft_intr_id);
1123 1255                  instance->unroll.soft_isr = 0;
1124 1256          }
1125 1257  
1126      -        if(instance->unroll.intr == 1)  {
     1258 +        if (instance->unroll.intr == 1) {
1127 1259                  mrsas_rem_intrs(instance);
1128 1260                  instance->unroll.intr = 0;
1129 1261          }
1130      -           
1131 1262  
1132      -        if(instance->unroll.taskq == 1)  {
     1263 +
     1264 +        if (instance->unroll.taskq == 1)         {
1133 1265                  if (instance->taskq) {
1134 1266                          ddi_taskq_destroy(instance->taskq);
1135 1267                          instance->unroll.taskq = 0;
1136 1268                  }
1137 1269  
1138 1270          }
1139      -         
1140      -        /*free dma memory allocated for
1141      -          cmds/frames/queues/driver version etc */
1142      -        if(instance->unroll.verBuff == 1) {
1143      -                mrsas_free_dma_obj(instance, instance->drv_ver_dma_obj);
     1271 +
     1272 +        /*
     1273 +         * free dma memory allocated for
     1274 +         * cmds/frames/queues/driver version etc
     1275 +         */
     1276 +        if (instance->unroll.verBuff == 1) {
     1277 +                (void) mrsas_free_dma_obj(instance, instance->drv_ver_dma_obj);
1144 1278                  instance->unroll.verBuff = 0;
1145 1279          }
1146 1280  
1147      -        if(instance->unroll.pdlist_buff == 1)  {
1148      -                if (instance->mr_tbolt_pd_list != NULL) 
     1281 +        if (instance->unroll.pdlist_buff == 1)  {
     1282 +                if (instance->mr_tbolt_pd_list != NULL) {
1149 1283                          kmem_free(instance->mr_tbolt_pd_list,
1150      -                                MRSAS_TBOLT_GET_PD_MAX(instance) * sizeof (struct mrsas_tbolt_pd));
     1284 +                            MRSAS_TBOLT_GET_PD_MAX(instance) *
     1285 +                            sizeof (struct mrsas_tbolt_pd));
     1286 +                }
1151 1287  
1152 1288                  instance->mr_tbolt_pd_list = NULL;
1153 1289                  instance->unroll.pdlist_buff = 0;
1154 1290          }
1155 1291  
1156      -        if(instance->unroll.ldlist_buff == 1)  {
1157      -                if (instance->mr_ld_list != NULL) 
     1292 +        if (instance->unroll.ldlist_buff == 1)  {
     1293 +                if (instance->mr_ld_list != NULL) {
1158 1294                          kmem_free(instance->mr_ld_list, MRDRV_MAX_LD
1159      -                                * sizeof (struct mrsas_ld));
     1295 +                            * sizeof (struct mrsas_ld));
     1296 +                }
1160 1297  
1161 1298                  instance->mr_ld_list = NULL;
1162 1299                  instance->unroll.ldlist_buff = 0;
1163 1300          }
1164 1301  
1165 1302          if (instance->tbolt) {
1166      -                if(instance->unroll.alloc_space_mpi2 == 1) {            
     1303 +                if (instance->unroll.alloc_space_mpi2 == 1) {
1167 1304                          free_space_for_mpi2(instance);
1168 1305                          instance->unroll.alloc_space_mpi2 = 0;
1169 1306                  }
1170 1307          } else {
1171      -                if(instance->unroll.alloc_space_mfi == 1) {             
     1308 +                if (instance->unroll.alloc_space_mfi == 1) {
1172 1309                          free_space_for_mfi(instance);
1173 1310                          instance->unroll.alloc_space_mfi = 0;
1174 1311                  }
1175 1312          }
1176 1313  
1177      -        if(instance->unroll.regs == 1)  {
     1314 +        if (instance->unroll.regs == 1)  {
1178 1315                  ddi_regs_map_free(&instance->regmap_handle);
1179 1316                  instance->unroll.regs = 0;
1180      -                con_log(CL_ANN1, (CE_CONT, "ddi_regs_map_free()  done."));
     1317 +                con_log(CL_ANN1, (CE_CONT, "ddi_regs_map_free()  done."));
1181 1318          }
1182      -
1183      -        return (DDI_SUCCESS);
1184 1319  }
1185 1320  
1186 1321  
1187 1322  
1188 1323  /*
1189 1324   * ************************************************************************** *
1190      - *                                                                            *
1191      - *             common entry points - for character driver types               *
1192      - *                                                                            *
     1325 + *                                                                            *
     1326 + *             common entry points - for character driver types               *
     1327 + *                                                                            *
1193 1328   * ************************************************************************** *
1194 1329   */
1195 1330  /*
1196 1331   * open - gets access to a device
1197 1332   * @dev:
1198 1333   * @openflags:
1199 1334   * @otyp:
1200 1335   * @credp:
1201 1336   *
1202 1337   * Access to a device by one or more application programs is controlled
1203 1338   * through the open() and close() entry points. The primary function of
1204 1339   * open() is to verify that the open request is allowed.
1205 1340   */
1206      -static  int
     1341 +static  int
1207 1342  mrsas_open(dev_t *dev, int openflags, int otyp, cred_t *credp)
1208 1343  {
1209 1344          int     rval = 0;
1210 1345  
1211 1346          con_log(CL_ANN1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
1212 1347  
1213 1348          /* Check root permissions */
1214 1349          if (drv_priv(credp) != 0) {
1215 1350                  con_log(CL_ANN, (CE_WARN,
1216 1351                      "mr_sas: Non-root ioctl access denied!"));
↓ open down ↓ 22 lines elided ↑ open up ↑
1239 1374  /*
1240 1375   * close - gives up access to a device
1241 1376   * @dev:
1242 1377   * @openflags:
1243 1378   * @otyp:
1244 1379   * @credp:
1245 1380   *
1246 1381   * close() should perform any cleanup necessary to finish using the minor
1247 1382   * device, and prepare the device (and driver) to be opened again.
1248 1383   */
1249      -static  int
     1384 +static  int
1250 1385  mrsas_close(dev_t dev, int openflags, int otyp, cred_t *credp)
1251 1386  {
1252 1387          int     rval = 0;
1253 1388  
1254 1389          con_log(CL_ANN1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
1255 1390  
1256 1391          /* no need for locks! */
1257 1392  
1258 1393          if (scsi_hba_close) {
1259 1394                  rval = scsi_hba_close(dev, openflags, otyp, credp);
↓ open down ↓ 33 lines elided ↑ open up ↑
1293 1428          instance = ddi_get_soft_state(mrsas_state, MINOR2INST(getminor(dev)));
1294 1429  
1295 1430          if (instance == NULL) {
1296 1431                  /* invalid minor number */
1297 1432                  con_log(CL_ANN, (CE_WARN, "mr_sas: adapter not found."));
1298 1433                  return (ENXIO);
1299 1434          }
1300 1435  
1301 1436          ioctl = (struct mrsas_ioctl *)kmem_zalloc(sizeof (struct mrsas_ioctl),
1302 1437              KM_SLEEP);
1303      -        if (ioctl == NULL) {
1304      -                /* Failed to allocate memory for ioctl  */
1305      -                con_log(CL_ANN, (CE_WARN, "mr_sas_ioctl: failed to allocate memory for ioctl"));
1306      -                return (ENXIO);
1307      -        }
     1438 +        ASSERT(ioctl);
1308 1439  
1309 1440          switch ((uint_t)cmd) {
1310 1441                  case MRSAS_IOCTL_FIRMWARE:
1311 1442                          if (ddi_copyin((void *)arg, ioctl,
1312 1443                              sizeof (struct mrsas_ioctl), mode)) {
1313 1444                                  con_log(CL_ANN, (CE_WARN, "mrsas_ioctl: "
1314 1445                                      "ERROR IOCTL copyin"));
1315 1446                                  kmem_free(ioctl, sizeof (struct mrsas_ioctl));
1316 1447                                  return (EFAULT);
1317 1448                          }
↓ open down ↓ 6 lines elided ↑ open up ↑
1324 1455  
1325 1456                          if (ddi_copyout((void *)ioctl, (void *)arg,
1326 1457                              (sizeof (struct mrsas_ioctl) - 1), mode)) {
1327 1458                                  con_log(CL_ANN, (CE_WARN,
1328 1459                                      "mrsas_ioctl: copy_to_user failed"));
1329 1460                                  rval = 1;
1330 1461                          }
1331 1462  
1332 1463                          break;
1333 1464                  case MRSAS_IOCTL_AEN:
1334      -                        con_log(CL_ANN, (CE_NOTE,
1335      -                                    "mrsas_ioctl: IOCTL Register AEN.\n"));
1336      -
1337 1465                          if (ddi_copyin((void *) arg, &aen,
1338 1466                              sizeof (struct mrsas_aen), mode)) {
1339 1467                                  con_log(CL_ANN, (CE_WARN,
1340 1468                                      "mrsas_ioctl: ERROR AEN copyin"));
1341 1469                                  kmem_free(ioctl, sizeof (struct mrsas_ioctl));
1342 1470                                  return (EFAULT);
1343 1471                          }
1344 1472  
1345 1473                          rval = handle_mfi_aen(instance, &aen);
1346 1474  
↓ open down ↓ 12 lines elided ↑ open up ↑
1359 1487                          con_log(CL_DLEVEL1, (CE_NOTE, "mrsas_ioctl: "
1360 1488                              "scsi_hba_ioctl called, ret = %x.", rval));
1361 1489          }
1362 1490  
1363 1491          kmem_free(ioctl, sizeof (struct mrsas_ioctl));
1364 1492          return (rval);
1365 1493  }
1366 1494  
1367 1495  /*
1368 1496   * ************************************************************************** *
1369      - *                                                                            *
1370      - *               common entry points - for block driver types                 *
1371      - *                                                                            *
     1497 + *                                                                            *
     1498 + *               common entry points - for block driver types                 *
     1499 + *                                                                            *
1372 1500   * ************************************************************************** *
1373 1501   */
     1502 +#ifdef __sparc
1374 1503  /*
1375 1504   * reset - TBD
1376 1505   * @dip:
1377 1506   * @cmd:
1378 1507   *
1379 1508   * TBD
1380 1509   */
1381 1510  /*ARGSUSED*/
1382 1511  static int
1383 1512  mrsas_reset(dev_info_t *dip, ddi_reset_cmd_t cmd)
↓ open down ↓ 16 lines elided ↑ open up ↑
1400 1529  
1401 1530          instance->func_ptr->disable_intr(instance);
1402 1531  
1403 1532          con_log(CL_ANN1, (CE_CONT, "flushing cache for instance %d",
1404 1533              instance_no));
1405 1534  
1406 1535          flush_cache(instance);
1407 1536  
1408 1537          return (DDI_SUCCESS);
1409 1538  }
1410      -
1411      -
     1539 +#else /* __sparc */
1412 1540  /*ARGSUSED*/
1413      -int
     1541 +static int
1414 1542  mrsas_quiesce(dev_info_t *dip)
1415 1543  {
1416 1544          int     instance_no;
1417 1545  
1418 1546          struct mrsas_instance   *instance;
1419 1547  
1420 1548          instance_no = ddi_get_instance(dip);
1421 1549          instance = (struct mrsas_instance *)ddi_get_soft_state
1422 1550              (mrsas_state, instance_no);
1423 1551  
↓ open down ↓ 26 lines elided ↑ open up ↑
1450 1578          }
1451 1579  
1452 1580          instance->func_ptr->disable_intr(instance);
1453 1581  
1454 1582          con_log(CL_ANN1, (CE_CONT, "flushing cache for instance %d",
1455 1583              instance_no));
1456 1584  
1457 1585          flush_cache(instance);
1458 1586  
1459 1587          if (wait_for_outstanding(instance)) {
1460      -                con_log(CL_ANN1, (CE_CONT, "wait_for_outstanding: return FAIL.\n"));
     1588 +                con_log(CL_ANN1,
     1589 +                    (CE_CONT, "wait_for_outstanding: return FAIL.\n"));
1461 1590                  return (DDI_FAILURE);
1462 1591          }
1463 1592          return (DDI_SUCCESS);
1464 1593  }
     1594 +#endif  /* __sparc */
1465 1595  
1466 1596  /*
1467 1597   * ************************************************************************** *
1468      - *                                                                            *
1469      - *                          entry points (SCSI HBA)                           *
1470      - *                                                                            *
     1598 + *                                                                            *
     1599 + *                          entry points (SCSI HBA)                           *
     1600 + *                                                                            *
1471 1601   * ************************************************************************** *
1472 1602   */
1473 1603  /*
1474 1604   * tran_tgt_init - initialize a target device instance
1475 1605   * @hba_dip:
1476 1606   * @tgt_dip:
1477 1607   * @tran:
1478 1608   * @sd:
1479 1609   *
1480 1610   * The tran_tgt_init() entry point enables the HBA to allocate and initialize
↓ open down ↓ 16 lines elided ↑ open up ↑
1497 1627              tgt, lun));
1498 1628  
1499 1629          instance = ADDR2MR(&sd->sd_address);
1500 1630  
1501 1631          if (ndi_dev_is_persistent_node(tgt_dip) == 0) {
1502 1632                  /*
1503 1633                   * If no persistent node exists, we don't allow .conf node
1504 1634                   * to be created.
1505 1635                   */
1506 1636                  if ((child = mrsas_find_child(instance, tgt, lun)) != NULL) {
1507      -                        con_log(CL_DLEVEL2, (CE_NOTE, "mrsas_tgt_init find child ="
     1637 +                        con_log(CL_DLEVEL2,
     1638 +                            (CE_NOTE, "mrsas_tgt_init find child ="
1508 1639                              " %p t = %d l = %d", (void *)child, tgt, lun));
1509 1640                          if (ndi_merge_node(tgt_dip, mrsas_name_node) !=
1510 1641                              DDI_SUCCESS)
1511 1642                                  /* Create this .conf node */
1512 1643                                  return (DDI_SUCCESS);
1513 1644                  }
1514 1645                  con_log(CL_DLEVEL2, (CE_NOTE, "mrsas_tgt_init in ndi_per "
1515 1646                      "DDI_FAILURE t = %d l = %d", tgt, lun));
1516 1647                  return (DDI_FAILURE);
1517 1648  
↓ open down ↓ 7 lines elided ↑ open up ↑
1525 1656                      strcmp(ddi_driver_name(sd->sd_dev), "sd") == 0) {
1526 1657                          mutex_enter(&instance->config_dev_mtx);
1527 1658                          instance->mr_ld_list[tgt].dip = tgt_dip;
1528 1659                          instance->mr_ld_list[tgt].lun_type = MRSAS_LD_LUN;
1529 1660                          instance->mr_ld_list[tgt].flag = MRDRV_TGT_VALID;
1530 1661                          mutex_exit(&instance->config_dev_mtx);
1531 1662                  }
1532 1663          }
1533 1664  
1534 1665  #ifdef PDSUPPORT
1535      -        else if(instance->tbolt) {
     1666 +        else if (instance->tbolt) {
1536 1667                  if (instance->mr_tbolt_pd_list[tgt].dip == NULL) {
1537 1668                          mutex_enter(&instance->config_dev_mtx);
1538 1669                          instance->mr_tbolt_pd_list[tgt].dip = tgt_dip;
1539      -                        instance->mr_tbolt_pd_list[tgt].flag = 
     1670 +                        instance->mr_tbolt_pd_list[tgt].flag =
1540 1671                              MRDRV_TGT_VALID;
1541 1672                          mutex_exit(&instance->config_dev_mtx);
1542 1673                          con_log(CL_ANN1, (CE_NOTE, "mrsas_tran_tgt_init:"
1543 1674                              "t%xl%x", tgt, lun));
1544 1675                  }
1545 1676          }
1546 1677  #endif
1547 1678  
1548 1679          return (DDI_SUCCESS);
1549 1680  }
↓ open down ↓ 13 lines elided ↑ open up ↑
1563 1694  
1564 1695          if (tgt < MRDRV_MAX_LD && lun == 0) {
1565 1696                  if (instance->mr_ld_list[tgt].dip == tgt_dip) {
1566 1697                          mutex_enter(&instance->config_dev_mtx);
1567 1698                          instance->mr_ld_list[tgt].dip = NULL;
1568 1699                          mutex_exit(&instance->config_dev_mtx);
1569 1700                  }
1570 1701          }
1571 1702  
1572 1703  #ifdef PDSUPPORT
1573      -        else if(instance->tbolt) {
     1704 +        else if (instance->tbolt) {
1574 1705                  mutex_enter(&instance->config_dev_mtx);
1575 1706                  instance->mr_tbolt_pd_list[tgt].dip = NULL;
1576 1707                  mutex_exit(&instance->config_dev_mtx);
1577 1708                  con_log(CL_ANN1, (CE_NOTE, "tgt_free: Setting dip = NULL"
1578 1709                      "for tgt:%x", tgt));
1579 1710          }
1580 1711  #endif
1581      -                
     1712 +
1582 1713  }
1583 1714  
1584 1715  dev_info_t *
1585 1716  mrsas_find_child(struct mrsas_instance *instance, uint16_t tgt, uint8_t lun)
1586 1717  {
1587 1718          dev_info_t *child = NULL;
1588 1719          char addr[SCSI_MAXNAMELEN];
1589 1720          char tmp[MAXNAMELEN];
1590 1721  
1591 1722          (void) sprintf(addr, "%x,%x", tgt, lun);
↓ open down ↓ 150 lines elided ↑ open up ↑
1742 1873   * involves a data transfer, DMA resources must also have been allocated for
1743 1874   * the scsi_pkt structure.
1744 1875   *
1745 1876   * Return Values :
1746 1877   *      TRAN_BUSY - request queue is full, no more free scbs
1747 1878   *      TRAN_ACCEPT - pkt has been submitted to the instance
1748 1879   */
1749 1880  static int
1750 1881  mrsas_tran_start(struct scsi_address *ap, register struct scsi_pkt *pkt)
1751 1882  {
1752      -        uchar_t         cmd_done = 0;
     1883 +        uchar_t         cmd_done = 0;
1753 1884  
1754 1885          struct mrsas_instance   *instance = ADDR2MR(ap);
1755 1886          struct mrsas_cmd        *cmd;
1756 1887  
1757 1888          con_log(CL_DLEVEL1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
1758 1889          if (instance->deadadapter == 1) {
1759 1890                  con_log(CL_ANN1, (CE_WARN,
1760 1891                      "mrsas_tran_start: return TRAN_FATAL_ERROR "
1761 1892                      "for IO, as the HBA doesnt take any more IOs"));
1762 1893                  if (pkt) {
↓ open down ↓ 33 lines elided ↑ open up ↑
1796 1927  
1797 1928                  return (TRAN_ACCEPT);
1798 1929          }
1799 1930  
1800 1931          if (cmd == NULL) {
1801 1932                  return (TRAN_BUSY);
1802 1933          }
1803 1934  
1804 1935          if ((pkt->pkt_flags & FLAG_NOINTR) == 0) {
1805 1936                  if (instance->fw_outstanding > instance->max_fw_cmds) {
1806      -                        cmn_err(CE_WARN, "mr_sas:Firmware BUSY, fw_outstanding(0x%X) > max_fw_cmds(0x%X)",
1807      -                                        instance->fw_outstanding, instance->max_fw_cmds );
     1937 +                        con_log(CL_ANN, (CE_CONT, "mr_sas:Firmware busy"));
     1938 +                        DTRACE_PROBE2(start_tran_err,
     1939 +                            uint16_t, instance->fw_outstanding,
     1940 +                            uint16_t, instance->max_fw_cmds);
1808 1941                          return_mfi_pkt(instance, cmd);
1809 1942                          return (TRAN_BUSY);
1810 1943                  }
1811 1944  
1812 1945                  /* Synchronize the Cmd frame for the controller */
1813 1946                  (void) ddi_dma_sync(cmd->frame_dma_obj.dma_handle, 0, 0,
1814 1947                      DDI_DMA_SYNC_FORDEV);
1815 1948                  con_log(CL_ANN, (CE_CONT, "issue_cmd_ppc: SCSI CDB[0]=0x%x"
1816 1949                      "cmd->index:%x\n", pkt->pkt_cdbp[0], cmd->index));
1817 1950                  instance->func_ptr->issue_cmd(cmd, instance);
1818 1951  
1819 1952          } else {
1820 1953                  struct mrsas_header *hdr = &cmd->frame->hdr;
1821 1954  
     1955 +                instance->func_ptr->issue_cmd_in_poll_mode(instance, cmd);
1822 1956  
1823      -                instance->func_ptr-> issue_cmd_in_poll_mode(instance, cmd);
1824      -
1825 1957                  pkt->pkt_reason         = CMD_CMPLT;
1826 1958                  pkt->pkt_statistics     = 0;
1827 1959                  pkt->pkt_state |= STATE_XFERRED_DATA | STATE_GOT_STATUS;
1828 1960  
1829 1961                  switch (ddi_get8(cmd->frame_dma_obj.acc_handle,
1830 1962                      &hdr->cmd_status)) {
1831 1963                  case MFI_STAT_OK:
1832 1964                          pkt->pkt_scbp[0] = STATUS_GOOD;
1833 1965                          break;
1834 1966  
1835 1967                  case MFI_STAT_SCSI_DONE_WITH_ERROR:
1836 1968                          con_log(CL_ANN, (CE_CONT,
1837      -                                "mrsas_tran_start: scsi done with error"));
     1969 +                            "mrsas_tran_start: scsi done with error"));
1838 1970                          pkt->pkt_reason = CMD_CMPLT;
1839 1971                          pkt->pkt_statistics = 0;
1840 1972  
1841 1973                          ((struct scsi_status *)pkt->pkt_scbp)->sts_chk = 1;
1842 1974                          break;
1843 1975  
1844 1976                  case MFI_STAT_DEVICE_NOT_FOUND:
1845 1977                          con_log(CL_ANN, (CE_CONT,
1846      -                                "mrsas_tran_start: device not found error"));
     1978 +                            "mrsas_tran_start: device not found error"));
1847 1979                          pkt->pkt_reason         = CMD_DEV_GONE;
1848 1980                          pkt->pkt_statistics     = STAT_DISCON;
1849 1981                          break;
1850 1982  
1851 1983                  default:
1852 1984                          ((struct scsi_status *)pkt->pkt_scbp)->sts_busy = 1;
1853 1985                  }
1854 1986  
     1987 +                (void) mrsas_common_check(instance, cmd);
     1988 +                DTRACE_PROBE2(start_nointr_done, uint8_t, hdr->cmd,
     1989 +                    uint8_t, hdr->cmd_status);
1855 1990                  return_mfi_pkt(instance, cmd);
1856 1991  
1857 1992                  if (pkt->pkt_comp) {
1858 1993                          (*pkt->pkt_comp)(pkt);
1859 1994                  }
1860 1995  
1861 1996          }
1862 1997  
1863 1998          return (TRAN_ACCEPT);
1864 1999  }
↓ open down ↓ 35 lines elided ↑ open up ↑
1900 2035   */
1901 2036  /*ARGSUSED*/
1902 2037  static int
1903 2038  mrsas_tran_reset(struct scsi_address *ap, int level)
1904 2039  {
1905 2040          struct mrsas_instance *instance = ADDR2MR(ap);
1906 2041  
1907 2042          con_log(CL_ANN1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
1908 2043  
1909 2044          if (wait_for_outstanding(instance)) {
1910      -                con_log(CL_ANN1, (CE_CONT, "wait_for_outstanding: return FAIL.\n"));
     2045 +                con_log(CL_ANN1,
     2046 +                    (CE_CONT, "wait_for_outstanding: return FAIL.\n"));
1911 2047                  return (DDI_FAILURE);
1912 2048          } else {
1913 2049                  return (DDI_SUCCESS);
1914 2050          }
1915 2051  }
1916 2052  
     2053 +#if 0
1917 2054  /*
1918 2055   * tran_bus_reset - reset the SCSI bus
1919 2056   * @dip:
1920 2057   * @level:
1921 2058   *
1922 2059   * The tran_bus_reset() vector in the scsi_hba_tran structure should be
1923 2060   * initialized during the HBA driver's attach(). The vector should point to
1924 2061   * an HBA entry point that is to be called when a user initiates a bus reset.
1925 2062   * Implementation is hardware specific. If the HBA driver cannot reset the
1926 2063   * SCSI bus without affecting the targets, the driver should fail RESET_BUS
↓ open down ↓ 4 lines elided ↑ open up ↑
1931 2068  mrsas_tran_bus_reset(dev_info_t *dip, int level)
1932 2069  {
1933 2070          int     instance_no = ddi_get_instance(dip);
1934 2071  
1935 2072          struct mrsas_instance   *instance = ddi_get_soft_state(mrsas_state,
1936 2073              instance_no);
1937 2074  
1938 2075          con_log(CL_ANN1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
1939 2076  
1940 2077          if (wait_for_outstanding(instance)) {
1941      -                con_log(CL_ANN1, (CE_CONT, "wait_for_outstanding: return FAIL.\n"));
     2078 +                con_log(CL_ANN1,
     2079 +                    (CE_CONT, "wait_for_outstanding: return FAIL.\n"));
1942 2080                  return (DDI_FAILURE);
1943 2081          } else {
1944 2082                  return (DDI_SUCCESS);
1945 2083          }
1946 2084  }
     2085 +#endif
1947 2086  
1948 2087  /*
1949 2088   * tran_getcap - get one of a set of SCSA-defined capabilities
1950 2089   * @ap:
1951 2090   * @cap:
1952 2091   * @whom:
1953 2092   *
1954 2093   * The target driver can request the current setting of the capability for a
1955 2094   * particular target by setting the whom parameter to nonzero. A whom value of
1956 2095   * zero indicates a request for the current setting of the general capability
↓ open down ↓ 14 lines elided ↑ open up ↑
1971 2110          if (cap == NULL) {
1972 2111                  return (-1);
1973 2112          }
1974 2113  
1975 2114          switch (scsi_hba_lookup_capstr(cap)) {
1976 2115          case SCSI_CAP_DMA_MAX:
1977 2116                  if (instance->tbolt) {
1978 2117                          /* Limit to 256k max transfer */
1979 2118                          rval = mrsas_tbolt_max_cap_maxxfer;
1980 2119                  } else {
1981      -                /* Limit to 16MB max transfer */
1982      -                rval = mrsas_max_cap_maxxfer;
     2120 +                        /* Limit to 16MB max transfer */
     2121 +                        rval = mrsas_max_cap_maxxfer;
1983 2122                  }
1984 2123                  break;
1985 2124          case SCSI_CAP_MSG_OUT:
1986 2125                  rval = 1;
1987 2126                  break;
1988 2127          case SCSI_CAP_DISCONNECT:
1989 2128                  rval = 0;
1990 2129                  break;
1991 2130          case SCSI_CAP_SYNCHRONOUS:
1992 2131                  rval = 0;
↓ open down ↓ 220 lines elided ↑ open up ↑
2213 2352   * Collect status for all completed commands and do callback
2214 2353   *
2215 2354   */
2216 2355  static uint_t
2217 2356  mrsas_isr(struct mrsas_instance *instance)
2218 2357  {
2219 2358          int             need_softintr;
2220 2359          uint32_t        producer;
2221 2360          uint32_t        consumer;
2222 2361          uint32_t        context;
2223      -        uint32_t        status, value;
2224 2362          int             retval;
2225 2363  
2226 2364          struct mrsas_cmd        *cmd;
2227 2365          struct mrsas_header     *hdr;
2228 2366          struct scsi_pkt         *pkt;
2229 2367  
2230 2368          con_log(CL_ANN1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
2231 2369          ASSERT(instance);
2232 2370          if (instance->tbolt) {
2233 2371                  mutex_enter(&instance->chip_mtx);
↓ open down ↓ 8 lines elided ↑ open up ↑
2242 2380          } else {
2243 2381                  if ((instance->intr_type == DDI_INTR_TYPE_FIXED) &&
2244 2382                      !instance->func_ptr->intr_ack(instance)) {
2245 2383                          return (DDI_INTR_UNCLAIMED);
2246 2384                  }
2247 2385          }
2248 2386  
2249 2387          (void) ddi_dma_sync(instance->mfi_internal_dma_obj.dma_handle,
2250 2388              0, 0, DDI_DMA_SYNC_FORCPU);
2251 2389  
     2390 +        if (mrsas_check_dma_handle(instance->mfi_internal_dma_obj.dma_handle)
     2391 +            != DDI_SUCCESS) {
     2392 +                mrsas_fm_ereport(instance, DDI_FM_DEVICE_NO_RESPONSE);
     2393 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST);
     2394 +                con_log(CL_ANN1, (CE_WARN,
     2395 +                    "mr_sas_isr(): FMA check, returning DDI_INTR_UNCLAIMED"));
     2396 +                return (DDI_INTR_CLAIMED);
     2397 +        }
     2398 +        con_log(CL_ANN1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__));
     2399 +
2252 2400  #ifdef OCRDEBUG
2253 2401          if (debug_consecutive_timeout_after_ocr_g == 1) {
2254 2402                  con_log(CL_ANN1, (CE_NOTE,
2255      -                "simulating consecutive timeout after ocr"));
     2403 +                    "simulating consecutive timeout after ocr"));
2256 2404                  return (DDI_INTR_CLAIMED);
2257 2405          }
2258 2406  #endif
2259 2407  
2260 2408          mutex_enter(&instance->completed_pool_mtx);
2261 2409          mutex_enter(&instance->cmd_pend_mtx);
2262 2410  
2263 2411          producer = ddi_get32(instance->mfi_internal_dma_obj.acc_handle,
2264 2412              instance->producer);
2265 2413          consumer = ddi_get32(instance->mfi_internal_dma_obj.acc_handle,
2266 2414              instance->consumer);
2267 2415  
2268 2416          con_log(CL_ANN, (CE_CONT, " producer %x consumer %x ",
2269 2417              producer, consumer));
2270 2418          if (producer == consumer) {
2271      -                con_log(CL_ANN, (CE_WARN, "producer ==  consumer case"));
     2419 +                con_log(CL_ANN, (CE_WARN, "producer ==  consumer case"));
     2420 +                DTRACE_PROBE2(isr_pc_err, uint32_t, producer,
     2421 +                    uint32_t, consumer);
2272 2422                  mutex_exit(&instance->cmd_pend_mtx);
2273 2423                  mutex_exit(&instance->completed_pool_mtx);
2274 2424                  return (DDI_INTR_CLAIMED);
2275 2425          }
2276 2426  
2277 2427          while (consumer != producer) {
2278 2428                  context = ddi_get32(instance->mfi_internal_dma_obj.acc_handle,
2279 2429                      &instance->reply_queue[consumer]);
2280 2430                  cmd = instance->cmd_list[context];
2281 2431  
2282 2432                  if (cmd->sync_cmd == MRSAS_TRUE) {
2283      -                hdr = (struct mrsas_header *)&cmd->frame->hdr;
2284      -                if (hdr) {
2285      -                        mlist_del_init(&cmd->list);
2286      -                }
     2433 +                        hdr = (struct mrsas_header *)&cmd->frame->hdr;
     2434 +                        if (hdr) {
     2435 +                                mlist_del_init(&cmd->list);
     2436 +                        }
2287 2437                  } else {
2288 2438                          pkt = cmd->pkt;
2289 2439                          if (pkt) {
2290 2440                                  mlist_del_init(&cmd->list);
2291 2441                          }
2292 2442                  }
2293 2443  
2294 2444                  mlist_add_tail(&cmd->list, &instance->completed_pool_list);
2295 2445  
2296 2446                  consumer++;
↓ open down ↓ 26 lines elided ↑ open up ↑
2323 2473                   */
2324 2474                  (void) mrsas_softintr(instance);
2325 2475          }
2326 2476  
2327 2477          return (DDI_INTR_CLAIMED);
2328 2478  }
2329 2479  
2330 2480  
2331 2481  /*
2332 2482   * ************************************************************************** *
2333      - *                                                                            *
2334      - *                                  libraries                                 *
2335      - *                                                                            *
     2483 + *                                                                            *
     2484 + *                                  libraries                                 *
     2485 + *                                                                            *
2336 2486   * ************************************************************************** *
2337 2487   */
2338 2488  /*
2339 2489   * get_mfi_pkt : Get a command from the free pool
2340 2490   * After successful allocation, the caller of this routine
2341 2491   * must clear the frame buffer (memset to zero) before
2342 2492   * using the packet further.
2343 2493   *
2344 2494   * ***** Note *****
2345 2495   * After clearing the frame buffer the context id of the
2346 2496   * frame buffer SHOULD be restored back.
2347 2497   */
2348 2498  static struct mrsas_cmd *
2349 2499  get_mfi_pkt(struct mrsas_instance *instance)
2350 2500  {
2351      -        mlist_t                 *head = &instance->cmd_pool_list;
     2501 +        mlist_t                 *head = &instance->cmd_pool_list;
2352 2502          struct mrsas_cmd        *cmd = NULL;
2353 2503  
2354 2504          mutex_enter(&instance->cmd_pool_mtx);
2355      -        ASSERT(mutex_owned(&instance->cmd_pool_mtx));
2356 2505  
2357 2506          if (!mlist_empty(head)) {
2358 2507                  cmd = mlist_entry(head->next, struct mrsas_cmd, list);
2359 2508                  mlist_del_init(head->next);
2360 2509          }
2361 2510          if (cmd != NULL) {
2362 2511                  cmd->pkt = NULL;
2363 2512                  cmd->retry_count_for_ocr = 0;
2364 2513                  cmd->drv_pkt_time = 0;
2365 2514  
↓ open down ↓ 3 lines elided ↑ open up ↑
2369 2518          return (cmd);
2370 2519  }
2371 2520  
2372 2521  static struct mrsas_cmd *
2373 2522  get_mfi_app_pkt(struct mrsas_instance *instance)
2374 2523  {
2375 2524          mlist_t                         *head = &instance->app_cmd_pool_list;
2376 2525          struct mrsas_cmd        *cmd = NULL;
2377 2526  
2378 2527          mutex_enter(&instance->app_cmd_pool_mtx);
2379      -        ASSERT(mutex_owned(&instance->app_cmd_pool_mtx));
2380 2528  
2381 2529          if (!mlist_empty(head)) {
2382 2530                  cmd = mlist_entry(head->next, struct mrsas_cmd, list);
2383 2531                  mlist_del_init(head->next);
2384 2532          }
2385      -        if (cmd != NULL){
     2533 +        if (cmd != NULL) {
2386 2534                  cmd->pkt = NULL;
2387 2535                  cmd->retry_count_for_ocr = 0;
2388 2536                  cmd->drv_pkt_time = 0;
2389 2537          }
2390 2538  
2391 2539          mutex_exit(&instance->app_cmd_pool_mtx);
2392 2540  
2393 2541          return (cmd);
2394 2542  }
2395 2543  /*
2396 2544   * return_mfi_pkt : Return a cmd to free command pool
2397 2545   */
2398 2546  static void
2399 2547  return_mfi_pkt(struct mrsas_instance *instance, struct mrsas_cmd *cmd)
2400 2548  {
2401 2549          mutex_enter(&instance->cmd_pool_mtx);
2402      -        ASSERT(mutex_owned(&instance->cmd_pool_mtx));
2403      -
     2550 +        /* use mlist_add_tail for debug assistance */
2404 2551          mlist_add_tail(&cmd->list, &instance->cmd_pool_list);
2405 2552  
2406 2553          mutex_exit(&instance->cmd_pool_mtx);
2407 2554  }
2408 2555  
2409 2556  static void
2410 2557  return_mfi_app_pkt(struct mrsas_instance *instance, struct mrsas_cmd *cmd)
2411 2558  {
2412 2559          mutex_enter(&instance->app_cmd_pool_mtx);
2413      -        ASSERT(mutex_owned(&instance->app_cmd_pool_mtx));
2414 2560  
2415 2561          mlist_add(&cmd->list, &instance->app_cmd_pool_list);
2416 2562  
2417 2563          mutex_exit(&instance->app_cmd_pool_mtx);
2418 2564  }
2419 2565  void
2420 2566  push_pending_mfi_pkt(struct mrsas_instance *instance, struct mrsas_cmd *cmd)
2421 2567  {
2422 2568          struct scsi_pkt *pkt;
2423 2569          struct mrsas_header     *hdr;
2424 2570          con_log(CL_DLEVEL2, (CE_NOTE, "push_pending_pkt(): Called\n"));
2425 2571          mutex_enter(&instance->cmd_pend_mtx);
2426      -        ASSERT(mutex_owned(&instance->cmd_pend_mtx));
2427      -        mlist_del_init(&cmd->list);  
     2572 +        mlist_del_init(&cmd->list);
2428 2573          mlist_add_tail(&cmd->list, &instance->cmd_pend_list);
2429 2574          if (cmd->sync_cmd == MRSAS_TRUE) {
2430 2575                  hdr = (struct mrsas_header *)&cmd->frame->hdr;
2431 2576                  if (hdr) {
2432 2577                          con_log(CL_ANN1, (CE_CONT,
2433 2578                              "push_pending_mfi_pkt: "
2434 2579                              "cmd %p index %x "
2435 2580                              "time %llx",
2436 2581                              (void *)cmd, cmd->index,
2437 2582                              gethrtime()));
2438      -                        /* Wait for specified interval  */
     2583 +                        /* Wait for specified interval  */
2439 2584                          cmd->drv_pkt_time = ddi_get16(
2440 2585                              cmd->frame_dma_obj.acc_handle, &hdr->timeout);
2441 2586                          if (cmd->drv_pkt_time < debug_timeout_g)
2442 2587                                  cmd->drv_pkt_time = (uint16_t)debug_timeout_g;
2443 2588                                  con_log(CL_ANN1, (CE_CONT,
2444      -                                        "push_pending_pkt(): "
2445      -                                        "Called IO Timeout Value %x\n",
2446      -                                        cmd->drv_pkt_time));
     2589 +                                    "push_pending_pkt(): "
     2590 +                                    "Called IO Timeout Value %x\n",
     2591 +                                    cmd->drv_pkt_time));
2447 2592                  }
2448 2593                  if (hdr && instance->timeout_id == (timeout_id_t)-1) {
2449 2594                          instance->timeout_id = timeout(io_timeout_checker,
2450 2595                              (void *) instance, drv_usectohz(MRSAS_1_SECOND));
2451 2596                  }
2452 2597          } else {
2453 2598                  pkt = cmd->pkt;
2454 2599                  if (pkt) {
2455 2600                          con_log(CL_ANN1, (CE_CONT,
2456 2601                              "push_pending_mfi_pkt: "
↓ open down ↓ 3 lines elided ↑ open up ↑
2460 2605                              gethrtime()));
2461 2606                          cmd->drv_pkt_time = (uint16_t)debug_timeout_g;
2462 2607                  }
2463 2608                  if (pkt && instance->timeout_id == (timeout_id_t)-1) {
2464 2609                          instance->timeout_id = timeout(io_timeout_checker,
2465 2610                              (void *) instance, drv_usectohz(MRSAS_1_SECOND));
2466 2611                  }
2467 2612          }
2468 2613  
2469 2614          mutex_exit(&instance->cmd_pend_mtx);
2470      -        
     2615 +
2471 2616  }
2472 2617  
2473 2618  int
2474 2619  mrsas_print_pending_cmds(struct mrsas_instance *instance)
2475 2620  {
2476 2621          mlist_t *head = &instance->cmd_pend_list;
2477 2622          mlist_t *tmp = head;
2478 2623          struct mrsas_cmd *cmd = NULL;
2479 2624          struct mrsas_header     *hdr;
2480 2625          unsigned int            flag = 1;
2481 2626          struct scsi_pkt *pkt;
2482 2627          int saved_level;
2483 2628          int cmd_count = 0;
2484 2629  
2485      -
2486 2630          saved_level = debug_level_g;
2487 2631          debug_level_g = CL_ANN1;
2488 2632  
2489 2633          cmn_err(CE_NOTE, "mrsas_print_pending_cmds(): Called\n");
2490 2634  
2491 2635          while (flag) {
2492 2636                  mutex_enter(&instance->cmd_pend_mtx);
2493 2637                  tmp     =       tmp->next;
2494 2638                  if (tmp == head) {
2495 2639                          mutex_exit(&instance->cmd_pend_mtx);
2496 2640                          flag = 0;
2497      -                        con_log(CL_ANN1, (CE_CONT, "mrsas_print_pending_cmds(): NO MORE CMDS PENDING....\n"));
     2641 +                        con_log(CL_ANN1, (CE_CONT, "mrsas_print_pending_cmds():"
     2642 +                            " NO MORE CMDS PENDING....\n"));
2498 2643                          break;
2499 2644                  } else {
2500 2645                          cmd = mlist_entry(tmp, struct mrsas_cmd, list);
2501 2646                          mutex_exit(&instance->cmd_pend_mtx);
2502 2647                          if (cmd) {
2503 2648                                  if (cmd->sync_cmd == MRSAS_TRUE) {
2504      -                                hdr = (struct mrsas_header *)&cmd->frame->hdr;
     2649 +                                        hdr = (struct mrsas_header *)
     2650 +                                            &cmd->frame->hdr;
2505 2651                                          if (hdr) {
2506      -                                        con_log(CL_ANN1, (CE_CONT,
2507      -                                            "print: cmd %p index 0x%x drv_pkt_time 0x%x (NO-PKT) hdr %p\n",
2508      -                                            (void *)cmd, cmd->index, cmd->drv_pkt_time, (void *)hdr));
     2652 +                                                con_log(CL_ANN1, (CE_CONT,
     2653 +                                                    "print: cmd %p index 0x%x "
     2654 +                                                    "drv_pkt_time 0x%x (NO-PKT)"
     2655 +                                                    " hdr %p\n", (void *)cmd,
     2656 +                                                    cmd->index,
     2657 +                                                    cmd->drv_pkt_time,
     2658 +                                                    (void *)hdr));
2509 2659                                          }
2510 2660                                  } else {
2511 2661                                          pkt = cmd->pkt;
2512 2662                                          if (pkt) {
2513 2663                                          con_log(CL_ANN1, (CE_CONT,
2514      -                                            "print: cmd %p index 0x%x drv_pkt_time 0x%x pkt %p \n",
2515      -                                            (void *)cmd, cmd->index,  cmd->drv_pkt_time, (void *)pkt));
     2664 +                                            "print: cmd %p index 0x%x "
     2665 +                                            "drv_pkt_time 0x%x pkt %p \n",
     2666 +                                            (void *)cmd, cmd->index,
     2667 +                                            cmd->drv_pkt_time, (void *)pkt));
2516 2668                                          }
2517 2669                                  }
2518 2670  
2519      -                                if (++cmd_count == 1)
2520      -                                        mrsas_print_cmd_details(instance, cmd, 0xDD);
2521      -                                else
2522      -                                        mrsas_print_cmd_details(instance, cmd, 1);
     2671 +                                if (++cmd_count == 1) {
     2672 +                                        mrsas_print_cmd_details(instance, cmd,
     2673 +                                            0xDD);
     2674 +                                } else {
     2675 +                                        mrsas_print_cmd_details(instance, cmd,
     2676 +                                            1);
     2677 +                                }
2523 2678  
2524 2679                          }
2525 2680                  }
2526 2681          }
2527 2682          con_log(CL_ANN1, (CE_CONT, "mrsas_print_pending_cmds(): Done\n"));
2528 2683  
2529      -        
     2684 +
2530 2685          debug_level_g = saved_level;
2531 2686  
2532 2687          return (DDI_SUCCESS);
2533 2688  }
2534 2689  
2535 2690  
2536 2691  int
2537 2692  mrsas_complete_pending_cmds(struct mrsas_instance *instance)
2538 2693  {
2539 2694  
↓ open down ↓ 51 lines elided ↑ open up ↑
2591 2746                      "mrsas_complete_pending_cmds:"
2592 2747                      "looping for more commands\n"));
2593 2748          }
2594 2749          mutex_exit(&instance->cmd_pend_mtx);
2595 2750  
2596 2751          con_log(CL_ANN1, (CE_CONT, "mrsas_complete_pending_cmds(): DONE\n"));
2597 2752          return (DDI_SUCCESS);
2598 2753  }
2599 2754  
2600 2755  void
2601      -mrsas_print_cmd_details(struct mrsas_instance *instance, 
2602      -                                        struct mrsas_cmd *cmd, int detail )
     2756 +mrsas_print_cmd_details(struct mrsas_instance *instance, struct mrsas_cmd *cmd,
     2757 +    int detail)
2603 2758  {
2604 2759          struct scsi_pkt *pkt = cmd->pkt;
2605 2760          Mpi2RaidSCSIIORequest_t *scsi_io = cmd->scsi_io_request;
2606      -        MPI2_SCSI_IO_VENDOR_UNIQUE *raidContext;
2607      -        uint8_t *cdb_p;
2608      -        char str[100], *strp;
2609      -        int i, j, len;
     2761 +        int i;
2610 2762          int saved_level;
     2763 +        ddi_acc_handle_t acc_handle =
     2764 +            instance->mpi2_frame_pool_dma_obj.acc_handle;
2611 2765  
2612      -
2613 2766          if (detail == 0xDD) {
2614 2767                  saved_level = debug_level_g;
2615 2768                  debug_level_g = CL_ANN1;
2616 2769          }
2617 2770  
2618 2771  
2619 2772          if (instance->tbolt) {
2620      -                con_log(CL_ANN1, (CE_CONT, "print_cmd_details: cmd %p cmd->index 0x%x SMID 0x%x timer 0x%x sec\n",
2621      -                         (void *)cmd, cmd->index, cmd->SMID, cmd->drv_pkt_time));
     2773 +                con_log(CL_ANN1, (CE_CONT, "print_cmd_details: cmd %p "
     2774 +                    "cmd->index 0x%x SMID 0x%x timer 0x%x sec\n",
     2775 +                    (void *)cmd, cmd->index, cmd->SMID, cmd->drv_pkt_time));
     2776 +        } else {
     2777 +                con_log(CL_ANN1, (CE_CONT, "print_cmd_details: cmd %p "
     2778 +                    "cmd->index 0x%x timer 0x%x sec\n",
     2779 +                    (void *)cmd, cmd->index, cmd->drv_pkt_time));
2622 2780          }
2623      -        else {
2624      -                con_log(CL_ANN1, (CE_CONT, "print_cmd_details: cmd %p cmd->index 0x%x timer 0x%x sec\n",
2625      -                         (void *)cmd, cmd->index, cmd->drv_pkt_time));
2626      -        }
2627 2781  
2628      -        if(pkt) {
     2782 +        if (pkt) {
2629 2783                  con_log(CL_ANN1, (CE_CONT, "scsi_pkt CDB[0]=0x%x",
2630      -                      pkt->pkt_cdbp[0]));
2631      -        }else {
     2784 +                    pkt->pkt_cdbp[0]));
     2785 +        } else {
2632 2786                  con_log(CL_ANN1, (CE_CONT, "NO-PKT"));
2633 2787          }
2634 2788  
2635      -        if((detail==0xDD) && instance->tbolt) {
     2789 +        if ((detail == 0xDD) && instance->tbolt) {
2636 2790                  con_log(CL_ANN1, (CE_CONT, "RAID_SCSI_IO_REQUEST\n"));
2637      -                con_log(CL_ANN1, (CE_CONT, "DevHandle=0x%X Function=0x%X IoFlags=0x%X SGLFlags=0x%X DataLength=0x%X\n",
2638      -                        ddi_get16(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->DevHandle),
2639      -                        ddi_get8(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->Function),
2640      -                        ddi_get16(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->IoFlags),
2641      -                        ddi_get16(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->SGLFlags),
2642      -                        ddi_get32(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->DataLength) ));
     2791 +                con_log(CL_ANN1, (CE_CONT, "DevHandle=0x%X Function=0x%X "
     2792 +                    "IoFlags=0x%X SGLFlags=0x%X DataLength=0x%X\n",
     2793 +                    ddi_get16(acc_handle, &scsi_io->DevHandle),
     2794 +                    ddi_get8(acc_handle, &scsi_io->Function),
     2795 +                    ddi_get16(acc_handle, &scsi_io->IoFlags),
     2796 +                    ddi_get16(acc_handle, &scsi_io->SGLFlags),
     2797 +                    ddi_get32(acc_handle, &scsi_io->DataLength)));
2643 2798  
2644      -                for(i=0; i < 32; i++)
2645      -                        con_log(CL_ANN1, (CE_CONT, "CDB[%d]=0x%x ",i,
2646      -                                ddi_get8(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->CDB.CDB32[i]) ));
     2799 +                for (i = 0; i < 32; i++) {
     2800 +                        con_log(CL_ANN1, (CE_CONT, "CDB[%d]=0x%x ", i,
     2801 +                            ddi_get8(acc_handle, &scsi_io->CDB.CDB32[i])));
     2802 +                }
2647 2803  
2648 2804                  con_log(CL_ANN1, (CE_CONT, "RAID-CONTEXT\n"));
2649      -                con_log(CL_ANN1, (CE_CONT, "status=0x%X extStatus=0x%X ldTargetId=0x%X timeoutValue=0x%X"
2650      -                        "regLockFlags=0x%X RAIDFlags=0x%X regLockRowLBA=0x%lX regLockLength=0x%X spanArm=0x%X\n",
2651      -                        ddi_get8(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->RaidContext.status),
2652      -                        ddi_get8(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->RaidContext.extStatus),
2653      -                        ddi_get16(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->RaidContext.ldTargetId),
2654      -                        ddi_get16(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->RaidContext.timeoutValue),
2655      -                        ddi_get8(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->RaidContext.regLockFlags),
2656      -                        ddi_get8(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->RaidContext.RAIDFlags),
2657      -                        ddi_get64(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->RaidContext.regLockRowLBA),
2658      -                        ddi_get32(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->RaidContext.regLockLength),
2659      -                        ddi_get8(instance->mpi2_frame_pool_dma_obj.acc_handle, &scsi_io->RaidContext.spanArm) ));
2660      -
2661      -
     2805 +                con_log(CL_ANN1, (CE_CONT, "status=0x%X extStatus=0x%X "
     2806 +                    "ldTargetId=0x%X timeoutValue=0x%X regLockFlags=0x%X "
     2807 +                    "RAIDFlags=0x%X regLockRowLBA=0x%" PRIu64
     2808 +                    " regLockLength=0x%X spanArm=0x%X\n",
     2809 +                    ddi_get8(acc_handle, &scsi_io->RaidContext.status),
     2810 +                    ddi_get8(acc_handle, &scsi_io->RaidContext.extStatus),
     2811 +                    ddi_get16(acc_handle, &scsi_io->RaidContext.ldTargetId),
     2812 +                    ddi_get16(acc_handle, &scsi_io->RaidContext.timeoutValue),
     2813 +                    ddi_get8(acc_handle, &scsi_io->RaidContext.regLockFlags),
     2814 +                    ddi_get8(acc_handle, &scsi_io->RaidContext.RAIDFlags),
     2815 +                    ddi_get64(acc_handle, &scsi_io->RaidContext.regLockRowLBA),
     2816 +                    ddi_get32(acc_handle, &scsi_io->RaidContext.regLockLength),
     2817 +                    ddi_get8(acc_handle, &scsi_io->RaidContext.spanArm)));
2662 2818          }
2663 2819  
2664 2820          if (detail == 0xDD) {
2665 2821                  debug_level_g = saved_level;
2666 2822          }
2667      -
2668      -        return;
2669 2823  }
2670 2824  
2671 2825  
2672 2826  int
2673 2827  mrsas_issue_pending_cmds(struct mrsas_instance *instance)
2674 2828  {
2675 2829          mlist_t *head   =       &instance->cmd_pend_list;
2676 2830          mlist_t *tmp    =       head->next;
2677 2831          struct mrsas_cmd *cmd = NULL;
2678 2832          struct scsi_pkt *pkt;
↓ open down ↓ 1 lines elided ↑ open up ↑
2680 2834          con_log(CL_ANN1, (CE_NOTE, "mrsas_issue_pending_cmds(): Called"));
2681 2835          while (tmp != head) {
2682 2836                  mutex_enter(&instance->cmd_pend_mtx);
2683 2837                  cmd = mlist_entry(tmp, struct mrsas_cmd, list);
2684 2838                  tmp = tmp->next;
2685 2839                  mutex_exit(&instance->cmd_pend_mtx);
2686 2840                  if (cmd) {
2687 2841                          con_log(CL_ANN1, (CE_CONT,
2688 2842                              "mrsas_issue_pending_cmds(): "
2689 2843                              "Got a cmd: cmd %p index 0x%x drv_pkt_time 0x%x ",
2690      -                                            (void *)cmd, cmd->index, cmd->drv_pkt_time));
     2844 +                            (void *)cmd, cmd->index, cmd->drv_pkt_time));
2691 2845  
     2846 +                        /* Reset command timeout value */
2692 2847                          if (cmd->drv_pkt_time < debug_timeout_g)
2693      -                                cmd->drv_pkt_time = (uint16_t)debug_timeout_g;  /* Reset command timeout value */
     2848 +                                cmd->drv_pkt_time = (uint16_t)debug_timeout_g;
2694 2849  
2695 2850                          cmd->retry_count_for_ocr++;
2696 2851  
2697 2852                          cmn_err(CE_CONT, "cmd retry count = %d\n",
2698 2853                              cmd->retry_count_for_ocr);
2699 2854  
2700 2855                          if (cmd->retry_count_for_ocr > IO_RETRY_COUNT) {
2701      -                                cmn_err(CE_WARN,
2702      -                                        "mrsas_issue_pending_cmds(): cmd->retry_count exceeded limit >%d\n",
     2856 +                                cmn_err(CE_WARN, "mrsas_issue_pending_cmds(): "
     2857 +                                    "cmd->retry_count exceeded limit >%d\n",
2703 2858                                      IO_RETRY_COUNT);
2704 2859                                  mrsas_print_cmd_details(instance, cmd, 0xDD);
2705 2860  
2706 2861                                  cmn_err(CE_WARN,
2707      -                                        "mrsas_issue_pending_cmds():"
     2862 +                                    "mrsas_issue_pending_cmds():"
2708 2863                                      "Calling KILL Adapter\n");
2709 2864                                  if (instance->tbolt)
2710      -                                        (void) mrsas_tbolt_kill_adapter(instance);
     2865 +                                        mrsas_tbolt_kill_adapter(instance);
2711 2866                                  else
2712 2867                                          (void) mrsas_kill_adapter(instance);
2713 2868                                  return (DDI_FAILURE);
2714 2869                          }
2715 2870  
2716 2871                          pkt = cmd->pkt;
2717 2872                          if (pkt) {
2718 2873                                  con_log(CL_ANN1, (CE_CONT,
2719 2874                                      "PENDING PKT-CMD ISSUE: cmd %p index %x "
2720 2875                                      "pkt %p time %llx",
2721 2876                                      (void *)cmd, cmd->index,
2722 2877                                      (void *)pkt,
2723 2878                                      gethrtime()));
2724 2879  
2725 2880                          } else {
2726 2881                                  cmn_err(CE_CONT,
2727      -                                        "mrsas_issue_pending_cmds(): "
2728      -                                        "NO-PKT, cmd %p index 0x%x drv_pkt_time 0x%x ",
2729      -                                            (void *)cmd, cmd->index, cmd->drv_pkt_time);
     2882 +                                    "mrsas_issue_pending_cmds(): NO-PKT, "
     2883 +                                    "cmd %p index 0x%x drv_pkt_time 0x%x ",
     2884 +                                    (void *)cmd, cmd->index, cmd->drv_pkt_time);
2730 2885                          }
2731 2886  
2732 2887  
2733 2888                          if (cmd->sync_cmd == MRSAS_TRUE) {
2734      -                                cmn_err(CE_CONT, "mrsas_issue_pending_cmds(): SYNC_CMD == TRUE \n");
2735      -
2736      -                                instance->func_ptr->issue_cmd_in_sync_mode(instance, cmd);
     2889 +                                cmn_err(CE_CONT, "mrsas_issue_pending_cmds(): "
     2890 +                                    "SYNC_CMD == TRUE \n");
     2891 +                                instance->func_ptr->issue_cmd_in_sync_mode(
     2892 +                                    instance, cmd);
2737 2893                          } else {
2738 2894                                  instance->func_ptr->issue_cmd(cmd, instance);
2739 2895                          }
2740 2896                  } else {
2741 2897                          con_log(CL_ANN1, (CE_CONT,
2742 2898                              "mrsas_issue_pending_cmds: NULL command\n"));
2743 2899                  }
2744 2900                  con_log(CL_ANN1, (CE_CONT,
2745 2901                      "mrsas_issue_pending_cmds:"
2746 2902                      "looping for more commands"));
↓ open down ↓ 88 lines elided ↑ open up ↑
2835 2991                      tot_frame_size - SENSE_LENGTH;
2836 2992  
2837 2993                  if (!cmd->frame || !cmd->sense) {
2838 2994                          cmn_err(CE_WARN,
2839 2995                              "mr_sas: pci_pool_alloc failed");
2840 2996                          retval = ENOMEM;
2841 2997                          goto mrsas_undo_frame_pool;
2842 2998                  }
2843 2999  
2844 3000                  ddi_put32(cmd->frame_dma_obj.acc_handle,
2845      -                                &cmd->frame->io.context, cmd->index);
     3001 +                    &cmd->frame->io.context, cmd->index);
2846 3002                  i++;
2847 3003  
2848 3004                  con_log(CL_DLEVEL3, (CE_NOTE, "[%x]-%x",
2849 3005                      cmd->index, cmd->frame_phys_addr));
2850 3006          }
2851 3007  
2852 3008          return (DDI_SUCCESS);
2853 3009  
2854 3010  mrsas_undo_frame_pool:
2855 3011          if (i > 0)
2856      -          destroy_mfi_frame_pool(instance);
     3012 +                destroy_mfi_frame_pool(instance);
2857 3013  
2858 3014          return (retval);
2859 3015  }
2860 3016  
2861 3017  /*
2862 3018   * free_additional_dma_buffer
2863 3019   */
2864 3020  static void
2865 3021  free_additional_dma_buffer(struct mrsas_instance *instance)
2866 3022  {
↓ open down ↓ 99 lines elided ↑ open up ↑
2966 3122                  return;
2967 3123          }
2968 3124  
2969 3125          max_cmd = instance->max_fw_cmds;
2970 3126  
2971 3127          /* size of cmd_list array */
2972 3128          sz = sizeof (struct mrsas_cmd *) * max_cmd;
2973 3129  
2974 3130          /* First free each cmd */
2975 3131          for (i = 0; i < max_cmd; i++) {
2976      -                if (instance->cmd_list[i] != NULL)
2977      -                        kmem_free(instance->cmd_list[i],sizeof (struct mrsas_cmd));
     3132 +                if (instance->cmd_list[i] != NULL) {
     3133 +                        kmem_free(instance->cmd_list[i],
     3134 +                            sizeof (struct mrsas_cmd));
     3135 +                }
2978 3136  
2979 3137                  instance->cmd_list[i] = NULL;
2980 3138          }
2981 3139  
2982 3140          /* Now, free cmd_list array */
2983 3141          if (instance->cmd_list != NULL)
2984      -                kmem_free(instance->cmd_list,sz);
     3142 +                kmem_free(instance->cmd_list, sz);
2985 3143  
2986 3144          instance->cmd_list = NULL;
2987 3145  
2988 3146          INIT_LIST_HEAD(&instance->cmd_pool_list);
2989 3147          INIT_LIST_HEAD(&instance->cmd_pend_list);
2990 3148          if (instance->tbolt) {
2991 3149                  INIT_LIST_HEAD(&instance->cmd_app_pool_list);
2992      -        }
2993      -        else {
     3150 +        } else {
2994 3151                  INIT_LIST_HEAD(&instance->app_cmd_pool_list);
2995 3152          }
2996 3153  
2997 3154  }
2998 3155  
2999 3156  
3000 3157  /*
3001 3158   * mrsas_alloc_cmd_pool
3002 3159   */
3003 3160  int
↓ open down ↓ 13 lines elided ↑ open up ↑
3017 3174  
3018 3175  
3019 3176          sz = sizeof (struct mrsas_cmd *) * max_cmd;
3020 3177  
3021 3178          /*
3022 3179           * instance->cmd_list is an array of struct mrsas_cmd pointers.
3023 3180           * Allocate the dynamic array first and then allocate individual
3024 3181           * commands.
3025 3182           */
3026 3183          instance->cmd_list = kmem_zalloc(sz, KM_SLEEP);
3027      -        if (instance->cmd_list == NULL) {
3028      -                con_log(CL_NONE, (CE_WARN,
3029      -                    "Failed to allocate memory for cmd_list"));
3030      -                return (DDI_FAILURE);
3031      -        }
     3184 +        ASSERT(instance->cmd_list);
3032 3185  
3033 3186          /* create a frame pool and assign one frame to each cmd */
3034 3187          for (count = 0; count < max_cmd; count++) {
3035      -                instance->cmd_list[count] = kmem_zalloc(sizeof (struct mrsas_cmd),
3036      -                    KM_SLEEP);
3037      -                if (instance->cmd_list[count] == NULL) {
3038      -                        con_log(CL_NONE, (CE_WARN,
3039      -                                "Failed to allocate memory for mrsas_cmd"));
3040      -                        goto mrsas_undo_cmds;
3041      -                }
     3188 +                instance->cmd_list[count] =
     3189 +                    kmem_zalloc(sizeof (struct mrsas_cmd), KM_SLEEP);
     3190 +                ASSERT(instance->cmd_list[count]);
3042 3191          }
3043 3192  
3044 3193          /* add all the commands to command pool */
3045 3194  
3046 3195          INIT_LIST_HEAD(&instance->cmd_pool_list);
3047 3196          INIT_LIST_HEAD(&instance->cmd_pend_list);
3048 3197          INIT_LIST_HEAD(&instance->app_cmd_pool_list);
3049 3198  
3050      -        reserve_cmd     = MRSAS_APP_RESERVED_CMDS;
     3199 +        reserve_cmd = MRSAS_APP_RESERVED_CMDS;
3051 3200  
3052      -        for (i = 0; i < reserve_cmd; i++) {  
3053      -                cmd             = instance->cmd_list[i];
3054      -                cmd->index      = i;
     3201 +        for (i = 0; i < reserve_cmd; i++) {
     3202 +                cmd = instance->cmd_list[i];
     3203 +                cmd->index = i;
3055 3204                  mlist_add_tail(&cmd->list, &instance->app_cmd_pool_list);
3056 3205          }
3057      -        
3058 3206  
     3207 +
3059 3208          for (i = reserve_cmd; i < max_cmd; i++) {
3060      -                cmd             = instance->cmd_list[i];
3061      -                cmd->index      = i;
     3209 +                cmd = instance->cmd_list[i];
     3210 +                cmd->index = i;
3062 3211                  mlist_add_tail(&cmd->list, &instance->cmd_pool_list);
3063 3212          }
3064 3213  
3065 3214          return (DDI_SUCCESS);
3066 3215  
3067 3216  mrsas_undo_cmds:
3068 3217          if (count > 0) {
3069 3218                  /* free each cmd */
3070 3219                  for (i = 0; i < count; i++) {
3071      -                        if (instance->cmd_list[i] != NULL)
3072      -                                kmem_free(instance->cmd_list[i],sizeof (struct mrsas_cmd));
     3220 +                        if (instance->cmd_list[i] != NULL) {
     3221 +                                kmem_free(instance->cmd_list[i],
     3222 +                                    sizeof (struct mrsas_cmd));
     3223 +                        }
3073 3224                          instance->cmd_list[i] = NULL;
3074 3225                  }
3075 3226          }
3076 3227  
3077 3228  mrsas_undo_cmd_list:
3078 3229          if (instance->cmd_list != NULL)
3079      -                kmem_free(instance->cmd_list,sz);
     3230 +                kmem_free(instance->cmd_list, sz);
3080 3231          instance->cmd_list = NULL;
3081 3232  
3082 3233          return (DDI_FAILURE);
3083 3234  }
3084 3235  
3085 3236  
3086 3237  /*
3087 3238   * free_space_for_mfi
3088 3239   */
3089 3240  static void
↓ open down ↓ 15 lines elided ↑ open up ↑
3105 3256          /* Free the cmd_list buffer itself */
3106 3257          mrsas_free_cmd_pool(instance);
3107 3258  }
3108 3259  
3109 3260  /*
3110 3261   * alloc_space_for_mfi
3111 3262   */
3112 3263  static int
3113 3264  alloc_space_for_mfi(struct mrsas_instance *instance)
3114 3265  {
3115      -        /* Allocate command pool ( memory for cmd_list & individual commands )*/
     3266 +        /* Allocate command pool (memory for cmd_list & individual commands) */
3116 3267          if (mrsas_alloc_cmd_pool(instance)) {
3117 3268                  cmn_err(CE_WARN, "error creating cmd pool");
3118      -                return (DDI_FAILURE); 
     3269 +                return (DDI_FAILURE);
3119 3270          }
3120 3271  
3121 3272          /* Allocate MFI Frame pool */
3122 3273          if (create_mfi_frame_pool(instance)) {
3123 3274                  cmn_err(CE_WARN, "error creating frame DMA pool");
3124 3275                  goto mfi_undo_cmd_pool;
3125 3276          }
3126 3277  
3127 3278          /* Allocate additional DMA buffer */
3128 3279          if (alloc_additional_dma_buffer(instance)) {
↓ open down ↓ 20 lines elided ↑ open up ↑
3149 3300  static int
3150 3301  get_ctrl_info(struct mrsas_instance *instance,
3151 3302      struct mrsas_ctrl_info *ctrl_info)
3152 3303  {
3153 3304          int     ret = 0;
3154 3305  
3155 3306          struct mrsas_cmd                *cmd;
3156 3307          struct mrsas_dcmd_frame *dcmd;
3157 3308          struct mrsas_ctrl_info  *ci;
3158 3309  
3159      -        if(instance->tbolt) {
     3310 +        if (instance->tbolt) {
3160 3311                  cmd = get_raid_msg_mfi_pkt(instance);
3161      -        }
3162      -        else {
     3312 +        } else {
3163 3313                  cmd = get_mfi_pkt(instance);
3164 3314          }
3165 3315  
3166 3316          if (!cmd) {
3167      -                cmn_err(CE_WARN,
3168      -                    "Failed to get a cmd from free-pool in get_ctrl_info(). fw_outstanding=0x%X max_fw_cmds=0x%X",
3169      -                                instance->fw_outstanding, instance->max_fw_cmds);
     3317 +                con_log(CL_ANN, (CE_WARN,
     3318 +                    "Failed to get a cmd for ctrl info"));
     3319 +                DTRACE_PROBE2(info_mfi_err, uint16_t, instance->fw_outstanding,
     3320 +                    uint16_t, instance->max_fw_cmds);
3170 3321                  return (DDI_FAILURE);
3171 3322          }
3172 3323  
3173 3324          /* Clear the frame buffer and assign back the context id */
3174 3325          (void) memset((char *)&cmd->frame[0], 0, sizeof (union mrsas_frame));
3175 3326          ddi_put32(cmd->frame_dma_obj.acc_handle, &cmd->frame->hdr.context,
3176 3327              cmd->index);
3177 3328  
3178 3329          dcmd = &cmd->frame->dcmd;
3179 3330  
↓ open down ↓ 23 lines elided ↑ open up ↑
3203 3354          ddi_put32(cmd->frame_dma_obj.acc_handle, &dcmd->opcode,
3204 3355              MR_DCMD_CTRL_GET_INFO);
3205 3356          ddi_put32(cmd->frame_dma_obj.acc_handle, &dcmd->sgl.sge32[0].phys_addr,
3206 3357              instance->internal_buf_dmac_add);
3207 3358          ddi_put32(cmd->frame_dma_obj.acc_handle, &dcmd->sgl.sge32[0].length,
3208 3359              sizeof (struct mrsas_ctrl_info));
3209 3360  
3210 3361          cmd->frame_count = 1;
3211 3362  
3212 3363          if (instance->tbolt) {
3213      -        mr_sas_tbolt_build_mfi_cmd(instance, cmd);
3214      -    }
3215      -        
     3364 +                mr_sas_tbolt_build_mfi_cmd(instance, cmd);
     3365 +        }
     3366 +
3216 3367          if (!instance->func_ptr->issue_cmd_in_poll_mode(instance, cmd)) {
3217      -        ret = 0;
     3368 +                ret = 0;
3218 3369  
3219      -        ctrl_info->max_request_size = ddi_get32(
3220      -            cmd->frame_dma_obj.acc_handle, &ci->max_request_size);
     3370 +                ctrl_info->max_request_size = ddi_get32(
     3371 +                    cmd->frame_dma_obj.acc_handle, &ci->max_request_size);
3221 3372  
3222      -        ctrl_info->ld_present_count = ddi_get16(
3223      -            cmd->frame_dma_obj.acc_handle, &ci->ld_present_count);
     3373 +                ctrl_info->ld_present_count = ddi_get16(
     3374 +                    cmd->frame_dma_obj.acc_handle, &ci->ld_present_count);
3224 3375  
3225      -        ctrl_info->properties.on_off_properties =
3226      -            ddi_get32(cmd->frame_dma_obj.acc_handle,
3227      -            &ci->properties.on_off_properties);
3228      -        ddi_rep_get8(cmd->frame_dma_obj.acc_handle,
3229      -            (uint8_t *)(ctrl_info->product_name),
3230      -            (uint8_t *)(ci->product_name), 80 * sizeof (char),
3231      -            DDI_DEV_AUTOINCR);
3232      -        /* should get more members of ci with ddi_get when needed */
     3376 +                ctrl_info->properties.on_off_properties = ddi_get32(
     3377 +                    cmd->frame_dma_obj.acc_handle,
     3378 +                    &ci->properties.on_off_properties);
     3379 +                ddi_rep_get8(cmd->frame_dma_obj.acc_handle,
     3380 +                    (uint8_t *)(ctrl_info->product_name),
     3381 +                    (uint8_t *)(ci->product_name), 80 * sizeof (char),
     3382 +                    DDI_DEV_AUTOINCR);
     3383 +                /* should get more members of ci with ddi_get when needed */
3233 3384          } else {
3234 3385                  cmn_err(CE_WARN, "get_ctrl_info: Ctrl info failed");
3235 3386                  ret = -1;
3236 3387          }
3237 3388  
3238      -        if(instance->tbolt) {
3239      -                return_raid_msg_mfi_pkt(instance, cmd);
     3389 +        if (mrsas_common_check(instance, cmd) != DDI_SUCCESS) {
     3390 +                ret = -1;
3240 3391          }
3241      -        else {
     3392 +        if (instance->tbolt) {
     3393 +                return_raid_msg_mfi_pkt(instance, cmd);
     3394 +        } else {
3242 3395                  return_mfi_pkt(instance, cmd);
3243 3396          }
3244      -        
     3397 +
3245 3398          return (ret);
3246 3399  }
3247 3400  
3248 3401  /*
3249 3402   * abort_aen_cmd
3250 3403   */
3251 3404  static int
3252 3405  abort_aen_cmd(struct mrsas_instance *instance,
3253 3406      struct mrsas_cmd *cmd_to_abort)
3254 3407  {
↓ open down ↓ 4 lines elided ↑ open up ↑
3259 3412  
3260 3413          con_log(CL_ANN1, (CE_NOTE, "chkpnt: abort_aen:%d", __LINE__));
3261 3414  
3262 3415          if (instance->tbolt) {
3263 3416                  cmd = get_raid_msg_mfi_pkt(instance);
3264 3417          } else {
3265 3418                  cmd = get_mfi_pkt(instance);
3266 3419          }
3267 3420  
3268 3421          if (!cmd) {
3269      -                cmn_err(CE_WARN,
3270      -                    "Failed to get a cmd from free-pool in abort_aen_cmd(). fw_outstanding=0x%X max_fw_cmds=0x%X",
3271      -                                instance->fw_outstanding, instance->max_fw_cmds);
     3422 +                con_log(CL_ANN1, (CE_WARN,
     3423 +                    "abort_aen_cmd():Failed to get a cmd for abort_aen_cmd"));
     3424 +                DTRACE_PROBE2(abort_mfi_err, uint16_t, instance->fw_outstanding,
     3425 +                    uint16_t, instance->max_fw_cmds);
3272 3426                  return (DDI_FAILURE);
3273 3427          }
     3428 +
3274 3429          /* Clear the frame buffer and assign back the context id */
3275 3430          (void) memset((char *)&cmd->frame[0], 0, sizeof (union mrsas_frame));
3276 3431          ddi_put32(cmd->frame_dma_obj.acc_handle, &cmd->frame->hdr.context,
3277 3432              cmd->index);
3278 3433  
3279 3434          abort_fr = &cmd->frame->abort;
3280 3435  
3281 3436          /* prepare and issue the abort frame */
3282 3437          ddi_put8(cmd->frame_dma_obj.acc_handle,
3283 3438              &abort_fr->cmd, MFI_CMD_OP_ABORT);
↓ open down ↓ 32 lines elided ↑ open up ↑
3316 3471                  return_mfi_pkt(instance, cmd);
3317 3472          }
3318 3473  
3319 3474          atomic_add_16(&instance->fw_outstanding, (-1));
3320 3475  
3321 3476          return (ret);
3322 3477  }
3323 3478  
3324 3479  
3325 3480  static int
3326      -mrsas_build_init_cmd(struct mrsas_instance *instance, struct mrsas_cmd **cmd_ptr)
     3481 +mrsas_build_init_cmd(struct mrsas_instance *instance,
     3482 +    struct mrsas_cmd **cmd_ptr)
3327 3483  {
3328 3484          struct mrsas_cmd                *cmd;
3329 3485          struct mrsas_init_frame         *init_frame;
3330 3486          struct mrsas_init_queue_info    *initq_info;
3331      -        struct mrsas_drv_ver            drv_ver_info;   
     3487 +        struct mrsas_drv_ver            drv_ver_info;
3332 3488  
3333 3489  
3334 3490          /*
3335 3491           * Prepare a init frame. Note the init frame points to queue info
3336 3492           * structure. Each frame has SGL allocated after first 64 bytes. For
3337 3493           * this frame - since we don't need any SGL - we use SGL's space as
3338 3494           * queue info structure
3339 3495           */
3340 3496          cmd = *cmd_ptr;
3341 3497  
↓ open down ↓ 38 lines elided ↑ open up ↑
3380 3536          ddi_put8(cmd->frame_dma_obj.acc_handle, &init_frame->cmd_status,
3381 3537              MFI_CMD_STATUS_POLL_MODE);
3382 3538          ddi_put16(cmd->frame_dma_obj.acc_handle, &init_frame->flags, 0);
3383 3539          ddi_put32(cmd->frame_dma_obj.acc_handle,
3384 3540              &init_frame->queue_info_new_phys_addr_lo,
3385 3541              cmd->frame_phys_addr + 64);
3386 3542          ddi_put32(cmd->frame_dma_obj.acc_handle,
3387 3543              &init_frame->queue_info_new_phys_addr_hi, 0);
3388 3544  
3389 3545  
3390      -        /* fill driver version information*/
     3546 +        /* fill driver version information */
3391 3547          fill_up_drv_ver(&drv_ver_info);
3392 3548  
3393 3549          /* allocate the driver version data transfer buffer */
3394      -        instance->drv_ver_dma_obj.size = sizeof(drv_ver_info.drv_ver);
     3550 +        instance->drv_ver_dma_obj.size = sizeof (drv_ver_info.drv_ver);
3395 3551          instance->drv_ver_dma_obj.dma_attr = mrsas_generic_dma_attr;
3396 3552          instance->drv_ver_dma_obj.dma_attr.dma_attr_addr_hi = 0xFFFFFFFFU;
3397 3553          instance->drv_ver_dma_obj.dma_attr.dma_attr_count_max = 0xFFFFFFFFU;
3398 3554          instance->drv_ver_dma_obj.dma_attr.dma_attr_sgllen = 1;
3399 3555          instance->drv_ver_dma_obj.dma_attr.dma_attr_align = 1;
3400 3556  
3401 3557          if (mrsas_alloc_dma_obj(instance, &instance->drv_ver_dma_obj,
3402 3558              (uchar_t)DDI_STRUCTURE_LE_ACC) != 1) {
3403 3559                  con_log(CL_ANN, (CE_WARN,
3404 3560                      "init_mfi : Could not allocate driver version buffer."));
3405 3561                  return (DDI_FAILURE);
3406 3562          }
3407      -        /* copy driver version to dma  buffer*/
3408      -        (void) memset(instance->drv_ver_dma_obj.buffer, 0,sizeof(drv_ver_info.drv_ver));
     3563 +        /* copy driver version to dma buffer */
     3564 +        (void) memset(instance->drv_ver_dma_obj.buffer, 0,
     3565 +            sizeof (drv_ver_info.drv_ver));
3409 3566          ddi_rep_put8(cmd->frame_dma_obj.acc_handle,
3410      -                (uint8_t *)drv_ver_info.drv_ver,
3411      -                (uint8_t *)instance->drv_ver_dma_obj.buffer, 
3412      -                sizeof(drv_ver_info.drv_ver), DDI_DEV_AUTOINCR);        
     3567 +            (uint8_t *)drv_ver_info.drv_ver,
     3568 +            (uint8_t *)instance->drv_ver_dma_obj.buffer,
     3569 +            sizeof (drv_ver_info.drv_ver), DDI_DEV_AUTOINCR);
3413 3570  
3414 3571  
3415      -        /*copy driver version physical address to init frame*/
3416      -        ddi_put64(cmd->frame_dma_obj.acc_handle,
3417      -            &init_frame->driverversion, instance->drv_ver_dma_obj.dma_cookie[0].dmac_address);
     3572 +        /* copy driver version physical address to init frame */
     3573 +        ddi_put64(cmd->frame_dma_obj.acc_handle, &init_frame->driverversion,
     3574 +            instance->drv_ver_dma_obj.dma_cookie[0].dmac_address);
3418 3575  
3419 3576          ddi_put32(cmd->frame_dma_obj.acc_handle, &init_frame->data_xfer_len,
3420 3577              sizeof (struct mrsas_init_queue_info));
3421 3578  
3422 3579          cmd->frame_count = 1;
3423 3580  
3424 3581          *cmd_ptr = cmd;
3425 3582  
3426 3583          return (DDI_SUCCESS);
3427 3584  }
3428 3585  
3429 3586  
3430 3587  /*
3431 3588   * mrsas_init_adapter_ppc - Initialize MFI interface adapter.
3432 3589   */
3433 3590  int
3434      -mrsas_init_adapter_ppc (struct mrsas_instance *instance)
     3591 +mrsas_init_adapter_ppc(struct mrsas_instance *instance)
3435 3592  {
3436 3593          struct mrsas_cmd                *cmd;
3437 3594  
3438      -        /* allocate memory for mfi adapter(cmd pool, individual commands, mfi frames etc */
3439      -        if (alloc_space_for_mfi(instance) != DDI_SUCCESS){
     3595 +        /*
     3596 +         * allocate memory for mfi adapter(cmd pool, individual commands, mfi
     3597 +         * frames etc
     3598 +         */
     3599 +        if (alloc_space_for_mfi(instance) != DDI_SUCCESS) {
3440 3600                  con_log(CL_ANN, (CE_NOTE,
3441      -                        "Error, failed to allocate memory for MFI adapter"));
3442      -                return (DDI_FAILURE); 
     3601 +                    "Error, failed to allocate memory for MFI adapter"));
     3602 +                return (DDI_FAILURE);
3443 3603          }
3444 3604  
3445 3605          /* Build INIT command */
3446 3606          cmd = get_mfi_pkt(instance);
3447 3607  
3448      -        if (mrsas_build_init_cmd(instance, &cmd) != DDI_SUCCESS){
3449      -                con_log(CL_ANN, (CE_NOTE,
3450      -                        "Error, failed to build INIT command"));
     3608 +        if (mrsas_build_init_cmd(instance, &cmd) != DDI_SUCCESS) {
     3609 +                con_log(CL_ANN,
     3610 +                    (CE_NOTE, "Error, failed to build INIT command"));
3451 3611  
3452 3612                  goto fail_undo_alloc_mfi_space;
3453 3613          }
3454 3614  
3455      -        //Disalbe interrupt before sending init frame ( see linux driver code)
3456      -        /* send INIT MFI frame in polled mode */
     3615 +        /*
     3616 +         * Disable interrupt before sending init frame ( see linux driver code)
     3617 +         * send INIT MFI frame in polled mode
     3618 +         */
3457 3619          if (instance->func_ptr->issue_cmd_in_poll_mode(instance, cmd)) {
3458 3620                  con_log(CL_ANN, (CE_WARN, "failed to init firmware"));
3459 3621                  goto fail_fw_init;
3460 3622          }
3461 3623  
3462      -        if (instance->func_ptr->read_fw_status_reg(instance) & 0x04000000) {
     3624 +        if (mrsas_common_check(instance, cmd) != DDI_SUCCESS)
     3625 +                goto fail_fw_init;
     3626 +        return_mfi_pkt(instance, cmd);
     3627 +
     3628 +        if (ctio_enable &&
     3629 +            (instance->func_ptr->read_fw_status_reg(instance) & 0x04000000)) {
3463 3630                  con_log(CL_ANN, (CE_NOTE, "mr_sas: IEEE SGL's supported"));
3464 3631                  instance->flag_ieee = 1;
     3632 +        } else {
     3633 +                instance->flag_ieee = 0;
3465 3634          }
3466 3635  
3467 3636          instance->unroll.alloc_space_mfi = 1;
3468 3637          instance->unroll.verBuff = 1;
3469 3638  
3470 3639          return (DDI_SUCCESS);
3471 3640  
3472 3641  
3473 3642  fail_fw_init:
3474      -        mrsas_free_dma_obj(instance, instance->drv_ver_dma_obj);
     3643 +        (void) mrsas_free_dma_obj(instance, instance->drv_ver_dma_obj);
3475 3644  
3476 3645  fail_undo_alloc_mfi_space:
3477 3646          return_mfi_pkt(instance, cmd);
3478 3647          free_space_for_mfi(instance);
3479 3648  
3480 3649          return (DDI_FAILURE);
3481 3650  
3482 3651  }
3483 3652  
3484 3653  /*
3485 3654   * mrsas_init_adapter - Initialize adapter.
3486 3655   */
3487 3656  int
3488      -mrsas_init_adapter (struct mrsas_instance *instance)
     3657 +mrsas_init_adapter(struct mrsas_instance *instance)
3489 3658  {
3490 3659          struct mrsas_ctrl_info          ctrl_info;
3491 3660  
3492 3661  
3493 3662          /* we expect the FW state to be READY */
3494 3663          if (mfi_state_transition_to_ready(instance)) {
3495 3664                  con_log(CL_ANN, (CE_WARN, "mr_sas: F/W is not ready"));
3496 3665                  return (DDI_FAILURE);
3497 3666          }
3498 3667  
↓ open down ↓ 11 lines elided ↑ open up ↑
3510 3679           * does not exceed max cmds that the FW can support
3511 3680           */
3512 3681          instance->max_fw_cmds =
3513 3682              instance->func_ptr->read_fw_status_reg(instance) & 0xFFFF;
3514 3683          instance->max_fw_cmds = instance->max_fw_cmds - 1;
3515 3684  
3516 3685  
3517 3686  
3518 3687          /* Initialize adapter */
3519 3688          if (instance->func_ptr->init_adapter(instance) != DDI_SUCCESS) {
3520      -                con_log(CL_ANN, (CE_WARN, "mr_sas: "
3521      -                        "could not initialize adapter"));
     3689 +                con_log(CL_ANN,
     3690 +                    (CE_WARN, "mr_sas: could not initialize adapter"));
3522 3691                  return (DDI_FAILURE);
3523 3692          }
3524      -        
     3693 +
3525 3694          /* gather misc FW related information */
3526 3695          instance->disable_online_ctrl_reset = 0;
3527 3696  
3528 3697          if (!get_ctrl_info(instance, &ctrl_info)) {
3529 3698                  instance->max_sectors_per_req = ctrl_info.max_request_size;
3530 3699                  con_log(CL_ANN1, (CE_NOTE,
3531 3700                      "product name %s ld present %d",
3532 3701                      ctrl_info.product_name, ctrl_info.ld_present_count));
3533 3702          } else {
3534 3703                  instance->max_sectors_per_req = instance->max_num_sge *
3535 3704                      PAGESIZE / 512;
3536 3705          }
3537 3706  
3538      -        if (ctrl_info.properties.on_off_properties & DISABLE_OCR_PROP_FLAG) {
     3707 +        if (ctrl_info.properties.on_off_properties & DISABLE_OCR_PROP_FLAG)
3539 3708                  instance->disable_online_ctrl_reset = 1;
3540      -                con_log(CL_ANN1, (CE_NOTE,
3541      -                        "Disable online control Flag is set\n"));
3542      -        }
3543      -        else {
3544      -                con_log(CL_ANN1, (CE_NOTE,
3545      -                        "Disable online control Flag is not set\n"));   
3546      -        }
3547 3709  
3548 3710          return (DDI_SUCCESS);
3549 3711  
3550 3712  }
3551 3713  
3552 3714  
3553 3715  
3554 3716  static int
3555 3717  mrsas_issue_init_mfi(struct mrsas_instance *instance)
3556 3718  {
↓ open down ↓ 68 lines elided ↑ open up ↑
3625 3787  
3626 3788          /* issue the init frame in polled mode */
3627 3789          if (instance->func_ptr->issue_cmd_in_poll_mode(instance, cmd)) {
3628 3790                  con_log(CL_ANN1, (CE_WARN,
3629 3791                      "mrsas_issue_init_mfi():failed to "
3630 3792                      "init firmware"));
3631 3793                  return_mfi_app_pkt(instance, cmd);
3632 3794                  return (DDI_FAILURE);
3633 3795          }
3634 3796  
     3797 +        if (mrsas_common_check(instance, cmd) != DDI_SUCCESS) {
     3798 +                return_mfi_pkt(instance, cmd);
     3799 +                return (DDI_FAILURE);
     3800 +        }
     3801 +
3635 3802          return_mfi_app_pkt(instance, cmd);
3636 3803          con_log(CL_ANN1, (CE_CONT, "mrsas_issue_init_mfi: Done"));
3637 3804  
3638 3805          return (DDI_SUCCESS);
3639 3806  }
3640 3807  /*
3641 3808   * mfi_state_transition_to_ready        : Move the FW to READY state
3642 3809   *
3643 3810   * @reg_set                     : MFI register set
3644 3811   */
↓ open down ↓ 36 lines elided ↑ open up ↑
3681 3848                           * to be set
3682 3849                           */
3683 3850                          /* WR_IB_MSG_0(MFI_INIT_CLEAR_HANDSHAKE, instance); */
3684 3851                          if (!instance->tbolt) {
3685 3852                                  WR_IB_DOORBELL(MFI_INIT_CLEAR_HANDSHAKE |
3686 3853                                      MFI_INIT_HOTPLUG, instance);
3687 3854                          } else {
3688 3855                                  WR_RESERVED0_REGISTER(MFI_INIT_CLEAR_HANDSHAKE |
3689 3856                                      MFI_INIT_HOTPLUG, instance);
3690 3857                          }
3691      -                        max_wait        = (instance->tbolt == 1) ? 180 : 2;
     3858 +                        max_wait        = (instance->tbolt == 1) ? 180 : 2;
3692 3859                          cur_state       = MFI_STATE_WAIT_HANDSHAKE;
3693 3860                          break;
3694 3861                  case MFI_STATE_BOOT_MESSAGE_PENDING:
3695 3862                          /* set the CLR bit in IMR0 */
3696 3863                          con_log(CL_ANN1, (CE_NOTE,
3697 3864                              "mr_sas: FW state boot message pending"));
3698 3865                          /*
3699 3866                           * PCI_Hot Plug: MFI F/W requires
3700 3867                           * (MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG)
3701 3868                           * to be set
3702 3869                           */
3703 3870                          if (!instance->tbolt) {
3704 3871                                  WR_IB_DOORBELL(MFI_INIT_HOTPLUG, instance);
3705 3872                          } else {
3706 3873                                  WR_RESERVED0_REGISTER(MFI_INIT_HOTPLUG,
3707 3874                                      instance);
3708 3875                          }
3709      -                        max_wait        = (instance->tbolt == 1) ? 180 : 10;
     3876 +                        max_wait        = (instance->tbolt == 1) ? 180 : 10;
3710 3877                          cur_state       = MFI_STATE_BOOT_MESSAGE_PENDING;
3711 3878                          break;
3712 3879                  case MFI_STATE_OPERATIONAL:
3713 3880                          /* bring it to READY state; assuming max wait 2 secs */
3714 3881                          instance->func_ptr->disable_intr(instance);
3715 3882                          con_log(CL_ANN1, (CE_NOTE,
3716 3883                              "mr_sas: FW in OPERATIONAL state"));
3717 3884                          /*
3718 3885                           * PCI_Hot Plug: MFI F/W requires
3719 3886                           * (MFI_INIT_READY | MFI_INIT_MFIMODE | MFI_INIT_ABORT)
↓ open down ↓ 2 lines elided ↑ open up ↑
3722 3889                          /* WR_IB_DOORBELL(MFI_INIT_READY, instance); */
3723 3890                          if (!instance->tbolt) {
3724 3891                                  WR_IB_DOORBELL(MFI_RESET_FLAGS, instance);
3725 3892                          } else {
3726 3893                                  WR_RESERVED0_REGISTER(MFI_RESET_FLAGS,
3727 3894                                      instance);
3728 3895  
3729 3896                                  for (i = 0; i < (10 * 1000); i++) {
3730 3897                                          status =
3731 3898                                              RD_RESERVED0_REGISTER(instance);
3732      -                                        if (status & 1)
     3899 +                                        if (status & 1) {
3733 3900                                                  delay(1 *
3734 3901                                                      drv_usectohz(MILLISEC));
3735      -                                        else
     3902 +                                        } else {
3736 3903                                                  break;
     3904 +                                        }
3737 3905                                  }
3738 3906  
3739 3907                          }
3740      -                        max_wait        = (instance->tbolt == 1) ? 180 : 10;
     3908 +                        max_wait        = (instance->tbolt == 1) ? 180 : 10;
3741 3909                          cur_state       = MFI_STATE_OPERATIONAL;
3742 3910                          break;
3743 3911                  case MFI_STATE_UNDEFINED:
3744 3912                          /* this state should not last for more than 2 seconds */
3745 3913                          con_log(CL_ANN1, (CE_NOTE, "FW state undefined"));
3746 3914  
3747      -                        max_wait        = (instance->tbolt == 1) ? 180 : 2;
     3915 +                        max_wait        = (instance->tbolt == 1) ? 180 : 2;
3748 3916                          cur_state       = MFI_STATE_UNDEFINED;
3749 3917                          break;
3750 3918                  case MFI_STATE_BB_INIT:
3751      -                        max_wait        = (instance->tbolt == 1) ? 180 : 2;
     3919 +                        max_wait        = (instance->tbolt == 1) ? 180 : 2;
3752 3920                          cur_state       = MFI_STATE_BB_INIT;
3753 3921                          break;
3754 3922                  case MFI_STATE_FW_INIT:
3755      -                        max_wait        = (instance->tbolt == 1) ? 180 : 2;
     3923 +                        max_wait        = (instance->tbolt == 1) ? 180 : 2;
3756 3924                          cur_state       = MFI_STATE_FW_INIT;
3757 3925                          break;
3758 3926                  case MFI_STATE_FW_INIT_2:
3759      -                        max_wait        = 180;
     3927 +                        max_wait        = 180;
3760 3928                          cur_state       = MFI_STATE_FW_INIT_2;
3761 3929                          break;
3762 3930                  case MFI_STATE_DEVICE_SCAN:
3763 3931                          max_wait        = 180;
3764 3932                          cur_state       = MFI_STATE_DEVICE_SCAN;
3765 3933                          prev_abs_reg_val = cur_abs_reg_val;
3766 3934                          con_log(CL_NONE, (CE_NOTE,
3767 3935                              "Device scan in progress ...\n"));
3768 3936                          break;
3769 3937                  case MFI_STATE_FLUSH_CACHE:
3770      -                        max_wait        = 180;
     3938 +                        max_wait        = 180;
3771 3939                          cur_state       = MFI_STATE_FLUSH_CACHE;
3772 3940                          break;
3773 3941                  default:
3774 3942                          con_log(CL_ANN1, (CE_NOTE,
3775 3943                              "mr_sas: Unknown state 0x%x", fw_state));
3776 3944                          return (ENODEV);
3777 3945                  }
3778 3946  
3779 3947                  /* the cur_state should not last for more than max_wait secs */
3780 3948                  for (i = 0; i < (max_wait * MILLISEC); i++) {
↓ open down ↓ 19 lines elided ↑ open up ↑
3800 3968                          con_log(CL_ANN1, (CE_WARN,
3801 3969                              "FW state hasn't changed in %d secs", max_wait));
3802 3970                          return (ENODEV);
3803 3971                  }
3804 3972          };
3805 3973  
3806 3974          if (!instance->tbolt) {
3807 3975                  fw_ctrl = RD_IB_DOORBELL(instance);
3808 3976                  con_log(CL_ANN1, (CE_CONT,
3809 3977                      "mfi_state_transition_to_ready:FW ctrl = 0x%x", fw_ctrl));
3810      -        }
3811 3978  
3812      -#if 0
3813      -        /*
3814      -         * Write 0xF to the doorbell register to do the following.
3815      -         * - Abort all outstanding commands (bit 0).
3816      -         * - Transition from OPERATIONAL to READY state (bit 1).
3817      -         * - Discard (possible) low MFA posted in 64-bit mode (bit-2).
3818      -         * - Set to release FW to continue running (i.e. BIOS handshake
3819      -         *   (bit 3).
3820      -         */
3821      -        if (!instance->tbolt) {
     3979 +                /*
     3980 +                 * Write 0xF to the doorbell register to do the following.
     3981 +                 * - Abort all outstanding commands (bit 0).
     3982 +                 * - Transition from OPERATIONAL to READY state (bit 1).
     3983 +                 * - Discard (possible) low MFA posted in 64-bit mode (bit-2).
     3984 +                 * - Set to release FW to continue running (i.e. BIOS handshake
     3985 +                 *   (bit 3).
     3986 +                 */
3822 3987                  WR_IB_DOORBELL(0xF, instance);
3823 3988          }
3824      -#endif
3825 3989  
     3990 +        if (mrsas_check_acc_handle(instance->regmap_handle) != DDI_SUCCESS) {
     3991 +                return (EIO);
     3992 +        }
     3993 +
3826 3994          return (DDI_SUCCESS);
3827 3995  }
3828 3996  
3829 3997  /*
3830 3998   * get_seq_num
3831 3999   */
3832 4000  static int
3833 4001  get_seq_num(struct mrsas_instance *instance,
3834 4002      struct mrsas_evt_log_info *eli)
3835 4003  {
↓ open down ↓ 3 lines elided ↑ open up ↑
3839 4007          struct mrsas_cmd                *cmd;
3840 4008          struct mrsas_dcmd_frame         *dcmd;
3841 4009          struct mrsas_evt_log_info *eli_tmp;
3842 4010          if (instance->tbolt) {
3843 4011                  cmd = get_raid_msg_mfi_pkt(instance);
3844 4012          } else {
3845 4013                  cmd = get_mfi_pkt(instance);
3846 4014          }
3847 4015  
3848 4016          if (!cmd) {
3849      -                cmn_err(CE_WARN,
3850      -                    "Failed to get a cmd from free-pool in get_seq_num(). fw_outstanding=0x%X max_fw_cmds=0x%X",
3851      -                        instance->fw_outstanding, instance->max_fw_cmds);
     4017 +                cmn_err(CE_WARN, "mr_sas: failed to get a cmd");
     4018 +                DTRACE_PROBE2(seq_num_mfi_err, uint16_t,
     4019 +                    instance->fw_outstanding, uint16_t, instance->max_fw_cmds);
3852 4020                  return (ENOMEM);
3853 4021          }
3854 4022  
3855 4023          /* Clear the frame buffer and assign back the context id */
3856 4024          (void) memset((char *)&cmd->frame[0], 0, sizeof (union mrsas_frame));
3857 4025          ddi_put32(cmd->frame_dma_obj.acc_handle, &cmd->frame->hdr.context,
3858 4026              cmd->index);
3859 4027  
3860      -        dcmd    = &cmd->frame->dcmd;
     4028 +        dcmd = &cmd->frame->dcmd;
3861 4029  
3862 4030          /* allocate the data transfer buffer */
3863 4031          dcmd_dma_obj.size = sizeof (struct mrsas_evt_log_info);
3864 4032          dcmd_dma_obj.dma_attr = mrsas_generic_dma_attr;
3865 4033          dcmd_dma_obj.dma_attr.dma_attr_addr_hi = 0xFFFFFFFFU;
3866 4034          dcmd_dma_obj.dma_attr.dma_attr_count_max = 0xFFFFFFFFU;
3867 4035          dcmd_dma_obj.dma_attr.dma_attr_sgllen = 1;
3868 4036          dcmd_dma_obj.dma_attr.dma_attr_align = 1;
3869 4037  
3870 4038          if (mrsas_alloc_dma_obj(instance, &dcmd_dma_obj,
↓ open down ↓ 90 lines elided ↑ open up ↑
3961 4129  }
3962 4130  
3963 4131  /*
3964 4132   * flush_cache
3965 4133   */
3966 4134  static void
3967 4135  flush_cache(struct mrsas_instance *instance)
3968 4136  {
3969 4137          struct mrsas_cmd                *cmd = NULL;
3970 4138          struct mrsas_dcmd_frame         *dcmd;
3971      -        uint32_t        max_cmd = instance->max_fw_cmds;
3972 4139          if (instance->tbolt) {
3973 4140                  cmd = get_raid_msg_mfi_pkt(instance);
3974 4141          } else {
3975 4142                  cmd = get_mfi_pkt(instance);
3976 4143          }
3977 4144  
3978 4145          if (!cmd) {
3979      -                cmn_err(CE_WARN,
3980      -                    "Failed to get a cmd from free-pool in flush_cache(). fw_outstanding=0x%X max_fw_cmds=0x%X",
3981      -                                instance->fw_outstanding, instance->max_fw_cmds);
     4146 +                con_log(CL_ANN1, (CE_WARN,
     4147 +                    "flush_cache():Failed to get a cmd for flush_cache"));
     4148 +                DTRACE_PROBE2(flush_cache_err, uint16_t,
     4149 +                    instance->fw_outstanding, uint16_t, instance->max_fw_cmds);
3982 4150                  return;
3983 4151          }
3984 4152  
3985 4153          /* Clear the frame buffer and assign back the context id */
3986 4154          (void) memset((char *)&cmd->frame[0], 0, sizeof (union mrsas_frame));
3987 4155          ddi_put32(cmd->frame_dma_obj.acc_handle, &cmd->frame->hdr.context,
3988 4156              cmd->index);
3989 4157  
3990 4158          dcmd = &cmd->frame->dcmd;
3991 4159  
↓ open down ↓ 33 lines elided ↑ open up ↑
4025 4193  /*
4026 4194   * service_mfi_aen-     Completes an AEN command
4027 4195   * @instance:                   Adapter soft state
4028 4196   * @cmd:                        Command to be completed
4029 4197   *
4030 4198   */
4031 4199  void
4032 4200  service_mfi_aen(struct mrsas_instance *instance, struct mrsas_cmd *cmd)
4033 4201  {
4034 4202          uint32_t        seq_num;
4035      -        uint32_t        i;
4036 4203          struct mrsas_evt_detail *evt_detail =
4037 4204              (struct mrsas_evt_detail *)instance->mfi_evt_detail_obj.buffer;
4038 4205          int             rval = 0;
4039 4206          int             tgt = 0;
4040 4207          uint8_t         dtype;
4041 4208  #ifdef PDSUPPORT
4042 4209          mrsas_pd_address_t      *pd_addr;
4043 4210  #endif
4044 4211          ddi_acc_handle_t                acc_handle;
4045 4212  
↓ open down ↓ 25 lines elided ↑ open up ↑
4071 4238              evt_detail->cl.members.class,
4072 4239              ddi_get16(acc_handle, &evt_detail->cl.members.locale),
4073 4240              ddi_get8(acc_handle, &evt_detail->arg_type)));
4074 4241  
4075 4242          switch (ddi_get32(acc_handle, &evt_detail->code)) {
4076 4243          case MR_EVT_CFG_CLEARED: {
4077 4244                  for (tgt = 0; tgt < MRDRV_MAX_LD; tgt++) {
4078 4245                          if (instance->mr_ld_list[tgt].dip != NULL) {
4079 4246                                  mutex_enter(&instance->config_dev_mtx);
4080 4247                                  instance->mr_ld_list[tgt].flag =
4081      -                                    ~MRDRV_TGT_VALID;
     4248 +                                    (uint8_t)~MRDRV_TGT_VALID;
4082 4249                                  mutex_exit(&instance->config_dev_mtx);
4083 4250                                  rval = mrsas_service_evt(instance, tgt, 0,
4084 4251                                      MRSAS_EVT_UNCONFIG_TGT, NULL);
4085 4252                                  con_log(CL_ANN1, (CE_WARN,
4086 4253                                      "mr_sas: CFG CLEARED AEN rval = %d "
4087 4254                                      "tgt id = %d", rval, tgt));
4088 4255                          }
4089 4256                  }
4090 4257                  break;
4091 4258          }
4092 4259  
4093 4260          case MR_EVT_LD_DELETED: {
4094 4261                  tgt = ddi_get16(acc_handle, &evt_detail->args.ld.target_id);
4095 4262                  mutex_enter(&instance->config_dev_mtx);
4096      -                instance->mr_ld_list[tgt].flag = ~MRDRV_TGT_VALID;
     4263 +                instance->mr_ld_list[tgt].flag = (uint8_t)~MRDRV_TGT_VALID;
4097 4264                  mutex_exit(&instance->config_dev_mtx);
4098 4265                  rval = mrsas_service_evt(instance,
4099 4266                      ddi_get16(acc_handle, &evt_detail->args.ld.target_id), 0,
4100 4267                      MRSAS_EVT_UNCONFIG_TGT, NULL);
4101 4268                  con_log(CL_ANN1, (CE_WARN, "mr_sas: LD DELETED AEN rval = %d "
4102 4269                      "tgt id = %d index = %d", rval,
4103 4270                      ddi_get16(acc_handle, &evt_detail->args.ld.target_id),
4104 4271                      ddi_get8(acc_handle, &evt_detail->args.ld.ld_index)));
4105 4272                  break;
4106 4273          } /* End of MR_EVT_LD_DELETED */
↓ open down ↓ 3 lines elided ↑ open up ↑
4110 4277                      ddi_get16(acc_handle, &evt_detail->args.ld.target_id), 0,
4111 4278                      MRSAS_EVT_CONFIG_TGT, NULL);
4112 4279                  con_log(CL_ANN1, (CE_WARN, "mr_sas: LD CREATED AEN rval = %d "
4113 4280                      "tgt id = %d index = %d", rval,
4114 4281                      ddi_get16(acc_handle, &evt_detail->args.ld.target_id),
4115 4282                      ddi_get8(acc_handle, &evt_detail->args.ld.ld_index)));
4116 4283                  break;
4117 4284          } /* End of MR_EVT_LD_CREATED */
4118 4285  
4119 4286  #ifdef PDSUPPORT
4120      -        case MR_EVT_PD_REMOVED_EXT: { 
     4287 +        case MR_EVT_PD_REMOVED_EXT: {
4121 4288                  if (instance->tbolt) {
4122 4289                          pd_addr = &evt_detail->args.pd_addr;
4123 4290                          dtype = pd_addr->scsi_dev_type;
4124 4291                          con_log(CL_DLEVEL1, (CE_NOTE,
4125      -                           " MR_EVT_PD_REMOVED_EXT: dtype = %x," 
     4292 +                            " MR_EVT_PD_REMOVED_EXT: dtype = %x,"
4126 4293                              " arg_type = %d ", dtype, evt_detail->arg_type));
4127      -                            tgt = ddi_get16(acc_handle, &evt_detail->args.pd.device_id);
     4294 +                        tgt = ddi_get16(acc_handle,
     4295 +                            &evt_detail->args.pd.device_id);
4128 4296                          mutex_enter(&instance->config_dev_mtx);
4129      -                        instance->mr_tbolt_pd_list[tgt].flag = (uint8_t)~MRDRV_TGT_VALID;
     4297 +                        instance->mr_tbolt_pd_list[tgt].flag =
     4298 +                            (uint8_t)~MRDRV_TGT_VALID;
4130 4299                          mutex_exit(&instance->config_dev_mtx);
4131      -                        rval = mrsas_service_evt(instance,
4132      -                        ddi_get16(acc_handle, &evt_detail->args.pd.device_id),
4133      -                            1, MRSAS_EVT_UNCONFIG_TGT, NULL);
     4300 +                        rval = mrsas_service_evt(instance, ddi_get16(
     4301 +                            acc_handle, &evt_detail->args.pd.device_id),
     4302 +                            1, MRSAS_EVT_UNCONFIG_TGT, NULL);
4134 4303                          con_log(CL_ANN1, (CE_WARN, "mr_sas: PD_REMOVED:"
4135 4304                              "rval = %d tgt id = %d ", rval,
4136      -                        ddi_get16(acc_handle, &evt_detail->args.pd.device_id)));
4137      -                        break;
     4305 +                            ddi_get16(acc_handle,
     4306 +                            &evt_detail->args.pd.device_id)));
4138 4307                  }
4139      -        }/* End of MR_EVT_PD_REMOVED_EXT */
     4308 +                break;
     4309 +        } /* End of MR_EVT_PD_REMOVED_EXT */
4140 4310  
4141 4311          case MR_EVT_PD_INSERTED_EXT: {
4142 4312                  if (instance->tbolt) {
4143 4313                          rval = mrsas_service_evt(instance,
4144      -                        ddi_get16(acc_handle, &evt_detail->args.pd.device_id),
4145      -                            1, MRSAS_EVT_CONFIG_TGT, NULL);
     4314 +                            ddi_get16(acc_handle,
     4315 +                            &evt_detail->args.pd.device_id),
     4316 +                            1, MRSAS_EVT_CONFIG_TGT, NULL);
4146 4317                          con_log(CL_ANN1, (CE_WARN, "mr_sas: PD_INSERTEDi_EXT:"
4147      -                            "rval = %d tgt id = %d ", rval,
4148      -                            ddi_get16(acc_handle, &evt_detail->args.pd.device_id)));
4149      -                        break;
     4318 +                            "rval = %d tgt id = %d ", rval,
     4319 +                            ddi_get16(acc_handle,
     4320 +                            &evt_detail->args.pd.device_id)));
4150 4321                  }
4151      -        }/* End of MR_EVT_PD_INSERTED_EXT */
     4322 +                break;
     4323 +        } /* End of MR_EVT_PD_INSERTED_EXT */
4152 4324  
4153 4325          case MR_EVT_PD_STATE_CHANGE: {
4154 4326                  if (instance->tbolt) {
4155      -                        tgt = ddi_get16(acc_handle, &evt_detail->args.pd.device_id);
4156      -                        if ((evt_detail->args.pd_state.prevState == PD_SYSTEM) &&
4157      -                            (evt_detail->args.pd_state.newState != PD_SYSTEM)) {
     4327 +                        tgt = ddi_get16(acc_handle,
     4328 +                            &evt_detail->args.pd.device_id);
     4329 +                        if ((evt_detail->args.pd_state.prevState ==
     4330 +                            PD_SYSTEM) &&
     4331 +                            (evt_detail->args.pd_state.newState != PD_SYSTEM)) {
4158 4332                                  mutex_enter(&instance->config_dev_mtx);
4159 4333                                  instance->mr_tbolt_pd_list[tgt].flag =
4160      -                                    (uint8_t)~MRDRV_TGT_VALID;
     4334 +                                    (uint8_t)~MRDRV_TGT_VALID;
4161 4335                                  mutex_exit(&instance->config_dev_mtx);
4162 4336                                  rval = mrsas_service_evt(instance,
4163      -                                    ddi_get16(acc_handle,
4164      -                                    &evt_detail->args.pd.device_id),
     4337 +                                    ddi_get16(acc_handle,
     4338 +                                    &evt_detail->args.pd.device_id),
4165 4339                                      1, MRSAS_EVT_UNCONFIG_TGT, NULL);
4166 4340                                  con_log(CL_ANN1, (CE_WARN, "mr_sas: PD_REMOVED:"
4167      -                                    "rval = %d tgt id = %d ", rval,
4168      -                                    ddi_get16(acc_handle,
4169      -                                    &evt_detail->args.pd.device_id)));  
     4341 +                                    "rval = %d tgt id = %d ", rval,
     4342 +                                    ddi_get16(acc_handle,
     4343 +                                    &evt_detail->args.pd.device_id)));
4170 4344                                  break;
4171      -                        }                                       
     4345 +                        }
4172 4346                          if ((evt_detail->args.pd_state.prevState
4173      -                            == UNCONFIGURED_GOOD) &&
4174      -                            (evt_detail->args.pd_state.newState == PD_SYSTEM)) {
     4347 +                            == UNCONFIGURED_GOOD) &&
     4348 +                            (evt_detail->args.pd_state.newState == PD_SYSTEM)) {
4175 4349                                  rval = mrsas_service_evt(instance,
4176      -                                ddi_get16(acc_handle,
4177      -                                    &evt_detail->args.pd.device_id),
4178      -                                    1, MRSAS_EVT_CONFIG_TGT, NULL);
     4350 +                                    ddi_get16(acc_handle,
     4351 +                                    &evt_detail->args.pd.device_id),
     4352 +                                    1, MRSAS_EVT_CONFIG_TGT, NULL);
4179 4353                                  con_log(CL_ANN1, (CE_WARN,
4180      -                                    "mr_sas: PD_INSERTED: rval = %d "
4181      -                                    " tgt id = %d ", rval,
4182      -                                    ddi_get16(acc_handle,
4183      -                                    &evt_detail->args.pd.device_id)));
     4354 +                                    "mr_sas: PD_INSERTED: rval = %d "
     4355 +                                    " tgt id = %d ", rval,
     4356 +                                    ddi_get16(acc_handle,
     4357 +                                    &evt_detail->args.pd.device_id)));
4184 4358                                  break;
4185      -                        }       
     4359 +                        }
4186 4360                  }
     4361 +                break;
4187 4362          }
4188 4363  #endif
4189 4364  
4190 4365          } /* End of Main Switch */
4191 4366  
4192 4367          /* get copy of seq_num and class/locale for re-registration */
4193 4368          seq_num = ddi_get32(acc_handle, &evt_detail->seq_num);
4194 4369          seq_num++;
4195 4370          (void) memset(instance->mfi_evt_detail_obj.buffer, 0,
4196 4371              sizeof (struct mrsas_evt_detail));
↓ open down ↓ 52 lines elided ↑ open up ↑
4249 4424  mrsas_initiate_ocr_if_fw_is_faulty(struct mrsas_instance *instance)
4250 4425  {
4251 4426          uint32_t        cur_abs_reg_val;
4252 4427          uint32_t        fw_state;
4253 4428  
4254 4429          cur_abs_reg_val =  instance->func_ptr->read_fw_status_reg(instance);
4255 4430          fw_state = cur_abs_reg_val & MFI_STATE_MASK;
4256 4431          if (fw_state == MFI_STATE_FAULT) {
4257 4432                  if (instance->disable_online_ctrl_reset == 1) {
4258 4433                          cmn_err(CE_WARN,
4259      -                                "mrsas_initiate_ocr_if_fw_is_faulty: "
4260      -                                "FW in Fault state, detected in ISR: "
4261      -                                "FW doesn't support ocr ");
     4434 +                            "mrsas_initiate_ocr_if_fw_is_faulty: "
     4435 +                            "FW in Fault state, detected in ISR: "
     4436 +                            "FW doesn't support ocr ");
4262 4437  
4263 4438                          return (ADAPTER_RESET_NOT_REQUIRED);
4264 4439                  } else {
4265 4440                          con_log(CL_ANN, (CE_NOTE,
4266      -                                "mrsas_initiate_ocr_if_fw_is_faulty: "
4267      -                                "FW in Fault state, detected in ISR: FW supports ocr "));
     4441 +                            "mrsas_initiate_ocr_if_fw_is_faulty: FW in Fault "
     4442 +                            "state, detected in ISR: FW supports ocr "));
4268 4443  
4269 4444                          return (ADAPTER_RESET_REQUIRED);
4270 4445                  }
4271 4446          }
4272 4447  
4273 4448          return (ADAPTER_RESET_NOT_REQUIRED);
4274 4449  }
4275 4450  
4276 4451  /*
4277 4452   * mrsas_softintr - The Software ISR
↓ open down ↓ 33 lines elided ↑ open up ↑
4311 4486          mutex_exit(&instance->completed_pool_mtx);
4312 4487  
4313 4488          /* perform all callbacks first, before releasing the SCBs */
4314 4489          mlist_for_each_safe(pos, next, &process_list) {
4315 4490                  cmd = mlist_entry(pos, struct mrsas_cmd, list);
4316 4491  
4317 4492                  /* syncronize the Cmd frame for the controller */
4318 4493                  (void) ddi_dma_sync(cmd->frame_dma_obj.dma_handle,
4319 4494                      0, 0, DDI_DMA_SYNC_FORCPU);
4320 4495  
     4496 +                if (mrsas_check_dma_handle(cmd->frame_dma_obj.dma_handle) !=
     4497 +                    DDI_SUCCESS) {
     4498 +                        mrsas_fm_ereport(instance, DDI_FM_DEVICE_NO_RESPONSE);
     4499 +                        ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST);
     4500 +                        con_log(CL_ANN1, (CE_WARN,
     4501 +                            "mrsas_softintr: "
     4502 +                            "FMA check reports DMA handle failure"));
     4503 +                        return (DDI_INTR_CLAIMED);
     4504 +                }
     4505 +
4321 4506                  hdr = &cmd->frame->hdr;
4322 4507  
4323 4508                  /* remove the internal command from the process list */
4324 4509                  mlist_del_init(&cmd->list);
4325 4510  
4326 4511                  switch (ddi_get8(cmd->frame_dma_obj.acc_handle, &hdr->cmd)) {
4327 4512                  case MFI_CMD_OP_PD_SCSI:
4328 4513                  case MFI_CMD_OP_LD_SCSI:
4329 4514                  case MFI_CMD_OP_LD_READ:
4330 4515                  case MFI_CMD_OP_LD_WRITE:
↓ open down ↓ 24 lines elided ↑ open up ↑
4355 4540                          pkt->pkt_reason         = CMD_CMPLT;
4356 4541                          pkt->pkt_statistics     = 0;
4357 4542                          pkt->pkt_state = STATE_GOT_BUS
4358 4543                              | STATE_GOT_TARGET | STATE_SENT_CMD
4359 4544                              | STATE_XFERRED_DATA | STATE_GOT_STATUS;
4360 4545  
4361 4546                          con_log(CL_ANN, (CE_CONT,
4362 4547                              "CDB[0] = %x completed for %s: size %lx context %x",
4363 4548                              pkt->pkt_cdbp[0], ((acmd->islogical) ? "LD" : "PD"),
4364 4549                              acmd->cmd_dmacount, hdr->context));
     4550 +                        DTRACE_PROBE3(softintr_cdb, uint8_t, pkt->pkt_cdbp[0],
     4551 +                            uint_t, acmd->cmd_cdblen, ulong_t,
     4552 +                            acmd->cmd_dmacount);
4365 4553  
4366 4554                          if (pkt->pkt_cdbp[0] == SCMD_INQUIRY) {
4367 4555                                  struct scsi_inquiry     *inq;
4368 4556  
4369 4557                                  if (acmd->cmd_dmacount != 0) {
4370 4558                                          bp_mapin(acmd->cmd_buf);
4371 4559                                          inq = (struct scsi_inquiry *)
4372 4560                                              acmd->cmd_buf->b_un.b_addr;
4373 4561  
4374 4562                                          /* don't expose physical drives to OS */
↓ open down ↓ 8 lines elided ↑ open up ↑
4383 4571                                                  display_scsi_inquiry(
4384 4572                                                      (caddr_t)inq);
4385 4573  
4386 4574                                                  /* for physical disk */
4387 4575                                                  hdr->cmd_status =
4388 4576                                                      MFI_STAT_DEVICE_NOT_FOUND;
4389 4577                                          }
4390 4578                                  }
4391 4579                          }
4392 4580  
     4581 +                        DTRACE_PROBE2(softintr_done, uint8_t, hdr->cmd,
     4582 +                            uint8_t, hdr->cmd_status);
     4583 +
4393 4584                          switch (hdr->cmd_status) {
4394 4585                          case MFI_STAT_OK:
4395 4586                                  pkt->pkt_scbp[0] = STATUS_GOOD;
4396 4587                                  break;
4397 4588                          case MFI_STAT_LD_CC_IN_PROGRESS:
4398 4589                          case MFI_STAT_LD_RECON_IN_PROGRESS:
4399 4590                                  pkt->pkt_scbp[0] = STATUS_GOOD;
4400 4591                                  break;
4401 4592                          case MFI_STAT_LD_INIT_IN_PROGRESS:
4402      -                                con_log(CL_ANN, (CE_WARN, "Initialization in Progress"));
     4593 +                                con_log(CL_ANN,
     4594 +                                    (CE_WARN, "Initialization in Progress"));
4403 4595                                  pkt->pkt_reason = CMD_TRAN_ERR;
4404 4596  
4405 4597                                  break;
4406 4598                          case MFI_STAT_SCSI_DONE_WITH_ERROR:
4407 4599                                  con_log(CL_ANN, (CE_CONT, "scsi_done error"));
4408 4600  
4409 4601                                  pkt->pkt_reason = CMD_CMPLT;
4410 4602                                  ((struct scsi_status *)
4411 4603                                      pkt->pkt_scbp)->sts_chk = 1;
4412 4604  
4413 4605                                  if (pkt->pkt_cdbp[0] == SCMD_TEST_UNIT_READY) {
4414      -
4415      -                                        con_log(CL_ANN, (CE_WARN, "TEST_UNIT_READY fail"));
4416      -
     4606 +                                        con_log(CL_ANN,
     4607 +                                            (CE_WARN, "TEST_UNIT_READY fail"));
4417 4608                                  } else {
4418 4609                                          pkt->pkt_state |= STATE_ARQ_DONE;
4419 4610                                          arqstat = (void *)(pkt->pkt_scbp);
4420 4611                                          arqstat->sts_rqpkt_reason = CMD_CMPLT;
4421 4612                                          arqstat->sts_rqpkt_resid = 0;
4422 4613                                          arqstat->sts_rqpkt_state |=
4423 4614                                              STATE_GOT_BUS | STATE_GOT_TARGET
4424 4615                                              | STATE_SENT_CMD
4425 4616                                              | STATE_XFERRED_DATA;
4426 4617                                          *(uint8_t *)&arqstat->sts_rqpkt_status =
↓ open down ↓ 46 lines elided ↑ open up ↑
4473 4664  
4474 4665                          default:
4475 4666                                  con_log(CL_ANN, (CE_CONT, "Unknown status!"));
4476 4667                                  pkt->pkt_reason = CMD_TRAN_ERR;
4477 4668  
4478 4669                                  break;
4479 4670                          }
4480 4671  
4481 4672                          atomic_add_16(&instance->fw_outstanding, (-1));
4482 4673  
     4674 +                        (void) mrsas_common_check(instance, cmd);
     4675 +
     4676 +                        if (acmd->cmd_dmahandle) {
     4677 +                                if (mrsas_check_dma_handle(
     4678 +                                    acmd->cmd_dmahandle) != DDI_SUCCESS) {
     4679 +                                        ddi_fm_service_impact(instance->dip,
     4680 +                                            DDI_SERVICE_UNAFFECTED);
     4681 +                                        pkt->pkt_reason = CMD_TRAN_ERR;
     4682 +                                        pkt->pkt_statistics = 0;
     4683 +                                }
     4684 +                        }
     4685 +
4483 4686                          /* Call the callback routine */
4484 4687                          if (((pkt->pkt_flags & FLAG_NOINTR) == 0) &&
4485 4688                              pkt->pkt_comp) {
4486 4689  
4487 4690                                  con_log(CL_DLEVEL1, (CE_NOTE, "mrsas_softintr: "
4488 4691                                      "posting to scsa cmd %p index %x pkt %p "
4489 4692                                      "time %llx", (void *)cmd, cmd->index,
4490 4693                                      (void *)pkt, gethrtime()));
4491 4694                                  (*pkt->pkt_comp)(pkt);
4492 4695  
↓ open down ↓ 31 lines elided ↑ open up ↑
4524 4727                  case MFI_CMD_OP_ABORT:
4525 4728                          con_log(CL_ANN, (CE_NOTE, "MFI_CMD_OP_ABORT complete"));
4526 4729                          /*
4527 4730                           * MFI_CMD_OP_ABORT successfully completed
4528 4731                           * in the synchronous mode
4529 4732                           */
4530 4733                          complete_cmd_in_sync_mode(instance, cmd);
4531 4734                          break;
4532 4735  
4533 4736                  default:
     4737 +                        mrsas_fm_ereport(instance, DDI_FM_DEVICE_NO_RESPONSE);
     4738 +                        ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST);
     4739 +
4534 4740                          if (cmd->pkt != NULL) {
4535 4741                                  pkt = cmd->pkt;
4536 4742                                  if (((pkt->pkt_flags & FLAG_NOINTR) == 0) &&
4537 4743                                      pkt->pkt_comp) {
4538 4744  
4539 4745                                          con_log(CL_ANN1, (CE_CONT, "posting to "
4540 4746                                              "scsa cmd %p index %x pkt %p"
4541 4747                                              "time %llx, default ", (void *)cmd,
4542 4748                                              cmd->index, (void *)pkt,
4543 4749                                              gethrtime()));
↓ open down ↓ 57 lines elided ↑ open up ↑
4601 4807              DDI_DMA_RDWR | DDI_DMA_STREAMING, DDI_DMA_SLEEP, NULL,
4602 4808              &obj->buffer, &alen, &obj->acc_handle) != DDI_SUCCESS) ||
4603 4809              alen < obj->size) {
4604 4810  
4605 4811                  ddi_dma_free_handle(&obj->dma_handle);
4606 4812  
4607 4813                  con_log(CL_ANN, (CE_WARN, "Failed : ddi_dma_mem_alloc"));
4608 4814  
4609 4815                  return (-1);
4610 4816          }
4611      -        if (obj->dma_handle == NULL) {
4612      -                con_log(CL_ANN, (CE_WARN, "Failed : ddi_dma_mem_alloc"));
4613      -                return (-1);
4614      -        }
4615 4817  
4616 4818          if (ddi_dma_addr_bind_handle(obj->dma_handle, NULL, obj->buffer,
4617 4819              obj->size, DDI_DMA_RDWR | DDI_DMA_STREAMING, DDI_DMA_SLEEP,
4618 4820              NULL, &obj->dma_cookie[0], &cookie_cnt) != DDI_SUCCESS) {
4619 4821  
4620 4822                  ddi_dma_mem_free(&obj->acc_handle);
4621 4823                  ddi_dma_free_handle(&obj->dma_handle);
4622 4824  
4623 4825                  con_log(CL_ANN, (CE_WARN, "Failed : ddi_dma_addr_bind_handle"));
4624 4826  
4625 4827                  return (-1);
4626 4828          }
4627      -        if (obj->acc_handle == NULL) {
4628      -                ddi_dma_mem_free(&obj->acc_handle);
4629      -                ddi_dma_free_handle(&obj->dma_handle);
4630 4829  
4631      -                con_log(CL_ANN, (CE_WARN, "Failed : ddi_dma_addr_bind_handle"));
     4830 +        if (mrsas_check_dma_handle(obj->dma_handle) != DDI_SUCCESS) {
     4831 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST);
4632 4832                  return (-1);
4633 4833          }
4634 4834  
     4835 +        if (mrsas_check_acc_handle(obj->acc_handle) != DDI_SUCCESS) {
     4836 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST);
     4837 +                return (-1);
     4838 +        }
4635 4839  
4636 4840          return (cookie_cnt);
4637 4841  }
4638 4842  
4639 4843  /*
4640 4844   * mrsas_free_dma_obj(struct mrsas_instance *, dma_obj_t)
4641 4845   *
4642 4846   * De-allocate the memory and other resources for an dma object, which must
4643 4847   * have been alloated by a previous call to mrsas_alloc_dma_obj()
4644 4848   */
4645 4849  int
4646 4850  mrsas_free_dma_obj(struct mrsas_instance *instance, dma_obj_t obj)
4647 4851  {
4648 4852  
4649      -        if ( (obj.dma_handle == NULL) || (obj.acc_handle == NULL) ) {
     4853 +        if ((obj.dma_handle == NULL) || (obj.acc_handle == NULL)) {
4650 4854                  return (DDI_SUCCESS);
4651 4855          }
4652 4856  
     4857 +        /*
     4858 +         * NOTE: These check-handle functions fail if *_handle == NULL, but
     4859 +         * this function succeeds because of the previous check.
     4860 +         */
     4861 +        if (mrsas_check_dma_handle(obj.dma_handle) != DDI_SUCCESS) {
     4862 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_UNAFFECTED);
     4863 +                return (DDI_FAILURE);
     4864 +        }
     4865 +
     4866 +        if (mrsas_check_acc_handle(obj.acc_handle) != DDI_SUCCESS) {
     4867 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_UNAFFECTED);
     4868 +                return (DDI_FAILURE);
     4869 +        }
     4870 +
4653 4871          (void) ddi_dma_unbind_handle(obj.dma_handle);
4654 4872          ddi_dma_mem_free(&obj.acc_handle);
4655 4873          ddi_dma_free_handle(&obj.dma_handle);
4656 4874          obj.acc_handle = NULL;
4657 4875          return (DDI_SUCCESS);
4658 4876  }
4659 4877  
4660 4878  /*
4661 4879   * mrsas_dma_alloc(instance_t *, struct scsi_pkt *, struct buf *,
4662 4880   * int, int (*)())
↓ open down ↓ 30 lines elided ↑ open up ↑
4693 4911                  dma_flags |= DDI_DMA_PARTIAL;
4694 4912          }
4695 4913  
4696 4914          dma_flags |= DDI_DMA_REDZONE;
4697 4915  
4698 4916          cb = (callback == NULL_FUNC) ? DDI_DMA_DONTWAIT : DDI_DMA_SLEEP;
4699 4917  
4700 4918          tmp_dma_attr.dma_attr_sgllen = instance->max_num_sge;
4701 4919          tmp_dma_attr.dma_attr_addr_hi = 0xffffffffffffffffull;
4702 4920          if (instance->tbolt) {
4703      -                //OCR-RESET FIX
4704      -                tmp_dma_attr.dma_attr_count_max = (U64)mrsas_tbolt_max_cap_maxxfer;  //limit to 256K
4705      -                tmp_dma_attr.dma_attr_maxxfer = (U64)mrsas_tbolt_max_cap_maxxfer;  //limit to 256K
     4921 +                /* OCR-RESET FIX */
     4922 +                tmp_dma_attr.dma_attr_count_max =
     4923 +                    (U64)mrsas_tbolt_max_cap_maxxfer;  /* limit to 256K */
     4924 +                tmp_dma_attr.dma_attr_maxxfer =
     4925 +                    (U64)mrsas_tbolt_max_cap_maxxfer;  /* limit to 256K */
4706 4926          }
4707 4927  
4708      -
4709 4928          if ((i = ddi_dma_alloc_handle(instance->dip, &tmp_dma_attr,
4710 4929              cb, 0, &acmd->cmd_dmahandle)) != DDI_SUCCESS) {
4711 4930                  switch (i) {
4712 4931                  case DDI_DMA_BADATTR:
4713 4932                          bioerror(bp, EFAULT);
4714 4933                          return (DDI_FAILURE);
4715 4934  
4716 4935                  case DDI_DMA_NORESOURCES:
4717 4936                          bioerror(bp, 0);
4718 4937                          return (DDI_FAILURE);
↓ open down ↓ 160 lines elided ↑ open up ↑
4879 5098  
4880 5099  /*
4881 5100   * build_cmd
4882 5101   */
4883 5102  static struct mrsas_cmd *
4884 5103  build_cmd(struct mrsas_instance *instance, struct scsi_address *ap,
4885 5104      struct scsi_pkt *pkt, uchar_t *cmd_done)
4886 5105  {
4887 5106          uint16_t        flags = 0;
4888 5107          uint32_t        i;
4889      -        uint32_t        context;
     5108 +        uint32_t        context;
4890 5109          uint32_t        sge_bytes;
4891 5110          uint32_t        tmp_data_xfer_len;
4892 5111          ddi_acc_handle_t acc_handle;
4893 5112          struct mrsas_cmd                *cmd;
4894 5113          struct mrsas_sge64              *mfi_sgl;
4895 5114          struct mrsas_sge_ieee           *mfi_sgl_ieee;
4896 5115          struct scsa_cmd                 *acmd = PKT2CMD(pkt);
4897      -        struct mrsas_pthru_frame        *pthru;
     5116 +        struct mrsas_pthru_frame        *pthru;
4898 5117          struct mrsas_io_frame           *ldio;
4899 5118  
4900 5119          /* find out if this is logical or physical drive command.  */
4901 5120          acmd->islogical = MRDRV_IS_LOGICAL(ap);
4902 5121          acmd->device_id = MAP_DEVICE_ID(instance, ap);
4903 5122          *cmd_done = 0;
4904 5123  
4905 5124          /* get the command packet */
4906 5125          if (!(cmd = get_mfi_pkt(instance))) {
4907      -                cmn_err(CE_WARN,
4908      -                    "Failed to get a cmd from free-pool in build_cmd(). fw_outstanding=0x%X max_fw_cmds=0x%X",
4909      -                                instance->fw_outstanding, instance->max_fw_cmds);
     5126 +                DTRACE_PROBE2(build_cmd_mfi_err, uint16_t,
     5127 +                    instance->fw_outstanding, uint16_t, instance->max_fw_cmds);
4910 5128                  return (NULL);
4911 5129          }
4912 5130  
4913 5131          acc_handle = cmd->frame_dma_obj.acc_handle;
4914 5132  
4915 5133          /* Clear the frame buffer and assign back the context id */
4916 5134          (void) memset((char *)&cmd->frame[0], 0, sizeof (union mrsas_frame));
4917 5135          ddi_put32(acc_handle, &cmd->frame->hdr.context, cmd->index);
4918 5136  
4919 5137          cmd->pkt = pkt;
4920 5138          cmd->cmd = acmd;
     5139 +        DTRACE_PROBE3(build_cmds, uint8_t, pkt->pkt_cdbp[0],
     5140 +            ulong_t, acmd->cmd_dmacount, ulong_t, acmd->cmd_dma_len);
4921 5141  
4922 5142          /* lets get the command directions */
4923 5143          if (acmd->cmd_flags & CFLAG_DMASEND) {
4924 5144                  flags = MFI_FRAME_DIR_WRITE;
4925 5145  
4926 5146                  if (acmd->cmd_flags & CFLAG_CONSISTENT) {
4927 5147                          (void) ddi_dma_sync(acmd->cmd_dmahandle,
4928 5148                              acmd->cmd_dma_offset, acmd->cmd_dma_len,
4929 5149                              DDI_DMA_SYNC_FORDEV);
4930 5150                  }
↓ open down ↓ 11 lines elided ↑ open up ↑
4942 5162  
4943 5163          if (instance->flag_ieee) {
4944 5164                  flags |= MFI_FRAME_IEEE;
4945 5165          }
4946 5166          flags |= MFI_FRAME_SGL64;
4947 5167  
4948 5168          switch (pkt->pkt_cdbp[0]) {
4949 5169  
4950 5170          /*
4951 5171           * case SCMD_SYNCHRONIZE_CACHE:
4952      -         *      flush_cache(instance);
     5172 +         *      flush_cache(instance);
4953 5173           *      return_mfi_pkt(instance, cmd);
4954 5174           *      *cmd_done = 1;
4955 5175           *
4956 5176           *      return (NULL);
4957 5177           */
4958 5178  
4959 5179          case SCMD_READ:
4960 5180          case SCMD_WRITE:
4961 5181          case SCMD_READ_G1:
4962 5182          case SCMD_WRITE_G1:
↓ open down ↓ 32 lines elided ↑ open up ↑
4995 5215                              acmd->cmd_cookiecnt);
4996 5216                          if (instance->flag_ieee) {
4997 5217                                  mfi_sgl_ieee =
4998 5218                                      (struct mrsas_sge_ieee *)&ldio->sgl;
4999 5219                          } else {
5000 5220                                  mfi_sgl = (struct mrsas_sge64   *)&ldio->sgl;
5001 5221                          }
5002 5222  
5003 5223                          context = ddi_get32(acc_handle, &ldio->context);
5004 5224  
5005      -                        if (acmd->cmd_cdblen == CDB_GROUP0) {                   /* 6-byte cdb */
     5225 +                        if (acmd->cmd_cdblen == CDB_GROUP0) {
     5226 +                                /* 6-byte cdb */
5006 5227                                  ddi_put32(acc_handle, &ldio->lba_count, (
5007 5228                                      (uint16_t)(pkt->pkt_cdbp[4])));
5008 5229  
5009 5230                                  ddi_put32(acc_handle, &ldio->start_lba_lo, (
5010 5231                                      ((uint32_t)(pkt->pkt_cdbp[3])) |
5011 5232                                      ((uint32_t)(pkt->pkt_cdbp[2]) << 8) |
5012 5233                                      ((uint32_t)((pkt->pkt_cdbp[1]) & 0x1F)
5013 5234                                      << 16)));
5014      -                        } else if (acmd->cmd_cdblen == CDB_GROUP1) {            /* 10-byte cdb */
     5235 +                        } else if (acmd->cmd_cdblen == CDB_GROUP1) {
     5236 +                                /* 10-byte cdb */
5015 5237                                  ddi_put32(acc_handle, &ldio->lba_count, (
5016 5238                                      ((uint16_t)(pkt->pkt_cdbp[8])) |
5017 5239                                      ((uint16_t)(pkt->pkt_cdbp[7]) << 8)));
5018 5240  
5019 5241                                  ddi_put32(acc_handle, &ldio->start_lba_lo, (
5020 5242                                      ((uint32_t)(pkt->pkt_cdbp[5])) |
5021 5243                                      ((uint32_t)(pkt->pkt_cdbp[4]) << 8) |
5022 5244                                      ((uint32_t)(pkt->pkt_cdbp[3]) << 16) |
5023 5245                                      ((uint32_t)(pkt->pkt_cdbp[2]) << 24)));
5024      -                        } else if (acmd->cmd_cdblen == CDB_GROUP5) {            /* 12-byte cdb */
     5246 +                        } else if (acmd->cmd_cdblen == CDB_GROUP5) {
     5247 +                                /* 12-byte cdb */
5025 5248                                  ddi_put32(acc_handle, &ldio->lba_count, (
5026 5249                                      ((uint32_t)(pkt->pkt_cdbp[9])) |
5027 5250                                      ((uint32_t)(pkt->pkt_cdbp[8]) << 8) |
5028 5251                                      ((uint32_t)(pkt->pkt_cdbp[7]) << 16) |
5029 5252                                      ((uint32_t)(pkt->pkt_cdbp[6]) << 24)));
5030 5253  
5031 5254                                  ddi_put32(acc_handle, &ldio->start_lba_lo, (
5032 5255                                      ((uint32_t)(pkt->pkt_cdbp[5])) |
5033 5256                                      ((uint32_t)(pkt->pkt_cdbp[4]) << 8) |
5034 5257                                      ((uint32_t)(pkt->pkt_cdbp[3]) << 16) |
5035 5258                                      ((uint32_t)(pkt->pkt_cdbp[2]) << 24)));
5036      -                        } else if (acmd->cmd_cdblen == CDB_GROUP4) {            /* 16-byte cdb */
     5259 +                        } else if (acmd->cmd_cdblen == CDB_GROUP4) {
     5260 +                                /* 16-byte cdb */
5037 5261                                  ddi_put32(acc_handle, &ldio->lba_count, (
5038 5262                                      ((uint32_t)(pkt->pkt_cdbp[13])) |
5039 5263                                      ((uint32_t)(pkt->pkt_cdbp[12]) << 8) |
5040 5264                                      ((uint32_t)(pkt->pkt_cdbp[11]) << 16) |
5041 5265                                      ((uint32_t)(pkt->pkt_cdbp[10]) << 24)));
5042 5266  
5043 5267                                  ddi_put32(acc_handle, &ldio->start_lba_lo, (
5044 5268                                      ((uint32_t)(pkt->pkt_cdbp[9])) |
5045 5269                                      ((uint32_t)(pkt->pkt_cdbp[8]) << 8) |
5046 5270                                      ((uint32_t)(pkt->pkt_cdbp[7]) << 16) |
↓ open down ↓ 95 lines elided ↑ open up ↑
5142 5366          cmd->frame_count = (sge_bytes / MRMFI_FRAME_SIZE) +
5143 5367              ((sge_bytes % MRMFI_FRAME_SIZE) ? 1 : 0) + 1;
5144 5368  
5145 5369          if (cmd->frame_count >= 8) {
5146 5370                  cmd->frame_count = 8;
5147 5371          }
5148 5372  
5149 5373          return (cmd);
5150 5374  }
5151 5375  
     5376 +#ifndef __sparc
5152 5377  /*
5153 5378   * wait_for_outstanding -       Wait for all outstanding cmds
5154 5379   * @instance:                           Adapter soft state
5155 5380   *
5156 5381   * This function waits for upto MRDRV_RESET_WAIT_TIME seconds for FW to
5157 5382   * complete all its outstanding commands. Returns error if one or more IOs
5158 5383   * are pending after this time period.
5159 5384   */
5160 5385  static int
5161 5386  wait_for_outstanding(struct mrsas_instance *instance)
↓ open down ↓ 8 lines elided ↑ open up ↑
5170 5395  
5171 5396                  drv_usecwait(MILLISEC); /* wait for 1000 usecs */;
5172 5397          }
5173 5398  
5174 5399          if (instance->fw_outstanding) {
5175 5400                  return (1);
5176 5401          }
5177 5402  
5178 5403          return (0);
5179 5404  }
     5405 +#endif  /* __sparc */
5180 5406  
5181      -
5182 5407  /*
5183 5408   * issue_mfi_pthru
5184 5409   */
5185 5410  static int
5186 5411  issue_mfi_pthru(struct mrsas_instance *instance, struct mrsas_ioctl *ioctl,
5187 5412      struct mrsas_cmd *cmd, int mode)
5188 5413  {
5189 5414          void            *ubuf;
5190 5415          uint32_t        kphys_addr = 0;
5191 5416          uint32_t        xferlen = 0;
5192      -        uint32_t new_xfer_length =0;
     5417 +        uint32_t        new_xfer_length = 0;
5193 5418          uint_t          model;
5194 5419          ddi_acc_handle_t        acc_handle = cmd->frame_dma_obj.acc_handle;
5195 5420          dma_obj_t                       pthru_dma_obj;
5196 5421          struct mrsas_pthru_frame        *kpthru;
5197 5422          struct mrsas_pthru_frame        *pthru;
5198 5423          int i;
5199 5424          pthru = &cmd->frame->pthru;
5200 5425          kpthru = (struct mrsas_pthru_frame *)&ioctl->frame[0];
5201 5426  
5202 5427          if (instance->adapterresetinprogress) {
↓ open down ↓ 16 lines elided ↑ open up ↑
5219 5444  #else
5220 5445                  con_log(CL_ANN1, (CE_CONT, "issue_mfi_pthru: DDI_MODEL_LP64"));
5221 5446                  xferlen = kpthru->sgl.sge64[0].length;
5222 5447                  ubuf    = (void *)(ulong_t)kpthru->sgl.sge64[0].phys_addr;
5223 5448  #endif
5224 5449          }
5225 5450  
5226 5451          if (xferlen) {
5227 5452                  /* means IOCTL requires DMA */
5228 5453                  /* allocate the data transfer buffer */
5229      -                //pthru_dma_obj.size = xferlen;
5230      -                MRSAS_GET_BOUNDARY_ALIGNED_LEN(xferlen,new_xfer_length,PAGESIZE);       
     5454 +                /* pthru_dma_obj.size = xferlen; */
     5455 +                MRSAS_GET_BOUNDARY_ALIGNED_LEN(xferlen, new_xfer_length,
     5456 +                    PAGESIZE);
5231 5457                  pthru_dma_obj.size = new_xfer_length;
5232 5458                  pthru_dma_obj.dma_attr = mrsas_generic_dma_attr;
5233 5459                  pthru_dma_obj.dma_attr.dma_attr_addr_hi = 0xFFFFFFFFU;
5234 5460                  pthru_dma_obj.dma_attr.dma_attr_count_max = 0xFFFFFFFFU;
5235 5461                  pthru_dma_obj.dma_attr.dma_attr_sgllen = 1;
5236 5462                  pthru_dma_obj.dma_attr.dma_attr_align = 1;
5237 5463  
5238 5464                  /* allocate kernel buffer for DMA */
5239 5465                  if (mrsas_alloc_dma_obj(instance, &pthru_dma_obj,
5240 5466                      (uchar_t)DDI_STRUCTURE_LE_ACC) != 1) {
↓ open down ↓ 26 lines elided ↑ open up ↑
5267 5493          ddi_put8(acc_handle, &pthru->scsi_status, 0);
5268 5494          ddi_put8(acc_handle, &pthru->target_id, kpthru->target_id);
5269 5495          ddi_put8(acc_handle, &pthru->lun, kpthru->lun);
5270 5496          ddi_put8(acc_handle, &pthru->cdb_len, kpthru->cdb_len);
5271 5497          ddi_put8(acc_handle, &pthru->sge_count, kpthru->sge_count);
5272 5498          ddi_put16(acc_handle, &pthru->timeout, kpthru->timeout);
5273 5499          ddi_put32(acc_handle, &pthru->data_xfer_len, kpthru->data_xfer_len);
5274 5500  
5275 5501          ddi_put32(acc_handle, &pthru->sense_buf_phys_addr_hi, 0);
5276 5502          pthru->sense_buf_phys_addr_lo = cmd->sense_phys_addr;
5277      -        /*ddi_put32(acc_handle, &pthru->sense_buf_phys_addr_lo, 0); */
     5503 +        /* ddi_put32(acc_handle, &pthru->sense_buf_phys_addr_lo, 0); */
5278 5504  
5279 5505          ddi_rep_put8(acc_handle, (uint8_t *)kpthru->cdb, (uint8_t *)pthru->cdb,
5280 5506              pthru->cdb_len, DDI_DEV_AUTOINCR);
5281 5507  
5282 5508          ddi_put16(acc_handle, &pthru->flags, kpthru->flags & ~MFI_FRAME_SGL64);
5283 5509          ddi_put32(acc_handle, &pthru->sgl.sge32[0].length, xferlen);
5284 5510          ddi_put32(acc_handle, &pthru->sgl.sge32[0].phys_addr, kphys_addr);
5285 5511  
5286 5512          cmd->sync_cmd = MRSAS_TRUE;
5287 5513          cmd->frame_count = 1;
↓ open down ↓ 18 lines elided ↑ open up ↑
5306 5532                                  }
5307 5533                          }
5308 5534                  }
5309 5535          }
5310 5536  
5311 5537          kpthru->cmd_status = ddi_get8(acc_handle, &pthru->cmd_status);
5312 5538          kpthru->scsi_status = ddi_get8(acc_handle, &pthru->scsi_status);
5313 5539  
5314 5540          con_log(CL_ANN, (CE_CONT, "issue_mfi_pthru: cmd_status %x, "
5315 5541              "scsi_status %x", kpthru->cmd_status, kpthru->scsi_status));
5316      -        
     5542 +        DTRACE_PROBE3(issue_pthru, uint8_t, kpthru->cmd, uint8_t,
     5543 +            kpthru->cmd_status, uint8_t, kpthru->scsi_status);
     5544 +
5317 5545          if (kpthru->sense_len) {
5318      -                uint sense_len = SENSE_LENGTH;
5319      -                void *sense_ubuf = (void *)(ulong_t)kpthru->sense_buf_phys_addr_lo;
     5546 +                uint_t sense_len = SENSE_LENGTH;
     5547 +                void *sense_ubuf =
     5548 +                    (void *)(ulong_t)kpthru->sense_buf_phys_addr_lo;
5320 5549                  if (kpthru->sense_len <= SENSE_LENGTH) {
5321 5550                          sense_len = kpthru->sense_len;
5322 5551                  }
5323      -                
     5552 +
5324 5553                  for (i = 0; i < sense_len; i++) {
5325 5554                          if (ddi_copyout(
5326 5555                              (uint8_t *)cmd->sense+i,
5327 5556                              (uint8_t *)sense_ubuf+i, 1, mode)) {
5328 5557                                  con_log(CL_ANN, (CE_WARN,
5329 5558                                      "issue_mfi_pthru : "
5330 5559                                      "copy to user space failed"));
5331 5560                          }
5332 5561                          con_log(CL_DLEVEL1, (CE_WARN,
5333      -                            "Copying Sense info sense_buff[%d] = 0x%X\n",i,*((uint8_t *)cmd->sense+i)));
     5562 +                            "Copying Sense info sense_buff[%d] = 0x%X",
     5563 +                            i, *((uint8_t *)cmd->sense + i)));
5334 5564                  }
5335 5565          }
5336 5566          (void) ddi_dma_sync(cmd->frame_dma_obj.dma_handle, 0, 0,
5337      -                    DDI_DMA_SYNC_FORDEV);
     5567 +            DDI_DMA_SYNC_FORDEV);
5338 5568  
5339 5569          if (xferlen) {
5340 5570                  /* free kernel buffer */
5341 5571                  if (mrsas_free_dma_obj(instance, pthru_dma_obj) != DDI_SUCCESS)
5342 5572                          return (DDI_FAILURE);
5343 5573          }
5344 5574  
5345 5575          return (DDI_SUCCESS);
5346 5576  }
5347 5577  
5348 5578  /*
5349 5579   * issue_mfi_dcmd
5350 5580   */
5351 5581  static int
5352 5582  issue_mfi_dcmd(struct mrsas_instance *instance, struct mrsas_ioctl *ioctl,
5353 5583      struct mrsas_cmd *cmd, int mode)
5354 5584  {
5355 5585          void            *ubuf;
5356 5586          uint32_t        kphys_addr = 0;
5357 5587          uint32_t        xferlen = 0;
5358      -        uint32_t        new_xfer_length = 0; 
     5588 +        uint32_t        new_xfer_length = 0;
5359 5589          uint32_t        model;
5360 5590          dma_obj_t       dcmd_dma_obj;
5361 5591          struct mrsas_dcmd_frame *kdcmd;
5362 5592          struct mrsas_dcmd_frame *dcmd;
5363 5593          ddi_acc_handle_t        acc_handle = cmd->frame_dma_obj.acc_handle;
5364 5594          int i;
5365 5595          dcmd = &cmd->frame->dcmd;
5366 5596          kdcmd = (struct mrsas_dcmd_frame *)&ioctl->frame[0];
5367 5597  
5368 5598          if (instance->adapterresetinprogress) {
5369      -                con_log(CL_ANN1, (CE_WARN, "Reset flag set, "
5370      -                "returning mfi_pkt and setting TRAN_BUSY\n"));
     5599 +                con_log(CL_ANN1, (CE_NOTE, "Reset flag set, "
     5600 +                "returning mfi_pkt and setting TRAN_BUSY"));
5371 5601                  return (DDI_FAILURE);
5372 5602          }
5373 5603          model = ddi_model_convert_from(mode & FMODELS);
5374 5604          if (model == DDI_MODEL_ILP32) {
5375 5605                  con_log(CL_ANN1, (CE_CONT, "issue_mfi_dcmd: DDI_MODEL_ILP32"));
5376 5606  
5377 5607                  xferlen = kdcmd->sgl.sge32[0].length;
5378 5608  
5379 5609                  ubuf    = (void *)(ulong_t)kdcmd->sgl.sge32[0].phys_addr;
5380 5610          } else {
↓ open down ↓ 3 lines elided ↑ open up ↑
5384 5614                  ubuf    = (void *)(ulong_t)kdcmd->sgl.sge32[0].phys_addr;
5385 5615  #else
5386 5616                  con_log(CL_ANN1, (CE_CONT, "issue_mfi_dcmd: DDI_MODEL_LP64"));
5387 5617                  xferlen = kdcmd->sgl.sge64[0].length;
5388 5618                  ubuf    = (void *)(ulong_t)kdcmd->sgl.sge64[0].phys_addr;
5389 5619  #endif
5390 5620          }
5391 5621          if (xferlen) {
5392 5622                  /* means IOCTL requires DMA */
5393 5623                  /* allocate the data transfer buffer */
5394      -                //dcmd_dma_obj.size = xferlen;
5395      -                 MRSAS_GET_BOUNDARY_ALIGNED_LEN(xferlen,new_xfer_length,PAGESIZE);
     5624 +                /* dcmd_dma_obj.size = xferlen; */
     5625 +                MRSAS_GET_BOUNDARY_ALIGNED_LEN(xferlen, new_xfer_length,
     5626 +                    PAGESIZE);
5396 5627                  dcmd_dma_obj.size = new_xfer_length;
5397 5628                  dcmd_dma_obj.dma_attr = mrsas_generic_dma_attr;
5398 5629                  dcmd_dma_obj.dma_attr.dma_attr_addr_hi = 0xFFFFFFFFU;
5399 5630                  dcmd_dma_obj.dma_attr.dma_attr_count_max = 0xFFFFFFFFU;
5400 5631                  dcmd_dma_obj.dma_attr.dma_attr_sgllen = 1;
5401 5632                  dcmd_dma_obj.dma_attr.dma_attr_align = 1;
5402 5633  
5403 5634                  /* allocate kernel buffer for DMA */
5404 5635                          if (mrsas_alloc_dma_obj(instance, &dcmd_dma_obj,
5405 5636                              (uchar_t)DDI_STRUCTURE_LE_ACC) != 1) {
5406      -                                con_log(CL_ANN, (CE_WARN, "issue_mfi_dcmd: "
5407      -                                    "could not allocate data transfer buffer."));
     5637 +                                con_log(CL_ANN,
     5638 +                                    (CE_WARN, "issue_mfi_dcmd: could not "
     5639 +                                    "allocate data transfer buffer."));
5408 5640                                  return (DDI_FAILURE);
5409 5641                          }
5410 5642                  (void) memset(dcmd_dma_obj.buffer, 0, xferlen);
5411 5643  
5412 5644                  /* If IOCTL requires DMA WRITE, do ddi_copyin IOCTL data copy */
5413 5645                  if (kdcmd->flags & MFI_FRAME_DIR_WRITE) {
5414 5646                          for (i = 0; i < xferlen; i++) {
5415 5647                                  if (ddi_copyin((uint8_t *)ubuf + i,
5416 5648                                      (uint8_t *)dcmd_dma_obj.buffer + i,
5417 5649                                      1, mode)) {
↓ open down ↓ 41 lines elided ↑ open up ↑
5459 5691                                          con_log(CL_ANN, (CE_WARN,
5460 5692                                              "issue_mfi_dcmd : "
5461 5693                                              "copy to user space failed"));
5462 5694                                          return (DDI_FAILURE);
5463 5695                                  }
5464 5696                          }
5465 5697                  }
5466 5698          }
5467 5699  
5468 5700          kdcmd->cmd_status = ddi_get8(acc_handle, &dcmd->cmd_status);
5469      -        con_log(CL_ANN, (CE_CONT, "issue_mfi_dcmd: cmd_status %x", kdcmd->cmd_status));
     5701 +        con_log(CL_ANN,
     5702 +            (CE_CONT, "issue_mfi_dcmd: cmd_status %x", kdcmd->cmd_status));
     5703 +        DTRACE_PROBE3(issue_dcmd, uint32_t, kdcmd->opcode, uint8_t,
     5704 +            kdcmd->cmd, uint8_t, kdcmd->cmd_status);
5470 5705  
5471 5706          if (xferlen) {
5472 5707                  /* free kernel buffer */
5473      -                        if (mrsas_free_dma_obj(instance, dcmd_dma_obj) != DDI_SUCCESS)
5474      -                                return (DDI_FAILURE);
     5708 +                if (mrsas_free_dma_obj(instance, dcmd_dma_obj) != DDI_SUCCESS)
     5709 +                        return (DDI_FAILURE);
5475 5710          }
5476 5711  
5477 5712          return (DDI_SUCCESS);
5478 5713  }
5479 5714  
5480 5715  /*
5481 5716   * issue_mfi_smp
5482 5717   */
5483 5718  static int
5484 5719  issue_mfi_smp(struct mrsas_instance *instance, struct mrsas_ioctl *ioctl,
↓ open down ↓ 65 lines elided ↑ open up ↑
5550 5785                  response_xferlen        = sge64[0].length;
5551 5786                  request_xferlen         = sge64[1].length;
5552 5787  
5553 5788                  response_ubuf   = (void *)(ulong_t)sge64[0].phys_addr;
5554 5789                  request_ubuf    = (void *)(ulong_t)sge64[1].phys_addr;
5555 5790  #endif
5556 5791          }
5557 5792          if (request_xferlen) {
5558 5793                  /* means IOCTL requires DMA */
5559 5794                  /* allocate the data transfer buffer */
5560      -                //request_dma_obj.size = request_xferlen;
5561      -                MRSAS_GET_BOUNDARY_ALIGNED_LEN(request_xferlen,new_xfer_length1,PAGESIZE);
     5795 +                /* request_dma_obj.size = request_xferlen; */
     5796 +                MRSAS_GET_BOUNDARY_ALIGNED_LEN(request_xferlen,
     5797 +                    new_xfer_length1, PAGESIZE);
5562 5798                  request_dma_obj.size = new_xfer_length1;
5563 5799                  request_dma_obj.dma_attr = mrsas_generic_dma_attr;
5564 5800                  request_dma_obj.dma_attr.dma_attr_addr_hi = 0xFFFFFFFFU;
5565 5801                  request_dma_obj.dma_attr.dma_attr_count_max = 0xFFFFFFFFU;
5566 5802                  request_dma_obj.dma_attr.dma_attr_sgllen = 1;
5567 5803                  request_dma_obj.dma_attr.dma_attr_align = 1;
5568 5804  
5569 5805                  /* allocate kernel buffer for DMA */
5570 5806                  if (mrsas_alloc_dma_obj(instance, &request_dma_obj,
5571 5807                      (uchar_t)DDI_STRUCTURE_LE_ACC) != 1) {
↓ open down ↓ 11 lines elided ↑ open up ↑
5583 5819                                  con_log(CL_ANN, (CE_WARN, "issue_mfi_smp: "
5584 5820                                      "copy from user space failed"));
5585 5821                                  return (DDI_FAILURE);
5586 5822                          }
5587 5823                  }
5588 5824          }
5589 5825  
5590 5826          if (response_xferlen) {
5591 5827                  /* means IOCTL requires DMA */
5592 5828                  /* allocate the data transfer buffer */
5593      -                //response_dma_obj.size = response_xferlen;
5594      -                MRSAS_GET_BOUNDARY_ALIGNED_LEN(response_xferlen,new_xfer_length2,PAGESIZE);
     5829 +                /* response_dma_obj.size = response_xferlen; */
     5830 +                MRSAS_GET_BOUNDARY_ALIGNED_LEN(response_xferlen,
     5831 +                    new_xfer_length2, PAGESIZE);
5595 5832                  response_dma_obj.size = new_xfer_length2;
5596 5833                  response_dma_obj.dma_attr = mrsas_generic_dma_attr;
5597 5834                  response_dma_obj.dma_attr.dma_attr_addr_hi = 0xFFFFFFFFU;
5598 5835                  response_dma_obj.dma_attr.dma_attr_count_max = 0xFFFFFFFFU;
5599 5836                  response_dma_obj.dma_attr.dma_attr_sgllen = 1;
5600 5837                  response_dma_obj.dma_attr.dma_attr_align = 1;
5601 5838  
5602 5839                  /* allocate kernel buffer for DMA */
5603 5840                  if (mrsas_alloc_dma_obj(instance, &response_dma_obj,
5604 5841                      (uchar_t)DDI_STRUCTURE_LE_ACC) != 1) {
↓ open down ↓ 109 lines elided ↑ open up ↑
5714 5951                                              "user space failed"));
5715 5952                                          return (DDI_FAILURE);
5716 5953                                  }
5717 5954                          }
5718 5955                  }
5719 5956          }
5720 5957  
5721 5958          ksmp->cmd_status = ddi_get8(acc_handle, &smp->cmd_status);
5722 5959          con_log(CL_ANN1, (CE_NOTE, "issue_mfi_smp: smp->cmd_status = %d",
5723 5960              ksmp->cmd_status));
     5961 +        DTRACE_PROBE2(issue_smp, uint8_t, ksmp->cmd, uint8_t, ksmp->cmd_status);
5724 5962  
5725 5963          if (request_xferlen) {
5726 5964                  /* free kernel buffer */
5727 5965                  if (mrsas_free_dma_obj(instance, request_dma_obj) !=
5728 5966                      DDI_SUCCESS)
5729 5967                          return (DDI_FAILURE);
5730 5968          }
5731 5969  
5732 5970          if (response_xferlen) {
5733 5971                  /* free kernel buffer */
↓ open down ↓ 36 lines elided ↑ open up ↑
5770 6008          }
5771 6009          model = ddi_model_convert_from(mode & FMODELS);
5772 6010          if (model == DDI_MODEL_ILP32) {
5773 6011                  con_log(CL_ANN1, (CE_CONT, "issue_mfi_stp: DDI_MODEL_ILP32"));
5774 6012  
5775 6013                  fis_xferlen     = kstp->sgl.sge32[0].length;
5776 6014                  data_xferlen    = kstp->sgl.sge32[1].length;
5777 6015  
5778 6016                  fis_ubuf        = (void *)(ulong_t)kstp->sgl.sge32[0].phys_addr;
5779 6017                  data_ubuf       = (void *)(ulong_t)kstp->sgl.sge32[1].phys_addr;
5780      -        }
5781      -        else
5782      -        {
     6018 +        } else {
5783 6019  #ifdef _ILP32
5784 6020                  con_log(CL_ANN1, (CE_CONT, "issue_mfi_stp: DDI_MODEL_ILP32"));
5785 6021  
5786 6022                  fis_xferlen     = kstp->sgl.sge32[0].length;
5787 6023                  data_xferlen    = kstp->sgl.sge32[1].length;
5788 6024  
5789 6025                  fis_ubuf        = (void *)(ulong_t)kstp->sgl.sge32[0].phys_addr;
5790 6026                  data_ubuf       = (void *)(ulong_t)kstp->sgl.sge32[1].phys_addr;
5791 6027  #else
5792 6028                  con_log(CL_ANN1, (CE_CONT, "issue_mfi_stp: DDI_MODEL_LP64"));
↓ open down ↓ 6 lines elided ↑ open up ↑
5799 6035  #endif
5800 6036          }
5801 6037  
5802 6038  
5803 6039          if (fis_xferlen) {
5804 6040                  con_log(CL_ANN, (CE_CONT, "issue_mfi_stp: "
5805 6041                      "fis_ubuf = %p fis_xferlen = %x", fis_ubuf, fis_xferlen));
5806 6042  
5807 6043                  /* means IOCTL requires DMA */
5808 6044                  /* allocate the data transfer buffer */
5809      -                //fis_dma_obj.size = fis_xferlen;
5810      -                MRSAS_GET_BOUNDARY_ALIGNED_LEN(fis_xferlen,new_xfer_length1,PAGESIZE);  
     6045 +                /* fis_dma_obj.size = fis_xferlen; */
     6046 +                MRSAS_GET_BOUNDARY_ALIGNED_LEN(fis_xferlen,
     6047 +                    new_xfer_length1, PAGESIZE);
5811 6048                  fis_dma_obj.size = new_xfer_length1;
5812 6049                  fis_dma_obj.dma_attr = mrsas_generic_dma_attr;
5813 6050                  fis_dma_obj.dma_attr.dma_attr_addr_hi = 0xFFFFFFFFU;
5814 6051                  fis_dma_obj.dma_attr.dma_attr_count_max = 0xFFFFFFFFU;
5815 6052                  fis_dma_obj.dma_attr.dma_attr_sgllen = 1;
5816 6053                  fis_dma_obj.dma_attr.dma_attr_align = 1;
5817 6054  
5818 6055                  /* allocate kernel buffer for DMA */
5819 6056                  if (mrsas_alloc_dma_obj(instance, &fis_dma_obj,
5820 6057                      (uchar_t)DDI_STRUCTURE_LE_ACC) != 1) {
↓ open down ↓ 13 lines elided ↑ open up ↑
5834 6071                          }
5835 6072                  }
5836 6073          }
5837 6074  
5838 6075          if (data_xferlen) {
5839 6076                  con_log(CL_ANN, (CE_CONT, "issue_mfi_stp: data_ubuf = %p "
5840 6077                      "data_xferlen = %x", data_ubuf, data_xferlen));
5841 6078  
5842 6079                  /* means IOCTL requires DMA */
5843 6080                  /* allocate the data transfer buffer */
5844      -                //data_dma_obj.size = data_xferlen;
5845      -                MRSAS_GET_BOUNDARY_ALIGNED_LEN(data_xferlen,new_xfer_length2,PAGESIZE); 
     6081 +                /* data_dma_obj.size = data_xferlen; */
     6082 +                MRSAS_GET_BOUNDARY_ALIGNED_LEN(data_xferlen, new_xfer_length2,
     6083 +                    PAGESIZE);
5846 6084                  data_dma_obj.size = new_xfer_length2;
5847 6085                  data_dma_obj.dma_attr = mrsas_generic_dma_attr;
5848 6086                  data_dma_obj.dma_attr.dma_attr_addr_hi = 0xFFFFFFFFU;
5849 6087                  data_dma_obj.dma_attr.dma_attr_count_max = 0xFFFFFFFFU;
5850 6088                  data_dma_obj.dma_attr.dma_attr_sgllen = 1;
5851 6089                  data_dma_obj.dma_attr.dma_attr_align = 1;
5852 6090  
5853      -/* allocate kernel buffer for DMA */
     6091 +                /* allocate kernel buffer for DMA */
5854 6092                  if (mrsas_alloc_dma_obj(instance, &data_dma_obj,
5855 6093                      (uchar_t)DDI_STRUCTURE_LE_ACC) != 1) {
5856 6094                          con_log(CL_ANN, (CE_WARN, "issue_mfi_stp: "
5857 6095                              "could not allocate data transfer buffer."));
5858 6096                          return (DDI_FAILURE);
5859 6097                  }
5860 6098                  (void) memset(data_dma_obj.buffer, 0, data_xferlen);
5861 6099  
5862 6100                  /* If IOCTL requires DMA WRITE, do ddi_copyin IOCTL data copy */
5863 6101                  for (i = 0; i < data_xferlen; i++) {
↓ open down ↓ 60 lines elided ↑ open up ↑
5924 6162                                      "issue_mfi_stp : copy to"
5925 6163                                      " user space failed"));
5926 6164                                  return (DDI_FAILURE);
5927 6165                          }
5928 6166                  }
5929 6167          }
5930 6168  
5931 6169          kstp->cmd_status = ddi_get8(acc_handle, &stp->cmd_status);
5932 6170          con_log(CL_ANN1, (CE_NOTE, "issue_mfi_stp: stp->cmd_status = %d",
5933 6171              kstp->cmd_status));
     6172 +        DTRACE_PROBE2(issue_stp, uint8_t, kstp->cmd, uint8_t, kstp->cmd_status);
5934 6173  
5935 6174          if (fis_xferlen) {
5936 6175                  /* free kernel buffer */
5937 6176                  if (mrsas_free_dma_obj(instance, fis_dma_obj) != DDI_SUCCESS)
5938 6177                          return (DDI_FAILURE);
5939 6178          }
5940 6179  
5941 6180          if (data_xferlen) {
5942 6181                  /* free kernel buffer */
5943 6182                  if (mrsas_free_dma_obj(instance, data_dma_obj) != DDI_SUCCESS)
↓ open down ↓ 143 lines elided ↑ open up ↑
6087 6326  
6088 6327          struct mrsas_header     *hdr;
6089 6328          struct mrsas_cmd        *cmd;
6090 6329  
6091 6330          if (instance->tbolt) {
6092 6331                  cmd = get_raid_msg_mfi_pkt(instance);
6093 6332          } else {
6094 6333                  cmd = get_mfi_pkt(instance);
6095 6334          }
6096 6335          if (!cmd) {
6097      -                cmn_err(CE_WARN,
6098      -                    "Failed to get a cmd from free-pool in handle_mfi_ioctl(). "
6099      -                        "fw_outstanding=0x%X max_fw_cmds=0x%X",
6100      -                        instance->fw_outstanding, instance->max_fw_cmds);
     6336 +                con_log(CL_ANN, (CE_WARN, "mr_sas: "
     6337 +                    "failed to get a cmd packet"));
     6338 +                DTRACE_PROBE2(mfi_ioctl_err, uint16_t,
     6339 +                    instance->fw_outstanding, uint16_t, instance->max_fw_cmds);
6101 6340                  return (DDI_FAILURE);
6102 6341          }
6103 6342  
6104 6343          /* Clear the frame buffer and assign back the context id */
6105 6344          (void) memset((char *)&cmd->frame[0], 0, sizeof (union mrsas_frame));
6106 6345          ddi_put32(cmd->frame_dma_obj.acc_handle, &cmd->frame->hdr.context,
6107 6346              cmd->index);
6108 6347  
6109 6348          hdr = (struct mrsas_header *)&ioctl->frame[0];
6110 6349  
↓ open down ↓ 11 lines elided ↑ open up ↑
6122 6361          case MFI_CMD_OP_PD_SCSI:
6123 6362                  rval = issue_mfi_pthru(instance, ioctl, cmd, mode);
6124 6363                  break;
6125 6364          default:
6126 6365                  con_log(CL_ANN, (CE_WARN, "handle_mfi_ioctl: "
6127 6366                      "invalid mfi ioctl hdr->cmd = %d", hdr->cmd));
6128 6367                  rval = DDI_FAILURE;
6129 6368                  break;
6130 6369          }
6131 6370  
     6371 +        if (mrsas_common_check(instance, cmd) != DDI_SUCCESS)
     6372 +                rval = DDI_FAILURE;
     6373 +
6132 6374          if (instance->tbolt) {
6133 6375                  return_raid_msg_mfi_pkt(instance, cmd);
6134 6376          } else {
6135 6377                  return_mfi_pkt(instance, cmd);
6136 6378          }
6137 6379  
6138 6380          return (rval);
6139 6381  }
6140 6382  
6141 6383  /*
↓ open down ↓ 84 lines elided ↑ open up ↑
6226 6468                  curr_aen.members.locale = LE_16(curr_aen.members.locale);
6227 6469          }
6228 6470  
6229 6471          if (instance->tbolt) {
6230 6472                  cmd = get_raid_msg_mfi_pkt(instance);
6231 6473          } else {
6232 6474                  cmd = get_mfi_pkt(instance);
6233 6475          }
6234 6476  
6235 6477          if (!cmd) {
6236      -                cmn_err(CE_WARN,
6237      -                    "Failed to get a cmd from free-pool in register_mfi_aen(). "
6238      -                        "fw_outstanding=0x%X max_fw_cmds=0x%X",
6239      -                        instance->fw_outstanding, instance->max_fw_cmds);
     6478 +                DTRACE_PROBE2(mfi_aen_err, uint16_t, instance->fw_outstanding,
     6479 +                    uint16_t, instance->max_fw_cmds);
6240 6480                  return (ENOMEM);
6241 6481          }
6242 6482  
6243      -
6244 6483          /* Clear the frame buffer and assign back the context id */
6245 6484          (void) memset((char *)&cmd->frame[0], 0, sizeof (union mrsas_frame));
6246 6485          ddi_put32(cmd->frame_dma_obj.acc_handle, &cmd->frame->hdr.context,
6247 6486              cmd->index);
6248 6487  
6249 6488          dcmd = &cmd->frame->dcmd;
6250 6489  
6251 6490          /* for(i = 0; i < DCMD_MBOX_SZ; i++) dcmd->mbox.b[i] = 0; */
6252 6491          (void) memset(dcmd->mbox.b, 0, DCMD_MBOX_SZ);
6253 6492  
↓ open down ↓ 44 lines elided ↑ open up ↑
6298 6537  }
6299 6538  
6300 6539  void
6301 6540  display_scsi_inquiry(caddr_t scsi_inq)
6302 6541  {
6303 6542  #define MAX_SCSI_DEVICE_CODE    14
6304 6543          int             i;
6305 6544          char            inquiry_buf[256] = {0};
6306 6545          int             len;
6307 6546          const char      *const scsi_device_types[] = {
6308      -                "Direct-Access    ",
     6547 +                "Direct-Access    ",
6309 6548                  "Sequential-Access",
6310      -                "Printer          ",
6311      -                "Processor        ",
6312      -                "WORM             ",
6313      -                "CD-ROM           ",
6314      -                "Scanner          ",
6315      -                "Optical Device   ",
6316      -                "Medium Changer   ",
6317      -                "Communications   ",
6318      -                "Unknown          ",
6319      -                "Unknown          ",
6320      -                "Unknown          ",
6321      -                "Enclosure        ",
     6549 +                "Printer          ",
     6550 +                "Processor        ",
     6551 +                "WORM             ",
     6552 +                "CD-ROM           ",
     6553 +                "Scanner          ",
     6554 +                "Optical Device   ",
     6555 +                "Medium Changer   ",
     6556 +                "Communications   ",
     6557 +                "Unknown          ",
     6558 +                "Unknown          ",
     6559 +                "Unknown          ",
     6560 +                "Enclosure        ",
6322 6561          };
6323 6562  
6324 6563          len = 0;
6325 6564  
6326      -        len += snprintf(inquiry_buf + len, 265 - len, "  Vendor: ");
     6565 +        len += snprintf(inquiry_buf + len, 265 - len, "  Vendor: ");
6327 6566          for (i = 8; i < 16; i++) {
6328 6567                  len += snprintf(inquiry_buf + len, 265 - len, "%c",
6329 6568                      scsi_inq[i]);
6330 6569          }
6331 6570  
6332      -        len += snprintf(inquiry_buf + len, 265 - len, "  Model: ");
     6571 +        len += snprintf(inquiry_buf + len, 265 - len, "  Model: ");
6333 6572  
6334 6573          for (i = 16; i < 32; i++) {
6335 6574                  len += snprintf(inquiry_buf + len, 265 - len, "%c",
6336 6575                      scsi_inq[i]);
6337 6576          }
6338 6577  
6339      -        len += snprintf(inquiry_buf + len, 265 - len, "  Rev: ");
     6578 +        len += snprintf(inquiry_buf + len, 265 - len, "  Rev: ");
6340 6579  
6341 6580          for (i = 32; i < 36; i++) {
6342 6581                  len += snprintf(inquiry_buf + len, 265 - len, "%c",
6343 6582                      scsi_inq[i]);
6344 6583          }
6345 6584  
6346 6585          len += snprintf(inquiry_buf + len, 265 - len, "\n");
6347 6586  
6348 6587  
6349 6588          i = scsi_inq[0] & 0x1f;
6350 6589  
6351 6590  
6352      -        len += snprintf(inquiry_buf + len, 265 - len, "  Type:   %s ",
     6591 +        len += snprintf(inquiry_buf + len, 265 - len, "  Type:   %s ",
6353 6592              i < MAX_SCSI_DEVICE_CODE ? scsi_device_types[i] :
6354      -            "Unknown          ");
     6593 +            "Unknown          ");
6355 6594  
6356 6595  
6357 6596          len += snprintf(inquiry_buf + len, 265 - len,
6358      -            "                 ANSI SCSI revision: %02x", scsi_inq[2] & 0x07);
     6597 +            "                 ANSI SCSI revision: %02x", scsi_inq[2] & 0x07);
6359 6598  
6360 6599          if ((scsi_inq[2] & 0x07) == 1 && (scsi_inq[3] & 0x0f) == 1) {
6361 6600                  len += snprintf(inquiry_buf + len, 265 - len, " CCS\n");
6362 6601          } else {
6363 6602                  len += snprintf(inquiry_buf + len, 265 - len, "\n");
6364 6603          }
6365 6604  
6366 6605          con_log(CL_DLEVEL2, (CE_CONT, inquiry_buf));
6367 6606  }
6368 6607  
6369      -void
     6608 +static void
6370 6609  io_timeout_checker(void *arg)
6371 6610  {
6372 6611          struct scsi_pkt *pkt;
6373 6612          struct mrsas_instance *instance = arg;
6374 6613          struct mrsas_cmd        *cmd = NULL;
6375 6614          struct mrsas_header     *hdr;
6376 6615          int time = 0;
6377 6616          int counter = 0;
6378 6617          struct mlist_head       *pos, *next;
6379 6618          mlist_t                 process_list;
↓ open down ↓ 2 lines elided ↑ open up ↑
6382 6621                  con_log(CL_ANN, (CE_NOTE, "io_timeout_checker:"
6383 6622                      " reset in progress"));
6384 6623  
6385 6624                  instance->timeout_id = timeout(io_timeout_checker,
6386 6625                      (void *) instance, drv_usectohz(MRSAS_1_SECOND));
6387 6626                  return;
6388 6627          }
6389 6628  
6390 6629          /* See if this check needs to be in the beginning or last in ISR */
6391 6630          if (mrsas_initiate_ocr_if_fw_is_faulty(instance) ==  1) {
6392      -                cmn_err(CE_WARN, "io_timeout_checker:"
     6631 +                cmn_err(CE_WARN, "io_timeout_checker: "
6393 6632                      "FW Fault, calling reset adapter");
6394      -                cmn_err(CE_CONT, "io_timeout_checker: fw_outstanding 0x%X max_fw_cmds 0x%X",
6395      -                        instance->fw_outstanding, instance->max_fw_cmds );
     6633 +                cmn_err(CE_CONT, "io_timeout_checker: "
     6634 +                    "fw_outstanding 0x%X max_fw_cmds 0x%X",
     6635 +                    instance->fw_outstanding, instance->max_fw_cmds);
6396 6636                  if (instance->adapterresetinprogress == 0) {
6397      -                        instance->adapterresetinprogress = 1;  
     6637 +                        instance->adapterresetinprogress = 1;
6398 6638                          if (instance->tbolt)
6399      -                                mrsas_tbolt_reset_ppc(instance);
     6639 +                                (void) mrsas_tbolt_reset_ppc(instance);
6400 6640                          else
6401      -                                mrsas_reset_ppc(instance);
6402      -                        instance->adapterresetinprogress = 0;   
     6641 +                                (void) mrsas_reset_ppc(instance);
     6642 +                        instance->adapterresetinprogress = 0;
6403 6643                  }
6404 6644                  instance->timeout_id = timeout(io_timeout_checker,
6405 6645                      (void *) instance, drv_usectohz(MRSAS_1_SECOND));
6406 6646                  return;
6407 6647          }
6408 6648  
6409 6649          INIT_LIST_HEAD(&process_list);
6410 6650  
6411 6651          mutex_enter(&instance->cmd_pend_mtx);
6412 6652          mlist_for_each_safe(pos, next, &instance->cmd_pend_list) {
↓ open down ↓ 2 lines elided ↑ open up ↑
6415 6655                  if (cmd == NULL) {
6416 6656                          continue;
6417 6657                  }
6418 6658  
6419 6659                  if (cmd->sync_cmd == MRSAS_TRUE) {
6420 6660                          hdr = (struct mrsas_header *)&cmd->frame->hdr;
6421 6661                          if (hdr == NULL) {
6422 6662                                  continue;
6423 6663                          }
6424 6664                          time = --cmd->drv_pkt_time;
6425      -                } else {     
     6665 +                } else {
6426 6666                          pkt = cmd->pkt;
6427 6667                          if (pkt == NULL) {
6428 6668                                  continue;
6429 6669                          }
6430 6670                          time = --cmd->drv_pkt_time;
6431 6671                  }
6432 6672                  if (time <= 0) {
6433 6673                          cmn_err(CE_WARN, "%llx: "
6434      -                            "io_timeout_checker: TIMING OUT: pkt "
6435      -                            ": %p, cmd %p fw_outstanding 0x%X max_fw_cmds 0x%X\n",
6436      -                                gethrtime(), (void *)pkt, (void *)cmd, instance->fw_outstanding, instance->max_fw_cmds);
     6674 +                            "io_timeout_checker: TIMING OUT: pkt: %p, "
     6675 +                            "cmd %p fw_outstanding 0x%X max_fw_cmds 0x%X\n",
     6676 +                            gethrtime(), (void *)pkt, (void *)cmd,
     6677 +                            instance->fw_outstanding, instance->max_fw_cmds);
6437 6678  
6438 6679                          counter++;
6439 6680                          break;
6440 6681                  }
6441 6682          }
6442 6683          mutex_exit(&instance->cmd_pend_mtx);
6443 6684  
6444 6685          if (counter) {
6445 6686                  if (instance->disable_online_ctrl_reset == 1) {
6446      -                        cmn_err(CE_WARN, "mr_sas %d: %s(): OCR is NOT supported by Firmware, KILL adapter!!!",
6447      -                            instance->instance, __func__);
     6687 +                        cmn_err(CE_WARN, "mr_sas %d: %s(): OCR is NOT "
     6688 +                            "supported by Firmware, KILL adapter!!!",
     6689 +                            instance->instance, __func__);
6448 6690  
6449 6691                          if (instance->tbolt)
6450      -                                (void) mrsas_tbolt_kill_adapter(instance);
     6692 +                                mrsas_tbolt_kill_adapter(instance);
6451 6693                          else
6452 6694                                  (void) mrsas_kill_adapter(instance);
6453 6695  
6454 6696                          return;
6455 6697                  } else {
6456      -                        if (cmd->retry_count_for_ocr <=  IO_RETRY_COUNT) {
     6698 +                        if (cmd->retry_count_for_ocr <=  IO_RETRY_COUNT) {
6457 6699                                  if (instance->adapterresetinprogress == 0) {
6458      -                                        if (instance->tbolt)
6459      -                                                mrsas_tbolt_reset_ppc(instance);
6460      -                                        else
6461      -                                                mrsas_reset_ppc(instance);
     6700 +                                        if (instance->tbolt) {
     6701 +                                                (void) mrsas_tbolt_reset_ppc(
     6702 +                                                    instance);
     6703 +                                        } else {
     6704 +                                                (void) mrsas_reset_ppc(
     6705 +                                                    instance);
     6706 +                                        }
6462 6707                                  }
6463 6708                          } else {
6464 6709                                  cmn_err(CE_WARN,
6465 6710                                      "io_timeout_checker: "
6466      -                                        "cmd %p cmd->index %d "
     6711 +                                    "cmd %p cmd->index %d "
6467 6712                                      "timed out even after 3 resets: "
6468 6713                                      "so KILL adapter", (void *)cmd, cmd->index);
6469 6714  
6470 6715                                  mrsas_print_cmd_details(instance, cmd, 0xDD);
6471 6716  
6472 6717                                  if (instance->tbolt)
6473      -                                        (void) mrsas_tbolt_kill_adapter(instance);
     6718 +                                        mrsas_tbolt_kill_adapter(instance);
6474 6719                                  else
6475 6720                                          (void) mrsas_kill_adapter(instance);
6476 6721                                  return;
6477 6722                          }
6478 6723                  }
6479 6724          }
6480 6725          con_log(CL_ANN, (CE_NOTE, "mrsas: "
6481 6726              "schedule next timeout check: "
6482 6727              "do timeout \n"));
6483 6728          instance->timeout_id =
↓ open down ↓ 27 lines elided ↑ open up ↑
6511 6756                          push_pending_mfi_pkt(instance, cmd);
6512 6757                  }
6513 6758  
6514 6759          } else {
6515 6760                  con_log(CL_DLEVEL1, (CE_NOTE, "%llx : issue_cmd_ppc:"
6516 6761                      "ISSUED CMD TO FW : called : cmd : %p, instance: %p"
6517 6762                      "(NO PKT)\n", gethrtime(), (void *)cmd, (void *)instance));
6518 6763          }
6519 6764  
6520 6765          mutex_enter(&instance->reg_write_mtx);
6521      -        ASSERT(mutex_owned(&instance->reg_write_mtx));
6522 6766          /* Issue the command to the FW */
6523 6767          WR_IB_QPORT((cmd->frame_phys_addr) |
6524 6768              (((cmd->frame_count - 1) << 1) | 1), instance);
6525 6769          mutex_exit(&instance->reg_write_mtx);
6526 6770  
6527 6771  }
6528 6772  
6529 6773  /*
6530 6774   * issue_cmd_in_sync_mode
6531 6775   */
↓ open down ↓ 20 lines elided ↑ open up ↑
6552 6796  
6553 6797                  return (DDI_SUCCESS);
6554 6798          } else {
6555 6799                  con_log(CL_ANN1, (CE_NOTE, "sync_mode_ppc: pushing the pkt\n"));
6556 6800                  push_pending_mfi_pkt(instance, cmd);
6557 6801          }
6558 6802  
6559 6803          cmd->cmd_status = ENODATA;
6560 6804  
6561 6805          mutex_enter(&instance->reg_write_mtx);
6562      -        ASSERT(mutex_owned(&instance->reg_write_mtx));
6563 6806          /* Issue the command to the FW */
6564 6807          WR_IB_QPORT((cmd->frame_phys_addr) |
6565 6808              (((cmd->frame_count - 1) << 1) | 1), instance);
6566 6809          mutex_exit(&instance->reg_write_mtx);
6567 6810  
6568 6811          mutex_enter(&instance->int_cmd_mtx);
6569 6812          for (i = 0; i < msecs && (cmd->cmd_status == ENODATA); i++) {
6570 6813                  cv_wait(&instance->int_cmd_cv, &instance->int_cmd_mtx);
6571 6814          }
6572 6815          mutex_exit(&instance->int_cmd_mtx);
↓ open down ↓ 18 lines elided ↑ open up ↑
6591 6834          uint16_t        flags;
6592 6835          uint32_t        msecs = MFI_POLL_TIMEOUT_SECS * MILLISEC;
6593 6836          struct mrsas_header *frame_hdr;
6594 6837  
6595 6838          con_log(CL_ANN1, (CE_NOTE, "issue_cmd_in_poll_mode_ppc: called"));
6596 6839  
6597 6840          frame_hdr = (struct mrsas_header *)cmd->frame;
6598 6841          ddi_put8(cmd->frame_dma_obj.acc_handle, &frame_hdr->cmd_status,
6599 6842              MFI_CMD_STATUS_POLL_MODE);
6600 6843          flags = ddi_get16(cmd->frame_dma_obj.acc_handle, &frame_hdr->flags);
6601      -        flags   |= MFI_FRAME_DONT_POST_IN_REPLY_QUEUE;
     6844 +        flags   |= MFI_FRAME_DONT_POST_IN_REPLY_QUEUE;
6602 6845  
6603 6846          ddi_put16(cmd->frame_dma_obj.acc_handle, &frame_hdr->flags, flags);
6604 6847  
6605 6848          /* issue the frame using inbound queue port */
6606 6849          WR_IB_QPORT((cmd->frame_phys_addr) |
6607 6850              (((cmd->frame_count - 1) << 1) | 1), instance);
6608 6851  
6609 6852          /* wait for cmd_status to change from 0xFF */
6610 6853          for (i = 0; i < msecs && (
6611 6854              ddi_get8(cmd->frame_dma_obj.acc_handle, &frame_hdr->cmd_status)
↓ open down ↓ 64 lines elided ↑ open up ↑
6676 6919  
6677 6920          /* check if it is our interrupt */
6678 6921          status = RD_OB_INTR_STATUS(instance);
6679 6922  
6680 6923          con_log(CL_ANN1, (CE_NOTE, "intr_ack_ppc: status = 0x%x", status));
6681 6924  
6682 6925          if (!(status & MFI_REPLY_2108_MESSAGE_INTR)) {
6683 6926                  ret = DDI_INTR_UNCLAIMED;
6684 6927          }
6685 6928  
     6929 +        if (mrsas_check_acc_handle(instance->regmap_handle) != DDI_SUCCESS) {
     6930 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST);
     6931 +                ret = DDI_INTR_UNCLAIMED;
     6932 +        }
     6933 +
6686 6934          if (ret == DDI_INTR_UNCLAIMED) {
6687 6935                  return (ret);
6688 6936          }
6689 6937          /* clear the interrupt by writing back the same value */
6690 6938          WR_OB_DOORBELL_CLEAR(status, instance);
6691 6939  
6692 6940          /* dummy READ */
6693 6941          status = RD_OB_INTR_STATUS(instance);
6694 6942  
6695 6943          con_log(CL_ANN1, (CE_NOTE, "intr_ack_ppc: interrupt cleared"));
↓ open down ↓ 7 lines elided ↑ open up ↑
6703 6951   * or FW is found to be fault even after 3 continuous resets.
6704 6952   */
6705 6953  
6706 6954  static int
6707 6955  mrsas_kill_adapter(struct mrsas_instance *instance)
6708 6956  {
6709 6957          if (instance->deadadapter == 1)
6710 6958                  return (DDI_FAILURE);
6711 6959  
6712 6960          con_log(CL_ANN1, (CE_NOTE, "mrsas_kill_adapter: "
6713      -                "Writing to doorbell with MFI_STOP_ADP "));
     6961 +            "Writing to doorbell with MFI_STOP_ADP "));
6714 6962          mutex_enter(&instance->ocr_flags_mtx);
6715 6963          instance->deadadapter = 1;
6716 6964          mutex_exit(&instance->ocr_flags_mtx);
6717 6965          instance->func_ptr->disable_intr(instance);
6718 6966          WR_IB_DOORBELL(MFI_STOP_ADP, instance);
6719 6967          (void) mrsas_complete_pending_cmds(instance);
6720 6968          return (DDI_SUCCESS);
6721 6969  }
6722 6970  
6723 6971  
↓ open down ↓ 29 lines elided ↑ open up ↑
6753 7001          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc: magic number written "
6754 7002              "to write sequence register\n"));
6755 7003          delay(100 * drv_usectohz(MILLISEC));
6756 7004          status = RD_OB_DRWE(instance);
6757 7005  
6758 7006          while (!(status & DIAG_WRITE_ENABLE)) {
6759 7007                  delay(100 * drv_usectohz(MILLISEC));
6760 7008                  status = RD_OB_DRWE(instance);
6761 7009                  if (retry++ == 100) {
6762 7010                          cmn_err(CE_WARN, "mrsas_reset_ppc: DRWE bit "
6763      -                            "check retry count %d\n", retry);
     7011 +                            "check retry count %d", retry);
6764 7012                          return (DDI_FAILURE);
6765 7013                  }
6766 7014          }
6767 7015          WR_IB_DRWE(status | DIAG_RESET_ADAPTER, instance);
6768 7016          delay(100 * drv_usectohz(MILLISEC));
6769 7017          status = RD_OB_DRWE(instance);
6770 7018          while (status & DIAG_RESET_ADAPTER) {
6771 7019                  delay(100 * drv_usectohz(MILLISEC));
6772 7020                  status = RD_OB_DRWE(instance);
6773 7021                  if (retry++ == 100) {
6774      -                        cmn_err(CE_WARN,
6775      -                                "mrsas_reset_ppc: RESET FAILED. KILL adapter called\n.");
     7022 +                        cmn_err(CE_WARN, "mrsas_reset_ppc: "
     7023 +                            "RESET FAILED. KILL adapter called.");
6776 7024  
6777 7025                          (void) mrsas_kill_adapter(instance);
6778 7026                          return (DDI_FAILURE);
6779 7027                  }
6780 7028          }
6781 7029          con_log(CL_ANN, (CE_NOTE, "mrsas_reset_ppc: Adapter reset complete"));
6782 7030          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc: "
6783 7031              "Calling mfi_state_transition_to_ready"));
6784 7032  
6785 7033          /* Mark HBA as bad, if FW is fault after 3 continuous resets */
↓ open down ↓ 14 lines elided ↑ open up ↑
6800 7048                  con_log(CL_ANN1, (CE_NOTE,  "mrsas_reset_ppc : FW is not ready "
6801 7049                      "FW state = 0x%x", fw_state));
6802 7050  
6803 7051                  if (fw_state == MFI_STATE_FAULT) {
6804 7052                          /* increment the count */
6805 7053                          instance->fw_fault_count_after_ocr++;
6806 7054                          if (instance->fw_fault_count_after_ocr
6807 7055                              < MAX_FW_RESET_COUNT) {
6808 7056                                  cmn_err(CE_WARN, "mrsas_reset_ppc: "
6809 7057                                      "FW is in fault after OCR count %d "
6810      -                                        "Retry Reset",
     7058 +                                    "Retry Reset",
6811 7059                                      instance->fw_fault_count_after_ocr);
6812 7060                                  goto retry_reset;
6813 7061  
6814 7062                          } else {
6815 7063                                  cmn_err(CE_WARN, "mrsas_reset_ppc: "
6816      -                                        "Max Reset Count exceeded >%d"
6817      -                                    "Mark HBA as bad, KILL adapter", MAX_FW_RESET_COUNT);
     7064 +                                    "Max Reset Count exceeded >%d"
     7065 +                                    "Mark HBA as bad, KILL adapter",
     7066 +                                    MAX_FW_RESET_COUNT);
6818 7067  
6819 7068                                  (void) mrsas_kill_adapter(instance);
6820 7069                                  return (DDI_FAILURE);
6821 7070                          }
6822 7071                  }
6823 7072          }
6824 7073          /* reset the counter as FW is up after OCR */
6825 7074          instance->fw_fault_count_after_ocr = 0;
6826 7075  
6827 7076  
↓ open down ↓ 20 lines elided ↑ open up ↑
6848 7097          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc: "
6849 7098              "mrsas_print_pending_cmd done\n"));
6850 7099  
6851 7100          instance->func_ptr->enable_intr(instance);
6852 7101          instance->fw_outstanding = 0;
6853 7102  
6854 7103          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc: "
6855 7104              "Calling mrsas_issue_pending_cmds"));
6856 7105          (void) mrsas_issue_pending_cmds(instance);
6857 7106          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc: "
6858      -        "issue_pending_cmds done.\n"));
     7107 +            "issue_pending_cmds done.\n"));
6859 7108  
6860 7109          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc: "
6861 7110              "Calling aen registration"));
6862 7111  
6863 7112  
6864 7113          instance->aen_cmd->retry_count_for_ocr = 0;
6865 7114          instance->aen_cmd->drv_pkt_time = 0;
6866 7115  
6867 7116          instance->func_ptr->issue_cmd(instance->aen_cmd, instance);
6868 7117          con_log(CL_ANN1, (CE_NOTE, "Unsetting adpresetinprogress flag.\n"));
↓ open down ↓ 1 lines elided ↑ open up ↑
6870 7119          mutex_enter(&instance->ocr_flags_mtx);
6871 7120          instance->adapterresetinprogress = 0;
6872 7121          mutex_exit(&instance->ocr_flags_mtx);
6873 7122          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc: "
6874 7123              "adpterresetinprogress flag unset"));
6875 7124  
6876 7125          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc done\n"));
6877 7126          return (DDI_SUCCESS);
6878 7127  }
6879 7128  
     7129 +/*
     7130 + * FMA functions.
     7131 + */
     7132 +int
     7133 +mrsas_common_check(struct mrsas_instance *instance, struct  mrsas_cmd *cmd)
     7134 +{
     7135 +        int ret = DDI_SUCCESS;
6880 7136  
     7137 +        if (cmd != NULL &&
     7138 +            mrsas_check_dma_handle(cmd->frame_dma_obj.dma_handle) !=
     7139 +            DDI_SUCCESS) {
     7140 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_UNAFFECTED);
     7141 +                if (cmd->pkt != NULL) {
     7142 +                        cmd->pkt->pkt_reason = CMD_TRAN_ERR;
     7143 +                        cmd->pkt->pkt_statistics = 0;
     7144 +                }
     7145 +                ret = DDI_FAILURE;
     7146 +        }
     7147 +        if (mrsas_check_dma_handle(instance->mfi_internal_dma_obj.dma_handle)
     7148 +            != DDI_SUCCESS) {
     7149 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_UNAFFECTED);
     7150 +                if (cmd != NULL && cmd->pkt != NULL) {
     7151 +                        cmd->pkt->pkt_reason = CMD_TRAN_ERR;
     7152 +                        cmd->pkt->pkt_statistics = 0;
     7153 +                }
     7154 +                ret = DDI_FAILURE;
     7155 +        }
     7156 +        if (mrsas_check_dma_handle(instance->mfi_evt_detail_obj.dma_handle) !=
     7157 +            DDI_SUCCESS) {
     7158 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_UNAFFECTED);
     7159 +                if (cmd != NULL && cmd->pkt != NULL) {
     7160 +                        cmd->pkt->pkt_reason = CMD_TRAN_ERR;
     7161 +                        cmd->pkt->pkt_statistics = 0;
     7162 +                }
     7163 +                ret = DDI_FAILURE;
     7164 +        }
     7165 +        if (mrsas_check_acc_handle(instance->regmap_handle) != DDI_SUCCESS) {
     7166 +                ddi_fm_service_impact(instance->dip, DDI_SERVICE_UNAFFECTED);
     7167 +
     7168 +                ddi_fm_acc_err_clear(instance->regmap_handle, DDI_FME_VER0);
     7169 +
     7170 +                if (cmd != NULL && cmd->pkt != NULL) {
     7171 +                        cmd->pkt->pkt_reason = CMD_TRAN_ERR;
     7172 +                        cmd->pkt->pkt_statistics = 0;
     7173 +                }
     7174 +                ret = DDI_FAILURE;
     7175 +        }
     7176 +
     7177 +        return (ret);
     7178 +}
     7179 +
     7180 +/*ARGSUSED*/
6881 7181  static int
     7182 +mrsas_fm_error_cb(dev_info_t *dip, ddi_fm_error_t *err, const void *impl_data)
     7183 +{
     7184 +        /*
     7185 +         * as the driver can always deal with an error in any dma or
     7186 +         * access handle, we can just return the fme_status value.
     7187 +         */
     7188 +        pci_ereport_post(dip, err, NULL);
     7189 +        return (err->fme_status);
     7190 +}
     7191 +
     7192 +static void
     7193 +mrsas_fm_init(struct mrsas_instance *instance)
     7194 +{
     7195 +        /* Need to change iblock to priority for new MSI intr */
     7196 +        ddi_iblock_cookie_t fm_ibc;
     7197 +
     7198 +        /* Only register with IO Fault Services if we have some capability */
     7199 +        if (instance->fm_capabilities) {
     7200 +                /* Adjust access and dma attributes for FMA */
     7201 +                endian_attr.devacc_attr_access = DDI_FLAGERR_ACC;
     7202 +                mrsas_generic_dma_attr.dma_attr_flags = DDI_DMA_FLAGERR;
     7203 +
     7204 +                /*
     7205 +                 * Register capabilities with IO Fault Services.
     7206 +                 * fm_capabilities will be updated to indicate
     7207 +                 * capabilities actually supported (not requested.)
     7208 +                 */
     7209 +
     7210 +                ddi_fm_init(instance->dip, &instance->fm_capabilities, &fm_ibc);
     7211 +
     7212 +                /*
     7213 +                 * Initialize pci ereport capabilities if ereport
     7214 +                 * capable (should always be.)
     7215 +                 */
     7216 +
     7217 +                if (DDI_FM_EREPORT_CAP(instance->fm_capabilities) ||
     7218 +                    DDI_FM_ERRCB_CAP(instance->fm_capabilities)) {
     7219 +                        pci_ereport_setup(instance->dip);
     7220 +                }
     7221 +
     7222 +                /*
     7223 +                 * Register error callback if error callback capable.
     7224 +                 */
     7225 +                if (DDI_FM_ERRCB_CAP(instance->fm_capabilities)) {
     7226 +                        ddi_fm_handler_register(instance->dip,
     7227 +                            mrsas_fm_error_cb, (void*) instance);
     7228 +                }
     7229 +        } else {
     7230 +                endian_attr.devacc_attr_access = DDI_DEFAULT_ACC;
     7231 +                mrsas_generic_dma_attr.dma_attr_flags = 0;
     7232 +        }
     7233 +}
     7234 +
     7235 +static void
     7236 +mrsas_fm_fini(struct mrsas_instance *instance)
     7237 +{
     7238 +        /* Only unregister FMA capabilities if registered */
     7239 +        if (instance->fm_capabilities) {
     7240 +                /*
     7241 +                 * Un-register error callback if error callback capable.
     7242 +                 */
     7243 +                if (DDI_FM_ERRCB_CAP(instance->fm_capabilities)) {
     7244 +                        ddi_fm_handler_unregister(instance->dip);
     7245 +                }
     7246 +
     7247 +                /*
     7248 +                 * Release any resources allocated by pci_ereport_setup()
     7249 +                 */
     7250 +                if (DDI_FM_EREPORT_CAP(instance->fm_capabilities) ||
     7251 +                    DDI_FM_ERRCB_CAP(instance->fm_capabilities)) {
     7252 +                        pci_ereport_teardown(instance->dip);
     7253 +                }
     7254 +
     7255 +                /* Unregister from IO Fault Services */
     7256 +                ddi_fm_fini(instance->dip);
     7257 +
     7258 +                /* Adjust access and dma attributes for FMA */
     7259 +                endian_attr.devacc_attr_access = DDI_DEFAULT_ACC;
     7260 +                mrsas_generic_dma_attr.dma_attr_flags = 0;
     7261 +        }
     7262 +}
     7263 +
     7264 +int
     7265 +mrsas_check_acc_handle(ddi_acc_handle_t handle)
     7266 +{
     7267 +        ddi_fm_error_t de;
     7268 +
     7269 +        if (handle == NULL) {
     7270 +                return (DDI_FAILURE);
     7271 +        }
     7272 +
     7273 +        ddi_fm_acc_err_get(handle, &de, DDI_FME_VERSION);
     7274 +
     7275 +        return (de.fme_status);
     7276 +}
     7277 +
     7278 +int
     7279 +mrsas_check_dma_handle(ddi_dma_handle_t handle)
     7280 +{
     7281 +        ddi_fm_error_t de;
     7282 +
     7283 +        if (handle == NULL) {
     7284 +                return (DDI_FAILURE);
     7285 +        }
     7286 +
     7287 +        ddi_fm_dma_err_get(handle, &de, DDI_FME_VERSION);
     7288 +
     7289 +        return (de.fme_status);
     7290 +}
     7291 +
     7292 +void
     7293 +mrsas_fm_ereport(struct mrsas_instance *instance, char *detail)
     7294 +{
     7295 +        uint64_t ena;
     7296 +        char buf[FM_MAX_CLASS];
     7297 +
     7298 +        (void) snprintf(buf, FM_MAX_CLASS, "%s.%s", DDI_FM_DEVICE, detail);
     7299 +        ena = fm_ena_generate(0, FM_ENA_FMT1);
     7300 +        if (DDI_FM_EREPORT_CAP(instance->fm_capabilities)) {
     7301 +                ddi_fm_ereport_post(instance->dip, buf, ena, DDI_NOSLEEP,
     7302 +                    FM_VERSION, DATA_TYPE_UINT8, FM_EREPORT_VERSION, NULL);
     7303 +        }
     7304 +}
     7305 +
     7306 +static int
6882 7307  mrsas_add_intrs(struct mrsas_instance *instance, int intr_type)
6883 7308  {
6884 7309  
6885 7310          dev_info_t *dip = instance->dip;
6886 7311          int     avail, actual, count;
6887 7312          int     i, flag, ret;
6888 7313  
6889 7314          con_log(CL_DLEVEL1, (CE_NOTE, "mrsas_add_intrs: intr_type = %x",
6890 7315              intr_type));
6891 7316  
↓ open down ↓ 21 lines elided ↑ open up ↑
6913 7338          /* Only one interrupt routine. So limit the count to 1 */
6914 7339          if (count > 1) {
6915 7340                  count = 1;
6916 7341          }
6917 7342  
6918 7343          /*
6919 7344           * Allocate an array of interrupt handlers. Currently we support
6920 7345           * only one interrupt. The framework can be extended later.
6921 7346           */
6922 7347          instance->intr_htable_size = count * sizeof (ddi_intr_handle_t);
6923      -        instance->intr_htable = kmem_zalloc(instance->intr_htable_size, KM_SLEEP);
6924      -        if (instance->intr_htable == NULL) {
6925      -                con_log(CL_ANN, (CE_WARN, "mrsas_add_intrs: "
6926      -                        "failed to allocate memory for intr-handle table"));
6927      -                instance->intr_htable_size = 0;
6928      -                return (DDI_FAILURE);
6929      -        }
     7348 +        instance->intr_htable = kmem_zalloc(instance->intr_htable_size,
     7349 +            KM_SLEEP);
     7350 +        ASSERT(instance->intr_htable);
6930 7351  
6931      -        flag = ((intr_type == DDI_INTR_TYPE_MSI) || (intr_type ==
6932      -                DDI_INTR_TYPE_MSIX)) ? DDI_INTR_ALLOC_STRICT:DDI_INTR_ALLOC_NORMAL;
     7352 +        flag = ((intr_type == DDI_INTR_TYPE_MSI) ||
     7353 +            (intr_type == DDI_INTR_TYPE_MSIX)) ?
     7354 +            DDI_INTR_ALLOC_STRICT : DDI_INTR_ALLOC_NORMAL;
6933 7355  
6934 7356          /* Allocate interrupt */
6935 7357          ret = ddi_intr_alloc(dip, instance->intr_htable, intr_type, 0,
6936      -                        count, &actual, flag);
     7358 +            count, &actual, flag);
6937 7359  
6938 7360          if ((ret != DDI_SUCCESS) || (actual == 0)) {
6939 7361                  con_log(CL_ANN, (CE_WARN, "mrsas_add_intrs: "
6940 7362                      "avail = %d", avail));
6941 7363                  goto mrsas_free_htable;
6942 7364          }
6943 7365  
6944 7366          if (actual < count) {
6945 7367                  con_log(CL_ANN, (CE_WARN, "mrsas_add_intrs: "
6946 7368                      "Requested = %d  Received = %d", count, actual));
↓ open down ↓ 57 lines elided ↑ open up ↑
7004 7426                          (void) ddi_intr_enable(instance->intr_htable[i]);
7005 7427                          con_log(CL_ANN, (CE_NOTE, "ddi intr enable returns "
7006 7428                              "%d", i));
7007 7429                  }
7008 7430          }
7009 7431  
7010 7432          return (DDI_SUCCESS);
7011 7433  
7012 7434  mrsas_free_handlers:
7013 7435          for (i = 0; i < actual; i++)
7014      -        {
7015 7436                  (void) ddi_intr_remove_handler(instance->intr_htable[i]);
7016      -        }
7017 7437  
7018 7438  mrsas_free_handles:
7019 7439          for (i = 0; i < actual; i++)
7020      -        {
7021 7440                  (void) ddi_intr_free(instance->intr_htable[i]);
7022      -        }
7023 7441  
7024 7442  mrsas_free_htable:
7025 7443          if (instance->intr_htable != NULL)
7026 7444                  kmem_free(instance->intr_htable, instance->intr_htable_size);
7027 7445  
7028      -        instance->intr_htable =NULL;
     7446 +        instance->intr_htable = NULL;
7029 7447          instance->intr_htable_size = 0;
7030 7448  
7031 7449          return (DDI_FAILURE);
7032 7450  
7033 7451  }
7034 7452  
7035 7453  
7036 7454  static void
7037 7455  mrsas_rem_intrs(struct mrsas_instance *instance)
7038 7456  {
7039 7457          int i;
7040 7458  
7041 7459          con_log(CL_ANN, (CE_NOTE, "mrsas_rem_intrs called"));
7042 7460  
7043 7461          /* Disable all interrupts first */
7044 7462          if (instance->intr_cap & DDI_INTR_FLAG_BLOCK) {
7045 7463                  (void) ddi_intr_block_disable(instance->intr_htable,
7046      -                                instance->intr_cnt);
     7464 +                    instance->intr_cnt);
7047 7465          } else {
7048 7466                  for (i = 0; i < instance->intr_cnt; i++) {
7049 7467                          (void) ddi_intr_disable(instance->intr_htable[i]);
7050 7468                  }
7051 7469          }
7052 7470  
7053 7471          /* Remove all the handlers */
7054 7472  
7055 7473          for (i = 0; i < instance->intr_cnt; i++) {
7056 7474                  (void) ddi_intr_remove_handler(instance->intr_htable[i]);
7057 7475                  (void) ddi_intr_free(instance->intr_htable[i]);
7058 7476          }
7059 7477  
7060 7478          if (instance->intr_htable != NULL)
7061 7479                  kmem_free(instance->intr_htable, instance->intr_htable_size);
7062 7480  
7063      -        instance->intr_htable =NULL;
     7481 +        instance->intr_htable = NULL;
7064 7482          instance->intr_htable_size = 0;
7065 7483  
7066 7484  }
7067 7485  
7068 7486  static int
7069 7487  mrsas_tran_bus_config(dev_info_t *parent, uint_t flags,
7070 7488      ddi_bus_config_op_t op, void *arg, dev_info_t **childp)
7071 7489  {
7072 7490          struct mrsas_instance *instance;
7073 7491          int config;
↓ open down ↓ 21 lines elided ↑ open up ↑
7095 7513                  }
7096 7514                  ptr++;
7097 7515  
7098 7516                  if (mrsas_parse_devname(arg, &tgt, &lun) != 0) {
7099 7517                          rval = NDI_FAILURE;
7100 7518                          break;
7101 7519                  }
7102 7520  
7103 7521                  if (lun == 0) {
7104 7522                          rval = mrsas_config_ld(instance, tgt, lun, childp);
7105      -                }
7106 7523  #ifdef PDSUPPORT
7107      -                else if ( instance->tbolt == 1 && lun != 0) {
7108      -                        rval = mrsas_tbolt_config_pd(instance, 
     7524 +                } else if (instance->tbolt == 1 && lun != 0) {
     7525 +                        rval = mrsas_tbolt_config_pd(instance,
7109 7526                              tgt, lun, childp);
7110      -                }
7111 7527  #endif
7112      -                else {
     7528 +                } else {
7113 7529                          rval = NDI_FAILURE;
7114 7530                  }
7115 7531  
7116 7532                  break;
7117 7533          }
7118 7534          case BUS_CONFIG_DRIVER:
7119 7535          case BUS_CONFIG_ALL: {
7120 7536  
7121 7537                  rval = mrsas_config_all_devices(instance);
7122 7538  
↓ open down ↓ 18 lines elided ↑ open up ↑
7141 7557  {
7142 7558          int rval, tgt;
7143 7559  
7144 7560          for (tgt = 0; tgt < MRDRV_MAX_LD; tgt++) {
7145 7561                  (void) mrsas_config_ld(instance, tgt, 0, NULL);
7146 7562  
7147 7563          }
7148 7564  
7149 7565  #ifdef PDSUPPORT
7150 7566          /* Config PD devices connected to the card */
7151      -        if(instance->tbolt) {
     7567 +        if (instance->tbolt) {
7152 7568                  for (tgt = 0; tgt < instance->mr_tbolt_pd_max; tgt++) {
7153 7569                          (void) mrsas_tbolt_config_pd(instance, tgt, 1, NULL);
7154 7570                  }
7155 7571          }
7156 7572  #endif
7157 7573  
7158 7574          rval = NDI_SUCCESS;
7159 7575          return (rval);
7160 7576  }
7161 7577  
↓ open down ↓ 61 lines elided ↑ open up ↑
7223 7639                              MRSAS_EVT_UNCONFIG_TGT, NULL);
7224 7640                          con_log(CL_ANN1, (CE_WARN,
7225 7641                              "mr_sas: DELETING STALE ENTRY rval = %d "
7226 7642                              "tgt id = %d ", rval, tgt));
7227 7643                          return (NDI_FAILURE);
7228 7644                  }
7229 7645                  return (NDI_SUCCESS);
7230 7646          }
7231 7647  
7232 7648          sd = kmem_zalloc(sizeof (struct scsi_device), KM_SLEEP);
7233      -        if (sd == NULL) {
7234      -                con_log(CL_ANN1, (CE_WARN,
7235      -                            "mrsas_config_ld: failed to allocate mem for scsi_device"));
7236      -                return (NDI_FAILURE);
7237      -        }
7238 7649          sd->sd_address.a_hba_tran = instance->tran;
7239 7650          sd->sd_address.a_target = (uint16_t)tgt;
7240 7651          sd->sd_address.a_lun = (uint8_t)lun;
7241 7652  
7242 7653          if (scsi_hba_probe(sd, NULL) == SCSIPROBE_EXISTS)
7243 7654                  rval = mrsas_config_scsi_device(instance, sd, ldip);
7244 7655          else
7245 7656                  rval = NDI_FAILURE;
7246 7657  
7247 7658          /* sd_unprobe is blank now. Free buffer manually */
↓ open down ↓ 114 lines elided ↑ open up ↑
7362 7773  
7363 7774          if ((ddi_taskq_dispatch(instance->taskq,
7364 7775              (void (*)(void *))mrsas_issue_evt_taskq, mrevt, DDI_NOSLEEP)) !=
7365 7776              DDI_SUCCESS) {
7366 7777                  con_log(CL_ANN1, (CE_NOTE,
7367 7778                      "mr_sas: Event task failed for t%dl%d event = %d",
7368 7779                      tgt, lun, event));
7369 7780                  kmem_free(mrevt, sizeof (struct mrsas_eventinfo));
7370 7781                  return (DDI_FAILURE);
7371 7782          }
7372      -
     7783 +        DTRACE_PROBE3(service_evt, int, tgt, int, lun, int, event);
7373 7784          return (DDI_SUCCESS);
7374 7785  }
7375 7786  
7376 7787  static void
7377 7788  mrsas_issue_evt_taskq(struct mrsas_eventinfo *mrevt)
7378 7789  {
7379 7790          struct mrsas_instance *instance = mrevt->instance;
7380 7791          dev_info_t *dip, *pdip;
7381 7792          int circ1 = 0;
7382 7793          char *devname;
7383 7794  
7384 7795          con_log(CL_ANN1, (CE_NOTE, "mrsas_issue_evt_taskq: called for"
7385 7796              " tgt %d lun %d event %d",
7386 7797              mrevt->tgt, mrevt->lun, mrevt->event));
7387 7798  
7388 7799          if (mrevt->tgt < MRDRV_MAX_LD && mrevt->lun == 0) {
7389 7800                  mutex_enter(&instance->config_dev_mtx);
7390 7801                  dip = instance->mr_ld_list[mrevt->tgt].dip;
7391 7802                  mutex_exit(&instance->config_dev_mtx);
7392      -        }
7393      -
7394 7803  #ifdef PDSUPPORT
7395      -        else {
     7804 +        } else {
7396 7805                  mutex_enter(&instance->config_dev_mtx);
7397 7806                  dip = instance->mr_tbolt_pd_list[mrevt->tgt].dip;
7398 7807                  mutex_exit(&instance->config_dev_mtx);
7399      -        }
7400 7808  #endif
     7809 +        }
7401 7810  
     7811 +
7402 7812          ndi_devi_enter(instance->dip, &circ1);
7403 7813          switch (mrevt->event) {
7404 7814          case MRSAS_EVT_CONFIG_TGT:
7405 7815                  if (dip == NULL) {
7406 7816  
7407 7817                          if (mrevt->lun == 0) {
7408 7818                                  (void) mrsas_config_ld(instance, mrevt->tgt,
7409 7819                                      0, NULL);
7410      -                        }
7411 7820  #ifdef PDSUPPORT
7412      -                        else if (instance->tbolt) {
     7821 +                        } else if (instance->tbolt) {
7413 7822                                  (void) mrsas_tbolt_config_pd(instance,
7414 7823                                      mrevt->tgt,
7415 7824                                      1, NULL);
7416      -                        }
7417 7825  #endif
     7826 +                        }
7418 7827                          con_log(CL_ANN1, (CE_NOTE,
7419 7828                              "mr_sas: EVT_CONFIG_TGT called:"
7420 7829                              " for tgt %d lun %d event %d",
7421 7830                              mrevt->tgt, mrevt->lun, mrevt->event));
7422 7831  
7423 7832                  } else {
7424 7833                          con_log(CL_ANN1, (CE_NOTE,
7425 7834                              "mr_sas: EVT_CONFIG_TGT dip != NULL:"
7426 7835                              " for tgt %d lun %d event %d",
7427 7836                              mrevt->tgt, mrevt->lun, mrevt->event));
↓ open down ↓ 27 lines elided ↑ open up ↑
7455 7864          }
7456 7865          kmem_free(mrevt, sizeof (struct mrsas_eventinfo));
7457 7866          ndi_devi_exit(instance->dip, circ1);
7458 7867  }
7459 7868  
7460 7869  
7461 7870  int
7462 7871  mrsas_mode_sense_build(struct scsi_pkt *pkt)
7463 7872  {
7464 7873          union scsi_cdb          *cdbp;
7465      -        uint16_t                page_code;
     7874 +        uint16_t                page_code;
7466 7875          struct scsa_cmd         *acmd;
7467 7876          struct buf              *bp;
7468 7877          struct mode_header      *modehdrp;
7469 7878  
7470 7879          cdbp = (void *)pkt->pkt_cdbp;
7471 7880          page_code = cdbp->cdb_un.sg.scsi[0];
7472 7881          acmd = PKT2CMD(pkt);
7473 7882          bp = acmd->cmd_buf;
7474 7883          if ((!bp) && bp->b_un.b_addr && bp->b_bcount && acmd->cmd_dmacount) {
7475 7884                  con_log(CL_ANN1, (CE_WARN, "Failing MODESENSE Command"));
↓ open down ↓ 31 lines elided ↑ open up ↑
7507 7916                              (uchar_t)(sizeof (struct mode_geometry));
7508 7917                          page4p->heads = 255;
7509 7918                          page4p->rpm = 10000;
7510 7919                          break;
7511 7920                  }
7512 7921                  default:
7513 7922                          break;
7514 7923          }
7515 7924          return (NULL);
7516 7925  }
7517      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX