summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2007-12-07 14:48:51 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2007-12-07 14:48:51 +0000
commit7119e06b99c29df5e9e03a1b931fbfaf55f04a5a (patch)
treee2342584fe1ebfa2698165955fc0bba7c5240884 /sys
parent5220f2c99539b84278633dac73e5311deae05cc6 (diff)
Replace lockmgr with rwlock.
advice from thib. Comments and ok tedu@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/agp.c27
-rw-r--r--sys/dev/pci/agpvar.h6
2 files changed, 16 insertions, 17 deletions
diff --git a/sys/dev/pci/agp.c b/sys/dev/pci/agp.c
index 2d8a4015ab5..144d33220a2 100644
--- a/sys/dev/pci/agp.c
+++ b/sys/dev/pci/agp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: agp.c,v 1.12 2007/12/06 22:49:39 oga Exp $ */
+/* $OpenBSD: agp.c,v 1.13 2007/12/07 14:48:50 oga Exp $ */
/*-
* Copyright (c) 2000 Doug Rabson
* All rights reserved.
@@ -165,7 +165,7 @@ agp_attach(struct device *parent, struct device *self, void *aux)
* agp_generic_bind_memory() since that function can sleep.
*/
- lockinit(&sc->sc_lock, PZERO|PCATCH, "agplk", 0, 0);
+ rw_init(&sc->sc_lock, "agplk");
TAILQ_INIT(&sc->sc_memory);
@@ -400,7 +400,6 @@ agp_free_gatt(struct agp_softc *sc, struct agp_gatt *gatt)
int
agp_generic_detach(struct agp_softc *sc)
{
- lockmgr(&sc->sc_lock, LK_DRAIN, NULL);
agp_flush_cache();
return (0);
}
@@ -512,11 +511,11 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem,
off_t i, k;
int nseg, error;
- lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&sc->sc_lock);
if (mem->am_is_bound) {
printf("AGP: memory already bound\n");
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
return (EINVAL);
}
@@ -525,7 +524,7 @@ agp_generic_bind_memory(struct agp_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);
+ rw_exit_write(&sc->sc_lock);
return (EINVAL);
}
@@ -541,7 +540,7 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem,
if ((error = bus_dmamem_alloc(sc->sc_dmat, mem->am_size, PAGE_SIZE, 0,
segs, nseg, &mem->am_nseg, BUS_DMA_WAITOK)) != 0) {
free(segs, M_AGP);
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
AGP_DPF("bus_dmamem_alloc failed %d\n", error);
return (error);
}
@@ -549,7 +548,7 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem,
mem->am_size, &mem->am_virtual, BUS_DMA_WAITOK)) != 0) {
bus_dmamem_free(sc->sc_dmat, segs, mem->am_nseg);
free(segs, M_AGP);
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
AGP_DPF("bus_dmamem_map failed %d\n", error);
return (error);
}
@@ -560,7 +559,7 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem,
mem->am_size);
bus_dmamem_free(sc->sc_dmat, segs, mem->am_nseg);
free(segs, M_AGP);
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
AGP_DPF("bus_dmamap_load failed %d\n", error);
return (error);
}
@@ -600,7 +599,7 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem,
bus_dmamem_free(sc->sc_dmat, mem->am_dmaseg,
mem->am_nseg);
free(mem->am_dmaseg, M_AGP);
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
AGP_DPF("AGP_BIND_PAGE failed %d\n", error);
return (error);
}
@@ -622,7 +621,7 @@ agp_generic_bind_memory(struct agp_softc *sc, struct agp_memory *mem,
mem->am_offset = offset;
mem->am_is_bound = 1;
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
return (0);
}
@@ -632,11 +631,11 @@ agp_generic_unbind_memory(struct agp_softc *sc, struct agp_memory *mem)
{
int i;
- lockmgr(&sc->sc_lock, LK_EXCLUSIVE, NULL);
+ rw_enter_write(&sc->sc_lock);
if (!mem->am_is_bound) {
printf("AGP: memory is not bound\n");
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
return (EINVAL);
}
@@ -660,7 +659,7 @@ agp_generic_unbind_memory(struct agp_softc *sc, struct agp_memory *mem)
mem->am_offset = 0;
mem->am_is_bound = 0;
- lockmgr(&sc->sc_lock, LK_RELEASE, NULL);
+ rw_exit_write(&sc->sc_lock);
return (0);
}
diff --git a/sys/dev/pci/agpvar.h b/sys/dev/pci/agpvar.h
index 9a6cff21007..25a28f8ae6e 100644
--- a/sys/dev/pci/agpvar.h
+++ b/sys/dev/pci/agpvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: agpvar.h,v 1.8 2007/12/06 22:49:39 oga Exp $ */
+/* $OpenBSD: agpvar.h,v 1.9 2007/12/07 14:48:50 oga Exp $ */
/* $NetBSD: agpvar.h,v 1.4 2001/10/01 21:54:48 fvdl Exp $ */
/*-
@@ -32,7 +32,7 @@
#ifndef _PCI_AGPVAR_H_
#define _PCI_AGPVAR_H_
-#include <sys/lock.h>
+#include <sys/rwlock.h>
/* #define AGP_DEBUG */
#ifdef AGP_DEBUG
@@ -130,7 +130,7 @@ struct agp_softc {
bus_addr_t sc_apaddr;
bus_size_t sc_apsize;
bus_dma_tag_t sc_dmat;
- struct lock sc_lock; /* lock for access to GATT */
+ struct rwlock sc_lock; /* lock for access to GATT */
pcitag_t sc_pcitag; /* PCI tag, in case we need it. */
pcireg_t sc_id;
pci_chipset_tag_t sc_pc;