Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/opencrypto rename crypto_mtx to cryptodev_mtx



details:   https://anonhg.NetBSD.org/src/rev/7a4f01cd7cba
branches:  trunk
changeset: 824345:7a4f01cd7cba
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Fri Jun 02 09:46:57 2017 +0000

description:
rename crypto_mtx to cryptodev_mtx

It is used by cryptodev.c and ocryptodev.c only.

diffstat:

 sys/opencrypto/cryptodev.c          |  158 ++++++++++++++++++------------------
 sys/opencrypto/cryptodev_internal.h |    4 +-
 sys/opencrypto/ocryptodev.c         |    8 +-
 3 files changed, 85 insertions(+), 85 deletions(-)

diffs (truncated from 605 to 300 lines):

diff -r 930643db6deb -r 7a4f01cd7cba sys/opencrypto/cryptodev.c
--- a/sys/opencrypto/cryptodev.c        Fri Jun 02 08:16:52 2017 +0000
+++ b/sys/opencrypto/cryptodev.c        Fri Jun 02 09:46:57 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cryptodev.c,v 1.91 2017/05/25 05:24:57 knakahara Exp $ */
+/*     $NetBSD: cryptodev.c,v 1.92 2017/06/02 09:46:57 knakahara Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $        */
 /*     $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $   */
 
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.91 2017/05/25 05:24:57 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.92 2017/06/02 09:46:57 knakahara Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -98,7 +98,7 @@
 
 #include "ioconf.h"
 
-kmutex_t crypto_mtx;
+kmutex_t cryptodev_mtx;
 
 struct csession {
        TAILQ_ENTRY(csession) next;
@@ -247,16 +247,16 @@
        struct fcrypt *criofcr;
        int criofd;
 
-       mutex_enter(&crypto_mtx);
+       mutex_enter(&cryptodev_mtx);
        getnanotime(&fcr->atime);
-       mutex_exit(&crypto_mtx);
+       mutex_exit(&cryptodev_mtx);
 
        switch (cmd) {
         case CRIOGET:   /* XXX deprecated, remove after 5.0 */
                if ((error = fd_allocfile(&criofp, &criofd)) != 0)
                        return error;
                criofcr = pool_get(&fcrpl, PR_WAITOK);
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
                TAILQ_INIT(&criofcr->csessions);
                TAILQ_INIT(&criofcr->crp_ret_mq);
                TAILQ_INIT(&criofcr->crp_ret_mkq);
@@ -269,7 +269,7 @@
                criofcr->sesn = 1;
                criofcr->requestid = 1;
                crypto_refcount++;
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                (void)fd_clone(criofp, criofd, (FREAD|FWRITE),
                              &cryptofops, criofcr);
                *(u_int32_t *)data = criofd;
@@ -289,9 +289,9 @@
                        goto mbail;
                }
 
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
                fcr->mtime = fcr->atime;
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                error = cryptodev_msession(fcr, snop, sgop->count);
                if (error) {
                        goto mbail;
@@ -303,22 +303,22 @@
                kmem_free(snop, sgop->count * sizeof(struct session_n_op));
                break;
        case CIOCFSESSION:
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
                fcr->mtime = fcr->atime;
                ses = *(u_int32_t *)data;
                cse = csefind(fcr, ses);
                if (cse == NULL) {
-                       mutex_exit(&crypto_mtx);
+                       mutex_exit(&cryptodev_mtx);
                        return EINVAL;
                }
                csedelete(fcr, cse);
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                error = csefree(cse);
                break;
        case CIOCNFSESSION:
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
                fcr->mtime = fcr->atime;
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                sfop = (struct crypt_sfop *)data;
                sesid = kmem_alloc((sfop->count * sizeof(u_int32_t)), 
                    KM_SLEEP);
@@ -330,11 +330,11 @@
                kmem_free(sesid, (sfop->count * sizeof(u_int32_t)));
                break;
        case CIOCCRYPT:
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
                fcr->mtime = fcr->atime;
                cop = (struct crypt_op *)data;
                cse = csefind(fcr, cop->ses);
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                if (cse == NULL) {
                        DPRINTF("csefind failed\n");
                        return EINVAL;
@@ -343,9 +343,9 @@
                DPRINTF("cryptodev_op error = %d\n", error);
                break;
        case CIOCNCRYPTM:
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
                fcr->mtime = fcr->atime;
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                mop = (struct crypt_mop *)data;
                cnop = kmem_alloc((mop->count * sizeof(struct crypt_n_op)),
                    KM_SLEEP);
@@ -365,9 +365,9 @@
                DPRINTF("cryptodev_key error = %d\n", error);
                break;
        case CIOCNFKEYM:
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
                fcr->mtime = fcr->atime;
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                mkop = (struct crypt_mkop *)data;
                knop = kmem_alloc((mkop->count * sizeof(struct crypt_n_kop)),
                    KM_SLEEP);
@@ -385,9 +385,9 @@
                error = crypto_getfeat((int *)data);
                break;
        case CIOCNCRYPTRETM:
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
                fcr->mtime = fcr->atime;
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                crypt_ret = (struct cryptret *)data;
                count = crypt_ret->count;
                crypt_res = kmem_alloc((count * sizeof(struct crypt_result)),  
@@ -632,7 +632,7 @@
         * XXX splcrypto() but needed to only if CRYPTO_F_CBIMM,
         * XXX disabled on NetBSD since 1.6O due to a race condition.
         * XXX But crypto_dispatch went to splcrypto() itself!  (And
-        * XXX now takes the crypto_mtx mutex itself).  We do, however,
+        * XXX now takes the cryptodev_mtx mutex itself).  We do, however,
         * XXX need to hold the mutex across the call to cv_wait().
         * XXX     (should we arrange for crypto_dispatch to return to
         * XXX      us with it held?  it seems quite ugly to do so.)
@@ -641,7 +641,7 @@
 eagain:
 #endif
        error = crypto_dispatch(crp);
-       mutex_enter(&crypto_mtx);
+       mutex_enter(&cryptodev_mtx);
 
        /* 
         * Don't touch crp before returned by any error or recieved
@@ -651,7 +651,7 @@
        switch (error) {
 #ifdef notyet  /* don't loop forever -- but EAGAIN not possible here yet */
        case EAGAIN:
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                goto eagain;
                break;
 #endif
@@ -659,7 +659,7 @@
                break;
        default:
                DPRINTF("not waiting, error.\n");
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                cv_destroy(&crp->crp_cv);
                goto bail;
        }
@@ -667,9 +667,9 @@
        while (!(crp->crp_flags & CRYPTO_F_DQRETQ)) {
                DPRINTF("cse->sid[%d]: sleeping on cv %p for crp %p\n",
                        (uint32_t)cse->sid, &crp->crp_cv, crp);
-               cv_wait(&crp->crp_cv, &crypto_mtx);     /* XXX cv_wait_sig? */
+               cv_wait(&crp->crp_cv, &cryptodev_mtx);  /* XXX cv_wait_sig? */
        }
-       mutex_exit(&crypto_mtx);
+       mutex_exit(&cryptodev_mtx);
        cv_destroy(&crp->crp_cv);
 
        if (crp->crp_etype != 0) {
@@ -729,19 +729,19 @@
        struct csession *cse = (struct csession *)crp->crp_opaque;
        int error = 0;
 
-       mutex_enter(&crypto_mtx);
+       mutex_enter(&cryptodev_mtx);
        cse->error = crp->crp_etype;
        if (crp->crp_etype == EAGAIN) {
                /* always drop mutex to call dispatch routine */
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                error = crypto_dispatch(crp);
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
        }
        if (error != 0 || (crp->crp_flags & CRYPTO_F_DONE)) {
                crp->crp_flags |= CRYPTO_F_DQRETQ;
                cv_signal(&crp->crp_cv);
        }
-       mutex_exit(&crypto_mtx);
+       mutex_exit(&cryptodev_mtx);
        return 0;
 }
 
@@ -752,12 +752,12 @@
        struct csession *cse = (struct csession *)crp->crp_opaque;
        int  error=0;
 
-       mutex_enter(&crypto_mtx);
+       mutex_enter(&cryptodev_mtx);
        cse->error = crp->crp_etype;
        if (crp->crp_etype == EAGAIN) {
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                error = crypto_dispatch(crp);
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
        }
        if (error != 0 || (crp->crp_flags & CRYPTO_F_DONE)) {
                cv_signal(&crp->crp_cv);
@@ -765,7 +765,7 @@
 
        TAILQ_INSERT_TAIL(&crp->fcrp->crp_ret_mq, crp, crp_next);
        selnotify(&crp->fcrp->sinfo, 0, 0);
-       mutex_exit(&crypto_mtx);
+       mutex_exit(&cryptodev_mtx);
        return 0;
 }
 
@@ -774,10 +774,10 @@
 {
        struct cryptkop *krp = op;
        
-       mutex_enter(&crypto_mtx);
+       mutex_enter(&cryptodev_mtx);
        krp->krp_flags |= CRYPTO_F_DQRETQ;
        cv_signal(&krp->krp_cv);
-       mutex_exit(&crypto_mtx);
+       mutex_exit(&cryptodev_mtx);
        return 0;
 }
 
@@ -786,11 +786,11 @@
 {
        struct cryptkop *krp = op;
 
-       mutex_enter(&crypto_mtx);
+       mutex_enter(&cryptodev_mtx);
        cv_signal(&krp->krp_cv);
        TAILQ_INSERT_TAIL(&krp->fcrp->crp_ret_mkq, krp, krp_next);
        selnotify(&krp->fcrp->sinfo, 0, 0);
-       mutex_exit(&crypto_mtx);
+       mutex_exit(&cryptodev_mtx);
        return 0;
 }
 
@@ -889,11 +889,11 @@
                goto fail;
        }
 
-       mutex_enter(&crypto_mtx);
+       mutex_enter(&cryptodev_mtx);
        while (!(krp->krp_flags & CRYPTO_F_DQRETQ)) {
-               cv_wait(&krp->krp_cv, &crypto_mtx);     /* XXX cv_wait_sig? */
+               cv_wait(&krp->krp_cv, &cryptodev_mtx);  /* XXX cv_wait_sig? */
        }
-       mutex_exit(&crypto_mtx);
+       mutex_exit(&cryptodev_mtx);
 
        if (krp->krp_status != 0) {
                DPRINTF("krp->krp_status 0x%08x\n", krp->krp_status);
@@ -939,17 +939,17 @@
        struct fcrypt *fcr = fp->f_fcrypt;
        struct csession *cse;
 
-       mutex_enter(&crypto_mtx);
+       mutex_enter(&cryptodev_mtx);
        while ((cse = TAILQ_FIRST(&fcr->csessions))) {
                TAILQ_REMOVE(&fcr->csessions, cse, next);
-               mutex_exit(&crypto_mtx);
+               mutex_exit(&cryptodev_mtx);
                (void)csefree(cse);
-               mutex_enter(&crypto_mtx);
+               mutex_enter(&cryptodev_mtx);
        }
        seldestroy(&fcr->sinfo);



Home | Main Index | Thread Index | Old Index