summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorPedro Martelletto <pedro@cvs.openbsd.org>2005-11-19 02:18:03 +0000
committerPedro Martelletto <pedro@cvs.openbsd.org>2005-11-19 02:18:03 +0000
commit4e00bfe9e4fce563a74dcd487149539b6bc02ba9 (patch)
treea134970c4687287588758bb78c439e9cde819bb9 /sys/dev
parent16017b33d1fad6b6fd295f39b365b33719b42ae9 (diff)
Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process pointer as an argument. Should fix many "process context required" bugs. Incentive and okay millert@, okay marc@. Various testing, thanks.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/i2o/iop.c15
-rw-r--r--sys/dev/i2o/iopsp.c6
-rw-r--r--sys/dev/isa/gscsio.c6
-rw-r--r--sys/dev/pci/vga_pci.c22
-rw-r--r--sys/dev/systrace.c61
-rw-r--r--sys/dev/usb/usb_port.h4
6 files changed, 56 insertions, 58 deletions
diff --git a/sys/dev/i2o/iop.c b/sys/dev/i2o/iop.c
index 203801c57ad..7239d9b417e 100644
--- a/sys/dev/i2o/iop.c
+++ b/sys/dev/i2o/iop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iop.c,v 1.26 2005/01/06 11:06:13 miod Exp $ */
+/* $OpenBSD: iop.c,v 1.27 2005/11/19 02:18:00 pedro Exp $ */
/* $NetBSD: iop.c,v 1.12 2001/03/21 14:27:05 ad Exp $ */
/*-
@@ -545,12 +545,12 @@ iop_config_interrupts(struct device *self)
config_found_sm(self, &ia, iop_vendor_print, iop_submatch);
#endif
- lockmgr(&sc->sc_conflock, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&sc->sc_conflock, LK_EXCLUSIVE, NULL);
if ((rv = iop_reconfigure(sc, 0)) == -1) {
printf("%s: configure failed (%d)\n", sc->sc_dv.dv_xname, rv);
return;
}
- lockmgr(&sc->sc_conflock, LK_RELEASE, NULL, curproc);
+ lockmgr(&sc->sc_conflock, LK_RELEASE, NULL);
kthread_create_deferred(iop_create_reconf_thread, sc);
}
@@ -584,7 +584,6 @@ void
iop_reconf_thread(void *cookie)
{
struct iop_softc *sc = cookie;
- struct proc *p = sc->sc_reconf_proc;
struct i2o_lct lct;
u_int32_t chgind;
int rv;
@@ -603,10 +602,10 @@ iop_reconf_thread(void *cookie)
sc->sc_dv.dv_xname, letoh32(lct.changeindicator), rv));
if (rv == 0 &&
- lockmgr(&sc->sc_conflock, LK_EXCLUSIVE, NULL, p) == 0) {
+ lockmgr(&sc->sc_conflock, LK_EXCLUSIVE, NULL) == 0) {
iop_reconfigure(sc, letoh32(lct.changeindicator));
chgind = sc->sc_chgind + 1;
- lockmgr(&sc->sc_conflock, LK_RELEASE, NULL, p);
+ lockmgr(&sc->sc_conflock, LK_RELEASE, NULL);
}
tsleep(iop_reconf_thread, PWAIT, "iopzzz", hz * 5);
@@ -2380,7 +2379,7 @@ iopioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
return (ENOTTY);
}
- if ((rv = lockmgr(&sc->sc_conflock, LK_SHARED, NULL, p)) != 0)
+ if ((rv = lockmgr(&sc->sc_conflock, LK_SHARED, NULL)) != 0)
return (rv);
switch (cmd) {
@@ -2409,7 +2408,7 @@ iopioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
break;
}
- lockmgr(&sc->sc_conflock, LK_RELEASE, NULL, p);
+ lockmgr(&sc->sc_conflock, LK_RELEASE, NULL);
return (rv);
}
diff --git a/sys/dev/i2o/iopsp.c b/sys/dev/i2o/iopsp.c
index 0626df4d9c5..4fc885728a7 100644
--- a/sys/dev/i2o/iopsp.c
+++ b/sys/dev/i2o/iopsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iopsp.c,v 1.7 2003/01/13 03:56:47 mickey Exp $ */
+/* $OpenBSD: iopsp.c,v 1.8 2005/11/19 02:18:00 pedro Exp $ */
/* $NetBSD$ */
/*-
@@ -376,7 +376,7 @@ iopsp_rescan(struct iopsp_softc *sc)
iop = (struct iop_softc *)sc->sc_dv.dv_parent;
- rv = lockmgr(&iop->sc_conflock, LK_EXCLUSIVE, NULL, curproc);
+ rv = lockmgr(&iop->sc_conflock, LK_EXCLUSIVE, NULL);
if (rv != 0) {
#ifdef I2ODEBUG
printf("iopsp_rescan: unable to acquire lock\n");
@@ -400,7 +400,7 @@ iopsp_rescan(struct iopsp_softc *sc)
if ((rv = iop_lct_get(iop)) == 0)
rv = iopsp_reconfig(&sc->sc_dv);
- lockmgr(&iop->sc_conflock, LK_RELEASE, NULL, curproc);
+ lockmgr(&iop->sc_conflock, LK_RELEASE, NULL);
return (rv);
}
diff --git a/sys/dev/isa/gscsio.c b/sys/dev/isa/gscsio.c
index 7ce7a91b1bb..7fd258dd445 100644
--- a/sys/dev/isa/gscsio.c
+++ b/sys/dev/isa/gscsio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gscsio.c,v 1.3 2004/11/17 16:53:05 mickey Exp $ */
+/* $OpenBSD: gscsio.c,v 1.4 2005/11/19 02:18:00 pedro Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
*
@@ -320,7 +320,7 @@ gscsio_acb_acquire_bus(void *cookie, int flags)
if (flags & I2C_F_POLL)
return (0);
- return (lockmgr(&acb->buslock, LK_EXCLUSIVE, NULL, curproc));
+ return (lockmgr(&acb->buslock, LK_EXCLUSIVE, NULL));
}
void
@@ -331,7 +331,7 @@ gscsio_acb_release_bus(void *cookie, int flags)
if (flags & I2C_F_POLL)
return;
- lockmgr(&acb->buslock, LK_RELEASE, NULL, curproc);
+ lockmgr(&acb->buslock, LK_RELEASE, NULL);
}
int
diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c
index 0229bf099ff..0df6667c1da 100644
--- a/sys/dev/pci/vga_pci.c
+++ b/sys/dev/pci/vga_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vga_pci.c,v 1.19 2005/11/10 22:57:37 martin Exp $ */
+/* $OpenBSD: vga_pci.c,v 1.20 2005/11/19 02:18:00 pedro Exp $ */
/* $NetBSD: vga_pci.c,v 1.3 1998/06/08 06:55:58 thorpej Exp $ */
/*-
@@ -546,7 +546,7 @@ agp_free_gatt(struct vga_pci_softc *sc, struct agp_gatt *gatt)
int
agp_generic_detach(struct vga_pci_softc *sc)
{
- lockmgr(&sc->sc_lock, LK_DRAIN, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_DRAIN, NULL);
agp_flush_cache();
return 0;
}
@@ -664,11 +664,11 @@ agp_generic_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem,
off_t i, k;
int contigpages, nseg, error;
- lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
if (mem->am_is_bound) {
printf("AGP: memory already bound\n");
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
return EINVAL;
}
@@ -677,7 +677,7 @@ agp_generic_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem,
|| offset + mem->am_size > AGP_GET_APERTURE(sc)) {
printf("AGP: binding memory at bad offset %#lx\n",
(unsigned long) offset);
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
return EINVAL;
}
@@ -729,7 +729,7 @@ agp_generic_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem,
}
if (contigpages == 0) {
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
return ENOMEM;
}
@@ -767,7 +767,7 @@ agp_generic_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem,
bus_dmamem_free(sc->sc_dmat, mem->am_dmaseg,
mem->am_nseg);
free(mem->am_dmaseg, M_DEVBUF);
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
return error;
}
}
@@ -788,7 +788,7 @@ agp_generic_bind_memory(struct vga_pci_softc *sc, struct agp_memory *mem,
mem->am_offset = offset;
mem->am_is_bound = 1;
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
return 0;
}
@@ -798,11 +798,11 @@ agp_generic_unbind_memory(struct vga_pci_softc *sc, struct agp_memory *mem)
{
int i;
- lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
if (!mem->am_is_bound) {
printf("AGP: memory is not bound\n");
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
return EINVAL;
}
@@ -826,7 +826,7 @@ agp_generic_unbind_memory(struct vga_pci_softc *sc, struct agp_memory *mem)
mem->am_offset = 0;
mem->am_is_bound = 0;
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
return 0;
}
diff --git a/sys/dev/systrace.c b/sys/dev/systrace.c
index 2c1fced238c..9fa8f3292cd 100644
--- a/sys/dev/systrace.c
+++ b/sys/dev/systrace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: systrace.c,v 1.38 2005/04/17 22:11:34 millert Exp $ */
+/* $OpenBSD: systrace.c,v 1.39 2005/11/19 02:18:00 pedro Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -139,13 +139,13 @@ struct lock systrace_lck;
static __inline void
systrace_lock(void)
{
- lockmgr(&systrace_lck, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&systrace_lck, LK_EXCLUSIVE, NULL);
}
static __inline void
systrace_unlock(void)
{
- lockmgr(&systrace_lck, LK_RELEASE, NULL, curproc);
+ lockmgr(&systrace_lck, LK_RELEASE, NULL);
}
/* Needs to be called with fst locked */
@@ -216,7 +216,7 @@ systracef_read(fp, poff, uio, cred)
again:
systrace_lock();
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
if ((process = TAILQ_FIRST(&fst->messages)) != NULL) {
error = uiomove((caddr_t)&process->msg,
@@ -236,7 +236,7 @@ systracef_read(fp, poff, uio, cred)
if (fp->f_flag & FNONBLOCK)
error = EAGAIN;
else {
- lockmgr(&fst->lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
error = tsleep(fst, PWAIT|PCATCH, "systrrd", 0);
if (error)
goto out;
@@ -245,7 +245,7 @@ systracef_read(fp, poff, uio, cred)
}
- lockmgr(&fst->lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
out:
return (error);
}
@@ -333,7 +333,7 @@ systracef_ioctl(fp, cmd, data, p)
return (ret);
systrace_lock();
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
if (pid) {
strp = systrace_findpid(fst, pid);
@@ -405,7 +405,7 @@ systracef_ioctl(fp, cmd, data, p)
}
unlock:
- lockmgr(&fst->lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
return (ret);
}
@@ -423,13 +423,13 @@ systracef_poll(fp, events, p)
return (0);
systrace_lock();
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
if (!TAILQ_EMPTY(&fst->messages))
revents = events & (POLLIN | POLLRDNORM);
else
selrecord(p, &fst->si);
- lockmgr(&fst->lock, LK_RELEASE, NULL, p);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
return (revents);
}
@@ -464,7 +464,7 @@ systracef_close(fp, p)
struct str_policy *strpol;
systrace_lock();
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
/* Untrace all processes */
@@ -493,7 +493,7 @@ systracef_close(fp, p)
vrele(fst->fd_cdir);
if (fst->fd_rdir)
vrele(fst->fd_rdir);
- lockmgr(&fst->lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
FREE(fp->f_data, M_XDATA);
fp->f_data = NULL;
@@ -639,14 +639,14 @@ systrace_exit(struct proc *proc)
strp = proc->p_systrace;
if (strp != NULL) {
fst = strp->parent;
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
/* Insert Exit message */
systrace_msg_child(fst, strp, -1);
systrace_detach(strp);
- lockmgr(&fst->lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
} else
systrace_unlock();
CLR(proc->p_flag, P_SYSTRACE);
@@ -666,7 +666,7 @@ systrace_fork(struct proc *oldproc, struct proc *p)
}
fst = oldstrp->parent;
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
if (systrace_insert_process(fst, p))
@@ -681,7 +681,7 @@ systrace_fork(struct proc *oldproc, struct proc *p)
/* Insert fork message */
systrace_msg_child(fst, oldstrp, p->p_pid);
out:
- lockmgr(&fst->lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
}
#define REACQUIRE_LOCK do { \
@@ -692,7 +692,7 @@ systrace_fork(struct proc *oldproc, struct proc *p)
return (error); \
} \
fst = strp->parent; \
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); \
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); \
systrace_unlock(); \
} while (0)
@@ -725,7 +725,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval)
fst = strp->parent;
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
/*
@@ -769,7 +769,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval)
error = EPERM;
}
systrace_replacefree(strp);
- lockmgr(&fst->lock, LK_RELEASE, NULL, p);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
if (policy == SYSTR_POLICY_PERMIT)
error = (*callp->sy_call)(p, v, retval);
return (error);
@@ -798,7 +798,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval)
}
fst = strp->parent;
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
if (strp->answer == SYSTR_POLICY_NEVER) {
@@ -833,7 +833,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval)
} else
CLR(strp->flags, STR_PROC_SETEUID|STR_PROC_SETEGID);
- lockmgr(&fst->lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
error = (*callp->sy_call)(p, v, retval);
@@ -876,7 +876,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval)
/* Acquire lock */
fst = strp->parent;
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
if (p->p_emul != oldemul) {
@@ -908,7 +908,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval)
}
out_unlock:
- lockmgr(&fst->lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
out:
return (error);
}
@@ -1321,7 +1321,7 @@ systrace_execve1(char *path, struct proc *p)
msg_execve = &strp->msg.msg_data.msg_execve;
fst = strp->parent;
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
/*
@@ -1332,7 +1332,7 @@ systrace_execve1(char *path, struct proc *p)
if (fst->issuser ||
fst->p_ruid != p->p_cred->p_ruid ||
fst->p_rgid != p->p_cred->p_rgid) {
- lockmgr(&fst->lock, LK_RELEASE, NULL, p);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
return;
}
strlcpy(msg_execve->path, path, MAXPATHLEN);
@@ -1475,7 +1475,7 @@ systrace_scriptname(struct proc *p, char *dst)
strp = p->p_systrace;
fst = strp->parent;
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
if (!fst->issuser && (ISSET(p->p_flag, P_SUGID) ||
@@ -1498,7 +1498,7 @@ systrace_scriptname(struct proc *p, char *dst)
out:
strp->scriptname[0] = '\0';
- lockmgr(&fst->lock, LK_RELEASE, NULL, p);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
return (error);
}
@@ -1516,7 +1516,7 @@ systrace_namei(struct nameidata *ndp)
strp = cnp->cn_proc->p_systrace;
if (strp != NULL) {
fst = strp->parent;
- lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc);
+ lockmgr(&fst->lock, LK_EXCLUSIVE, NULL);
systrace_unlock();
for (i = 0; i < strp->nfname; i++)
@@ -1529,7 +1529,7 @@ systrace_namei(struct nameidata *ndp)
strcmp(cnp->cn_pnbuf, strp->scriptname) == 0)
hamper = 1;
- lockmgr(&fst->lock, LK_RELEASE, NULL, curproc);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
} else
systrace_unlock();
@@ -1746,7 +1746,6 @@ systrace_make_msg(struct str_process *strp, int type)
{
struct str_message *msg = &strp->msg;
struct fsystrace *fst = strp->parent;
- struct proc *p = strp->proc;
int st, pri;
pri = PWAIT|PCATCH;
@@ -1772,7 +1771,7 @@ systrace_make_msg(struct str_process *strp, int type)
systrace_wakeup(fst);
/* Release the lock - XXX */
- lockmgr(&fst->lock, LK_RELEASE, NULL, p);
+ lockmgr(&fst->lock, LK_RELEASE, NULL);
while (1) {
st = tsleep(strp, pri, "systrmsg", 0);
diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h
index f14cd65d90f..e32e5287831 100644
--- a/sys/dev/usb/usb_port.h
+++ b/sys/dev/usb/usb_port.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_port.h,v 1.59 2005/09/26 22:19:01 miod Exp $ */
+/* $OpenBSD: usb_port.h,v 1.60 2005/11/19 02:18:01 pedro Exp $ */
/* $NetBSD: usb_port.h,v 1.62 2003/02/15 18:33:30 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_port.h,v 1.21 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -322,7 +322,7 @@ typedef struct timeout usb_callout_t;
#define usb_callout_pending(h) timeout_pending(&(h))
#define usb_uncallout(h, f, d) timeout_del(&(h))
-#define usb_lockmgr(l, f, sl, p) lockmgr((l), (f), (sl), (p))
+#define usb_lockmgr(l, f, sl, p) lockmgr((l), (f), (sl))
#define USB_DECLARE_DRIVER_CLASS(dname, devclass) \
int __CONCAT(dname,_match)(struct device *, void *, void *); \