public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Mundt <lethal@linux-sh.org>
To: linux-sh@vger.kernel.org
Subject: Re: ioremap() on SH
Date: Thu, 14 Feb 2008 14:57:44 +0000	[thread overview]
Message-ID: <20080214145744.GB14777@linux-sh.org> (raw)
In-Reply-To: <cda58cb80802140636i69449582v6ecc03449df46b02@mail.gmail.com>

On Thu, Feb 14, 2008 at 03:36:31PM +0100, Franck Bui-Huu wrote:
> I'm puzzled by the implementation of ioremap() on SH architecture.
> 
> Here it is:
> 
>         if (likely(PXSEG(offset) < P3SEG && PXSEG(last_addr) < P3SEG)) {
>                 if (unlikely(flags & _PAGE_CACHABLE))
>                         return (void __iomem *)P1SEGADDR(offset);
> 
>                 return (void __iomem *)P2SEGADDR(offset);
>         }
> 
>         return __ioremap(offset, size, flags);
> 
> where 'offset' is a physical address...
> 
> If I understand correctly PXSEG(x) is used to get the segment of a
> _virtual_ address, so doing PXSEG(offset) looks weird.
> 
In 29-bit physical mode, there is no real differentiation. P1 and P2 are
both non-translatable sections that refer to the low 512M (P1 is cached,
and P2 is uncached). If you're using the MIPS terminology, these are
KSEG0 and KSEG1 respectively. In the nommu context the logic is
simplified since we don't really have that sort of segmentation, so
there's still a direct 1:1 correlation between physical and virtual there
also. Thus, we can take a P2 address with a cached remap and hand back
the P1 equivalent, and vice versa for cached->uncached transitions.

Page table mappings are only used for certain parts of P3 and other parts
of the address space. There are also non-translatable holes in the
address space further along that need special care, so there is further
special casing for those.

The comment above the __ioremap() prototype attempts to clarify some of
this. There are additional notes in arch/sh/mm/ioremap_32.c as well,
mostly relating to the special casing in the P3 address space.

There are also cases where address space behaviour is determined by
special PTE bits relative to a given chip-select. PCMCIA and CF via area
5 and area 6 are examples of this, and are traditionally why P3 remapping
requires special handling. Other P3 addresses don't generally require
special casing, and can use fairly standard page table mapping.

sh64 on the other hand accomplishes similar behaviour through the mapping
of 512M superpages in the DTLB (using wired entries), which can be seen
in arch/sh/kernel/head_64.S.

Hope that helps.

  reply	other threads:[~2008-02-14 14:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-14 14:36 ioremap() on SH Franck Bui-Huu
2008-02-14 14:57 ` Paul Mundt [this message]
2008-02-14 16:42 ` Franck Bui-Huu
2008-02-14 17:09 ` Paul Mundt
2008-02-14 19:39 ` Franck Bui-Huu
2008-02-15 13:15 ` Stuart MENEFY
2008-02-15 21:12 ` Franck Bui-Huu
2008-02-18 13:44 ` Stuart MENEFY

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=20080214145744.GB14777@linux-sh.org \
    --to=lethal@linux-sh.org \
    --cc=linux-sh@vger.kernel.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