Source-Changes-HG archive

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

[src/pgoyette-localcount]: src/sys/arch Adapt the machine/arch dependent code...



details:   https://anonhg.NetBSD.org/src/rev/4547938144c5
branches:  pgoyette-localcount
changeset: 852826:4547938144c5
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Jul 20 23:50:53 2016 +0000

description:
Adapt the machine/arch dependent code to the new {b,c}devsw reference
counting.

XXX Most of these will require testing by someone other than myself, as
I have a limited selection of hardware!

diffstat:

 sys/arch/acorn32/mainbus/fd.c      |  18 +++++++++++++-----
 sys/arch/alpha/alpha/machdep.c     |  23 ++++++++++++++++-------
 sys/arch/amd64/amd64/machdep.c     |  36 ++++++++++++++++++++++++++----------
 sys/arch/amiga/amiga/machdep.c     |  19 ++++++++++++++-----
 sys/arch/amiga/dev/ser.c           |  10 +++++++---
 sys/arch/arm/arm32/stubs.c         |  23 +++++++++++++++--------
 sys/arch/atari/atari/autoconf.c    |  20 +++++++++++++-------
 sys/arch/atari/atari/machdep.c     |   9 ++++++---
 sys/arch/atari/dev/md_root.c       |   8 +++++---
 sys/arch/cesfic/cesfic/machdep.c   |  29 +++++++++++++++++++----------
 sys/arch/hp300/dev/dcm.c           |  10 +++++++---
 sys/arch/hp300/hp300/machdep.c     |  26 +++++++++++++++++---------
 sys/arch/hppa/hppa/machdep.c       |  16 +++++++++++-----
 sys/arch/i386/i386/dumpsys.c       |  36 ++++++++++++++++++++++++++----------
 sys/arch/luna68k/luna68k/machdep.c |  18 ++++++++++++++----
 sys/arch/mac68k/dev/zs_kgdb.c      |  12 +++++++++---
 sys/arch/mac68k/mac68k/machdep.c   |  18 ++++++++++++++----
 sys/arch/mips/mips/mips_machdep.c  |  23 ++++++++++++++++-------
 sys/arch/mipsco/obio/zs_kgdb.c     |  12 +++++++++---
 sys/arch/mvme68k/mvme68k/machdep.c |  15 +++++++++++----
 sys/arch/news68k/news68k/machdep.c |  20 +++++++++++++++-----
 sys/arch/next68k/dev/zs_kgdb.c     |  12 +++++++++---
 sys/arch/next68k/next68k/machdep.c |  17 +++++++++++++----
 sys/arch/sgimips/dev/zs_kgdb.c     |  11 ++++++++---
 sys/arch/sparc/dev/zs_kgdb.c       |  11 ++++++++---
 sys/arch/sparc/sparc/machdep.c     |  15 +++++++++++----
 sys/arch/sparc64/sparc64/machdep.c |  16 ++++++++++++----
 sys/arch/sun2/dev/consinit.c       |  12 +++++++++---
 sys/arch/sun2/dev/zs_kgdb.c        |  12 +++++++++---
 sys/arch/sun2/sun2/machdep.c       |  15 ++++++++++-----
 sys/arch/sun3/dev/zs_kgdb.c        |  12 +++++++++---
 sys/arch/sun3/sun3/machdep.c       |  16 ++++++++++++----
 sys/arch/sun3/sun3x/machdep.c      |  16 ++++++++++++----
 sys/arch/vax/vax/machdep.c         |   8 +++++---
 sys/arch/x68k/x68k/machdep.c       |  18 ++++++++++++++----
 sys/arch/xen/xen/xbdback_xenbus.c  |  16 ++++++++++++----
 36 files changed, 436 insertions(+), 172 deletions(-)

diffs (truncated from 2332 to 300 lines):

diff -r 24c0bdc5f89f -r 4547938144c5 sys/arch/acorn32/mainbus/fd.c
--- a/sys/arch/acorn32/mainbus/fd.c     Wed Jul 20 23:47:55 2016 +0000
+++ b/sys/arch/acorn32/mainbus/fd.c     Wed Jul 20 23:50:53 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.58.2.2 2016/07/20 02:06:15 pgoyette Exp $     */
+/*     $NetBSD: fd.c,v 1.58.2.3 2016/07/20 23:50:53 pgoyette Exp $     */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.58.2.2 2016/07/20 02:06:15 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.58.2.3 2016/07/20 23:50:53 pgoyette Exp $");
 
 #include "opt_ddb.h"
 
@@ -1543,18 +1543,24 @@
        int s;
        int type;
        int floppysize;
+       const struct bdevsw *bdev;
 
-       if (bdevsw_lookup(dev) != &fd_bdevsw)
+       if ((bdev = bdevsw_lookup_acquire(dev)) != &fd_bdevsw) {
+               bdevsw_release(bdev);
                return(EINVAL);
+       }
 
-       if (md->md_type == MD_UNCONFIGURED || md->md_addr == 0)
+       if (md->md_type == MD_UNCONFIGURED || md->md_addr == 0) {
+               bdevsw_release(bdev);
                return(EBUSY);
+       }
 
        type = FDTYPE(dev) - 1;
        if (type < 0) type = 0;
        floppysize = fd_types[type].size << (fd_types[type].secsize + 7);
         
        if (md->md_size < floppysize) {
+               bdevsw_release(bdev);
                printf("Memory disc is not big enough for floppy image\n");
                return(EINVAL);
        }
@@ -1575,8 +1581,9 @@
 
        if (fdopen(bp->b_dev, 0, 0, curlwp) != 0) {
                brelse(bp, 0);          
+               bdevsw_release(bdev);
                printf("Cannot open floppy device\n");
-                       return(EINVAL);
+               return(EINVAL);
        }
 
        for (loop = 0;
@@ -1606,5 +1613,6 @@
        brelse(bp, 0);
 
        splx(s);
+       bdevsw_release(bdev);
        return(0);
 }
diff -r 24c0bdc5f89f -r 4547938144c5 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c    Wed Jul 20 23:47:55 2016 +0000
+++ b/sys/arch/alpha/alpha/machdep.c    Wed Jul 20 23:50:53 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.346 2014/10/17 18:14:42 uebayasi Exp $ */
+/* $NetBSD: machdep.c,v 1.346.4.1 2016/07/20 23:50:53 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.346 2014/10/17 18:14:42 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.346.4.1 2016/07/20 23:50:53 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1116,9 +1116,9 @@
        cpu_kcore_hdr_t *cpuhdrp;
        phys_ram_seg_t *memsegp;
        const struct bdevsw *bdev;
-       int i;
+       int i, error;
 
-       bdev = bdevsw_lookup(dumpdev);
+       bdev = bdevsw_lookup_acquire(dumpdev);
        if (bdev == NULL)
                return (ENXIO);
        dump = bdev->d_dump;
@@ -1150,7 +1150,9 @@
                memsegp[i].size = mem_clusters[i].size & ~PAGE_MASK;
        }
 
-       return (dump(dumpdev, dumplo, (void *)buf, dbtob(1)));
+       error = (dump(dumpdev, dumplo, (void *)buf, dbtob(1)));
+       bdevsw_release(bdev);
+       return error;
 }
 
 /*
@@ -1213,9 +1215,13 @@
 
        if (dumpdev == NODEV)
                return;
-       bdev = bdevsw_lookup(dumpdev);
-       if (bdev == NULL || bdev->d_psize == NULL)
+       bdev = bdevsw_lookup_acquire(dumpdev);
+       if (bdev == NULL)
                return;
+       if (bdev->d_psize == NULL) {
+               bdevsw_release(bdev);
+               return;
+       }
 
        /*
         * For dumps during autoconfiguration,
@@ -1224,6 +1230,7 @@
        if (dumpsize == 0)
                cpu_dumpconf();
        if (dumplo <= 0) {
+               bdevsw_release(bdev);
                printf("\ndump to dev %u,%u not possible\n",
                    major(dumpdev), minor(dumpdev));
                return;
@@ -1234,6 +1241,7 @@
        psize = bdev_size(dumpdev);
        printf("dump ");
        if (psize == -1) {
+               bdevsw_release(bdev);
                printf("area unavailable\n");
                return;
        }
@@ -1276,6 +1284,7 @@
        }
 
 err:
+       bdevsw_release(bdev);
        switch (error) {
 
        case ENXIO:
diff -r 24c0bdc5f89f -r 4547938144c5 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Wed Jul 20 23:47:55 2016 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Wed Jul 20 23:50:53 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.223 2016/07/13 15:53:26 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.223.2.1 2016/07/20 23:50:53 pgoyette Exp $       */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223 2016/07/13 15:53:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223.2.1 2016/07/20 23:50:53 pgoyette Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -937,12 +937,13 @@
        size_t to_write;
        int error;
 
-       bdev = bdevsw_lookup(dumpdev);
+       bdev = bdevsw_lookup_acquire(dumpdev);
        to_write = roundup(dump_headerbuf_ptr - dump_headerbuf, dbtob(1));
        error = bdev->d_dump(dumpdev, dump_header_blkno,
            dump_headerbuf, to_write);
        dump_header_blkno += btodb(to_write);
        dump_headerbuf_ptr = dump_headerbuf;
+       bdevsw_release(bdev);
        return error;
 }
 
@@ -1031,8 +1032,9 @@
        kcore_seg_t seg;
        cpu_kcore_hdr_t cpuhdr;
        const struct bdevsw *bdev;
+       int err;
 
-       bdev = bdevsw_lookup(dumpdev);
+       bdev = bdevsw_lookup_acquire(dumpdev);
        if (bdev == NULL)
                return (ENXIO);
 
@@ -1053,7 +1055,9 @@
        /*
         * Write out the memory segment descriptors.
         */
-       return dump_seg_iter(dump_header_addseg);
+       err = dump_seg_iter(dump_header_addseg);
+       bdevsw_release(bdev);
+       return err;
 }
 
 /*
@@ -1083,7 +1087,7 @@
 
        if (dumpdev == NODEV)
                return ENODEV;
-       bdev = bdevsw_lookup(dumpdev);
+       bdev = bdevsw_lookup_acquire(dumpdev);
        if (bdev == NULL || bdev->d_psize == NULL)
                return ENODEV;
 
@@ -1108,19 +1112,24 @@
 
                error = (*dump)(dumpdev, blkno, (void *)dumpspace, n);
                pmap_kremove_local(dumpspace, n);
-               if (error)
+               if (error) {
+                       bdevsw_release(bdev);
                        return error;
+               }
                maddr += n;
                blkno += btodb(n);              /* XXX? */
 
 #if 0  /* XXX this doesn't work.  grr. */
                /* operator aborting dump? */
-               if (sget() != NULL)
+               if (sget() != NULL) {
+                       bdevsw_release(bdev);
                        return EINTR;
+               }
 #endif
        }
        dump_header_blkno = blkno;
 
+       bdevsw_release(bdev);
        return 0;
 }
 
@@ -1134,9 +1143,13 @@
        if (dumpdev == NODEV)
                return;
 
-       bdev = bdevsw_lookup(dumpdev);
-       if (bdev == NULL || bdev->d_psize == NULL)
+       bdev = bdevsw_lookup_acquire(dumpdev);
+       if (bdev == NULL)
                return;
+       if (bdev->d_psize == NULL) {
+               bdevsw_release(bdev);
+               return;
+       }
        /*
         * For dumps during autoconfiguration,
         * if dump device has already configured...
@@ -1149,6 +1162,7 @@
            (unsigned long long)minor(dumpdev), dumplo, dumpsize);
 
        if (dumplo <= 0 || dumpsize <= 0) {
+               bdevsw_release(bdev);
                printf(" not possible\n");
                return;
        }
@@ -1156,6 +1170,7 @@
        psize = bdev_size(dumpdev);
        printf("\ndump ");
        if (psize == -1) {
+               bdevsw_release(bdev);
                printf("area unavailable\n");
                return;
        }
@@ -1228,6 +1243,7 @@
                break;
        }
 failed:
+       bdevsw_release(bdev);
        printf("\n\n");
        delay(5000000);         /* 5 seconds */
 }
diff -r 24c0bdc5f89f -r 4547938144c5 sys/arch/amiga/amiga/machdep.c
--- a/sys/arch/amiga/amiga/machdep.c    Wed Jul 20 23:47:55 2016 +0000
+++ b/sys/arch/amiga/amiga/machdep.c    Wed Jul 20 23:50:53 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.246 2016/04/02 08:16:54 mlelstv Exp $    */
+/*     $NetBSD: machdep.c,v 1.246.2.1 2016/07/20 23:50:53 pgoyette Exp $       */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -50,7 +50,7 @@
 #include "empm.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.246 2016/04/02 08:16:54 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.246.2.1 2016/07/20 23:50:53 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -467,6 +467,7 @@
        int nblks;
        int i;
        extern int end[];
+       const struct bdevsw *bdev;
 
        memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr));



Home | Main Index | Thread Index | Old Index