]> git.lizzy.rs Git - plan9front.git/commitdiff
kernel: get rid of unused ucallocb
authorcinap_lenrek <cinap_lenrek@felloff.net>
Fri, 9 Oct 2020 20:05:32 +0000 (22:05 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Fri, 9 Oct 2020 20:05:32 +0000 (22:05 +0200)
the whole idea of a ucallocb() is bad, as even access to the
metadata header would be in uncached memory. also, it tuns out
that it was never used by anyone.

sys/src/9/kw/fns.h
sys/src/9/omap/beagle
sys/src/9/omap/fns.h
sys/src/9/omap/ucallocb.c [deleted file]
sys/src/9/port/ucallocb.c [deleted file]
sys/src/9/teg2/fns.h
sys/src/9/teg2/ts

index 50c6ea014ca84562b0f881e5df93e4ed70b3220a..f74e993cc6f92a96ee9e5927f268f6bf1b84d862 100644 (file)
@@ -110,10 +110,7 @@ uintptr mmukunmap(uintptr, uintptr, usize);
 extern void* mmuuncache(void*, usize);
 extern void* ucalloc(usize);
 extern void* ucallocalign(usize size, int align, usize span);
-extern Block* ucallocb(int);
 extern void ucfree(void*);
-extern void ucfreeb(Block*);
-extern Block* uciallocb(int);
 
 /*
  * Things called from port.
index 6b5d94a2b1a22583cb1429c92c7c9a5edc69702d..99b69005f4e2d6a58014052a5c4a5faadae325c2 100644 (file)
@@ -64,7 +64,6 @@ misc
        softfpu
        uarti8250
        ucalloc
-       ucallocb
 
 port
        int cpuserver = 1;
index 68a9298263817f66ed11fcf7907a80a5a80f421e..f52a2fa60f4a0ba82b6b5165a3f90f35957942ee 100644 (file)
@@ -125,10 +125,8 @@ uintptr mmukmap(uintptr, uintptr, usize);
 uintptr mmukunmap(uintptr, uintptr, usize);
 extern void* mmuuncache(void*, usize);
 extern void* ucalloc(usize);
-extern Block* ucallocb(int);
 extern void* ucallocalign(usize size, int align, int span);
 extern void ucfree(void*);
-extern void ucfreeb(Block*);
 
 /*
  * Things called from port.
diff --git a/sys/src/9/omap/ucallocb.c b/sys/src/9/omap/ucallocb.c
deleted file mode 100644 (file)
index 93a07d3..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * allocate Blocks from uncached memory
- */
-#include       "u.h"
-#include       "../port/lib.h"
-#include       "mem.h"
-#include       "dat.h"
-#include       "fns.h"
-#include       "error.h"
-
-enum
-{
-       Hdrspc          = 64,           /* leave room for high-level headers */
-       Bdead           = 0x51494F42,   /* "QIOB" */
-};
-
-struct
-{
-       Lock;
-       ulong   bytes;
-} ucialloc;
-
-static Block*
-_ucallocb(int size)
-{
-       Block *b;
-       ulong addr;
-
-       if((b = ucalloc(sizeof(Block)+size+Hdrspc)) == nil)
-               return nil;
-
-       b->next = nil;
-       b->list = nil;
-       b->free = 0;
-       b->flag = 0;
-
-       /* align start of data portion by rounding up */
-       addr = (ulong)b;
-       addr = ROUND(addr + sizeof(Block), BLOCKALIGN);
-       b->base = (uchar*)addr;
-
-       /* align end of data portion by rounding down */
-       b->lim = ((uchar*)b) + msize(b);
-       addr = (ulong)(b->lim);
-       addr = addr & ~(BLOCKALIGN-1);
-       b->lim = (uchar*)addr;
-
-       /* leave sluff at beginning for added headers */
-       b->rp = b->lim - ROUND(size, BLOCKALIGN);
-       if(b->rp < b->base)
-               panic("_ucallocb");
-       b->wp = b->rp;
-
-       return b;
-}
-
-Block*
-ucallocb(int size)
-{
-       Block *b;
-
-       /*
-        * Check in a process and wait until successful.
-        * Can still error out of here, though.
-        */
-       if(up == nil)
-               panic("ucallocb without up: %#p", getcallerpc(&size));
-       if((b = _ucallocb(size)) == nil)
-               panic("ucallocb: no memory for %d bytes", size);
-       setmalloctag(b, getcallerpc(&size));
-
-       return b;
-}
-
-Block*
-uciallocb(int size)
-{
-       Block *b;
-       static int m1, m2, mp;
-
-       if(0 && ucialloc.bytes > conf.ialloc){
-               if((m1++%10000)==0){
-                       if(mp++ > 1000){
-                               active.exiting = 1;
-                               exit(0);
-                       }
-                       iprint("uciallocb: limited %lud/%lud\n",
-                               ucialloc.bytes, conf.ialloc);
-               }
-               return nil;
-       }
-
-       if((b = _ucallocb(size)) == nil){
-               if(0 && (m2++%10000)==0){
-                       if(mp++ > 1000){
-                               active.exiting = 1;
-                               exit(0);
-                       }
-                       iprint("uciallocb: no memory %lud/%lud\n",
-                               ucialloc.bytes, conf.ialloc);
-               }
-               return nil;
-       }
-       setmalloctag(b, getcallerpc(&size));
-       b->flag = BINTR;
-
-       ilock(&ucialloc);
-       ucialloc.bytes += b->lim - b->base;
-       iunlock(&ucialloc);
-
-       return b;
-}
-
-void
-ucfreeb(Block *b)
-{
-       void *dead = (void*)Bdead;
-
-       if(b == nil)
-               return;
-
-       /*
-        * drivers which perform non cache coherent DMA manage their own buffer
-        * pool of uncached buffers and provide their own free routine.
-        */
-       if(b->free) {
-               b->free(b);
-               return;
-       }
-       if(b->flag & BINTR) {
-               ilock(&ucialloc);
-               ucialloc.bytes -= b->lim - b->base;
-               iunlock(&ucialloc);
-       }
-
-       /* poison the block in case someone is still holding onto it */
-       b->next = dead;
-       b->rp = dead;
-       b->wp = dead;
-       b->lim = dead;
-       b->base = dead;
-
-       ucfree(b);
-}
diff --git a/sys/src/9/port/ucallocb.c b/sys/src/9/port/ucallocb.c
deleted file mode 100644 (file)
index 410aa62..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * allocate Blocks from uncached memory
- */
-#include       "u.h"
-#include       "../port/lib.h"
-#include       "mem.h"
-#include       "dat.h"
-#include       "fns.h"
-#include       "error.h"
-
-enum
-{
-       Hdrspc          = 64,           /* leave room for high-level headers */
-       Bdead           = 0x51494F42,   /* "QIOB" */
-};
-
-struct
-{
-       Lock;
-       ulong   bytes;
-} ucialloc;
-
-static Block*
-_ucallocb(int size)
-{
-       Block *b;
-       uintptr addr;
-
-       if((b = ucalloc(sizeof(Block)+size+Hdrspc)) == nil)
-               return nil;
-
-       b->next = nil;
-       b->list = nil;
-       b->free = nil;
-       b->flag = 0;
-
-       /* align start of data portion by rounding up */
-       addr = (uintptr)b;
-       addr = ROUND(addr + sizeof(Block), BLOCKALIGN);
-       b->base = (uchar*)addr;
-
-       /* align end of data portion by rounding down */
-       b->lim = (uchar*)b + msize(b);
-       addr = (uintptr)b->lim;
-       addr &= ~(BLOCKALIGN-1);
-       b->lim = (uchar*)addr;
-
-       /* leave sluff at beginning for added headers */
-       b->rp = b->lim - ROUND(size, BLOCKALIGN);
-       if(b->rp < b->base)
-               panic("_ucallocb");
-       b->wp = b->rp;
-
-       return b;
-}
-
-Block*
-ucallocb(int size)
-{
-       Block *b;
-
-       /*
-        * Check in a process and wait until successful.
-        * Can still error out of here, though.
-        */
-       if(up == nil)
-               panic("ucallocb without up: %#p", getcallerpc(&size));
-       if((b = _ucallocb(size)) == nil)
-               panic("ucallocb: no memory for %d bytes", size);
-       setmalloctag(b, getcallerpc(&size));
-
-       return b;
-}
-
-Block*
-uciallocb(int size)
-{
-       Block *b;
-       static int m1, m2, mp;
-
-       if((b = _ucallocb(size)) == nil){
-               if(0 && (m2++%10000)==0){
-                       if(mp++ > 1000)
-                               panic("uciallocb: out of memory");
-                       iprint("uciallocb: no memory %lud/%lud\n",
-                               ucialloc.bytes, conf.ialloc);
-               }
-               return nil;
-       }
-       setmalloctag(b, getcallerpc(&size));
-       b->flag = BINTR;
-
-       ilock(&ucialloc);
-       ucialloc.bytes += b->lim - b->base;
-       iunlock(&ucialloc);
-
-       return b;
-}
-
-void
-ucfreeb(Block *b)
-{
-       void *dead = (void*)Bdead;
-
-       if(b == nil)
-               return;
-
-       /*
-        * drivers which perform non cache coherent DMA manage their own buffer
-        * pool of uncached buffers and provide their own free routine.
-        */
-       if(b->free != nil) {
-               b->free(b);
-               return;
-       }
-       if(b->flag & BINTR) {
-               ilock(&ucialloc);
-               ucialloc.bytes -= b->lim - b->base;
-               iunlock(&ucialloc);
-       }
-
-       /* poison the block in case someone is still holding onto it */
-       b->next = dead;
-       b->rp = dead;
-       b->wp = dead;
-       b->lim = dead;
-       b->base = dead;
-
-       ucfree(b);
-}
index 801656c0eedaa93b5894b9814fb274c6d06ada1a..0c8733a55e5e08ae5073885b54ce7a3b63a4f4b3 100644 (file)
@@ -164,10 +164,8 @@ uintptr mmukmap(uintptr, uintptr, usize);
 uintptr mmukunmap(uintptr, uintptr, usize);
 extern void* mmuuncache(void*, usize);
 extern void* ucalloc(usize);
-extern Block* ucallocb(int);
 extern void* ucallocalign(usize size, int align, int span);
 extern void ucfree(void*);
-extern void ucfreeb(Block*);
 
 /*
  * Things called from port.
index 3573a7dba3222a3c5580c7f2db9d88d440928f53..b02b790456ad3fbf82f3c9cc4469f5064b744f83 100644 (file)
@@ -66,7 +66,6 @@ misc
 #      sdaoe           sdscsi
        uarti8250
        ucalloc
-       ucallocb
 # include vfp3 to use hardware fp, otherwise include softfpu
        vfp3
 #      softfpu