kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: lroluk@gmail.com (Luca Ellero)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Best practice to lock a read/write to a HW register
Date: Fri, 15 Nov 2013 09:53:07 +0100	[thread overview]
Message-ID: <5285E0F3.3040801@gmail.com> (raw)
In-Reply-To: <CAB6A5-BF7j3MVMkTMCQ+Bb16+ay4y847izMPP8KRk-2X+i39kg@mail.gmail.com>

Il 15/11/2013 02:30, manty kuma ha wrote:
> Ideally, it depends on the platform you are working. You need to 
> discuss with them for the correct approach. For Qualcomm they have 
> some hardware caled as RPU(Register protection unit). They have 
> systems calls exposed for using them. You can associtate it to the 
> register you want protection. I dont know if there is any way you 
> could do it in Linux itself?
>
> Regards,
> Sandeep
>
>
> On Thu, Nov 14, 2013 at 9:14 PM, Bernd Petrovitsch 
> <bernd at petrovitsch.priv.at <mailto:bernd@petrovitsch.priv.at>> wrote:
>
>     Hi!
>
>     On Don, 2013-11-14 at 11:32 +0100, Luca Ellero wrote:
>     [...]
>     > can someone please show me which is the best practice to lock a
>     > read/write to a hardware register.
>     > In other words if, in a driver, I want to modify a bit in a HW
>     register,
>     > I have to read the register, set/reset the relevant bit and
>     write back
>     > the reg.
>     > But what can I do to be sure that no other code modifies the
>     register
>     > between my read and write?
>     > Is spin_lock() suitable for this purpose?
>
>     If the read-modify-write (read: the critical section) run-time is
>     short,
>     a spin-lock is the usual means. If it is needed from IRQ-context - see
>     also other mails - you must use the *_irq() variant.
>
>             Bernd
>     --
>     Bernd Petrovitsch                  Email :
>     bernd at petrovitsch.priv.at <mailto:bernd@petrovitsch.priv.at>
>                          LUGA : http://www.luga.at
>
>
>     _______________________________________________
>     Kernelnewbies mailing list
>     Kernelnewbies at kernelnewbies.org
>     <mailto:Kernelnewbies@kernelnewbies.org>
>     http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>


Thanks to all,
your suggestions are very appreciated
Best regards
Luca

      reply	other threads:[~2013-11-15  8:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14 10:32 Best practice to lock a read/write to a HW register Luca Ellero
2013-11-14 11:20 ` Mandeep Sandhu
2013-11-14 11:51 ` binoy.jayan at wipro.com
2013-11-14 12:14 ` Bernd Petrovitsch
2013-11-15  1:30   ` manty kuma
2013-11-15  8:53     ` Luca Ellero [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=5285E0F3.3040801@gmail.com \
    --to=lroluk@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).