mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 09:41:03 -04:00
dev/mem: use sx instead of rw lock
Some ops require sleepable context to success, like DMAP demotion. Reviewed by: alc, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50970
This commit is contained in:
parent
c5f5d0cf49
commit
ca554a7dea
1 changed files with 9 additions and 10 deletions
|
|
@ -26,15 +26,14 @@
|
|||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/memrange.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sx.h>
|
||||
|
||||
static struct rwlock mr_lock;
|
||||
static struct sx mr_lock;
|
||||
|
||||
/*
|
||||
* Implementation-neutral, kernel-callable functions for manipulating
|
||||
|
|
@ -46,7 +45,7 @@ mem_range_init(void)
|
|||
|
||||
if (mem_range_softc.mr_op == NULL)
|
||||
return;
|
||||
rw_init(&mr_lock, "memrange");
|
||||
sx_init(&mr_lock, "memrange");
|
||||
mem_range_softc.mr_op->init(&mem_range_softc);
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +55,7 @@ mem_range_destroy(void)
|
|||
|
||||
if (mem_range_softc.mr_op == NULL)
|
||||
return;
|
||||
rw_destroy(&mr_lock);
|
||||
sx_destroy(&mr_lock);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -67,12 +66,12 @@ mem_range_attr_get(struct mem_range_desc *mrd, int *arg)
|
|||
if (mem_range_softc.mr_op == NULL)
|
||||
return (EOPNOTSUPP);
|
||||
nd = *arg;
|
||||
rw_rlock(&mr_lock);
|
||||
sx_slock(&mr_lock);
|
||||
if (nd == 0)
|
||||
*arg = mem_range_softc.mr_ndesc;
|
||||
else
|
||||
bcopy(mem_range_softc.mr_desc, mrd, nd * sizeof(*mrd));
|
||||
rw_runlock(&mr_lock);
|
||||
sx_sunlock(&mr_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -83,8 +82,8 @@ mem_range_attr_set(struct mem_range_desc *mrd, int *arg)
|
|||
|
||||
if (mem_range_softc.mr_op == NULL)
|
||||
return (EOPNOTSUPP);
|
||||
rw_wlock(&mr_lock);
|
||||
sx_xlock(&mr_lock);
|
||||
ret = mem_range_softc.mr_op->set(&mem_range_softc, mrd, arg);
|
||||
rw_wunlock(&mr_lock);
|
||||
sx_xunlock(&mr_lock);
|
||||
return (ret);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue