Print this page
XXXX don't fail device detach when it's physically removed

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/devcfg.c
          +++ new/usr/src/uts/common/os/devcfg.c
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
       21 +
  21   22  /*
  22   23   * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
       24 + * Copyright 2018 Nexenta Systems, Inc.
  24   25   * Copyright 2012 Garrett D'Amore <garrett@damore.org>.  All rights reserved.
  25   26   * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  26   27   * Copyright (c) 2016 by Delphix. All rights reserved.
  27   28   */
  28   29  
  29   30  #include <sys/note.h>
  30   31  #include <sys/t_lock.h>
  31   32  #include <sys/cmn_err.h>
  32   33  #include <sys/instance.h>
  33   34  #include <sys/conf.h>
↓ open down ↓ 1319 lines elided ↑ open up ↑
1353 1354   */
1354 1355  static int
1355 1356  detach_node(dev_info_t *dip, uint_t flag)
1356 1357  {
1357 1358          struct devnames *dnp;
1358 1359          int             rv;
1359 1360  
1360 1361          ASSERT(DEVI_BUSY_OWNED(ddi_get_parent(dip)));
1361 1362          ASSERT(i_ddi_node_state(dip) == DS_ATTACHED);
1362 1363  
1363      -        /* check references */
1364      -        if (DEVI(dip)->devi_ref)
     1364 +        /* Check references */
     1365 +        if (DEVI(dip)->devi_ref != 0 && !DEVI(dip)->devi_gone)
1365 1366                  return (DDI_FAILURE);
1366 1367  
1367 1368          NDI_CONFIG_DEBUG((CE_CONT, "detach_node: 0x%p(%s%d)\n",
1368 1369              (void *)dip, ddi_driver_name(dip), ddi_get_instance(dip)));
1369 1370  
1370 1371          /*
1371 1372           * NOTE: If we are processing a pHCI node then the calling code
1372 1373           * must detect this and ndi_devi_enter() in (vHCI, parent(pHCI))
1373 1374           * order unless pHCI and vHCI are siblings.  Code paths leading
1374 1375           * here that must ensure this ordering include:
↓ open down ↓ 2439 lines elided ↑ open up ↑
3814 3815   *      b /pci@8,700000/ib@1,1:port=1/ioc@xxxxxx,yyyyyyy:dhcp
3815 3816   * Case (a), we first look for minor node "port=1,pkey...".
3816 3817   * Failing that, we will pass "port=1,pkey..." to the bus_config
3817 3818   * entry point of ib (HCA) driver.
3818 3819   * Case (b), configure ib@1,1 as usual. Then invoke ib's bus_config
3819 3820   * with argument "ioc@xxxxxxx,yyyyyyy:port=1". After configuring
3820 3821   * the ioc, look for minor node dhcp. If not found, pass ":dhcp"
3821 3822   * to ioc's bus_config entry point.
3822 3823   */
3823 3824  int
3824      -resolve_pathname(char *pathname,
3825      -        dev_info_t **dipp, dev_t *devtp, int *spectypep)
     3825 +resolve_pathname(char *pathname, dev_info_t **dipp, dev_t *devtp,
     3826 +    int *spectypep)
3826 3827  {
3827 3828          int                     error;
3828 3829          dev_info_t              *parent, *child;
3829 3830          struct pathname         pn;
3830 3831          char                    *component, *config_name;
3831 3832          char                    *minorname = NULL;
3832 3833          char                    *prev_minor = NULL;
3833 3834          dev_t                   devt = NODEV;
3834 3835          int                     spectype;
3835 3836          struct ddi_minor_data   *dmn;
↓ open down ↓ 5210 lines elided ↑ open up ↑
9046 9047          }
9047 9048  out:
9048 9049          (void) tsd_set(tsd_ddi_redirect, NULL);
9049 9050  
9050 9051          return (currdip);
9051 9052  }
9052 9053  
9053 9054  char *
9054 9055  ddi_curr_redirect(char *curr)
9055 9056  {
9056      -        char    *alias;
     9057 +        char *alias;
9057 9058          int i;
9058 9059  
9059 9060          if (ddi_aliases_present == B_FALSE)
9060 9061                  return (NULL);
9061 9062  
9062 9063          if (tsd_get(tsd_ddi_redirect))
9063 9064                  return (NULL);
9064 9065  
9065 9066          (void) tsd_set(tsd_ddi_redirect, (void *)1);
9066 9067  
↓ open down ↓ 130 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX