Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/dev Faster error handling for iommu_dmamap_...



details:   https://anonhg.NetBSD.org/src/rev/80918c45a55f
branches:  trunk
changeset: 502972:80918c45a55f
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Jan 28 01:26:57 2001 +0000

description:
Faster error handling for iommu_dmamap_load_raw; avoid loading the map
and unloading on error when we clearly can't get out without an error.

diffstat:

 sys/arch/sparc64/dev/iommu.c |  9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diffs (30 lines):

diff -r 4bf1ae7826c4 -r 80918c45a55f sys/arch/sparc64/dev/iommu.c
--- a/sys/arch/sparc64/dev/iommu.c      Sun Jan 28 00:59:27 2001 +0000
+++ b/sys/arch/sparc64/dev/iommu.c      Sun Jan 28 01:26:57 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iommu.c,v 1.28 2001/01/27 03:40:39 eeh Exp $   */
+/*     $NetBSD: iommu.c,v 1.29 2001/01/28 01:26:57 martin Exp $        */
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -693,6 +693,11 @@
                 * load each segment individually.
                 */
 
+               /* We'll never end up with less segments than we got as input.
+                  this gives us a chance to fail quickly */
+               if (nsegs > map->_dm_segcnt)
+                       return (E2BIG);
+
                i = 0;
                dvmaddr += (segs[i].ds_addr & PGOFSET);
                map->dm_segs[i].ds_addr = dvmaddr;
@@ -737,6 +742,8 @@
                }
                map->dm_nsegs = i;
 
+               /* bail out if we created more segments than the dmamap is
+                  allowed to carry */
                if (i > map->_dm_segcnt) {
                        iommu_dvmamap_unload(t, is, map);
                        return (E2BIG);



Home | Main Index | Thread Index | Old Index