mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Albert Cahalan" <acahalan@gmail.com>
To: benh@kernel.crashing.org, linux-kernel@vger.kernel.org,
	jbarnes@virtuousgeek.org, alan@lxorguk.ukuu.org.uk,
	davem@davemloft.net, jgarzik@pobox.com, paulus@samba.org,
	torvalds@osdl.org, akpm@osdl.org, segher@kernel.crashing.org
Subject: Re: [RFC] MMIO accessors & barriers documentation
Date: Tue, 12 Sep 2006 01:33:21 -0400	[thread overview]
Message-ID: <787b0d920609112233u16a1cbcv2bf4ffa6b378dcd7@mail.gmail.com> (raw)

Benjamin Herrenschmidt writes:

>  1- io_to_io_barrier() : This barrier provides ordering requirement #1
> between two MMIO accesses. It's to be used in conjuction with fully
> relaxed accessors of Class 3.
>
>  2- memory_to_io_wb() : This barrier provides ordering requirement #2
> between a memory store and an MMIO store. It can be used in conjunction
> with write accessors of Class 2 and 3.
>
>  3- io_to_memory_rb(value) : This barrier provides ordering requirement
> #3 between an MMIO read and a subsequent read from memory. For
> implementation purposes on some architectures, the value actually read
> by the MMIO read shall be passed as an argument to this barrier. (This
> allows to generate the appropriate CPU instruction magic to force the
> CPU to consider the value as being "used" and thus force the read to be
> performed immediately). It can be used in conjunction with read
> accessors of Class 2 and 3
>
>  4- io_to_lock_wb() : This barrier provides ordering requirement #4
> between an MMIO store and a subsequent spin_unlock(). It can be used in
> conjunction with write accessors of Class 2 and 3.

These can really multiply: read or write, RAM and various types
of IO space, etc.

Let's have a generic arch-provided macro and let gcc do some work
for us.

Example usage:
fence(FENCE_READ_RAM|FENCE_READ_PCI_IO, FENCE_WRITE_PCI_MMIO);

Example implementation for PowerPC:

#define PPC_RAM (FENCE_READ_RAM|FENCE_WRITE_RAM)
#define PPC_MMIO (FENCE_READ_PCI_MMIO|FENCE_READ_PCI_CONFIG|\
 FENCE_READ_PCI_RAM|FENCE_READ_PCI_IO | FENCE_WRITE_PCI_MMIO|\
 FENCE_WRITE_PCI_CONFIG|FENCE_WRITE_PCI_RAM|FENCE_WRITE_PCI_IO)
#define PPC_OTHER (~(PPC_RAM|PPC_MMIO))

#define fence(before,after) do{ \
if(before&PPC_RAM && after&PPC_MMIO) \
        __asm__ __volatile__ ("sync" : : : "memory"); \
else if(before&PPC_MMIO && after&PPC_RAM) \
        __asm__ __volatile__ ("sync" : : : "memory"); \
else if((before|after) & PPC_OTHER) \
        __asm__ __volatile__ ("sync" : : : "memory"); \
else if(before && after) \
        __asm__ __volatile__ ("eieio" : : : "memory"); \
}while(0)

             reply	other threads:[~2006-09-12  5:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-12  5:33 Albert Cahalan [this message]
2006-09-12  5:48 ` Benjamin Herrenschmidt
  -- strict thread matches above, loose matches on Subject: below --
2006-09-11  4:03 Benjamin Herrenschmidt
2006-09-11  8:57 ` Alan Cox
2006-09-11  9:17   ` Benjamin Herrenschmidt
2006-09-11 10:07     ` Alan Cox
2006-09-11  9:59       ` Benjamin Herrenschmidt
2006-09-11 17:26         ` Alan Cox
2006-09-11 21:29           ` Benjamin Herrenschmidt
2006-09-12  5:48       ` Eric W. Biederman
2006-09-12  5:56         ` Benjamin Herrenschmidt
2006-09-12  6:27           ` Eric W. Biederman
2006-09-12  7:13             ` Benjamin Herrenschmidt
2006-09-12 15:19               ` Segher Boessenkool
2006-09-12 21:22                 ` Benjamin Herrenschmidt
2006-09-13  0:12                   ` Segher Boessenkool
2006-09-13  1:34                     ` Benjamin Herrenschmidt
2006-09-11 18:39 ` Jesse Barnes
2006-09-11 21:45   ` Benjamin Herrenschmidt
2006-09-11 21:54     ` Jeff Garzik
2006-09-11 22:56       ` Benjamin Herrenschmidt
2006-09-11 23:08         ` Roland Dreier
2006-09-11 23:18           ` Benjamin Herrenschmidt
2006-09-11 23:24         ` Jeff Garzik
2006-09-12  0:46           ` Benjamin Herrenschmidt
2006-09-12 15:32           ` Segher Boessenkool
2006-09-11 22:05     ` Jesse Barnes
2006-09-11 23:01       ` Benjamin Herrenschmidt

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=787b0d920609112233u16a1cbcv2bf4ffa6b378dcd7@mail.gmail.com \
    --to=acahalan@gmail.com \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=jbarnes@virtuousgeek.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.org \
    --cc=segher@kernel.crashing.org \
    --cc=torvalds@osdl.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

all inboxes | Powered by JetHome®