kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: pranjas@gmail.com (Pranay Srivastava)
To: kernelnewbies@lists.kernelnewbies.org
Subject: mmap - post/pre actions
Date: Wed, 16 Sep 2015 14:32:35 +0530	[thread overview]
Message-ID: <CA+aCy1EvBhRsREvMtHvASb+EDGx6R7kd+G5sn0cA2SUZoRLSfg@mail.gmail.com> (raw)
In-Reply-To: <CAJ2oMhL_uDPQLMztxCLMOX7YsvhxqKEPqKbpfROovzxHo24gsg@mail.gmail.com>

Hi Ran

On Wed, Sep 16, 2015 at 1:10 AM, Ran Shalit <ranshalit@gmail.com> wrote:
> Hello,
>
> I need to implement mmap for non-volatile memory chip (NVRAM).
> I already did something simple, but now I understand that it is not complete:
> The nvram need to be unlock and locked after finishing the memory task
> of read/write.

I guess you are better off with an ioctl call to the driver and be
done with the read/write. You won't get
faults once you've mapped it. So I don't think you can do locking via
your driver after that.

If you are thinking of doing something like below

P1--->mmap--->driver [OK]
P2-->mmap--->driver[OK]

You won't be able to get the faults for the below cases as you would've already
filled the vma for that in your vm_fault handler.

P1--->writes to mmaped [No fault]
P2--->writes to mmaped [No fault]

You can't lock once both have mapped. What you can do is provide a
different mapping[?] and then
sync that mapping I guess? But that's just insane.

If you say that subsequent mmap would fail then again you'll have to
code user-space to work with this.

Better off with ioctl rather than mmap.
>
> Does mmap can handle such post/pre actions or not ( I guess that if
> not -  I will need to use read/write alternatives) ?
>
> Thank you,
> Ran
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



-- 
        ---P.K.S

      parent reply	other threads:[~2015-09-16  9:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-15 19:40 mmap - post/pre actions Ran Shalit
2015-09-15 19:51 ` Valdis.Kletnieks at vt.edu
2015-09-16  9:02 ` Pranay Srivastava [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=CA+aCy1EvBhRsREvMtHvASb+EDGx6R7kd+G5sn0cA2SUZoRLSfg@mail.gmail.com \
    --to=pranjas@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).