/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This is the lock device driver.
*
* The lock driver provides a variation of inter-process mutexes with the
* following twist in semantics:
* A waiter for a lock after a set timeout can "break" the lock and
* grab it from the current owner (without informing the owner).
*
* These semantics result in temporarily multiple processes thinking they
* own the lock. This usually does not make sense for cases where locks are
* used to protect a critical region and it is important to serialize access
* to data structures. As breaking the lock will also lose the serialization
* and result in corrupt data structures.
*
* The usage for winlock driver is primarily driven by the graphics system
* when doing DGA (direct graphics access) graphics. The locks are used to
* protect access to the frame buffer (presumably reflects back to the screen)
* between competing processes that directly write to the screen as opposed
* to going through the window server etc.
* In this case, the result of breaking the lock at worst causes the screen
* image to be distorted and is easily fixed by doing a "refresh"
*
* In well-behaved applications, the lock is held for a very short time and
* the breaking semantics do not come into play. Not having this feature and
* using normal inter-process mutexes will result in a misbehaved application
* from grabbing the screen writing capability from the window manager and
* effectively make the system look like it is hung (mouse pointer does not
* move).
*
* A secondary aspect of the winlock driver is that it allows for extremely
* write is all that is needed (not even a function call). And the window
* manager is the only DGA writer usually and this optimized for. Occasionally
* some processes might do DGA graphics and cause kernel faults to handle
* the contention/locking (and that has got to be slow!).
*
* The following IOCTLs are supported:
*
* GRABPAGEALLOC:
* Compatibility with old cgsix device driver lockpage ioctls.
* Lockpages created this way must be an entire page for compatibility with
* older software. This ioctl allocates a lock context with its own
* private lock page. The unique "ident" that identifies this lock is
* returned.
*
* GRABPAGEFREE:
* Compatibility with cgsix device driver lockpage ioctls. This
* ioctl releases the lock context allocated by GRABPAGEALLOC.
*
* GRABLOCKINFO:
* Returns a one-word flag. '1' means that multiple clients may
* access this lock page. Older device drivers returned '0',
* meaning that only two clients could access a lock page.
*
* GRABATTACH:
* Not supported. This ioctl would have grabbed all lock pages
* on behalf of the calling program.
*
* WINLOCKALLOC:
* Allocate a lock context. This ioctl accepts a key value. as
* its argument. If the key is zero, a new lock context is
* created, and its "ident" is returned. If the key is nonzero,
* all existing contexts are checked to see if they match they
* key. If a match is found, its reference count is incremented
* and its ident is returned, otherwise a new context is created
* and its ident is returned.
*
* WINLOCKFREE:
* Free a lock context. This ioctl accepts the ident of a lock
* context and decrements its reference count. Once the reference
* count reaches zero *and* all mappings are released, the lock
* context is freed. When all the lock context in the lock page are
* freed, the lock page is freed as well.
*
* WINLOCKSETTIMEOUT:
* Set lock timeout for a context. This ioctl accepts the ident
* of a lock context and a timeout value in milliseconds.
* Whenever lock contention occurs, the timer is started and the lock is
* broken after the timeout expires. If timeout value is zero, lock does
* not timeout. This value will be rounded to the nearest clock
* tick, so don't try to use it for real-time control or something.
*
* WINLOCKGETTIMEOUT:
* Get lock timeout from a context.
*
* WINLOCKDUMP:
* Dump state of this device.
*
*
*
* Every lock context consists of two mappings for the client to the lock
* page. These mappings are known as the "lock page" and "unlock page"
* to the client. The first mmap to the lock context (identified by the
* sy_ident field returns during alloc) allocates mapping to the lock page,
* the second mmap allocates a mapping to the unlock page.
* The mappings dont have to be ordered in virtual address space, but do
* need to be ordered in time. Mapping and unmapping of these lock and unlock
* pages should happen in pairs. Doing them one at a time or unmapping one
* and leaving one mapped etc cause undefined behaviors.
* The mappings are always of length PAGESIZE, and type MAP_SHARED.
*
* The first ioctl is to ALLOC a lock, either based on a key (if trying to
* grab a preexisting lock) or 0 (gets a default new one)
* This ioctl returns a value in sy_ident which is needed to do the
*
* The "page number" portion of the sy_ident needs to be passed as the
* file offset when doing an mmap for both the lock page and unlock page
*
* The value returned by mmap ( a user virtual address) needs to be
* incremented by the "page offset" portion of sy_ident to obtain the
* pointer to the actual lock. (Skipping this step, does not cause any
* visible error, but the process will be using the wrong lock!)
*
* On a fork(), the child process will inherit the mappings for free, but
* will not inherit the parent's lock ownership if any. The child should NOT
* do an explicit FREE on the lock context unless it did an explicit ALLOC.
* Only one process at a time is allowed to have a valid hat
* mapping to a lock page. This is enforced by this driver.
* A client acquires a lock by writing a '1' to the lock page.
* Note, that it is not necessary to read and veryify that the lock is '0'
* prior to writing a '1' in it.
* If it does not already have a valid mapping to that page, the driver
* takes a fault (devmap_access), loads the client mapping
* and allows the client to continue. The client releases the lock by
* writing a '0' to the unlock page. Again, if it does not have a valid
* mapping to the unlock page, the segment driver takes a fault,
* loads the mapping, and lets the client continue. From this point
* forward, the client can make as many locks and unlocks as it
* wants, without any more faults into the kernel.
*
* If a different process wants to acquire a lock, it takes a page fault
* when it writes the '1' to the lock page. If the segment driver sees
* that the lock page contained a zero, then it invalidates the owner's
* mappings and gives the mappings to this process.
*
* If there is already a '1' in the lock page when the second client
* tries to access the lock page, then a lock exists. The segment
* driver sleeps the second client and, if applicable, starts the
* timeout on the lock. The owner's mapping to the unlock page
* is invalidated so that the driver will be woken again when the owner
* releases the lock.
*
* When the locking client finally writes a '0' to the unlock page, the
* segment driver takes another fault. The client is given a valid
* mapping, not to the unlock page, but to the "trash page", and allowed
* to continue. Meanwhile, the sleeping client is given a valid mapping
*
* RFE: There is a leak if process exits before freeing allocated locks
* But currently not tracking which locks were allocated by which
* process and we do not have a clean entry point into the driver
* to do garbage collection. If the interface used a file descriptor for each
* lock it allocs, then the driver can free up stuff in the _close routine
*/
nulldev, /* open */
nulldev, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
winlock_ioctl, /* ioctl */
winlock_devmap, /* devmap */
nodev, /* mmap */
winlocksegmap, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* prop_op */
NULL, /* streamtab */
0, /* rev */
nodev, /* aread */
nodev /* awrite */
};
0, /* refcount */
winlock_info, /* info */
nulldev, /* identify */
nulldev, /* probe */
winlock_attach, /* attach */
winlock_detach, /* detach */
nodev, /* reset */
&winlock_cb_ops, /* driver ops */
NULL, /* bus ops */
NULL, /* power */
ddi_quiesce_not_needed, /* quiesce */
};
void **);
devmap_cookie_t, void **, devmap_cookie_t, void **);
static int winlockmap_dup(devmap_cookie_t, void *,
devmap_cookie_t, void **);
static
};
#if DEBUG
static int lock_debug = 0;
#else
#endif
/* Driver supports two styles of locks */
/*
* These structures describe a lock context. We permit multiple
* clients (not just two) to access a lock page
*
* The "cookie" identifies the lock context. It is the page number portion
* sy_ident returned on lock allocation. Cookie is used in later ioctls.
* "cookie" is lockid * PAGESIZE
* "lockptr" is the kernel virtual address to the lock itself
* The page offset portion of lockptr is the page offset portion of sy_ident
*/
/*
* per-process information about locks. This is the private field of
* a devmap mapping. Note that usually *two* mappings point to this.
*/
/*
* Each process using winlock is associated with a segproc structure
* In various driver entry points, we need to search to find the right
* segproc structure (If we were using file handles for each lock this
* would not have been necessary).
* It would have been simple to use the process pid (and ddi_get_pid)
* However, during fork devmap_dup is called in the parent process context
* and using the pid complicates the code by introducing orphans.
* Instead we use the as pointer for the process as a cookie
* which requires delving into various non-DDI kosher structs
*/
typedef struct segproc {
} SegProc;
/* per lock context information */
typedef struct seglock {
} SegLock;
/*
* Number of locks that can fit in a page. Driver can support only that many.
* For oldsytle locks, it is relatively easy to increase the limit as each
* is in a separate page (MAX_LOCKS mostly serves to prevent runaway allocation
* For newstyle locks, this is trickier as the code needs to allow for mapping
* into the second or third page of the cookie for some locks.
*/
/* Protections setting for winlock user mappings */
/*
* The trash page is where unwanted writes go
* when a process is releasing a lock.
*/
/* For newstyle allocations a common page of locks is used */
/*
* winlock_mutex protects
* lock_list
* lock_free_list
* "next" field in SegLock
* next_lock
* trashpage_cookie
* lockpage & lockpage_cookie
*
* SegLock_mutex protects
* rest of fields in SegLock
* All fields in list of SegProc (lp->clients)
*
* Lock ordering is winlock_mutex->SegLock_mutex
*
* During devmap callbacks, the pointer to SegProc is stored as the private
* data in the devmap handle. This pointer will not go stale (i.e., the
* SegProc getting deleted) as the SegProc is not deleted until both the
* lockseg and unlockseg have been unmapped and the pointers stored in
* the devmap handles have been NULL'ed.
* But before this pointer is used to access any fields (other than the 'lp')
* lp->mutex must be held.
*/
/*
* The allocation code tries to allocate from lock_free_list
* first, otherwise it uses kmem_zalloc. When lock list is idle, all
* locks in lock_free_list are kmem_freed
*/
/* Routines to find a lock in lock_list based on offset or key */
/* Routines to find and allocate SegProc structures */
/* Delete client from lock's client list */
/* Create a new lock */
/* Destroy lock */
static void seglock_destroylock(SegLock *);
static void lock_destroyall(void);
/* Helper functions in winlockmap_access */
static int lock_giveup(SegLock *, int);
/* routines called from ioctl */
static int seglock_grabinfo(intptr_t, int);
static int seglock_grabfree(intptr_t, int);
static int seglock_gettimeout(intptr_t, int);
static int seglock_settimeout(intptr_t, int);
static void seglock_dump_all(void);
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
== DDI_FAILURE) {
return (DDI_FAILURE);
}
winlock_dip = devi;
return (DDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
if (cmd != DDI_DETACH)
return (DDI_FAILURE);
return (DDI_FAILURE);
}
/* destroy any common stuff created */
if (trashpage_cookie != NULL) {
}
}
winlock_dip = NULL;
return (DDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
register int error;
/* initialize result */
/* only valid instance (i.e., getminor) is 0 */
return (DDI_FAILURE);
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
if (winlock_dip == NULL)
error = DDI_FAILURE;
else {
*result = (void *)winlock_dip;
error = DDI_SUCCESS;
}
break;
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
error = DDI_SUCCESS;
break;
default:
error = DDI_FAILURE;
}
return (error);
}
/*ARGSUSED*/
int
{
switch (cmd) {
/*
* ioctls that used to be handled by framebuffers (defined in fbio.h)
* RFE: No code really calls the GRAB* ioctls now. Should EOL.
*/
case GRABPAGEALLOC:
case GRABPAGEFREE:
case GRABLOCKINFO:
case GRABATTACH:
return (EINVAL); /* GRABATTACH is not supported (never was) */
case WINLOCKALLOC:
case WINLOCKFREE:
case WINLOCKSETTIMEOUT:
case WINLOCKGETTIMEOUT:
case WINLOCKDUMP:
return (0);
#ifdef DEBUG
case (WIOC|255):
lock_debug = arg;
return (0);
#endif
default:
return (ENOTTY); /* Why is this not EINVAL */
}
}
int
{
/* Only MAP_SHARED mappings are supported */
return (EINVAL);
}
/* Use devmap_setup to setup the mapping */
}
/*ARGSUSED*/
int
{
int err;
*maplen = 0;
/* Check if the lock exists, i.e., has been created by alloc */
/* off is the sy_ident returned in the alloc ioctl */
return (ENXIO);
}
/*
* The offset bits in mmap(2) offset has to be same as in lockptr
* OR the offset should be 0 (i.e. masked off)
*/
if (((off & PAGEOFFSET) != 0) &&
"mmap offset %llx mismatch with lockptr %p\n",
return (EINVAL);
}
/* Only supports PAGESIZE length mappings */
return (EINVAL);
}
/*
* Set up devmap to point at page associated with lock
* RFE: At this point we dont know if this is a lockpage or unlockpage
* a lockpage would not need DEVMAP_ALLOW_REMAP setting
* We could have kept track of the mapping order here,
* but devmap framework does not support storing any state in this
* devmap callback as it does not callback for error cleanup if some
* other error happens in the framework.
* RFE: We should modify the winlock mmap interface so that the
* user process marks in the offset passed in whether this is for a
* lock or unlock mapping instead of guessing based on order of maps
* This would cleanup other things (such as in fork)
*/
DEVMAP_ALLOW_REMAP, 0)) < 0) {
return (err);
}
/*
* No mappings are loaded to those segments yet. The correctness
* loading the translations without calling _access callback.
*/
return (0);
}
/*
* This routine is called by the devmap framework after the devmap entry point
* above and the mapping is setup in seg_dev.
* We store the pointer to the per-process context in the devmap private data.
*/
/*ARGSUSED*/
static int
{
/* Find the per-process context for this lock, alloc one if not found */
/*
* RFE: Determining which is a lock vs unlock seg is based on order
* of mmaps, we should change that to be derivable from off
*/
} else {
/* attempting to map lock more than twice */
return (ENOMEM);
}
return (DDI_SUCCESS);
}
/*
* duplicate a segment, as in fork()
* On fork, the child inherits the mappings to the lock
* lp->alloccount is NOT incremented, so child should not do a free().
* Semantics same as if done an alloc(), map(), map().
* This way it would work fine if doing an exec() variant later
* Child does not inherit any UFLAGS set in parent
* The lock and unlock pages are started off unmapped, i.e., child does not
* own the lock.
* The code assumes that the child process has a valid pid at this point
* RFE: This semantics depends on fork not duplicating the hat mappings
* (which is the current implementation). To enforce it would need to
* call devmap_unload from here - not clear if that is allowed.
*/
static int
void **newpvt)
{
/*
* Note: At this point, the child process does have a pid, but
* the arguments passed to as_dup and hence to devmap_dup dont pass it
* down. So we cannot use normal seglock_findclient - which finds the
* parent sdp itself!
* Instead we allocate the child's SegProc by using the child as pointer
* RFE: we are using the as stucture which means peeking into the
* devmap_cookie. This is not DDI-compliant. Need a compliant way of
* getting at either the as or, better, a way to get the child's new pid
*/
} else {
}
}
return (0);
}
/*ARGSUSED*/
static void
{
/*
* We always create PAGESIZE length mappings, so there should never
* be a partial unmapping case
*/
/* make sure this process doesn't own the lock */
/*
* Not handling errors - i.e., errors in unloading mapping
*/
(void) lock_giveup(lp, 0);
}
} else {
}
}
/*ARGSUSED*/
static int
{
int err;
/* Driver handles only DEVMAP_ACCESS type of faults */
if (type != DEVMAP_ACCESS)
return (-1);
/* should be using a SegProc that corresponds to current process */
/*
* If process is faulting but does not have both segments mapped
* return error (should cause a segv).
* RFE: could give it a permanent trashpage
*/
err = -1;
} else {
}
return (err);
}
/* INTERNAL ROUTINES START HERE */
/*
* search the lock_list list for the specified cookie
* The cookie is the sy_ident field returns by ALLOC ioctl.
* This has two parts:
* the pageoffset bits contain offset into the lock page.
* the pagenumber bits contain the lock id.
* The user code is supposed to pass in only the pagenumber portion
* (i.e. mask off the pageoffset bits). However the code below
* does the mask in case the users are not diligent
* if found, returns with mutex for SegLock structure held
*/
static SegLock *
{
break; /* return with lp->mutex held */
}
}
return (lp);
}
/*
* search the lock_list list for the specified non-zero key
* if found, returns with lock for SegLock structure held
*/
static SegLock *
{
/* The driver allows multiple locks with key 0, dont search */
if (key == 0)
return (NULL);
break;
}
return (lp);
}
/*
* Create a new lock context.
* Returns with SegLock mutex held
*/
static SegLock *
{
(void *)lock_free_list, next_lock));
if (lock_free_list != NULL) {
lp = lock_free_list;
return (NULL);
} else {
++next_lock;
}
if (style == OLDSTYLE_LOCK) {
} else {
}
return (lp);
}
/*
* Routine to destory a lock structure.
* This routine is called while holding the lp->mutex but not the
* winlock_mutex.
*/
static void
{
}
/*
* Reduce cookie by 1, makes it non page-aligned and invalid
* This prevents any valid lookup from finding this lock
* so when we drop the lock and regrab it it will still
* be there and nobody else would have attached to it
*/
/* Drop and reacquire mutexes in right order */
/* reincrement the cookie to get the original valid cookie */
/* Remove lp from lock_list */
} else {
}
}
/* Add to lock_free_list */
lock_free_list = lp;
/* Check if all locks deleted and cleanup */
}
}
/* Routine to find a SegProc corresponding to the tag */
static SegProc *
{
break;
}
return (sdp);
}
/* Routine to find (and if needed allocate) a SegProc corresponding to tag */
static SegProc *
{
/* Search and return if existing one found */
return (sdp);
/* Allocate a new SegProc */
return (sdp);
}
/*
* search a context's client list for the given client and delete
*/
static void
{
} else {
}
}
}
/*
* Routine to verify if a SegProc and SegLock
* Destroys the structures if they are ready
* Can be called with sdp == NULL if want to verify only the lock state
* caller should hold the lp->mutex
* and this routine drops the mutex
*/
static void
{
/* see if both segments unmapped from client structure */
/* see if this is last client in the entire lock context */
} else {
}
}
/* IOCTLS START HERE */
static int
{
int i = 1;
/* multiple clients per lock supported - see comments up top */
return (EFAULT);
return (0);
}
static int
{
int err;
if (style == OLDSTYLE_LOCK) {
key = 0;
} else {
mode)) {
return (EFAULT);
}
}
/* Allocate lockpage on first new style alloc */
}
/* Allocate trashpage on first alloc (any style) */
if (trashpage_cookie == NULL) {
}
++lp->alloccount;
} else {
return (ENOMEM);
}
if (style == OLDSTYLE_LOCK) {
} else {
}
if (err) {
/* On error, should undo allocation */
lp->alloccount--;
/* Verify and delete if lock is unused now */
return (EFAULT);
}
return (0);
}
static int
{
!= 0) {
return (EFAULT);
}
return (EINVAL);
}
if (lp->alloccount > 0)
lp->alloccount--;
/* Verify and delete if lock is unused now */
return (0);
}
/*
* Sets timeout in lock and UFLAGS in client
* the UFLAGS are stored in the client structure and persistent only
* till the unmap of the lock pages. If the process sets UFLAGS
* structure will get deleted and the UFLAGS will be lost. The process
* will need to resetup the flags.
*/
static int
{
return (EFAULT);
}
return (EINVAL);
/* if timeout modified, wake up any sleepers */
}
/*
* If the process is trying to set UFLAGS,
* Find the client segproc and allocate one if needed
* Set the flags preserving the kernel flags
* If the process is clearing UFLAGS
* Find the client segproc but dont allocate one if does not exist
*/
/* If clearing UFLAGS leaves the segment or lock idle, delete */
return (0);
}
return (0);
}
static int
{
return (EFAULT);
return (EINVAL);
/*
* If this process has an active allocated lock return those flags
* Dont allocate a client structure on gettimeout
* If not, return 0.
*/
} else {
}
return (EFAULT);
return (0);
}
/*
* Handle lock segment faults here...
*
* This is where the magic happens.
*/
/* ARGSUSED */
static int
{
int err;
"seglock_lockfault: hdl=%p, sdp=%p, lp=%p owner=%p\n",
/* lockfault is always called with sdp in current process context */
/* If Lock has no current owner, give the mapping to new owner */
}
/*
* Current owner is faulting on owned lock segment OR
* Current owner is faulting on unlock page and has no waiters
* Then can give the mapping to current owner
*/
} else {
/*
* Owner must be writing to unlock page and there are waiters.
* other cases have been checked earlier.
* Release the lock, owner, and owners mappings
* As the owner is trying to write to the unlock page, leave
* it with a trashpage mapping and wake up the sleepers
*/
}
}
/*
* If old owner faulting on trash unlock mapping,
* load hat mappings to trash page
* RFE: non-owners should NOT be faulting on unlock mapping as they
* as first supposed to fault on the lock seg. We could give them
* a trash page or return error.
*/
DEVMAP_ACCESS, rw));
}
/*
* Non-owner faulting. Need to check current LOCK state.
*
* Before reading lock value in LOCK(lp), we must make sure that
* the owner cannot change its value before we change mappings
* or else we could end up either with a hung process
* or more than one process thinking they have the lock.
* We do that by unloading the owner's mappings
*/
if (err != 0)
return (err); /* unable to remove owner mapping */
/*
* If lock is not held, then current owner mappings were
* unloaded above and we can give the lock to the new owner
*/
"Free lock (%p): Giving mapping to new owner %d\n",
(void *)lp, ddi_get_pid()));
}
/*
* A non-owning process tried to write (presumably to the lockpage,
* but it doesn't matter) but the lock is held; we need to sleep for
* the lock while there is an owner.
*/
int rval;
/*
* No timeout has been specified for this lock;
* we'll simply sleep on the condition variable.
*/
} else {
/*
* A timeout _has_ been specified for this lock. We need
* to wake up and possibly steal this lock if the owner
* does not let it go. Note that all sleepers on a lock
* with a timeout wait; the sleeper with the earliest
* timeout will wakeup, and potentially steal the lock
* Stealing the lock will cause a broadcast on the
* locksleep cv and thus kick the other timed waiters
* and cause everyone to restart in a new timedwait
*/
}
/*
* Timeout and still old owner - steal lock
* Force-Release lock and give old owner a trashpage mapping
*/
/*
* If successful, will break out of loop
*/
} else if (rval == 0) { /* signal pending */
"Process %d signalled while waiting on lock %d\n",
return (FC_MAKE_ERR(EINTR));
}
}
/*
* Give mapping to this process and save a fault later
*/
}
/*
* Utility: give a valid mapping to lock and unlock pages to current process.
* Caller responsible for unloading old owner's mappings
*/
static int
{
int err = 0;
/* give_mapping is always called with sdp in current process context */
/* remap any old trash mappings */
/* current owner should not have a trash mapping */
"new owner %d remapping old trash mapping\n",
ddi_get_pid()));
/*
* unable to remap old trash page,
* abort before changing owner
*/
"aborting: error in umem_remap %d\n", err));
return (err);
}
}
/* we have a new owner now */
DEVMAP_ACCESS, rw)) != 0) {
return (err);
}
/* Force unload unlock mapping if there are waiters */
" lock has %d sleepers => remove unlock mapping\n",
} else {
/*
* while here, give new owner a valid mapping to unlock
* page so we don't get called again.
*/
}
return (err);
}
/*
* Unload owner's mappings, release the lock and wakeup any sleepers
* If trash, then the old owner is given a trash mapping
* => old owner held lock too long and caused a timeout
*/
static int
{
/*
* owner loses lockpage/unlockpage mappings and gains a
* trashpage mapping, if needed.
*/
if (!trash) {
/*
* We do not handle errors in devmap_unload in the !trash case,
* release the lock. Errors in unloading the mapping are not
* going to affect that (unmap does not take error return).
*/
} else {
int err;
/* error unloading lockseg mapping. abort giveup */
return (err);
}
/*
* old owner gets mapping to trash page so it can continue
* devmap_umem_remap does a hat_unload (and does it holding
* the right locks), so no need to devmap_unload on unlockseg
*/
/* error remapping to trash page, abort giveup */
return (err);
}
/*
* Preload mapping to trash page by calling devmap_load
* However, devmap_load can only be called on the faulting
* process context and not on the owner's process context
* we preload only if we happen to be in owner process context
* Other processes will fault on the unlock mapping
* and be given a trash mapping at that time.
*/
}
}
/* Clear the lock value in underlying page so new owner can grab it */
}
return (0);
}
/*
* destroy all allocated memory.
*/
static void
lock_destroyall(void)
{
}
next_lock = 0;
}
/* RFE: create mdb walkers instead of dump routines? */
static void
seglock_dump_all(void)
{
}
}
#ifdef DEBUG
if (lock_debug < 3) {
return;
}
"lock %p, key=%d, cookie=%d, nalloc=%u, lock=%d, wait=%d\n",
"style=%d, lockptr=%p, timeout=%ld, clients=%p, owner=%p\n",
"process tag=%p, lockseg=%p, unlockseg=%p\n",
}
}
#endif
}
&mod_driverops, /* Type of module. This one is a driver */
"Winlock Driver", /* Name of the module */
&winlock_ops, /* driver ops */
};
(void *)&modldrv,
0,
0,
0
};
int
_init(void)
{
int e;
e = mod_install(&modlinkage);
if (e) {
}
return (e);
}
int
{
}
int
_fini(void)
{
int e;
e = mod_remove(&modlinkage);
if (e == 0) {
}
return (e);
}