Lines Matching defs:dip

332  *	the dip from all contracts associated with the contract being freed,
349 * and devi_ct_count that controls state changes to a dip
364 static void ct_barrier_acquire(dev_info_t *dip);
365 static void ct_barrier_release(dev_info_t *dip);
366 static int ct_barrier_held(dev_info_t *dip);
367 static int ct_barrier_empty(dev_info_t *dip);
368 static void ct_barrier_wait_for_release(dev_info_t *dip);
369 static int ct_barrier_wait_for_empty(dev_info_t *dip, int secs);
370 static void ct_barrier_decr(dev_info_t *dip);
371 static void ct_barrier_incr(dev_info_t *dip);
504 dev_info_t *dip;
558 dip = NULL;
559 if (resolve_pathname(str_value, &dip, NULL, &spec_type) != 0) {
562 ddi_release_devi(dip);
807 dev_info_t *dip;
813 dip = ctd->cond_dip;
814 if (dip == NULL) {
816 * The dip has been removed, this is a dangling contract
817 * Check that dip linkages are NULL
831 * contract_device_remove_dip() which may free off dip before
835 if (mutex_tryenter(&(DEVI(dip)->devi_ct_lock)) != 0)
849 ct_barrier_wait_for_release(dip);
852 list_remove(&(DEVI(dip)->devi_ct), ctd);
853 ctd->cond_dip = NULL; /* no longer linked to dip */
854 contract_rele(ct); /* remove hold for dip linkage */
857 mutex_exit(&(DEVI(dip)->devi_ct_lock));
973 contract_device_dvclean(dev_info_t *dip)
978 ASSERT(dip);
980 /* pdip can be NULL if we have contracts against the root dip */
981 pdip = ddi_get_parent(dip);
983 if (pdip && DEVI_BUSY_OWNED(pdip) || !pdip && DEVI_BUSY_OWNED(dip)) {
987 (void) ddi_pathname(dip, path);
996 (void) ddi_deviname(dip, devnm);
1000 (void) devfs_clean(dip, NULL, DV_CLEAN_FORCE);
1008 * Results in the ACK or NACK being recorded on the dip for one particular
1018 dev_info_t *dip;
1029 dip = ctd->cond_dip;
1049 if (dip)
1050 ndi_hold_devi(dip);
1057 if (cmd != CT_NACK && evtype == CT_DEV_EV_OFFLINE && dip) {
1059 error = contract_device_dvclean(dip);
1063 ddi_release_devi(dip);
1069 if (dip)
1070 ddi_release_devi(dip);
1072 if (dip == NULL) {
1096 mutex_enter(&DEVI(dip)->devi_ct_lock);
1101 mutex_exit(&DEVI(dip)->devi_ct_lock);
1102 ndi_hold_devi(dip);
1104 (void) ddi_pathname(dip, buf);
1105 ddi_release_devi(dip);
1125 ct_barrier_decr(dip);
1126 mutex_exit(&DEVI(dip)->devi_ct_lock);
1204 dev_info_t *dip;
1220 dip = e_ddi_hold_devi_by_path(path, 0);
1221 if (dip == NULL) {
1232 mutex_enter(&(DEVI(dip)->devi_ct_lock));
1233 ct_barrier_acquire(dip);
1234 mutex_exit(&(DEVI(dip)->devi_ct_lock));
1249 * It is safe to set the dip pointer in the contract
1250 * as the contract will always be destroyed before the dip
1253 ctd->cond_dip = dip;
1261 ctd->cond_state = DEVI_IS_DEVICE_DEGRADED(dip) ?
1285 mutex_enter(&(DEVI(dip)->devi_ct_lock));
1286 ct_barrier_release(dip);
1287 mutex_exit(&(DEVI(dip)->devi_ct_lock));
1289 ddi_release_devi(dip);
1303 * Insert device contract into list hanging off the dip
1307 mutex_enter(&(DEVI(dip)->devi_ct_lock));
1308 list_insert_tail(&(DEVI(dip)->devi_ct), ctd);
1311 ct_barrier_release(dip);
1312 mutex_exit(&(DEVI(dip)->devi_ct_lock));
1314 ddi_release_devi(dip);
1417 wait_for_acks(dev_info_t *dip, dev_t dev, int spec_type, uint_t evtype)
1425 ASSERT(MUTEX_HELD(&(DEVI(dip)->devi_ct_lock)));
1426 ASSERT(dip);
1432 CT_DEBUG((CE_NOTE, "%s: entered: dip: %p", f, (void *)dip));
1434 if (ct_barrier_wait_for_empty(dip, CT_DEV_ACKTIME) == -1) {
1438 CT_DEBUG((CE_NOTE, "%s: timed out: %p", f, (void *)dip));
1443 for (ctd = list_head(&(DEVI(dip)->devi_ct)); ctd != NULL;
1444 ctd = list_next(&(DEVI(dip)->devi_ct), ctd)) {
1448 ASSERT(ctd->cond_dip == dip);
1468 f, (void *)dip));
1474 f, (void *)dip));
1481 CT_DEBUG((CE_NOTE, "%s: result = ACK, dip=%p", f, (void *)dip));
1484 CT_DEBUG((CE_NOTE, "%s: result = NONE (timed-out), dip=%p",
1485 f, (void *)dip));
1487 CT_DEBUG((CE_NOTE, "%s: result = NONE, dip=%p",
1488 f, (void *)dip));
1499 get_state(dev_info_t *dip)
1501 if (DEVI_IS_DEVICE_OFFLINE(dip) || DEVI_IS_DEVICE_DOWN(dip))
1503 else if (DEVI_IS_DEVICE_DEGRADED(dip))
1513 set_cond_state(dev_info_t *dip)
1515 uint_t state = get_state(dip);
1519 ASSERT(ct_barrier_held(dip));
1521 for (ctd = list_head(&(DEVI(dip)->devi_ct)); ctd != NULL;
1522 ctd = list_next(&(DEVI(dip)->devi_ct), ctd)) {
1524 ASSERT(ctd->cond_dip == dip);
1539 * dip, evaluates the following cases
1542 * - bumps up the outstanding negotiation counts on the dip
1543 * - marks the dip as undergoing negotiation (devi_ct_neg)
1582 contract_device_publish(dev_info_t *dip, dev_t dev, int spec_type,
1598 ASSERT(dip);
1606 sync = is_sync_neg(get_state(dip), evtype);
1609 DEVI(dip)->devi_flags |= DEVI_CT_NOP;
1615 } else if (DEVI(dip)->devi_flags & DEVI_CT_NOP) {
1616 DEVI(dip)->devi_flags &= ~DEVI_CT_NOP;
1622 (void) ddi_pathname(dip, path);
1624 mutex_enter(&(DEVI(dip)->devi_ct_lock));
1631 set_cond_state(dip);
1640 if (evtype == CT_EV_NEGEND && !DEVI(dip)->devi_ct_neg) {
1642 ct_barrier_release(dip);
1643 mutex_exit(&(DEVI(dip)->devi_ct_lock));
1651 ASSERT(ct_barrier_held(dip));
1659 ct_barrier_acquire(dip);
1664 for (ctd = list_head(&(DEVI(dip)->devi_ct)); ctd != NULL;
1665 ctd = list_next(&(DEVI(dip)->devi_ct), ctd)) {
1672 ASSERT(ctd->cond_dip == dip);
1756 ct_barrier_incr(dip);
1757 DEVI(dip)->devi_ct_neg = 1; /* waiting for negend */
1834 * by holding the dip's devi_ct_lock we ensure that
1860 * on dip.
1870 ct_barrier_release(dip);
1871 DEVI(dip)->devi_ct_neg = 0;
1872 CT_DEBUG((CE_NOTE, "publish: negend: reset dip state: dip=%p",
1873 (void *)dip));
1874 } else if (DEVI(dip)->devi_ct_neg) {
1876 ASSERT(!ct_barrier_empty(dip));
1877 CT_DEBUG((CE_NOTE, "publish: sync count=%d, dip=%p",
1878 DEVI(dip)->devi_ct_count, (void *)dip));
1884 ASSERT(ct_barrier_empty(dip));
1885 ASSERT(DEVI(dip)->devi_ct_neg == 0);
1887 "dip=%p", (void *)dip));
1905 (void) wait_for_acks(dip, dev, spec_type, evtype);
1906 } else if (DEVI(dip)->devi_ct_neg) {
1909 result = wait_for_acks(dip, dev, spec_type, evtype);
1922 mutex_exit(&(DEVI(dip)->devi_ct_lock));
1941 contract_device_offline(dev_info_t *dip, dev_t dev, int spec_type)
1950 result = contract_device_publish(dip, dev, spec_type, evtype, nvl);
1957 contract_device_negend(dip, dev, spec_type, CT_EV_FAILURE);
1971 contract_device_degrade(dev_info_t *dip, dev_t dev, int spec_type)
1979 (void) contract_device_publish(dip, dev, spec_type, evtype, nvl);
1990 contract_device_undegrade(dev_info_t *dip, dev_t dev, int spec_type)
1998 (void) contract_device_publish(dip, dev, spec_type, evtype, nvl);
2010 contract_device_negend(dev_info_t *dip, dev_t dev, int spec_type, int result)
2018 "dip: %p", result, (void *)dip));
2025 (void) contract_device_publish(dip, dev, spec_type, evtype, nvl);
2027 CT_DEBUG((CE_NOTE, "contract_device_negend(): exit dip: %p",
2028 (void *)dip));
2037 contract_device_negotiate(dev_info_t *dip, dev_t dev, int spec_type,
2042 ASSERT(dip);
2050 result = contract_device_offline(dip, dev, spec_type);
2055 "dip (%p)", evtype, dev, spec_type, (void *)dip);
2070 contract_device_finalize(dev_info_t *dip, dev_t dev, int spec_type,
2073 ASSERT(dip);
2081 contract_device_negend(dip, dev, spec_type, ct_result);
2084 contract_device_degrade(dip, dev, spec_type);
2085 contract_device_negend(dip, dev, spec_type, ct_result);
2088 contract_device_undegrade(dip, dev, spec_type);
2089 contract_device_negend(dip, dev, spec_type, ct_result);
2093 "event (%d) for dev_t (%lu) and spec (%d), dip (%p)",
2094 evtype, dev, spec_type, (void *)dip);
2104 contract_device_remove_dip(dev_info_t *dip)
2110 mutex_enter(&(DEVI(dip)->devi_ct_lock));
2111 ct_barrier_wait_for_release(dip);
2113 for (ctd = list_head(&(DEVI(dip)->devi_ct)); ctd != NULL; ctd = next) {
2114 next = list_next(&(DEVI(dip)->devi_ct), ctd);
2115 list_remove(&(DEVI(dip)->devi_ct), ctd);
2118 * Unlink the dip associated with this contract
2121 ASSERT(ctd->cond_dip == dip);
2122 ctd->cond_dip = NULL; /* no longer linked to dip */
2123 contract_rele(ct); /* remove hold for dip linkage */
2124 CT_DEBUG((CE_NOTE, "ct: remove_dip: removed dip from contract: "
2128 ASSERT(list_is_empty(&(DEVI(dip)->devi_ct)));
2129 mutex_exit(&(DEVI(dip)->devi_ct_lock));
2136 ct_barrier_acquire(dev_info_t *dip)
2138 ASSERT(MUTEX_HELD(&(DEVI(dip)->devi_ct_lock)));
2140 while (DEVI(dip)->devi_ct_count != -1)
2141 cv_wait(&(DEVI(dip)->devi_ct_cv), &(DEVI(dip)->devi_ct_lock));
2142 DEVI(dip)->devi_ct_count = 0;
2147 ct_barrier_release(dev_info_t *dip)
2149 ASSERT(MUTEX_HELD(&(DEVI(dip)->devi_ct_lock)));
2150 ASSERT(DEVI(dip)->devi_ct_count != -1);
2151 DEVI(dip)->devi_ct_count = -1;
2152 cv_broadcast(&(DEVI(dip)->devi_ct_cv));
2157 ct_barrier_held(dev_info_t *dip)
2159 ASSERT(MUTEX_HELD(&(DEVI(dip)->devi_ct_lock)));
2160 return (DEVI(dip)->devi_ct_count != -1);
2164 ct_barrier_empty(dev_info_t *dip)
2166 ASSERT(MUTEX_HELD(&(DEVI(dip)->devi_ct_lock)));
2167 ASSERT(DEVI(dip)->devi_ct_count != -1);
2168 return (DEVI(dip)->devi_ct_count == 0);
2172 ct_barrier_wait_for_release(dev_info_t *dip)
2174 ASSERT(MUTEX_HELD(&(DEVI(dip)->devi_ct_lock)));
2175 while (DEVI(dip)->devi_ct_count != -1)
2176 cv_wait(&(DEVI(dip)->devi_ct_cv), &(DEVI(dip)->devi_ct_lock));
2180 ct_barrier_decr(dev_info_t *dip)
2183 DEVI(dip)->devi_ct_count));
2185 ASSERT(MUTEX_HELD(&(DEVI(dip)->devi_ct_lock)));
2186 ASSERT(DEVI(dip)->devi_ct_count > 0);
2188 DEVI(dip)->devi_ct_count--;
2189 if (DEVI(dip)->devi_ct_count == 0) {
2190 cv_broadcast(&DEVI(dip)->devi_ct_cv);
2196 ct_barrier_incr(dev_info_t *dip)
2198 ASSERT(ct_barrier_held(dip));
2199 DEVI(dip)->devi_ct_count++;
2203 ct_barrier_wait_for_empty(dev_info_t *dip, int secs)
2207 ASSERT(MUTEX_HELD(&(DEVI(dip)->devi_ct_lock)));
2210 while (DEVI(dip)->devi_ct_count) {
2211 if (cv_timedwait(&(DEVI(dip)->devi_ct_cv),
2212 &(DEVI(dip)->devi_ct_lock), abstime) == -1) {