All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Marco Tessore <marco.tessore@axelsw.it>, xenomai@xenomai.org
Subject: Re: [Xenomai] Question about rtdm_mmap_to user
Date: Wed, 16 Jul 2014 12:26:47 +0200	[thread overview]
Message-ID: <53C65367.1050301@xenomai.org> (raw)
In-Reply-To: <53C550DF.4090500@axelsw.it>

On 07/15/2014 06:03 PM, Marco Tessore wrote:
> Good morning,
> I would like to share a buffer between user space task and kernel space 
> realtime driver.
> 
> I used the function rtdm_mmap_to user in the following way:
> 
> In the driver, in the function myDriver_ioctl_rt I have the code:
> 
>         spild->agg_write_frame_buffer allocated with kalloc
> 
>          ret = rtdm_mmap_to_user( user_info,
>                  spild->agg_write_frame_buffer,
>                  agg_fun_local.data_size,
>                  PROT_READ|PROT_WRITE ,
>                  &tmpPtr,
>                  NULL,
>                  NULL
>          );
>          agg_fun_local.data_buffer = (uint8_t *) tmpPtr;
> 
>          rtdm_printk("mmap = %X\n", (unsigned) 
> agg_fun_local.data_buffer); // print the returned address
> 
>          if (ret)
>          {
>              rtdm_printk("mmap error1\n");
> 
>              kfree(spild->agg_write_frame_buffer);
>              return ret;
>          }
> 
>          // check data
>          spild->agg_write_frame_buffer[0] = 0xBE;
>          spild->agg_write_frame_buffer[1] = 0xEF;
> 
>          // then returned the agg_fun_local structure to userspace
> 
> In the user space process I have the following code:
>      ret = rt_dev_ioctl( device, IOCTL_MYDRIVER, &agg_fun );
>      if (ret)
>      {
>          printf("PREP_AGG_WRITE failed, ret = %X", (int) ret);
>      }
> 
>      printf("USER = Address = %X\n", (unsigned) agg_fun.data_buffer);
>      printf("USER check %X%X\n", pAggFun->data_buffer[0], 
> agg_fun.data_buffer[1]);
> 
> I have verified that the address in userspace is the same of the one 
> returned by the rtdm_mmap_to_user.
> The problem is that in the process I cannot see the check data written 
> in the driver.
> 
> Is there something wrong in my code?
> Are there some constraints tha I haven't took into account?

On which platform do you do this? If on ARM with a VIVT cache, you have
to flush the cache after writing one side for the other side to see the
change, or map the region with writecombine.

-- 
                                                                Gilles.


      reply	other threads:[~2014-07-16 10:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15 16:03 [Xenomai] Question about rtdm_mmap_to user Marco Tessore
2014-07-16 10:26 ` Gilles Chanteperdrix [this message]

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=53C65367.1050301@xenomai.org \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=marco.tessore@axelsw.it \
    --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.