diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2007-11-28 13:52:24 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2007-11-28 13:52:24 +0000 |
commit | 012174a91c0de9d1b03265ab959fe6bc197aa24d (patch) | |
tree | 4b49100a5b0e46ac4cbe31bef55d5ede3d3ffa6d | |
parent | e7c04e32673153ddccc24744722a9667da332794 (diff) |
finish conversion to workq. remove list remnants, and put spl in the right
places. handle the no workq case here. ok deraadt
-rw-r--r-- | sys/crypto/crypto.c | 33 | ||||
-rw-r--r-- | sys/crypto/cryptodev.h | 4 |
2 files changed, 24 insertions, 13 deletions
diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c index 7db11688340..434c0571dec 100644 --- a/sys/crypto/crypto.c +++ b/sys/crypto/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.50 2007/11/25 15:56:16 tedu Exp $ */ +/* $OpenBSD: crypto.c,v 1.51 2007/11/28 13:52:23 tedu Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -417,25 +417,29 @@ crypto_dispatch(struct cryptop *crp) hid = (crp->crp_sid >> 32) & 0xffffffff; if (hid < crypto_drivers_num) crypto_drivers[hid].cc_queued++; + splx(s); - crp->crp_next = NULL; - workq_add_task(crypto_workq, WQ_DIRECTOK, (workq_fn)crypto_invoke, crp, NULL); + if (crypto_workq) { + workq_add_task(crypto_workq, 0, + (workq_fn)crypto_invoke, crp, NULL); + } else { + crypto_invoke(crp); + } - splx(s); return 0; } int crypto_kdispatch(struct cryptkop *krp) { - int s; - - s = splvm(); - krp->krp_next = NULL; - workq_add_task(crypto_workq, WQ_DIRECTOK, (workq_fn)crypto_kinvoke, krp, NULL); + if (crypto_workq) { + workq_add_task(crypto_workq, 0, + (workq_fn)crypto_kinvoke, krp, NULL); + } else { + crypto_kinvoke(krp); + } - splx(s); return 0; } @@ -448,11 +452,13 @@ crypto_kinvoke(struct cryptkop *krp) extern int cryptodevallowsoft; u_int32_t hid; int error; + int s; /* Sanity checks. */ if (krp == NULL || krp->krp_callback == NULL) return (EINVAL); + s = splvm(); for (hid = 0; hid < crypto_drivers_num; hid++) { if ((crypto_drivers[hid].cc_flags & CRYPTOCAP_F_SOFTWARE) && cryptodevallowsoft == 0) @@ -468,6 +474,7 @@ crypto_kinvoke(struct cryptkop *krp) if (hid == crypto_drivers_num) { krp->krp_status = ENODEV; crypto_kdone(krp); + splx(s); return (0); } @@ -480,6 +487,7 @@ crypto_kinvoke(struct cryptkop *krp) krp->krp_status = error; crypto_kdone(krp); } + splx(s); return (0); } @@ -493,14 +501,17 @@ crypto_invoke(struct cryptop *crp) u_int64_t nid; u_int32_t hid; int error; + int s; /* Sanity checks. */ if (crp == NULL || crp->crp_callback == NULL) return EINVAL; + s = splvm(); if (crp->crp_desc == NULL || crypto_drivers == NULL) { crp->crp_etype = EINVAL; crypto_done(crp); + splx(s); return 0; } @@ -532,6 +543,7 @@ crypto_invoke(struct cryptop *crp) } } + splx(s); return 0; migrate: @@ -544,6 +556,7 @@ crypto_invoke(struct cryptop *crp) crp->crp_etype = EAGAIN; crypto_done(crp); + splx(s); return 0; } diff --git a/sys/crypto/cryptodev.h b/sys/crypto/cryptodev.h index 58a3eeabb64..6616a718d58 100644 --- a/sys/crypto/cryptodev.h +++ b/sys/crypto/cryptodev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptodev.h,v 1.45 2007/05/27 05:33:47 tedu Exp $ */ +/* $OpenBSD: cryptodev.h,v 1.46 2007/11/28 13:52:23 tedu Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) @@ -171,7 +171,6 @@ struct cryptop { int (*crp_callback)(struct cryptop *); /* Callback function */ - struct cryptop *crp_next; caddr_t crp_mac; }; @@ -218,7 +217,6 @@ struct cryptkop { u_int32_t krp_hid; struct crparam krp_param[CRK_MAXPARAM]; /* kvm */ int (*krp_callback)(struct cryptkop *); - struct cryptkop *krp_next; }; /* Crypto capabilities structure */ |