linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <marcelo.tosatti@cyclades.com>
To: Paul Mackerras <paulus@samba.org>, Dan Malek <dan@embeddededge.com>
Cc: Jeff Garzik <jgarzik@pobox.com>,
	linux-kernel@vger.kernel.org,
	linux-ppc-embedded <linuxppc-embedded@ozlabs.org>
Subject: Re: [PATCH] MPC8xx PCMCIA driver
Date: Tue, 30 Aug 2005 12:07:05 -0300	[thread overview]
Message-ID: <20050830150705.GA6140@dmt.cnet> (raw)
In-Reply-To: <17171.57693.981385.165290@cargo.ozlabs.ibm.com>

Hi Paul, Jeff,

On Tue, Aug 30, 2005 at 02:32:29PM +1000, Paul Mackerras wrote:
> Marcelo Tosatti writes:
> 
> > The memory map structure which contains device configuration/registers
> > is _always_ directly mapped with pte's (the 8xx is a chip with builtin
> > UART/network/etc functionality).
> > 
> > I don't think there is a need to use read/write acessors.

Bullshit, yep :) 

> Generally on PowerPC you need to use at least the eieio instruction to
> prevent reordering of the loads and stores to the device.  It's
> possible that 8xx is sufficiently in-order that you get away without
> putting in barrier instructions (eieio or sync), but it's not good
> practice to omit them.

On 8xx, guarded mappings seem to ensure synchronous operation of
load/store instructions.

Since the internal memory map is guarded, eieio is redudant (ie thats
why it gets away without explicit barriers now).

>From MPC860UM.pdf: 5.2.5.2.1 eieio Behavior

The purpose of eieio is to prevent loads and stores from executing
speculatively when appropriate. This might be desirable for a FIFO,
where performing a read or write changes the FIFO's data. This should
not be done unless it is certain that the instruction will be completed
and not cancelled. The same function as eieio can be accomplished by
defining a memory space as having the guarded attribute in the MMU, in
which case, the eieio instruction is redundant. However, eieio could be
useful in the rare event that a region where speculative accesses are
not allowed lies in the middle of a non-guarded page.

There is nothing which prevents compiler reordering though, as Jeff
notes.

> You can use accessors such as in_be32 and in_le32 in this situation,
> when you have a kernel virtual address that is already mapped to the
> device.

Do you think it would be worth to have lighterweight versions of
in_be32/in_le32 functions (without eieio and isync) ? Would avoid the
increase in code size and consequently cache footprint.

The IMMAP is referenced directly _all over_ the 8xx core code, must be
fixed.

> There are multiple reasons:
>
> * Easier reviewing.  One cannot easily distinguish between writing to
> normal kernel virtual memory and "magic" memory that produces magicaly
> side effects such as initiating DMA of a net packet.
> 
> * Compiler safety.  As the code is written now, you have no guarantees
> that the compiler won't combine two stores to the same location, etc.
> Accessor macros are a convenient place to add compiler barriers or
> 'volatile' notations that the MPC8xx code lacks.
>
> * Maintainable.  foo_read[bwl] or foo_read{8,16,32} are preferred
> because that's the way other bus accessors look like -- yes even
> embedded SoC buses benefit from these code patterns.  You want your
> driver to look like other drivers as much as possible.
>
> * Convenience.  The accessors can be a zero overhead memory read/write
> at a minimum.  But they can also be convenient places to use special
> memory read/write instructions that specify uncached memop, compiler
> barriers, memory barriers, etc.

  reply	other threads:[~2005-08-30 17:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-30  2:48 [PATCH] MPC8xx PCMCIA driver Marcelo Tosatti
2005-08-30  3:39 ` Jeff Garzik
2005-08-30  3:53   ` Marcelo Tosatti
2005-08-30  4:32     ` Paul Mackerras
2005-08-30 15:07       ` Marcelo Tosatti [this message]
2005-08-30  4:33     ` Jeff Garzik
2005-08-30  7:06 ` Russell King
2005-09-01  8:53 ` Dominik Brodowski
2005-09-01 11:44   ` Magnus Damm
2005-09-01 14:51   ` Marcelo Tosatti
2005-09-14 14:11   ` Marcelo Tosatti
2005-09-14 14:27     ` Dominik Brodowski
2005-09-14 18:21       ` Marcelo Tosatti
2005-09-14 18:46         ` Jeff Garzik

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=20050830150705.GA6140@dmt.cnet \
    --to=marcelo.tosatti@cyclades.com \
    --cc=dan@embeddededge.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-embedded@ozlabs.org \
    --cc=paulus@samba.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).