summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/cpr/cpr_driver.c6
-rw-r--r--usr/src/uts/common/fs/devfs/devfs_subr.c6
-rw-r--r--usr/src/uts/common/fs/specfs/specvnops.c6
-rw-r--r--usr/src/uts/common/io/devinfo.c6
-rw-r--r--usr/src/uts/common/io/hotplug/pcihp/pcihp.c4
-rw-r--r--usr/src/uts/common/io/usb/clients/audio/usb_ac/usb_ac_dacf.c4
-rw-r--r--usr/src/uts/common/io/usb/usba/hubdi.c6
-rw-r--r--usr/src/uts/common/io/usb/usba/usba.c4
-rw-r--r--usr/src/uts/common/os/devcfg.c59
-rw-r--r--usr/src/uts/common/os/devctl.c4
-rw-r--r--usr/src/uts/common/os/sunddi.c4
-rw-r--r--usr/src/uts/common/os/sunmdi.c22
-rw-r--r--usr/src/uts/common/os/sunndi.c4
-rw-r--r--usr/src/uts/common/os/sunpm.c2
-rw-r--r--usr/src/uts/common/pcmcia/nexus/pcmcia.c6
-rw-r--r--usr/src/uts/common/rpc/rpcib.c4
-rw-r--r--usr/src/uts/common/sys/ddi_implfuncs.h28
-rw-r--r--usr/src/uts/common/sys/dditypes.h13
-rw-r--r--usr/src/uts/sun4u/io/pci/db21554.c6
-rw-r--r--usr/src/uts/sun4u/io/pci/simba.c6
-rw-r--r--usr/src/uts/sun4u/io/sbd.c4
-rw-r--r--usr/src/uts/sun4u/io/sbd_io.c5
-rw-r--r--usr/src/uts/sun4u/ngdr/io/dr_quiesce.c5
-rw-r--r--usr/src/uts/sun4u/os/mach_ddi_impl.c6
-rw-r--r--usr/src/uts/sun4u/starfire/io/drmach.c5
25 files changed, 114 insertions, 111 deletions
diff --git a/usr/src/uts/common/cpr/cpr_driver.c b/usr/src/uts/common/cpr/cpr_driver.c
index 4d84637a6b..deb6241319 100644
--- a/usr/src/uts/common/cpr/cpr_driver.c
+++ b/usr/src/uts/common/cpr/cpr_driver.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -70,7 +70,7 @@ cpr_suspend_devices(dev_info_t *dip)
DEBUG2(errp("Suspending device %s\n", devi_string(dip, buf)));
ASSERT((DEVI(dip)->devi_cpr_flags & DCF_CPR_SUSPENDED) == 0);
- if (i_ddi_node_state(dip) != DS_READY)
+ if (!i_ddi_devi_attached(dip))
error = DDI_FAILURE;
else
error = devi_detach(dip, DDI_SUSPEND);
@@ -138,7 +138,7 @@ cpr_resume_devices(dev_info_t *start, int resume_failed)
* before cpr gets around to issuing it a DDI_RESUME,
* we'll have problems.
*/
- if (i_ddi_node_state(dip) != DS_READY) {
+ if (!i_ddi_devi_attached(dip)) {
DEBUG2(errp("WARNING: Skipping %s, device "
"not ready for resume\n",
devi_string(dip, buf)));
diff --git a/usr/src/uts/common/fs/devfs/devfs_subr.c b/usr/src/uts/common/fs/devfs/devfs_subr.c
index 864ed2ad60..42dd03db8f 100644
--- a/usr/src/uts/common/fs/devfs/devfs_subr.c
+++ b/usr/src/uts/common/fs/devfs/devfs_subr.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -778,7 +778,7 @@ dv_find_leafnode(dev_info_t *devi, char *minor_nm, struct ddi_minor_data *r_mi)
{
struct ddi_minor_data *dmd;
- ASSERT(i_ddi_node_state(devi) >= DS_ATTACHED);
+ ASSERT(i_ddi_devi_attached(devi));
ASSERT(MUTEX_HELD(&DEVI(devi)->devi_lock));
dcmn_err3(("dv_find_leafnode: %s\n", minor_nm));
@@ -1010,7 +1010,7 @@ founddv:
goto notfound;
}
- ASSERT(devi && (i_ddi_node_state(devi) >= DS_ATTACHED));
+ ASSERT(devi && i_ddi_devi_attached(devi));
/*
* Invalidate cache to notice newly created minor nodes.
diff --git a/usr/src/uts/common/fs/specfs/specvnops.c b/usr/src/uts/common/fs/specfs/specvnops.c
index 13a9b4bfd9..d4ee630b92 100644
--- a/usr/src/uts/common/fs/specfs/specvnops.c
+++ b/usr/src/uts/common/fs/specfs/specvnops.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -320,7 +320,7 @@ spec_size(struct snode *csp)
/* Return non-cached UNKNOWN_SIZE if not attached. */
if (((csp->s_flag & SDIPSET) == 0) || (csp->s_dip == NULL) ||
- (i_ddi_node_state(csp->s_dip) < DS_ATTACHED)) {
+ !i_ddi_devi_attached(csp->s_dip)) {
mutex_exit(&csp->s_lock);
return ((cvp->v_type == VCHR) ? 0 : UNKNOWN_SIZE);
}
@@ -553,7 +553,7 @@ spec_open(struct vnode **vpp, int flag, struct cred *cr)
#ifdef DEBUG
/* verify attach/open exclusion guarantee */
dip = csp->s_dip;
- ASSERT((dip == NULL) || (i_ddi_node_state(dip) >= DS_ATTACHED));
+ ASSERT((dip == NULL) || i_ddi_devi_attached(dip));
#endif /* DEBUG */
if ((error = secpolicy_spec_open(cr, cvp, flag)) != 0)
diff --git a/usr/src/uts/common/io/devinfo.c b/usr/src/uts/common/io/devinfo.c
index 3533f193fe..be0447ee7e 100644
--- a/usr/src/uts/common/io/devinfo.c
+++ b/usr/src/uts/common/io/devinfo.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1633,7 +1633,7 @@ di_copytree(struct dev_info *root, di_off_t *off_p, struct di_state *st)
(void *)root, *off_p));
/* force attach drivers */
- if ((i_ddi_node_state((dev_info_t *)root) == DS_READY) &&
+ if (i_ddi_devi_attached((dev_info_t *)root) &&
(st->command & DINFOSUBTREE) && (st->command & DINFOFORCE)) {
(void) ndi_devi_config((dev_info_t *)root,
NDI_CONFIG | NDI_DEVI_PERSIST | NDI_NO_EVENT |
@@ -2927,7 +2927,7 @@ di_getprop(struct ddi_prop *prop, di_off_t *off_p, struct di_state *st,
* the driver property list. No one should rely on such
* properties.
*/
- if (i_ddi_node_state((dev_info_t *)dip) < DS_ATTACHED) {
+ if (!i_ddi_devi_attached((dev_info_t *)dip)) {
off = *off_p;
*off_p = 0;
return (off);
diff --git a/usr/src/uts/common/io/hotplug/pcihp/pcihp.c b/usr/src/uts/common/io/hotplug/pcihp/pcihp.c
index f56ada1d63..1a9e236856 100644
--- a/usr/src/uts/common/io/hotplug/pcihp/pcihp.c
+++ b/usr/src/uts/common/io/hotplug/pcihp/pcihp.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -650,7 +650,7 @@ pcihp_list_occupants(dev_info_t *dip, void *hdl)
* ask for the property explicitly which will cause it
* to be re-freshed right before checking with rcm.
*/
- if ((major == -1) || (i_ddi_node_state(dip) < DS_ATTACHED))
+ if ((major == -1) || !i_ddi_devi_attached(dip))
return (DDI_WALK_PRUNECHILD);
/*
diff --git a/usr/src/uts/common/io/usb/clients/audio/usb_ac/usb_ac_dacf.c b/usr/src/uts/common/io/usb/clients/audio/usb_ac/usb_ac_dacf.c
index 8c1092367b..b9a2cd41a8 100644
--- a/usr/src/uts/common/io/usb/clients/audio/usb_ac/usb_ac_dacf.c
+++ b/usr/src/uts/common/io/usb/clients/audio/usb_ac/usb_ac_dacf.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -512,7 +512,7 @@ usb_ac_mux_walk_siblings(usb_ac_state_t *uacp, ldi_handle_t mux_lh)
continue;
}
- if (i_ddi_node_state(child_dip) < DS_ATTACHED) {
+ if (!i_ddi_devi_attached(child_dip)) {
child_dip = ddi_get_next_sibling(child_dip);
continue;
diff --git a/usr/src/uts/common/io/usb/usba/hubdi.c b/usr/src/uts/common/io/usb/usba/hubdi.c
index e54be2c21d..551ad462f4 100644
--- a/usr/src/uts/common/io/usb/usba/hubdi.c
+++ b/usr/src/uts/common/io/usb/usba/hubdi.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -2184,7 +2184,7 @@ hubd_check_disconnected_ports(dev_info_t *dip, void *arg)
*/
if (!usba_is_root_hub(dip)) {
if ((ddi_driver_major(dip) != hub_major) ||
- (i_ddi_node_state(dip) < DS_ATTACHED)) {
+ !i_ddi_devi_attached(dip)) {
return (DDI_WALK_PRUNECHILD);
}
@@ -7646,7 +7646,7 @@ hubd_cfgadm_state(hubd_t *hubd, usb_port_t port)
* connected, now check if driver exists
*/
if (DEVI_IS_DEVICE_OFFLINE(child_dip) ||
- (i_ddi_node_state(child_dip) < DS_ATTACHED)) {
+ !i_ddi_devi_attached(child_dip)) {
state = HUBD_CFGADM_UNCONFIGURED;
} else {
state = HUBD_CFGADM_CONFIGURED;
diff --git a/usr/src/uts/common/io/usb/usba/usba.c b/usr/src/uts/common/io/usb/usba/usba.c
index ddf114cbc3..f72ebec531 100644
--- a/usr/src/uts/common/io/usb/usba/usba.c
+++ b/usr/src/uts/common/io/usb/usba/usba.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -2751,7 +2751,7 @@ usba_check_for_leaks(usba_device_t *usba_device)
dev_data = entry->cddl_dev_data;
- if (i_ddi_node_state(dip) < DS_ATTACHED) {
+ if (!i_ddi_devi_attached(dip)) {
USB_DPRINTF_L2(DPRINT_MASK_USBA,
usba_log_handle,
"%s%d: leaking dev_data 0x%p",
diff --git a/usr/src/uts/common/os/devcfg.c b/usr/src/uts/common/os/devcfg.c
index 30331fb171..b9cf08eb88 100644
--- a/usr/src/uts/common/os/devcfg.c
+++ b/usr/src/uts/common/os/devcfg.c
@@ -1422,7 +1422,7 @@ ddi_uninitchild(dev_info_t *dip)
}
/*
- * i_ddi_attachchild: transform node to DS_READY state
+ * i_ddi_attachchild: transform node to DS_READY/i_ddi_devi_attached() state
*/
static int
i_ddi_attachchild(dev_info_t *dip)
@@ -1455,7 +1455,8 @@ i_ddi_attachchild(dev_info_t *dip)
* i_ddi_detachchild: transform node down to DS_PROBED state
* If it fails, put it back to DS_READY state.
* NOTE: A node that fails detach may be at DS_ATTACHED instead
- * of DS_READY for a small amount of time.
+ * of DS_READY for a small amount of time - this is the source of
+ * transient DS_READY->DS_ATTACHED->DS_READY state changes.
*/
static int
i_ddi_detachchild(dev_info_t *dip, uint_t flags)
@@ -1782,6 +1783,18 @@ i_ddi_set_node_state(dev_info_t *dip, ddi_node_state_t state)
}
/*
+ * Determine if node is attached. The implementation accommodates transient
+ * DS_READY->DS_ATTACHED->DS_READY state changes. Outside this file, this
+ * function should be instead of i_ddi_node_state() DS_ATTACHED/DS_READY
+ * state checks.
+ */
+int
+i_ddi_devi_attached(dev_info_t *dip)
+{
+ return (DEVI(dip)->devi_node_state >= DS_ATTACHED);
+}
+
+/*
* Common function for finding a node in a sibling list given name and addr.
*
* By default, name is matched with devi_node_name. The following
@@ -3121,7 +3134,7 @@ struct match_info {
dev_info_t *dip; /* result */
char *nodename; /* if non-null, nodename must match */
int instance; /* if != -1, instance must match */
- int attached; /* if != 0, state >= DS_ATTACHED */
+ int attached; /* if != 0, i_ddi_devi_attached() */
};
static int
@@ -3133,8 +3146,7 @@ i_find_devi(dev_info_t *dip, void *arg)
(strcmp(ddi_node_name(dip), info->nodename) == 0)) &&
((info->instance == -1) ||
(ddi_get_instance(dip) == info->instance)) &&
- ((info->attached == 0) ||
- (i_ddi_node_state(dip) >= DS_ATTACHED))) {
+ ((info->attached == 0) || i_ddi_devi_attached(dip))) {
info->dip = dip;
ndi_hold_devi(dip);
return (DDI_WALK_TERMINATE);
@@ -3285,7 +3297,7 @@ resolve_pathname(char *pathname,
return (error);
pn_skipslash(&pn);
- ASSERT(i_ddi_node_state(parent) >= DS_ATTACHED);
+ ASSERT(i_ddi_devi_attached(parent));
ndi_hold_devi(parent);
component = kmem_alloc(MAXNAMELEN, KM_SLEEP);
@@ -3322,7 +3334,7 @@ resolve_pathname(char *pathname,
return (-1);
}
- ASSERT(i_ddi_node_state(child) >= DS_ATTACHED);
+ ASSERT(i_ddi_devi_attached(child));
ndi_rele_devi(parent);
parent = child;
pn_skipslash(&pn);
@@ -3346,7 +3358,7 @@ resolve_pathname(char *pathname,
return (-1);
}
minorname = NULL; /* look for default minor */
- ASSERT(i_ddi_node_state(child) >= DS_ATTACHED);
+ ASSERT(i_ddi_devi_attached(child));
ndi_rele_devi(parent);
parent = child;
}
@@ -3752,7 +3764,7 @@ i_ndi_devi_report_status_change(dev_info_t *dip, char *path)
status = "quiesced";
} else if (DEVI_IS_BUS_DOWN(dip)) {
status = "down";
- } else if (i_ddi_node_state(dip) == DS_READY) {
+ } else if (i_ddi_devi_attached(dip)) {
status = "online";
} else {
status = "unknown";
@@ -4274,8 +4286,7 @@ init_bound_node_ev(dev_info_t *pdip, dev_info_t *dip, int flags)
{
if (need_remove_event(dip, flags) &&
i_ddi_node_state(dip) == DS_BOUND &&
- i_ddi_node_state(pdip) >= DS_ATTACHED &&
- !(DEVI_IS_DEVICE_OFFLINE(dip)))
+ i_ddi_devi_attached(pdip) && !DEVI_IS_DEVICE_OFFLINE(dip))
(void) ddi_initchild(pdip, dip);
}
@@ -4287,7 +4298,7 @@ devi_attach_node(dev_info_t *dip, uint_t flags)
{
mutex_enter(&(DEVI(dip)->devi_lock));
if (flags & NDI_DEVI_ONLINE) {
- if (i_ddi_node_state(dip) != DS_READY)
+ if (!i_ddi_devi_attached(dip))
DEVI_SET_REPORT(dip);
DEVI_SET_DEVICE_ONLINE(dip);
}
@@ -4372,7 +4383,7 @@ static int
config_immediate_children(dev_info_t *pdip, uint_t flags, major_t major)
{
int circ;
- ASSERT(i_ddi_node_state(pdip) >= DS_ATTACHED);
+ ASSERT(i_ddi_devi_attached(pdip));
if (!NEXUS_DRV(ddi_get_driver(pdip)))
return (NDI_SUCCESS);
@@ -4423,7 +4434,7 @@ devi_config_common(dev_info_t *dip, int flags, major_t major)
int error;
int (*f)();
- if (i_ddi_node_state(dip) < DS_READY)
+ if (!i_ddi_devi_attached(dip))
return (NDI_FAILURE);
if (pm_pre_config(dip, NULL) != DDI_SUCCESS)
@@ -4616,7 +4627,7 @@ ndi_devi_config_one(dev_info_t *dip, char *devnm, dev_info_t **dipp, int flags)
int branch_event = 0;
ASSERT(dipp);
- ASSERT(i_ddi_node_state(dip) >= DS_ATTACHED);
+ ASSERT(i_ddi_devi_attached(dip));
NDI_CONFIG_DEBUG((CE_CONT,
"ndi_devi_config_one: par = %s%d (%p), child = %s\n",
@@ -4676,7 +4687,7 @@ ndi_devi_config_obp_args(dev_info_t *parent, char *devnm,
int (*f)();
ASSERT(childp);
- ASSERT(i_ddi_node_state(parent) >= DS_ATTACHED);
+ ASSERT(i_ddi_devi_attached(parent));
NDI_CONFIG_DEBUG((CE_CONT, "ndi_devi_config_obp_args: "
"par = %s%d (%p), child = %s\n", ddi_driver_name(parent),
@@ -4706,7 +4717,7 @@ devi_detach_node(dev_info_t *dip, uint_t flags)
ddi_eventcookie_t cookie;
if (flags & NDI_POST_EVENT) {
- if (pdip && i_ddi_node_state(pdip) >= DS_ATTACHED) {
+ if (pdip && i_ddi_devi_attached(pdip)) {
if (ddi_get_eventcookie(dip, DDI_DEVI_REMOVE_EVENT,
&cookie) == NDI_SUCCESS)
(void) ndi_post_event(dip, dip, cookie, NULL);
@@ -4902,7 +4913,7 @@ devi_unconfig_common(
* the bus_unconfig entry point cannot be used to remove
* or unconfigure the descendants.
*/
- if (i_ddi_node_state(dip) < DS_ATTACHED ||
+ if (!i_ddi_devi_attached(dip) ||
(DEVI(dip)->devi_ops->devo_bus_ops == NULL) ||
(DEVI(dip)->devi_ops->devo_bus_ops->busops_rev < BUSO_REV_5) ||
(f = DEVI(dip)->devi_ops->devo_bus_ops->bus_unconfig) == NULL) {
@@ -4995,7 +5006,7 @@ ndi_devi_unconfig_one(
dev_info_t *child;
struct brevq_node *brevq = NULL;
- ASSERT(i_ddi_node_state(pdip) >= DS_ATTACHED);
+ ASSERT(i_ddi_devi_attached(pdip));
NDI_CONFIG_DEBUG((CE_CONT,
"ndi_devi_unconfig_one: par = %s%d (%p), child = %s\n",
@@ -5190,7 +5201,7 @@ ndi_devi_online(dev_info_t *dip, uint_t flags)
* We skip the devfs_clean() step because the cache invalidation
* is done higher up in the device tree.
*/
- if (rv == NDI_SUCCESS && i_ddi_node_state(pdip) == DS_READY &&
+ if (rv == NDI_SUCCESS && i_ddi_devi_attached(pdip) &&
!DEVI_BUSY_OWNED(pdip))
(void) devfs_clean(pdip, NULL, 0);
return (rv);
@@ -5466,7 +5477,7 @@ hold_devi(major_t major, int instance, int flags)
* detach_node() code path.
*/
ndi_hold_devi(dip);
- if ((i_ddi_node_state(dip) >= DS_ATTACHED) &&
+ if (i_ddi_devi_attached(dip) &&
!DEVI_IS_DETACHING(dip)) {
UNLOCK_DEV_OPS(&(dnp->dn_lock));
return (dip); /* fast-path with devi held */
@@ -5688,7 +5699,7 @@ i_ddi_attach_node_hierarchy(dev_info_t *dip)
{
dev_info_t *parent;
- if (i_ddi_node_state(dip) == DS_READY)
+ if (i_ddi_devi_attached(dip))
return (DDI_SUCCESS);
/*
@@ -5840,7 +5851,7 @@ i_ddi_devs_attached(major_t major)
dnp = &devnamesp[major];
LOCK_DEV_OPS(&dnp->dn_lock);
for (dip = dnp->dn_head; dip != NULL; dip = ddi_get_next(dip)) {
- if (i_ddi_node_state(dip) >= DS_ATTACHED) {
+ if (i_ddi_devi_attached(dip)) {
error = DDI_SUCCESS;
break;
}
@@ -6356,7 +6367,7 @@ mt_config_driver(struct mt_config_handle *hdl)
ndi_hold_devi(dip);
/* skip leaf nodes and nodes not fully attached */
- if ((i_ddi_node_state(dip) < DS_READY) || is_leaf_node(dip)) {
+ if (!i_ddi_devi_attached(dip) || is_leaf_node(dip)) {
ndi_rele_devi(dip);
dip = ddi_get_next(dip);
continue;
diff --git a/usr/src/uts/common/os/devctl.c b/usr/src/uts/common/os/devctl.c
index cd160bfad1..57a7c05ac8 100644
--- a/usr/src/uts/common/os/devctl.c
+++ b/usr/src/uts/common/os/devctl.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1180,7 +1180,7 @@ e_devid_minor_to_devlist(
int minor_all = 0;
int ndevts = *devtcntp;
- ASSERT(i_ddi_node_state(dip) >= DS_ATTACHED);
+ ASSERT(i_ddi_devi_attached(dip));
/* are we looking for a set of minor nodes? */
if ((minor_name == DEVID_MINOR_NAME_ALL) ||
diff --git a/usr/src/uts/common/os/sunddi.c b/usr/src/uts/common/os/sunddi.c
index 2dd6f5c074..34066adc50 100644
--- a/usr/src/uts/common/os/sunddi.c
+++ b/usr/src/uts/common/os/sunddi.c
@@ -1757,7 +1757,7 @@ ddi_prop_search_common(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
*/
bop = ddi_bus_prop_op;
- if ((i_ddi_node_state(pdip) == DS_READY) &&
+ if (i_ddi_devi_attached(pdip) &&
(i_ddi_node_state(dip) >= DS_INITIALIZED))
bop = DEVI(pdip)->devi_ops->devo_bus_ops->bus_prop_op;
@@ -5046,7 +5046,7 @@ ddi_dev_affinity(dev_info_t *a, dev_info_t *b)
int
ddi_streams_driver(dev_info_t *dip)
{
- if ((i_ddi_node_state(dip) >= DS_ATTACHED) &&
+ if (i_ddi_devi_attached(dip) &&
(DEVI(dip)->devi_ops->devo_cb_ops != NULL) &&
(DEVI(dip)->devi_ops->devo_cb_ops->cb_str != NULL))
return (DDI_SUCCESS);
diff --git a/usr/src/uts/common/os/sunmdi.c b/usr/src/uts/common/os/sunmdi.c
index 9c6ada65a3..208136b2f9 100644
--- a/usr/src/uts/common/os/sunmdi.c
+++ b/usr/src/uts/common/os/sunmdi.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
@@ -1599,7 +1599,7 @@ mdi_failover(dev_info_t *vdip, dev_info_t *cdip, int flags)
* checks again.
*/
if ((MDI_CLIENT_IS_DETACHED(ct)) || (MDI_CLIENT_IS_FAILED(ct)) ||
- (i_ddi_node_state(ct->ct_dip) < DS_READY)) {
+ (!i_ddi_devi_attached(ct->ct_dip))) {
/*
* Client is in failed state. Nothing more to do.
*/
@@ -1867,8 +1867,7 @@ mdi_select_path(dev_info_t *cdip, struct buf *bp, int flags,
* If not so, let the vHCI driver manually select a path
* (standby) and let the probe/attach process to continue.
*/
- if ((MDI_CLIENT_IS_DETACHED(ct)) ||
- i_ddi_node_state(cdip) < DS_READY) {
+ if (MDI_CLIENT_IS_DETACHED(ct) || !i_ddi_devi_attached(cdip)) {
MDI_DEBUG(4, (CE_NOTE, cdip, "!Devi is onlining\n"));
MDI_CLIENT_UNLOCK(ct);
return (MDI_DEVI_ONLINING);
@@ -3211,8 +3210,7 @@ i_mdi_pi_state_change(mdi_pathinfo_t *pip, mdi_pathinfo_state_t state, int flag)
switch (MDI_CLIENT_STATE(ct)) {
case MDI_CLIENT_STATE_OPTIMAL:
case MDI_CLIENT_STATE_DEGRADED:
- if (cdip &&
- (i_ddi_node_state(cdip) < DS_READY) &&
+ if (cdip && !i_ddi_devi_attached(cdip) &&
((state == MDI_PATHINFO_STATE_ONLINE) ||
(state == MDI_PATHINFO_STATE_STANDBY))) {
@@ -3362,7 +3360,7 @@ mdi_pi_online(mdi_pathinfo_t *pip, int flags)
*/
cdip = ct->ct_dip;
ASSERT(cdip);
- if (cdip == NULL || (i_ddi_node_state(cdip) < DS_ATTACHED))
+ if (cdip == NULL || !i_ddi_devi_attached(cdip))
return (rv);
MDI_CLIENT_LOCK(ct);
@@ -5625,7 +5623,7 @@ i_mdi_pm_rele_client(mdi_client_t *ct, int decr)
{
ASSERT(ct);
- if (i_ddi_node_state(ct->ct_dip) >= DS_READY) {
+ if (i_ddi_devi_attached(ct->ct_dip)) {
ct->ct_power_cnt -= decr;
MDI_DEBUG(4, (CE_NOTE, ct->ct_dip, "i_mdi_pm_rele_client "
"ct_power_cnt = %d decr = %d\n", ct->ct_power_cnt, decr));
@@ -5963,7 +5961,7 @@ i_mdi_pm_pre_unconfig_one(dev_info_t *child, int *held, int flags)
while (MDI_CLIENT_IS_POWER_TRANSITION(ct))
cv_wait(&ct->ct_powerchange_cv, &ct->ct_mutex);
- if (i_ddi_node_state(ct->ct_dip) < DS_READY) {
+ if (!i_ddi_devi_attached(ct->ct_dip)) {
MDI_DEBUG(4, (CE_NOTE, child,
"i_mdi_pm_pre_unconfig node detached already\n"));
MDI_CLIENT_UNLOCK(ct);
@@ -6064,7 +6062,7 @@ i_mdi_pm_post_config_one(dev_info_t *child)
/* another thread might have powered it down or detached it */
if ((MDI_CLIENT_IS_POWERED_DOWN(ct) &&
!DEVI_IS_ATTACHING(ct->ct_dip)) ||
- (i_ddi_node_state(ct->ct_dip) < DS_READY &&
+ (!i_ddi_devi_attached(ct->ct_dip) &&
!DEVI_IS_ATTACHING(ct->ct_dip))) {
MDI_DEBUG(4, (CE_NOTE, child,
"i_mdi_pm_post_config i_mdi_pm_reset_client\n"));
@@ -6137,8 +6135,8 @@ i_mdi_pm_post_unconfig_one(dev_info_t *child)
/* failure detaching or another thread just attached it */
if ((MDI_CLIENT_IS_POWERED_DOWN(ct) &&
- i_ddi_node_state(ct->ct_dip) == DS_READY) ||
- (i_ddi_node_state(ct->ct_dip) != DS_READY &&
+ i_ddi_devi_attached(ct->ct_dip)) ||
+ (!i_ddi_devi_attached(ct->ct_dip) &&
!DEVI_IS_ATTACHING(ct->ct_dip))) {
MDI_DEBUG(4, (CE_NOTE, child,
"i_mdi_pm_post_unconfig i_mdi_pm_reset_client\n"));
diff --git a/usr/src/uts/common/os/sunndi.c b/usr/src/uts/common/os/sunndi.c
index 4def654094..1e3cac22e8 100644
--- a/usr/src/uts/common/os/sunndi.c
+++ b/usr/src/uts/common/os/sunndi.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -476,7 +476,7 @@ ndi_devctl_device_online(dev_info_t *dip, struct devctl_iocdata *dcp,
* Invalidate devfs cached directory contents. For the checks
* in the "if" condition see the comment in ndi_devi_online().
*/
- if (i_ddi_node_state(dip) == DS_READY && !DEVI_BUSY_OWNED(dip))
+ if (i_ddi_devi_attached(dip) && !DEVI_BUSY_OWNED(dip))
(void) devfs_clean(dip, NULL, 0);
} else if (rval == NDI_BUSY) {
diff --git a/usr/src/uts/common/os/sunpm.c b/usr/src/uts/common/os/sunpm.c
index 219edaa243..cd77e635d6 100644
--- a/usr/src/uts/common/os/sunpm.c
+++ b/usr/src/uts/common/os/sunpm.c
@@ -1697,7 +1697,7 @@ find_dip(dev_info_t *dip, char *dev_name, int holddip)
for (; dip != NULL; dip = ddi_get_next_sibling(dip)) {
if (strcmp(ddi_node_name(dip), device) == 0) {
/* If the driver isn't loaded, we prune the search */
- if (i_ddi_node_state(dip) < DS_READY) {
+ if (!i_ddi_devi_attached(dip)) {
continue;
}
if (strcmp(ddi_get_name_addr(dip), addr) == 0) {
diff --git a/usr/src/uts/common/pcmcia/nexus/pcmcia.c b/usr/src/uts/common/pcmcia/nexus/pcmcia.c
index 60f548560b..3449e11db5 100644
--- a/usr/src/uts/common/pcmcia/nexus/pcmcia.c
+++ b/usr/src/uts/common/pcmcia/nexus/pcmcia.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -4097,8 +4097,8 @@ pcmcia_dump_minors(dev_info_t *dip)
np = (dev_info_t *)DEVI(np)->devi_next) {
char *cf2 = "";
char *cur = "";
- if (i_ddi_node_state(np) == DS_READY)
- cf2 = "DS_READY";
+ if (i_ddi_devi_attached(np))
+ cf2 = "ATTACHED";
if (np == dip)
cur = "CUR";
cmn_err(CE_CONT, "\tsibs: %s %s %s\n",
diff --git a/usr/src/uts/common/rpc/rpcib.c b/usr/src/uts/common/rpc/rpcib.c
index 8c20e57203..a6c7440f8e 100644
--- a/usr/src/uts/common/rpc/rpcib.c
+++ b/usr/src/uts/common/rpc/rpcib.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -4498,7 +4498,7 @@ rib_get_ibd_insts_cb(dev_info_t *dip, void *arg)
ib_guid_t hca_guid;
ib_gid_t port_gid;
- if ((i_ddi_node_state(dip) >= DS_ATTACHED) &&
+ if (i_ddi_devi_attached(dip) &&
(strcmp(ddi_node_name(dip), "ibport") == 0) &&
(strstr(ddi_get_name_addr(dip), "ipib") != NULL)) {
diff --git a/usr/src/uts/common/sys/ddi_implfuncs.h b/usr/src/uts/common/sys/ddi_implfuncs.h
index 86f2d6a1c5..8ece7a52f5 100644
--- a/usr/src/uts/common/sys/ddi_implfuncs.h
+++ b/usr/src/uts/common/sys/ddi_implfuncs.h
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -201,17 +201,6 @@ extern int
i_ddi_minorname_to_devtspectype(dev_info_t *dip, char *minor_name,
dev_t *devp, int *spectypep);
-
-/*
- * Helper functions
- */
-char *i_ddi_strdup(char *, uint_t);
-void i_ddi_prop_list_delete(ddi_prop_t *);
-ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t);
-int i_ddi_load_drvconf(major_t);
-int i_ddi_unload_drvconf(major_t);
-ddi_node_state_t i_ddi_node_state(dev_info_t *);
-
/*
* Routines in ddi_v9_asm.s
*/
@@ -219,21 +208,24 @@ extern int do_peek(size_t, void *, void *);
extern int do_poke(size_t, void *, void *);
extern void peek_fault(void);
extern void poke_fault(void);
-
extern int peekpoke_mem(ddi_ctl_enum_t, peekpoke_ctlops_t *);
+/*
+ * Helper functions
+ */
char *i_ddi_strdup(char *, uint_t);
-void i_ddi_parse_name(char *, char **, char **, char **);
+void i_ddi_prop_list_delete(ddi_prop_t *);
+ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t);
+int i_ddi_load_drvconf(major_t);
+int i_ddi_unload_drvconf(major_t);
ddi_node_state_t i_ddi_node_state(dev_info_t *);
+int i_ddi_devi_attached(dev_info_t *);
+void i_ddi_parse_name(char *, char **, char **, char **);
void i_ddi_set_node_state(dev_info_t *, ddi_node_state_t);
int i_ddi_detach_installed_driver(major_t, int);
-int i_ddi_load_drvconf(major_t);
-int i_ddi_unload_drvconf(major_t);
void i_ddi_set_binding_name(dev_info_t *, char *);
void i_ddi_bind_devs();
void i_ddi_unbind_devs(major_t);
-ddi_prop_t *i_ddi_prop_list_dup(ddi_prop_t *, uint_t);
-void i_ddi_prop_list_delete(ddi_prop_t *);
ddi_prop_list_t *i_ddi_prop_list_create(ddi_prop_t *);
struct devnames;
void i_ddi_prop_list_hold(ddi_prop_list_t *, struct devnames *);
diff --git a/usr/src/uts/common/sys/dditypes.h b/usr/src/uts/common/sys/dditypes.h
index 98850cf9c0..c9272af1bf 100644
--- a/usr/src/uts/common/sys/dditypes.h
+++ b/usr/src/uts/common/sys/dditypes.h
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -184,7 +184,12 @@ typedef enum {
} ddi_devmap_cmd_t;
/*
- * Definitions for node state
+ * Definitions for node state.
+ *
+ * NOTE: DS_ATTACHED and DS_READY should only be used by the devcfg.c state
+ * model code itself, other code should use i_ddi_devi_attached() to avoid
+ * logic errors associated with transient DS_READY->DS_ATTACHED->DS_READY
+ * state changes while the node is attached.
*/
typedef enum {
DS_INVAL = -1,
@@ -193,8 +198,8 @@ typedef enum {
DS_BOUND, /* in per-driver list */
DS_INITIALIZED, /* bus address assigned */
DS_PROBED, /* device known to exist */
- DS_ATTACHED, /* driver attached */
- DS_READY /* post attach complete */
+ DS_ATTACHED, /* don't use, see NOTE above: driver attached */
+ DS_READY /* don't use, see NOTE above: post attach complete */
} ddi_node_state_t;
/*
diff --git a/usr/src/uts/sun4u/io/pci/db21554.c b/usr/src/uts/sun4u/io/pci/db21554.c
index 9e6a6d76f1..9574d2bdc2 100644
--- a/usr/src/uts/sun4u/io/pci/db21554.c
+++ b/usr/src/uts/sun4u/io/pci/db21554.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -2448,7 +2448,7 @@ db_save_config_regs(db_ctrl_t *dbp)
for (i = 0, dip = ddi_get_child(dbp->dip); dip != NULL;
dip = ddi_get_next_sibling(dip)) {
- if (i_ddi_node_state(dip) >= DS_ATTACHED)
+ if (i_ddi_devi_attached(dip))
i++;
}
dbp->config_state_index = i;
@@ -2476,7 +2476,7 @@ db_save_config_regs(db_ctrl_t *dbp)
dip != NULL;
dip = ddi_get_next_sibling(dip)) {
- if (i_ddi_node_state(dip) < DS_ATTACHED)
+ if (!i_ddi_devi_attached(dip))
continue;
if (pci_config_setup(dip, &config_handle) != DDI_SUCCESS) {
diff --git a/usr/src/uts/sun4u/io/pci/simba.c b/usr/src/uts/sun4u/io/pci/simba.c
index 8bf59520dd..896568309f 100644
--- a/usr/src/uts/sun4u/io/pci/simba.c
+++ b/usr/src/uts/sun4u/io/pci/simba.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -896,7 +896,7 @@ simba_save_config_regs(simba_devstate_t *simba_p)
for (i = 0, dip = ddi_get_child(simba_p->dip); dip != NULL;
dip = ddi_get_next_sibling(dip)) {
- if (i_ddi_node_state(dip) >= DS_ATTACHED)
+ if (i_ddi_devi_attached(dip))
i++;
}
if (!i)
@@ -914,7 +914,7 @@ simba_save_config_regs(simba_devstate_t *simba_p)
dip != NULL;
dip = ddi_get_next_sibling(dip)) {
- if (i_ddi_node_state(dip) < DS_ATTACHED) {
+ if (!i_ddi_devi_attached(dip)) {
DEBUG4(D_DETACH, "%s%d: skipping unattached %s%d\n",
ddi_driver_name(simba_p->dip),
ddi_get_instance(simba_p->dip),
diff --git a/usr/src/uts/sun4u/io/sbd.c b/usr/src/uts/sun4u/io/sbd.c
index 9f1cbc2f1a..8e41b8ea1f 100644
--- a/usr/src/uts/sun4u/io/sbd.c
+++ b/usr/src/uts/sun4u/io/sbd.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -4784,7 +4784,7 @@ sbd_board_discovery(sbd_board_t *sbp)
/*
* XXX Is the devstate check needed ?
*/
- if (i_ddi_node_state(dip) >= DS_ATTACHED ||
+ if (i_ddi_devi_attached(dip) ||
ddi_get_devstate(dip) == DDI_DEVSTATE_UP) {
/*
diff --git a/usr/src/uts/sun4u/io/sbd_io.c b/usr/src/uts/sun4u/io/sbd_io.c
index 06d34c2e7d..4f07908874 100644
--- a/usr/src/uts/sun4u/io/sbd_io.c
+++ b/usr/src/uts/sun4u/io/sbd_io.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -369,8 +369,7 @@ sbd_check_io_attached(dev_info_t *dip, void *arg)
int state;
state = ddi_get_devstate(dip);
- if (i_ddi_node_state(dip) >= DS_ATTACHED ||
- (state == DDI_DEVSTATE_UP)) {
+ if (i_ddi_devi_attached(dip) || (state == DDI_DEVSTATE_UP)) {
*tdip = NULL;
return (DDI_WALK_TERMINATE);
}
diff --git a/usr/src/uts/sun4u/ngdr/io/dr_quiesce.c b/usr/src/uts/sun4u/ngdr/io/dr_quiesce.c
index 4c5fd3f9e3..5fe1d75be6 100644
--- a/usr/src/uts/sun4u/ngdr/io/dr_quiesce.c
+++ b/usr/src/uts/sun4u/ngdr/io/dr_quiesce.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -294,8 +294,7 @@ dr_check_dip(dev_info_t *dip, void *arg, uint_t ref)
PR_QR("\n %s (major# %d) is referenced(%u)\n",
dname, major, ref);
}
- if (dr_is_unsafe_major(major) &&
- i_ddi_node_state(dip) >= DS_ATTACHED) {
+ if (dr_is_unsafe_major(major) && i_ddi_devi_attached(dip)) {
PR_QR("\n %s (major# %d) not hotpluggable\n",
dname, major);
if (rp->arr != NULL && rp->idx != NULL)
diff --git a/usr/src/uts/sun4u/os/mach_ddi_impl.c b/usr/src/uts/sun4u/os/mach_ddi_impl.c
index 05d18b5ca8..195d86520b 100644
--- a/usr/src/uts/sun4u/os/mach_ddi_impl.c
+++ b/usr/src/uts/sun4u/os/mach_ddi_impl.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -989,8 +989,8 @@ e_ddi_branch_unconfigure(
if (flags & DEVI_BRANCH_EVENT)
nflags |= NDI_POST_EVENT;
- if (i_ddi_node_state(pdip) == DS_READY &&
- i_ddi_node_state(rdip) >= DS_INITIALIZED) {
+ if (i_ddi_devi_attached(pdip) &&
+ (i_ddi_node_state(rdip) >= DS_INITIALIZED)) {
rv = ndi_devi_unconfig_one(pdip, devnm+1, dipp, nflags);
} else {
rv = e_ddi_devi_unconfig(rdip, dipp, nflags);
diff --git a/usr/src/uts/sun4u/starfire/io/drmach.c b/usr/src/uts/sun4u/starfire/io/drmach.c
index 55e76717ad..6a982ccee1 100644
--- a/usr/src/uts/sun4u/starfire/io/drmach.c
+++ b/usr/src/uts/sun4u/starfire/io/drmach.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -2911,8 +2911,7 @@ drmach_io_is_attached(drmachid_t id, int *yes)
}
state = ddi_get_devstate(dip);
- *yes = ((i_ddi_node_state(dip) >= DS_ATTACHED) ||
- (state == DDI_DEVSTATE_UP));
+ *yes = (i_ddi_devi_attached(dip) || (state == DDI_DEVSTATE_UP));
return (NULL);
}