All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Fillod Stephane <stephane.fillod@domain.hid>
Cc: xenomai-help <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] RTDM mmap and DMA
Date: Thu, 27 Dec 2007 00:37:53 +0100	[thread overview]
Message-ID: <18290.58833.261791.68352@domain.hid> (raw)
In-Reply-To: <0B45E93C5FF65740AEAE690BF3848B7A4AB2DF@rennsmail04.eu.thmulti.com>

[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 568 bytes --]

Fillod Stephane wrote:
 > Perrine Martignoni wrote:
 > >Currently, I write an RTDM module and I would like to do DMA and mmap
 > to perform transfers who have hard constraints.
 > >I would like to know if there is an example in a driver who would help
 > me to do this.
 > 
 > I'm looking for the same need, except I'm not using RTDM, and everything
 > is in userland. Using the attached patch against Xenomai 2.4.0, I hope
 > to make it to work with something like this:

I propose the attached modifications. Is it Ok for you ?

-- 


					    Gilles Chanteperdrix.

[-- Attachment #2: heap_dma.2.patch --]
[-- Type: text/plain, Size: 2263 bytes --]

Index: ksrc/nucleus/heap.c
===================================================================
--- ksrc/nucleus/heap.c	(revision 3301)
+++ ksrc/nucleus/heap.c	(working copy)
@@ -1180,7 +1180,11 @@
 		 * space. Assume that we can wait to get the required memory.
 		 */
 
-		ptr = kmalloc(size, kmflags | GFP_KERNEL);
+		if (size <= KMALLOC_MAX_SIZE)
+			ptr = kmalloc(size, kmflags | GFP_KERNEL);
+		else
+			ptr = (void*) __get_free_pages(kmflags | GFP_KERNEL,
+						       get_order(size));
 
 		if (!ptr)
 			return NULL;
@@ -1212,7 +1216,10 @@
 		for (vaddr = vabase; vaddr < vabase + size; vaddr += PAGE_SIZE)
 			ClearPageReserved(virt_to_page(vaddr));
 
-		kfree(ptr);
+		if (size <= KMALLOC_MAX_SIZE)
+			kfree(ptr);
+		else
+			free_pages((unsigned long)ptr, get_order(size));
 	}
 }
 
Index: ksrc/skins/native/heap.c
===================================================================
--- ksrc/skins/native/heap.c	(revision 3301)
+++ ksrc/skins/native/heap.c	(working copy)
@@ -730,6 +730,7 @@
 	info->usablemem = xnheap_usable_mem(&heap->heap_base);
 	info->usedmem = xnheap_used_mem(&heap->heap_base);
 	info->mode = heap->mode;
+	info->phys_addr = (heap->mode & H_SINGLE) ? virt_to_phys(heap->sba):0;
 
       unlock_and_exit:
 
Index: include/native/heap.h
===================================================================
--- include/native/heap.h	(revision 3301)
+++ include/native/heap.h	(working copy)
@@ -48,6 +48,8 @@
 
     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
 
+    unsigned long phys_addr;	/* !< Physical address. */
+
 } RT_HEAP_INFO;
 
 typedef struct rt_heap_placeholder {
Index: include/asm-generic/wrappers.h
===================================================================
--- include/asm-generic/wrappers.h	(revision 3301)
+++ include/asm-generic/wrappers.h	(working copy)
@@ -27,6 +27,7 @@
 
 #include <linux/version.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
@@ -281,4 +282,8 @@
 #define trace_mark(ev, fmt, args...)	do { } while (0)
 #endif /* CONFIG_MARKERS */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#define KMALLOC_MAX_SIZE 131072
+#endif /* !KMALLOC_MAX_SIZE */
+
 #endif /* _XENO_ASM_GENERIC_WRAPPERS_H */

  parent reply	other threads:[~2007-12-26 23:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-14 13:59 [Xenomai-help] RTDM mmap and DMA Fillod Stephane
2007-12-14 15:50 ` Perrine Martignoni
2007-12-23 13:09 ` Gilles Chanteperdrix
2007-12-26 23:37 ` Gilles Chanteperdrix [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-01-03 18:40 Fillod Stephane
2007-12-27 15:39 Fillod Stephane
2007-12-27 15:43 ` Gilles Chanteperdrix
2007-12-28 21:59 ` Gilles Chanteperdrix
2007-12-18 17:40 Fillod Stephane
2007-12-18 17:55 ` Gilles Chanteperdrix
2007-12-17 14:40 Fillod Stephane
2007-12-14 11:24 Perrine Martignoni
2007-12-18  9:21 ` Stéphane ANCELOT
2007-12-18  9:29 ` Jan Kiszka
2007-12-18 10:10   ` Gilles Chanteperdrix
2007-12-18 10:16     ` Perrine Martignoni
2007-12-18 10:18       ` Gilles Chanteperdrix
2007-12-18 10:12   ` Perrine Martignoni
2007-12-18 12:47     ` Jan Kiszka
2007-12-18 13:20       ` Gilles Chanteperdrix
2007-12-18 14:11       ` Perrine Martignoni
2007-12-18 14:22         ` Jan Kiszka
2007-12-18 14:41           ` Perrine Martignoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18290.58833.261791.68352@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=stephane.fillod@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.