tech-kern archive

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

rbus size and end confuse



Hi! all,


I think, rbus is confusing 'size' and 'end'.  rbus uses 'end' to extent
functions.  man extent(9) describes

  extent_create() creates an extent map managing the space from start to
  end inclusive.

However some functions assumes 'end' is not inclusive.

for example, see attahed patch.

Thanks,
--
kiyohara
Index: arch/sparc64/sparc64/rbus_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/rbus_machdep.c,v
retrieving revision 1.16
diff -u -r1.16 rbus_machdep.c
--- arch/sparc64/sparc64/rbus_machdep.c 1 Jul 2011 18:49:24 -0000       1.16
+++ arch/sparc64/sparc64/rbus_machdep.c 9 Apr 2012 15:04:48 -0000
@@ -90,7 +90,7 @@
                panic("rbus_pccbb_parent_mem: extent is not initialized");
 
        start = ex->ex_start;
-       size = ex->ex_end - start;
+       size = ex->ex_end - start + 1;
 
        return rbus_new_root_share(pa->pa_memt, ex, start, size, 0);
 }
@@ -108,7 +108,7 @@
                panic("rbus_pccbb_parent_io: extent is not initialized");
 
        start = ex->ex_start;
-       size = ex->ex_end - start;
+       size = ex->ex_end - start + 1;
 
        return rbus_new_root_share(pa->pa_iot, ex, start, size, 0);
 }
Index: dev/cardbus/rbus.c
===================================================================
RCS file: /cvsroot/src/sys/dev/cardbus/rbus.c,v
retrieving revision 1.29
diff -u -r1.29 rbus.c
--- dev/cardbus/rbus.c  27 Jan 2012 18:53:07 -0000      1.29
+++ dev/cardbus/rbus.c  9 Apr 2012 15:04:48 -0000
@@ -253,7 +253,7 @@
 {
        rbus_tag_t rb;
        struct extent *ex = NULL;
-       bus_addr_t end = start + size;
+       bus_addr_t end = start + size - 1;
 
        if (flags == RBUS_SPACE_SHARE) {
                ex = parent->rb_ext;
@@ -269,7 +269,7 @@
                return 0;
        }
 
-       rb = rbus_new_body(parent->rb_bt, parent, ex, start, start + size,
+       rb = rbus_new_body(parent->rb_bt, parent, ex, start, end,
            offset, flags);
 
        if ((rb == NULL) && (flags == RBUS_SPACE_DEDICATE)) {
@@ -293,13 +293,14 @@
 {
        rbus_tag_t rb;
        struct extent *ex;
+       bus_addr_t end = start + size - 1;
 
-       if (NULL == (ex = extent_create("rbus root", start, start + size,
+       if (NULL == (ex = extent_create("rbus root", start, end,
            NULL, 0, EX_NOCOALESCE|EX_NOWAIT))) {
                return NULL;
        }
 
-       rb = rbus_new_body(bt, NULL, ex, start, start + size, offset,
+       rb = rbus_new_body(bt, NULL, ex, start, end, offset,
            RBUS_SPACE_DEDICATE);
 
        if (rb == NULL) {
@@ -320,17 +321,19 @@
 rbus_tag_t
 rbus_new_root_share(bus_space_tag_t bt, struct extent *ex, bus_addr_t start, 
bus_size_t size, bus_addr_t offset)
 {
+       bus_addr_t end = start + size - 1;
+
        /* sanity check */
-       if (start < ex->ex_start || start + size > ex->ex_end) {
+       if (start < ex->ex_start || end > ex->ex_end) {
                /*
-                * out of range: [start, size] should be contained in
+                * out of range: [start, end] should be contained in
                 * parent space
                 */
                return 0;
                /* Should I invoke panic? */
        }
 
-       return rbus_new_body(bt, NULL, ex, start, start + size, offset,
+       return rbus_new_body(bt, NULL, ex, start, end, offset,
            RBUS_SPACE_SHARE);
 }
 


Home | Main Index | Thread Index | Old Index