Lines Matching refs:lp
306 struct seglock *lp; /* associated lock context */ member
334 #define LOCK(lp) (*((lp)->lockptr)) argument
405 #define seglock_findclient(lp) seglock_find_specific((lp), CURPROC_ID) argument
406 #define seglock_allocclient(lp) seglock_alloc_specific((lp), CURPROC_ID) argument
587 SegLock *lp; in winlock_devmap() local
597 if ((lp = seglock_findlock((uint_t)off)) == NULL) { in winlock_devmap()
606 ((off ^ (uintptr_t)(lp->lockptr)) & (offset_t)PAGEOFFSET) != 0) { in winlock_devmap()
609 off, (void *)lp->lockptr)); in winlock_devmap()
610 mutex_exit(&lp->mutex); /* mutex held by seglock_findlock */ in winlock_devmap()
616 mutex_exit(&lp->mutex); /* mutex held by seglock_findlock */ in winlock_devmap()
634 lp->umem_cookie, 0, PAGESIZE, WINLOCK_PROT, in winlock_devmap()
636 mutex_exit(&lp->mutex); /* held by seglock_findlock */ in winlock_devmap()
645 mutex_exit(&lp->mutex); /* mutex held by seglock_findlock */ in winlock_devmap()
660 SegLock *lp = seglock_findlock((uint_t)off); /* returns w/ mutex held */ in winlockmap_map() local
666 sdp = seglock_allocclient(lp); in winlockmap_map()
678 mutex_exit(&lp->mutex); /* mutex held by seglock_findlock */ in winlockmap_map()
683 mutex_exit(&lp->mutex); /* mutex held by seglock_findlock */ in winlockmap_map()
708 SegLock *lp = sdp->lp; in winlockmap_dup() local
710 mutex_enter(&lp->mutex); in winlockmap_dup()
723 ndp = seglock_alloc_specific(lp, in winlockmap_dup()
738 mutex_exit(&lp->mutex); in winlockmap_dup()
751 SegLock *lp = sdp->lp; in winlockmap_unmap() local
759 mutex_enter(&lp->mutex); in winlockmap_unmap()
762 if (sdp == lp->owner) { in winlockmap_unmap()
767 (void) lock_giveup(lp, 0); in winlockmap_unmap()
770 ASSERT(sdp != lp->owner); in winlockmap_unmap()
779 garbage_collect_lock(lp, sdp); in winlockmap_unmap()
788 SegLock *lp = sdp->lp; in winlockmap_access() local
795 mutex_enter(&lp->mutex); in winlockmap_access()
809 err = seglock_lockfault(dhp, sdp, lp, rw); in winlockmap_access()
811 mutex_exit(&lp->mutex); in winlockmap_access()
833 SegLock *lp; in seglock_findlock() local
837 for (lp = lock_list; lp != NULL; lp = lp->next) { in seglock_findlock()
838 mutex_enter(&lp->mutex); in seglock_findlock()
839 if (cookie == lp->cookie) { in seglock_findlock()
842 mutex_exit(&lp->mutex); in seglock_findlock()
845 return (lp); in seglock_findlock()
855 SegLock *lp; in seglock_findkey() local
861 for (lp = lock_list; lp != NULL; lp = lp->next) { in seglock_findkey()
862 mutex_enter(&lp->mutex); in seglock_findkey()
863 if (key == lp->key) in seglock_findkey()
865 mutex_exit(&lp->mutex); in seglock_findkey()
867 return (lp); in seglock_findkey()
878 SegLock *lp; in seglock_createlock() local
885 lp = lock_free_list; in seglock_createlock()
886 lock_free_list = lp->next; in seglock_createlock()
890 lp = kmem_zalloc(sizeof (SegLock), KM_SLEEP); in seglock_createlock()
891 lp->cookie = (next_lock + 1) * (uint_t)PAGESIZE; in seglock_createlock()
892 mutex_init(&lp->mutex, NULL, MUTEX_DEFAULT, NULL); in seglock_createlock()
893 cv_init(&lp->locksleep, NULL, CV_DEFAULT, NULL); in seglock_createlock()
897 mutex_enter(&lp->mutex); in seglock_createlock()
898 ASSERT((lp->cookie/PAGESIZE) <= next_lock); in seglock_createlock()
901 lp->lockptr = (int *)ddi_umem_alloc(PAGESIZE, in seglock_createlock()
902 DDI_UMEM_SLEEP, &(lp->umem_cookie)); in seglock_createlock()
904 lp->lockptr = ((int *)lockpage) + ((lp->cookie/PAGESIZE) - 1); in seglock_createlock()
905 lp->umem_cookie = lockpage_cookie; in seglock_createlock()
908 ASSERT(lp->lockptr != NULL); in seglock_createlock()
909 lp->style = style; in seglock_createlock()
910 lp->sleepers = 0; in seglock_createlock()
911 lp->alloccount = 1; in seglock_createlock()
912 lp->timeout = LOCKTIME*hz; in seglock_createlock()
913 lp->clients = NULL; in seglock_createlock()
914 lp->owner = NULL; in seglock_createlock()
915 LOCK(lp) = 0; in seglock_createlock()
916 lp->next = lock_list; in seglock_createlock()
917 lock_list = lp; in seglock_createlock()
918 return (lp); in seglock_createlock()
928 seglock_destroylock(SegLock *lp) in seglock_destroylock() argument
930 ASSERT(MUTEX_HELD(&lp->mutex)); in seglock_destroylock()
934 lp->cookie, lp->key)); in seglock_destroylock()
936 ASSERT(lp->alloccount == 0); in seglock_destroylock()
937 ASSERT(lp->clients == NULL); in seglock_destroylock()
938 ASSERT(lp->owner == NULL); in seglock_destroylock()
939 ASSERT(lp->sleepers == 0); in seglock_destroylock()
942 if (lp->style == OLDSTYLE_LOCK) { in seglock_destroylock()
943 ddi_umem_free(lp->umem_cookie); in seglock_destroylock()
945 lp->umem_cookie = NULL; in seglock_destroylock()
946 lp->lockptr = NULL; in seglock_destroylock()
947 lp->key = 0; in seglock_destroylock()
955 lp->cookie--; in seglock_destroylock()
958 mutex_exit(&lp->mutex); in seglock_destroylock()
960 mutex_enter(&lp->mutex); in seglock_destroylock()
963 lp->cookie++; in seglock_destroylock()
964 ASSERT((lp->cookie & PAGEOFFSET) == 0); in seglock_destroylock()
965 ASSERT(lp->alloccount == 0); in seglock_destroylock()
966 ASSERT(lp->clients == NULL); in seglock_destroylock()
967 ASSERT(lp->owner == NULL); in seglock_destroylock()
968 ASSERT(lp->sleepers == 0); in seglock_destroylock()
971 if (lock_list == lp) { in seglock_destroylock()
972 lock_list = lp->next; in seglock_destroylock()
975 while (tmp->next != lp) { in seglock_destroylock()
979 tmp->next = lp->next; in seglock_destroylock()
983 lp->next = lock_free_list; in seglock_destroylock()
984 lock_free_list = lp; in seglock_destroylock()
985 mutex_exit(&lp->mutex); in seglock_destroylock()
998 seglock_find_specific(SegLock *lp, void *tag) in seglock_find_specific() argument
1002 ASSERT(MUTEX_HELD(&lp->mutex)); in seglock_find_specific()
1004 for (sdp = lp->clients; sdp != NULL; sdp = sdp->next) { in seglock_find_specific()
1014 seglock_alloc_specific(SegLock *lp, void *tag) in seglock_alloc_specific() argument
1018 ASSERT(MUTEX_HELD(&lp->mutex)); in seglock_alloc_specific()
1022 sdp = seglock_find_specific(lp, tag); in seglock_alloc_specific()
1027 tag, lp->cookie)); in seglock_alloc_specific()
1031 sdp->next = lp->clients; in seglock_alloc_specific()
1032 lp->clients = sdp; in seglock_alloc_specific()
1033 sdp->lp = lp; in seglock_alloc_specific()
1043 seglock_deleteclient(SegLock *lp, SegProc *sdp) in seglock_deleteclient() argument
1045 ASSERT(MUTEX_HELD(&lp->mutex)); in seglock_deleteclient()
1046 ASSERT(lp->owner != sdp); /* Not current owner of lock */ in seglock_deleteclient()
1051 ddi_get_pid(), lp->cookie)); in seglock_deleteclient()
1052 if (lp->clients == sdp) { in seglock_deleteclient()
1053 lp->clients = sdp->next; in seglock_deleteclient()
1055 SegProc *tmp = lp->clients; in seglock_deleteclient()
1074 garbage_collect_lock(SegLock *lp, SegProc *sdp) in garbage_collect_lock() argument
1076 ASSERT(MUTEX_HELD(&lp->mutex)); in garbage_collect_lock()
1079 seglock_deleteclient(lp, sdp); in garbage_collect_lock()
1082 if ((lp->clients == NULL) && (lp->alloccount == 0)) { in garbage_collect_lock()
1083 seglock_destroylock(lp); in garbage_collect_lock()
1085 mutex_exit(&lp->mutex); in garbage_collect_lock()
1106 struct seglock *lp; in seglock_graballoc() local
1137 if ((lp = seglock_findkey(key)) != NULL) { in seglock_graballoc()
1139 key, lp->cookie)); in seglock_graballoc()
1140 ++lp->alloccount; in seglock_graballoc()
1141 } else if ((lp = seglock_createlock(style)) != NULL) { in seglock_graballoc()
1143 key, lp->cookie)); in seglock_graballoc()
1144 lp->key = key; in seglock_graballoc()
1150 ASSERT((lp != NULL) && MUTEX_HELD(&lp->mutex)); in seglock_graballoc()
1155 err = ddi_copyout((caddr_t)&lp->cookie, (caddr_t)arg, in seglock_graballoc()
1156 sizeof (lp->cookie), mode); in seglock_graballoc()
1158 wla.sy_ident = lp->cookie + in seglock_graballoc()
1159 (uint_t)((uintptr_t)(lp->lockptr) & PAGEOFFSET); in seglock_graballoc()
1166 lp->alloccount--; in seglock_graballoc()
1169 garbage_collect_lock(lp, NULL); in seglock_graballoc()
1173 mutex_exit(&lp->mutex); in seglock_graballoc()
1180 struct seglock *lp; in seglock_grabfree() local
1189 if ((lp = seglock_findlock(offset)) == NULL) { in seglock_grabfree()
1194 lp->key, lp->cookie, lp->alloccount)); in seglock_grabfree()
1196 if (lp->alloccount > 0) in seglock_grabfree()
1197 lp->alloccount--; in seglock_grabfree()
1200 garbage_collect_lock(lp, NULL); in seglock_grabfree()
1216 SegLock *lp; in seglock_settimeout() local
1224 if ((lp = seglock_findlock(wlt.sy_ident)) == NULL) in seglock_settimeout()
1227 lp->timeout = MSEC_TO_TICK_ROUNDUP(wlt.sy_timeout); in seglock_settimeout()
1229 if (lp->sleepers > 0) { in seglock_settimeout()
1230 cv_broadcast(&lp->locksleep); in seglock_settimeout()
1241 sdp = seglock_allocclient(lp); in seglock_settimeout()
1243 } else if ((sdp = seglock_findclient(lp)) != NULL) { in seglock_settimeout()
1246 garbage_collect_lock(lp, sdp); in seglock_settimeout()
1249 mutex_exit(&lp->mutex); /* mutex held by seglock_findlock */ in seglock_settimeout()
1256 SegLock *lp; in seglock_gettimeout() local
1263 if ((lp = seglock_findlock(wlt.sy_ident)) == NULL) in seglock_gettimeout()
1266 wlt.sy_timeout = TICK_TO_MSEC(lp->timeout); in seglock_gettimeout()
1272 if ((sdp = seglock_findclient(lp)) != NULL) { in seglock_gettimeout()
1277 mutex_exit(&lp->mutex); /* mutex held by seglock_findlock */ in seglock_gettimeout()
1293 seglock_lockfault(devmap_cookie_t dhp, SegProc *sdp, SegLock *lp, uint_t rw) in seglock_lockfault() argument
1295 SegProc *owner = lp->owner; in seglock_lockfault()
1298 ASSERT(MUTEX_HELD(&lp->mutex)); in seglock_lockfault()
1301 (void *)dhp, (void *)sdp, (void *)lp, (void *)owner)); in seglock_lockfault()
1309 return (give_mapping(lp, sdp, rw)); in seglock_lockfault()
1318 if ((sdp->lockseg == dhp) || (lp->sleepers == 0)) { in seglock_lockfault()
1320 return (give_mapping(lp, sdp, rw)); in seglock_lockfault()
1329 ASSERT((dhp == sdp->unlockseg) && (lp->sleepers != 0)); in seglock_lockfault()
1331 return (lock_giveup(lp, 1)); in seglock_lockfault()
1346 return (devmap_load(sdp->unlockseg, lp->cookie, PAGESIZE, in seglock_lockfault()
1360 err = devmap_unload(owner->lockseg, lp->cookie, PAGESIZE); in seglock_lockfault()
1361 err |= devmap_unload(owner->unlockseg, lp->cookie, PAGESIZE); in seglock_lockfault()
1369 if (LOCK(lp) == 0) { in seglock_lockfault()
1372 (void *)lp, ddi_get_pid())); in seglock_lockfault()
1373 return (give_mapping(lp, sdp, rw)); in seglock_lockfault()
1384 lp->sleepers++; in seglock_lockfault()
1385 while ((owner = lp->owner) != NULL) { in seglock_lockfault()
1388 if ((lp->timeout == 0) || (owner->flag & SY_NOTIMEOUT)) { in seglock_lockfault()
1393 rval = cv_wait_sig(&lp->locksleep, &lp->mutex); in seglock_lockfault()
1405 rval = cv_reltimedwait_sig(&lp->locksleep, in seglock_lockfault()
1406 &lp->mutex, lp->timeout, TR_CLOCK_TICK); in seglock_lockfault()
1413 if ((rval == -1) && (lp->owner == owner)) { in seglock_lockfault()
1419 ddi_get_pid(), lp->cookie); in seglock_lockfault()
1420 (void) lock_giveup(lp, 1); in seglock_lockfault()
1424 ddi_get_pid(), lp->cookie); in seglock_lockfault()
1425 lp->sleepers--; in seglock_lockfault()
1430 lp->sleepers--; in seglock_lockfault()
1434 return (give_mapping(lp, sdp, rw)); in seglock_lockfault()
1443 give_mapping(SegLock *lp, SegProc *sdp, uint_t rw) in give_mapping() argument
1447 ASSERT(MUTEX_HELD(&lp->mutex)); in give_mapping()
1448 ASSERT(!((lp->owner == NULL) && (LOCK(lp) != 0))); in give_mapping()
1455 ASSERT(sdp != lp->owner); in give_mapping()
1461 lp->umem_cookie, 0, PAGESIZE, WINLOCK_PROT, 0, 0)) != 0) { in give_mapping()
1474 lp->owner = sdp; in give_mapping()
1476 if ((err = devmap_load(sdp->lockseg, lp->cookie, PAGESIZE, in give_mapping()
1482 if (lp->sleepers) { in give_mapping()
1486 lp->sleepers)); in give_mapping()
1487 err = devmap_unload(sdp->unlockseg, lp->cookie, PAGESIZE); in give_mapping()
1494 err = devmap_load(sdp->unlockseg, lp->cookie, PAGESIZE, in give_mapping()
1506 lock_giveup(SegLock *lp, int trash) in lock_giveup() argument
1508 SegProc *owner = lp->owner; in lock_giveup()
1511 (void *)lp, (void *)ID(lp->owner), trash)); in lock_giveup()
1513 ASSERT(MUTEX_HELD(&lp->mutex)); in lock_giveup()
1527 (void) devmap_unload(owner->lockseg, lp->cookie, PAGESIZE); in lock_giveup()
1528 (void) devmap_unload(owner->unlockseg, lp->cookie, PAGESIZE); in lock_giveup()
1532 if (err = devmap_unload(owner->lockseg, lp->cookie, PAGESIZE)) { in lock_giveup()
1557 (void) devmap_load(owner->unlockseg, lp->cookie, in lock_giveup()
1562 lp->owner = NULL; in lock_giveup()
1565 LOCK(lp) = 0; in lock_giveup()
1567 if (lp->sleepers) { in lock_giveup()
1568 DEBUGF(4, (CE_CONT, " waking up, lp=%p\n", (void *)lp)); in lock_giveup()
1569 cv_broadcast(&lp->locksleep); in lock_giveup()
1581 SegLock *lp, *lpnext; in lock_destroyall() local
1587 for (lp = lock_free_list; lp != NULL; lp = lpnext) { in lock_destroyall()
1588 mutex_enter(&lp->mutex); in lock_destroyall()
1589 lpnext = lp->next; in lock_destroyall()
1590 ASSERT(lp->clients == NULL); in lock_destroyall()
1591 ASSERT(lp->owner == NULL); in lock_destroyall()
1592 ASSERT(lp->alloccount == 0); in lock_destroyall()
1593 mutex_destroy(&lp->mutex); in lock_destroyall()
1594 cv_destroy(&lp->locksleep); in lock_destroyall()
1595 kmem_free(lp, sizeof (SegLock)); in lock_destroyall()
1606 SegLock *lp; in seglock_dump_all() local
1612 for (lp = lock_list; lp != NULL; lp = lp->next) { in seglock_dump_all()
1613 mutex_enter(&lp->mutex); in seglock_dump_all()
1615 lp->cookie, lp->key, lp->alloccount, in seglock_dump_all()
1616 lp->clients ? 'Y' : 'N', in seglock_dump_all()
1617 lp->owner ? 'Y' : 'N', in seglock_dump_all()
1618 lp->lockptr != 0 && LOCK(lp) ? 'Y' : 'N', in seglock_dump_all()
1619 lp->sleepers); in seglock_dump_all()
1620 mutex_exit(&lp->mutex); in seglock_dump_all()
1623 for (lp = lock_free_list; lp != NULL; lp = lp->next) { in seglock_dump_all()
1624 mutex_enter(&lp->mutex); in seglock_dump_all()
1626 lp->cookie, lp->key, lp->alloccount, in seglock_dump_all()
1627 lp->clients ? 'Y' : 'N', in seglock_dump_all()
1628 lp->owner ? 'Y' : 'N', in seglock_dump_all()
1629 lp->lockptr != 0 && LOCK(lp) ? 'Y' : 'N', in seglock_dump_all()
1630 lp->sleepers); in seglock_dump_all()
1631 mutex_exit(&lp->mutex); in seglock_dump_all()
1640 for (lp = lock_list; lp != NULL; lp = lp->next) { in seglock_dump_all()
1643 mutex_enter(&lp->mutex); in seglock_dump_all()
1646 (void *)lp, lp->key, lp->cookie, lp->alloccount, in seglock_dump_all()
1647 lp->lockptr != 0 ? LOCK(lp) : -1, lp->sleepers); in seglock_dump_all()
1651 lp->style, (void *)lp->lockptr, lp->timeout, in seglock_dump_all()
1652 (void *)lp->clients, (void *)lp->owner); in seglock_dump_all()
1655 for (sdp = lp->clients; sdp != NULL; sdp = sdp->next) { in seglock_dump_all()
1658 (void *)sdp, sdp == lp->owner ? " (owner)" : "", in seglock_dump_all()
1659 (void *)sdp->lp, sdp->flag, (void *)ID(sdp), in seglock_dump_all()
1662 mutex_exit(&lp->mutex); in seglock_dump_all()