Module: xenomai-forge
Branch: master
Commit: 94dc49a194d87d571d85286c21bf3925bb2ea2f1
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=94dc49a194d87d571d85286c21bf3925bb2ea2f1

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Dec 31 18:37:36 2011 +0100

cobalt, drivers: reduce wrapping to host memory allocators

Small/medium memory chunks (up to 128k) can be obtained from kmalloc()
directly, for all the architectures we support.

For the time being, we allocate potentially larger chunks from
alloc_pages_exact() through the new xnarch_alloc_pages() generic
wrapper, which gives us physically contiguous memory.

---

 include/asm-arm/system.h         |   34 ----------------------------------
 include/asm-blackfin/system.h    |   28 ----------------------------
 include/asm-generic/system.h     |   10 ++++++++++
 include/asm-nios2/system.h       |   28 ----------------------------
 include/asm-powerpc/system.h     |   34 ----------------------------------
 include/asm-sh/system.h          |   34 ----------------------------------
 include/asm-x86/system_32.h      |   32 --------------------------------
 include/asm-x86/system_64.h      |   34 ----------------------------------
 kernel/cobalt/apc.c              |    2 +-
 kernel/cobalt/mq.c               |    7 +++----
 kernel/cobalt/nucleus/pod.c      |   12 ++++++------
 kernel/cobalt/nucleus/registry.c |   15 ++++++---------
 kernel/cobalt/nucleus/shadow.c   |   14 +++++++-------
 kernel/cobalt/registry.c         |   12 ++++--------
 kernel/cobalt/rtdm/syscall.c     |    6 +++---
 kernel/cobalt/syscall.c          |    6 +++---
 kernel/drivers/ipc/bufp.c        |    6 +++---
 kernel/drivers/ipc/iddp.c        |    6 +++---
 kernel/drivers/ipc/xddp.c        |    6 +++---
 19 files changed, 52 insertions(+), 274 deletions(-)

diff --git a/include/asm-arm/system.h b/include/asm-arm/system.h
index feb4782..44be20c 100644
--- a/include/asm-arm/system.h
+++ b/include/asm-arm/system.h
@@ -206,40 +206,6 @@ static inline int xnarch_fault_fpu_p(struct 
ipipe_trap_data *d)
 
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline void *xnarch_alloc_host_mem (u_long bytes)
-{
-       if (bytes > 128*1024)
-               return vmalloc(bytes);
-
-       return kmalloc(bytes,GFP_KERNEL);
-}
-
-static inline void xnarch_free_host_mem (void *chunk, u_long bytes)
-{
-       if (bytes > 128*1024)
-               vfree(chunk);
-       else
-               kfree(chunk);
-}
-
-static inline void *xnarch_alloc_stack_mem(u_long bytes)
-{
-       return kmalloc(bytes, GFP_KERNEL);
-}
-
-static inline void xnarch_free_stack_mem(void *chunk, u_long bytes)
-{
-       kfree(chunk);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
 #else /* !__KERNEL__ */
 
 #include <nucleus/system.h>
diff --git a/include/asm-blackfin/system.h b/include/asm-blackfin/system.h
index c59be8c..757e607 100644
--- a/include/asm-blackfin/system.h
+++ b/include/asm-blackfin/system.h
@@ -85,30 +85,6 @@ typedef struct xnarchtcb {   /* Per-thread arch-dependent 
block */
 
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline void *xnarch_alloc_host_mem(u_long bytes)
-{
-       return kmalloc(bytes,GFP_KERNEL);
-}
-
-static inline void xnarch_free_host_mem(void *chunk, u_long bytes)
-{
-       kfree(chunk);
-}
-
-static inline void *xnarch_alloc_stack_mem(u_long bytes)
-{
-       return kmalloc(bytes, GFP_KERNEL);
-}
-
-static inline void xnarch_free_stack_mem(void *chunk, u_long bytes)
-{
-       kfree(chunk);
-}
-
 #define __xnarch_head_syscall_entry()                          \
        do      {                                               \
                if (xnsched_resched_p(xnpod_current_sched()))   \
@@ -117,10 +93,6 @@ static inline void xnarch_free_stack_mem(void *chunk, 
u_long bytes)
 
 #define xnarch_head_syscall_entry      __xnarch_head_syscall_entry
 
-#ifdef __cplusplus
-}
-#endif
-
 #else /* !__KERNEL__ */
 
 #include <nucleus/system.h>
diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index b5704d3..e5bc798 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -398,6 +398,16 @@ static inline int xnarch_remap_kmem_page_range(struct 
vm_area_struct *vma,
        return remap_pfn_range(vma, from, to >> PAGE_SHIFT, size, prot);
 }
 
+static inline void *xnarch_alloc_pages(size_t size)
+{
+       return alloc_pages_exact(size, GFP_KERNEL);
+}
+
+static inline void xnarch_free_pages(void *p, size_t size)
+{
+       return free_pages_exact(p, size);
+}
+
 #define xnarch_finalize_no_switch(dead_tcb) do { } while(0)
 
 #ifdef rthal_fault_range
diff --git a/include/asm-nios2/system.h b/include/asm-nios2/system.h
index a76beef..7a5d5d2 100644
--- a/include/asm-nios2/system.h
+++ b/include/asm-nios2/system.h
@@ -88,34 +88,6 @@ typedef struct xnarchtcb {   /* Per-thread arch-dependent 
block */
 
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline void *xnarch_alloc_host_mem(u_long bytes)
-{
-       return kmalloc(bytes,GFP_KERNEL);
-}
-
-static inline void xnarch_free_host_mem(void *chunk, u_long bytes)
-{
-       kfree(chunk);
-}
-
-static inline void *xnarch_alloc_stack_mem(u_long bytes)
-{
-       return kmalloc(bytes, GFP_KERNEL);
-}
-
-static inline void xnarch_free_stack_mem(void *chunk, u_long bytes)
-{
-       kfree(chunk);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
 #else /* !__KERNEL__ */
 
 #include <nucleus/system.h>
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index 1ea76f4..b549d85 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -116,40 +116,6 @@ typedef struct xnarchtcb { /* Per-thread arch-dependent 
block */
 
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline void *xnarch_alloc_host_mem(u_long bytes)
-{
-       if (bytes > 128 * 1024)
-               return vmalloc(bytes);
-
-       return kmalloc(bytes, GFP_KERNEL);
-}
-
-static inline void xnarch_free_host_mem(void *chunk, u_long bytes)
-{
-       if (bytes > 128 * 1024)
-               vfree(chunk);
-       else
-               kfree(chunk);
-}
-
-static inline void *xnarch_alloc_stack_mem(u_long bytes)
-{
-       return kmalloc(bytes, GFP_KERNEL);
-}
-
-static inline void xnarch_free_stack_mem(void *chunk, u_long bytes)
-{
-       kfree(chunk);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
 #else /* !__KERNEL__ */
 
 #include <nucleus/system.h>
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index ded3ff3..c2952da 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -84,40 +84,6 @@ typedef struct xnarchtcb {   /* Per-thread arch-dependent 
block */
                                (d)->exception == IPIPE_TRAP_BP)
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline void *xnarch_alloc_host_mem(u_long bytes)
-{
-       if (bytes > 128 * 1024)
-               return vmalloc(bytes);
-
-       return kmalloc(bytes, GFP_KERNEL);
-}
-
-static inline void xnarch_free_host_mem(void *chunk, u_long bytes)
-{
-       if (bytes > 128 * 1024)
-               vfree(chunk);
-       else
-               kfree(chunk);
-}
-
-static inline void *xnarch_alloc_stack_mem(u_long bytes)
-{
-       return kmalloc(bytes, GFP_KERNEL);
-}
-
-static inline void xnarch_free_stack_mem(void *chunk, u_long bytes)
-{
-       kfree(chunk);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
 #else /* !__KERNEL__ */
 
 #include <nucleus/system.h>
diff --git a/include/asm-x86/system_32.h b/include/asm-x86/system_32.h
index 41b51f2..491fb60 100644
--- a/include/asm-x86/system_32.h
+++ b/include/asm-x86/system_32.h
@@ -81,38 +81,6 @@ typedef struct xnarchtcb {      /* Per-thread arch-dependent 
block */
                                 ((d)->exception == 1 || (d)->exception == 3))
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline void *xnarch_alloc_host_mem(u_long bytes)
-
-{
-       if (bytes > 128*1024)
-               return vmalloc(bytes);
-
-       return kmalloc(bytes,GFP_KERNEL);
-}
-
-static inline void xnarch_free_host_mem(void *chunk, u_long bytes)
-
-{
-       if (bytes > 128*1024)
-               vfree(chunk);
-       else
-               kfree(chunk);
-}
-
-static inline void *xnarch_alloc_stack_mem(u_long bytes)
-{
-       return kmalloc(bytes, GFP_KERNEL);
-}
-
-static inline void xnarch_free_stack_mem(void *chunk, u_long bytes)
-{
-       kfree(chunk);
-}
-
 static inline int xnarch_shadow_p (xnarchtcb_t *tcb, struct task_struct *task)
 {
     return tcb->espp == &task->thread.sp;
diff --git a/include/asm-x86/system_64.h b/include/asm-x86/system_64.h
index b9dda84..6194052 100644
--- a/include/asm-x86/system_64.h
+++ b/include/asm-x86/system_64.h
@@ -89,40 +89,6 @@ typedef struct xnarchtcb {      /* Per-thread arch-dependent 
block */
                                 ((d)->exception == 1 || (d)->exception == 3))
 #define xnarch_fault_notify(d) (!xnarch_fault_bp_p(d))
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-static inline void *xnarch_alloc_host_mem(u_long bytes)
-{
-       if (bytes > 128*1024)
-               return vmalloc(bytes);
-
-       return kmalloc(bytes,GFP_KERNEL);
-}
-
-static inline void xnarch_free_host_mem(void *chunk, u_long bytes)
-{
-       if (bytes > 128*1024)
-               vfree(chunk);
-       else
-               kfree(chunk);
-}
-
-static inline void *xnarch_alloc_stack_mem(u_long bytes)
-{
-       return kmalloc(bytes, GFP_KERNEL);
-}
-
-static inline void xnarch_free_stack_mem(void *chunk, u_long bytes)
-{
-       kfree(chunk);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
 #else /* !__KERNEL__ */
 
 #include <nucleus/system.h>
diff --git a/kernel/cobalt/apc.c b/kernel/cobalt/apc.c
index fa75102..fc9121f 100644
--- a/kernel/cobalt/apc.c
+++ b/kernel/cobalt/apc.c
@@ -62,7 +62,7 @@ static void cobalt_lostage_handle_request(void *cookie)
                rq->out = (reqnum + 1) & (COBALT_LO_MAX_REQUESTS - 1);
 
                if (req->type == COBALT_LO_FREE_REQ)
-                       xnarch_free_host_mem(req->arg, req->size);
+                       xnarch_free_pages(req->arg, req->size);
        }
 }
 
diff --git a/kernel/cobalt/mq.c b/kernel/cobalt/mq.c
index 49174a7..bfd5646 100644
--- a/kernel/cobalt/mq.c
+++ b/kernel/cobalt/mq.c
@@ -115,9 +115,8 @@ static inline int cobalt_mq_init(cobalt_mq_t * mq, const 
struct mq_attr *attr)
        memsize = msgsize * attr->mq_maxmsg;
        memsize = PAGE_ALIGN(memsize);
 
-       mem = (char *)xnarch_alloc_host_mem(memsize);
-
-       if (!mem)
+       mem = xnarch_alloc_pages(memsize);
+       if (mem == NULL)
                return ENOSPC;
 
        mq->memsize = memsize;
@@ -155,7 +154,7 @@ static inline void cobalt_mq_destroy(cobalt_mq_t *mq)
        if (!xnpod_root_p())
                cobalt_schedule_lostage(COBALT_LO_FREE_REQ, mq->mem, 
mq->memsize);
        else
-               xnarch_free_host_mem(mq->mem, mq->memsize);
+               xnarch_free_pages(mq->mem, mq->memsize);
 
        if (resched)
                xnpod_schedule();
diff --git a/kernel/cobalt/nucleus/pod.c b/kernel/cobalt/nucleus/pod.c
index cd54f08..12a72af 100644
--- a/kernel/cobalt/nucleus/pod.c
+++ b/kernel/cobalt/nucleus/pod.c
@@ -269,14 +269,14 @@ void xnpod_schedule_deferred(void)
 static void xnpod_flush_heap(xnheap_t *heap,
                             void *extaddr, u_long extsize, void *cookie)
 {
-       xnarch_free_host_mem(extaddr, extsize);
+       xnarch_free_pages(extaddr, extsize);
 }
 
 #if CONFIG_XENO_OPT_SYS_STACKPOOLSZ > 0
 static void xnpod_flush_stackpool(xnheap_t *heap,
                                  void *extaddr, u_long extsize, void *cookie)
 {
-       xnarch_free_stack_mem(extaddr, extsize);
+       xnarch_free_pages(extaddr, extsize);
 }
 #endif
 
@@ -337,7 +337,7 @@ int xnpod_init(void)
 
        xnlock_put_irqrestore(&nklock, s);
 
-       heapaddr = xnarch_alloc_host_mem(xnmod_sysheap_size);
+       heapaddr = xnarch_alloc_pages(xnmod_sysheap_size);
        if (heapaddr == NULL ||
            xnheap_init(&kheap, heapaddr, xnmod_sysheap_size,
                        XNHEAP_PAGE_SIZE) != 0) {
@@ -358,11 +358,11 @@ int xnpod_init(void)
         * requires, still allowing the system heap to rely on a
         * vmalloc'ed segment.
         */
-       heapaddr = xnarch_alloc_stack_mem(CONFIG_XENO_OPT_SYS_STACKPOOLSZ * 
1024);
+       heapaddr = xnarch_alloc_pages(CONFIG_XENO_OPT_SYS_STACKPOOLSZ * 1024);
        if (heapaddr == NULL ||
            xnheap_init(&kstacks, heapaddr, CONFIG_XENO_OPT_SYS_STACKPOOLSZ * 
1024,
                        XNHEAP_PAGE_SIZE) != 0) {
-               xnheap_destroy(&kheap, &xnpod_flush_heap, NULL);
+               xnheap_destroy(&kheap, xnpod_flush_heap, NULL);
                return -ENOMEM;
        }
        xnheap_set_label(&kstacks, "stack pool");
@@ -468,7 +468,7 @@ void xnpod_shutdown(int xtype)
 
        xnregistry_cleanup();
        xnarch_notify_halt();
-       xnheap_destroy(&kheap, &xnpod_flush_heap, NULL);
+       xnheap_destroy(&kheap, xnpod_flush_heap, NULL);
 #if CONFIG_XENO_OPT_SYS_STACKPOOLSZ > 0
        xnheap_destroy(&kstacks, &xnpod_flush_stackpool, NULL);
 #endif
diff --git a/kernel/cobalt/nucleus/registry.c b/kernel/cobalt/nucleus/registry.c
index 4aa2931..7683495 100644
--- a/kernel/cobalt/nucleus/registry.c
+++ b/kernel/cobalt/nucleus/registry.c
@@ -115,8 +115,8 @@ int xnregistry_init(void)
 
        int n, ret;
 
-       registry_obj_slots =
-               xnarch_alloc_host_mem(CONFIG_XENO_OPT_REGISTRY_NRSLOTS * 
sizeof(struct xnobject));
+       registry_obj_slots = kmalloc(CONFIG_XENO_OPT_REGISTRY_NRSLOTS *
+                                    sizeof(struct xnobject), GFP_KERNEL);
        if (registry_obj_slots == NULL)
                return -ENOMEM;
 
@@ -157,8 +157,8 @@ int xnregistry_init(void)
 
        registry_hash_entries =
            primes[obj_hash_max(CONFIG_XENO_OPT_REGISTRY_NRSLOTS / 100)];
-       registry_hash_table = xnarch_alloc_host_mem(sizeof(struct xnobject *) *
-                                                   registry_hash_entries);
+       registry_hash_table = kmalloc(sizeof(struct xnobject *) *
+                                     registry_hash_entries, GFP_KERNEL);
 
        if (registry_hash_table == NULL) {
 #ifdef CONFIG_XENO_OPT_VFILE
@@ -205,9 +205,7 @@ void xnregistry_cleanup(void)
        }
 #endif /* CONFIG_XENO_OPT_VFILE */
 
-       xnarch_free_host_mem(registry_hash_table,
-                      sizeof(struct xnobject *) * registry_hash_entries);
-
+       kfree(registry_hash_table);
        xnsynch_destroy(&registry_hash_synch);
 
 #ifdef CONFIG_XENO_OPT_VFILE
@@ -217,8 +215,7 @@ void xnregistry_cleanup(void)
        xnvfile_destroy_dir(&registry_vfroot);
 #endif /* CONFIG_XENO_OPT_VFILE */
 
-       xnarch_free_host_mem(registry_obj_slots,
-                            CONFIG_XENO_OPT_REGISTRY_NRSLOTS * sizeof(struct 
xnobject));
+       kfree(registry_obj_slots);
 }
 
 #ifdef CONFIG_XENO_OPT_VFILE
diff --git a/kernel/cobalt/nucleus/shadow.c b/kernel/cobalt/nucleus/shadow.c
index 8c315f4..82f9e92 100644
--- a/kernel/cobalt/nucleus/shadow.c
+++ b/kernel/cobalt/nucleus/shadow.c
@@ -1742,7 +1742,7 @@ static struct xnsysent __systab[] = {
 static void post_ppd_release(struct xnheap *h)
 {
        struct xnsys_ppd *p = container_of(h, struct xnsys_ppd, sem_heap);
-       xnarch_free_host_mem(p, sizeof(*p));
+       kfree(p);
 }
 
 static inline char *get_exe_path(struct task_struct *p)
@@ -1799,7 +1799,7 @@ static void *xnshadow_sys_event(int event, void *data)
 
        switch(event) {
        case XNSHADOW_CLIENT_ATTACH:
-               p = xnarch_alloc_host_mem(sizeof(*p));
+               p = kmalloc(sizeof(*p), GFP_KERNEL);
                if (p == NULL)
                        return ERR_PTR(-ENOMEM);
 
@@ -1807,7 +1807,7 @@ static void *xnshadow_sys_event(int event, void *data)
                                         CONFIG_XENO_OPT_SEM_HEAPSZ * 1024,
                                         XNARCH_SHARED_HEAP_FLAGS);
                if (ret) {
-                       xnarch_free_host_mem(p, sizeof(*p));
+                       kfree(p);
                        return ERR_PTR(ret);
                }
 
@@ -1819,7 +1819,7 @@ static void *xnshadow_sys_event(int event, void *data)
                        printk(KERN_WARNING
                               "Xenomai: %s[%d] cannot map MAYDAY page\n",
                               current->comm, current->pid);
-                       xnarch_free_host_mem(p, sizeof(*p));
+                       kfree(p);
                        return ERR_PTR(-ENOMEM);
                }
 
@@ -2666,7 +2666,7 @@ int xnshadow_mount(void)
        }
 
        size = sizeof(xnqueue_t) * PPD_HASH_SIZE;
-       ppd_hash = xnarch_alloc_host_mem(size);
+       ppd_hash = kmalloc(size, GFP_KERNEL);
        if (ppd_hash == NULL) {
                xnshadow_cleanup();
                printk(KERN_WARNING
@@ -2694,8 +2694,8 @@ void xnshadow_cleanup(void)
        }
 
        if (ppd_hash)
-               xnarch_free_host_mem(ppd_hash,
-                              sizeof(xnqueue_t) * PPD_HASH_SIZE);
+               kfree(ppd_hash);
+
        ppd_hash = NULL;
 
        for_each_online_cpu(cpu) {
diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c
index 786a76b..7f4341e 100644
--- a/kernel/cobalt/registry.c
+++ b/kernel/cobalt/registry.c
@@ -394,8 +394,8 @@ int cobalt_reg_pkg_init(unsigned buckets_count, unsigned 
maxfds)
        size = sizeof(cobalt_node_t) * buckets_count +
                sizeof(cobalt_desc_t) * maxfds + sizeof(unsigned) * mapsize;
 
-       chunk = (char *)xnarch_alloc_host_mem(size);
-       if (!chunk)
+       chunk = kmalloc(size, GFP_KERNEL);
+       if (chunk == NULL)
                return ENOMEM;
 
        cobalt_reg.node_buckets = (cobalt_node_t **) chunk;
@@ -427,8 +427,8 @@ int cobalt_reg_pkg_init(unsigned buckets_count, unsigned 
maxfds)
 
 void cobalt_reg_pkg_cleanup(void)
 {
-       size_t size;
        unsigned i;
+
        for (i = 0; i < cobalt_reg.maxfds; i++)
                if (cobalt_reg.descs[i]) {
 #if XENO_DEBUG(POSIX)
@@ -447,9 +447,5 @@ void cobalt_reg_pkg_cleanup(void)
        }
 #endif /* XENO_DEBUG(POSIX) */
 
-       size = sizeof(cobalt_node_t) * cobalt_reg.buckets_count
-               + sizeof(cobalt_desc_t) * cobalt_reg.maxfds
-               + sizeof(unsigned) * cobalt_reg.mapsz;
-
-       xnarch_free_host_mem(cobalt_reg.node_buckets, size);
+       kfree(cobalt_reg.node_buckets);
 }
diff --git a/kernel/cobalt/rtdm/syscall.c b/kernel/cobalt/rtdm/syscall.c
index 51d4ec3..6b83a44 100644
--- a/kernel/cobalt/rtdm/syscall.c
+++ b/kernel/cobalt/rtdm/syscall.c
@@ -110,8 +110,8 @@ static void *rtdm_skin_callback(int event, void *data)
 
        switch (event) {
        case XNSHADOW_CLIENT_ATTACH:
-               process = xnarch_alloc_host_mem(sizeof(*process));
-               if (!process)
+               process = kmalloc(sizeof(*process), GFP_KERNEL);
+               if (process == NULL)
                        return ERR_PTR(-ENOSPC);
 
 #ifdef CONFIG_XENO_OPT_VFILE
@@ -127,7 +127,7 @@ static void *rtdm_skin_callback(int event, void *data)
 
                cleanup_owned_contexts(process);
 
-               xnarch_free_host_mem(process, sizeof(*process));
+               kfree(process);
 
                break;
        }
diff --git a/kernel/cobalt/syscall.c b/kernel/cobalt/syscall.c
index 7b89eb1..bff6ac2 100644
--- a/kernel/cobalt/syscall.c
+++ b/kernel/cobalt/syscall.c
@@ -309,8 +309,8 @@ static void *cobalt_eventcb(int event, void *data)
 
        switch (event) {
        case XNSHADOW_CLIENT_ATTACH:
-               q = (cobalt_queues_t *) xnarch_alloc_host_mem(sizeof(*q));
-               if (!q)
+               q = kmalloc(sizeof(*q), GFP_KERNEL);
+               if (q == NULL)
                        return ERR_PTR(-ENOSPC);
 
                initq(&q->kqueues.condq);
@@ -335,7 +335,7 @@ static void *cobalt_eventcb(int event, void *data)
                cobalt_mutexq_cleanup(&q->kqueues);
                cobalt_condq_cleanup(&q->kqueues);
 
-               xnarch_free_host_mem(q, sizeof(*q));
+               kfree(q);
 
                return NULL;
        }
diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index e7ab3e0..b9a0b96 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -169,7 +169,7 @@ static int bufp_close(struct rtipc_private *priv,
                xnregistry_remove(sk->handle);
 
        if (sk->bufmem)
-               xnarch_free_host_mem(sk->bufmem, sk->bufsz);
+               xnarch_free_pages(sk->bufmem, sk->bufsz);
 
        return 0;
 }
@@ -716,7 +716,7 @@ static int __bufp_bind_socket(struct rtipc_private *priv,
        if (sk->bufsz == 0)
                return -ENOBUFS;
 
-       sk->bufmem = xnarch_alloc_host_mem(sk->bufsz);
+       sk->bufmem = xnarch_alloc_pages(sk->bufsz);
        if (sk->bufmem == NULL) {
                ret = -ENOMEM;
                goto fail;
@@ -731,7 +731,7 @@ static int __bufp_bind_socket(struct rtipc_private *priv,
                ret = xnregistry_enter(sk->label, sk,
                                       &sk->handle, &__bufp_pnode.node);
                if (ret) {
-                       xnarch_free_host_mem(sk->bufmem, sk->bufsz);
+                       xnarch_free_pages(sk->bufmem, sk->bufsz);
                        goto fail;
                }
        }
diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c
index 70c1eb6..b1c1d1e 100644
--- a/kernel/drivers/ipc/iddp.c
+++ b/kernel/drivers/ipc/iddp.c
@@ -188,7 +188,7 @@ static void __iddp_free_mbuf(struct iddp_socket *sk,
 static void __iddp_flush_pool(struct xnheap *heap,
                              void *poolmem, u_long poolsz, void *cookie)
 {
-       xnarch_free_host_mem(poolmem, poolsz);
+       xnarch_free_pages(poolmem, poolsz);
 }
 
 static int iddp_socket(struct rtipc_private *priv,
@@ -564,7 +564,7 @@ static int __iddp_bind_socket(struct rtipc_private *priv,
        poolsz = sk->poolsz;
        if (poolsz > 0) {
                poolsz = xnheap_rounded_size(poolsz, XNHEAP_PAGE_SIZE);
-               poolmem = xnarch_alloc_host_mem(poolsz);
+               poolmem = xnarch_alloc_pages(poolsz);
                if (poolmem == NULL) {
                        ret = -ENOMEM;
                        goto fail;
@@ -573,7 +573,7 @@ static int __iddp_bind_socket(struct rtipc_private *priv,
                ret = xnheap_init(&sk->privpool,
                                  poolmem, poolsz, XNHEAP_PAGE_SIZE);
                if (ret) {
-                       xnarch_free_host_mem(poolmem, poolsz);
+                       xnarch_free_pages(poolmem, poolsz);
                        goto fail;
                }
                xnheap_set_label(&sk->privpool, "ippd: %d", port);
diff --git a/kernel/drivers/ipc/xddp.c b/kernel/drivers/ipc/xddp.c
index 4939330..d3a0e5e 100644
--- a/kernel/drivers/ipc/xddp.c
+++ b/kernel/drivers/ipc/xddp.c
@@ -112,7 +112,7 @@ static struct xnpnode_link __xddp_pnode = {
 static void __xddp_flush_pool(xnheap_t *heap,
                              void *poolmem, u_long poolsz, void *cookie)
 {
-       xnarch_free_host_mem(poolmem, poolsz);
+       xnarch_free_pages(poolmem, poolsz);
 }
 
 static void *__xddp_alloc_handler(size_t size, void *xstate) /* nklock free */
@@ -708,7 +708,7 @@ static int __xddp_bind_socket(struct rtipc_private *priv,
        poolsz = sk->poolsz;
        if (poolsz > 0) {
                poolsz = xnheap_rounded_size(poolsz + sk->reqbufsz, 
XNHEAP_PAGE_SIZE);
-               poolmem = xnarch_alloc_host_mem(poolsz);
+               poolmem = xnarch_alloc_pages(poolsz);
                if (poolmem == NULL) {
                        ret = -ENOMEM;
                        goto fail;
@@ -717,7 +717,7 @@ static int __xddp_bind_socket(struct rtipc_private *priv,
                ret = xnheap_init(&sk->privpool,
                                  poolmem, poolsz, XNHEAP_PAGE_SIZE);
                if (ret) {
-                       xnarch_free_host_mem(poolmem, poolsz);
+                       xnarch_free_pages(poolmem, poolsz);
                        goto fail;
                }
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to