LKML Archive on
help / color / mirror / Atom feed
From: Andi Kleen <>
To:, Ingo Molnar <>,,
Subject: [PATCH] Fix direct mapping correctly in ioremap
Date: Thu, 14 Feb 2008 12:59:05 +0100	[thread overview]
Message-ID: <> (raw)

Fix direct mapping correctly in ioremap

[This fixes the general ioremap bug I mentioned earlier. It was
fortunately easier to fix that I thought first.]

set_memory_*/cpa is not currently able to resolve ioremap addresses to
their direct mapping aliases.

However uncached ioremap still needs to fix up the direct mapping
to be uncached when the direct mapping happens to overlap
the remapped area. Otherwise there would be a cached mapping
to the uncached ioremap area and that is not allowed in the x86

Do this explicitely in ioremap() by passing the direct mapping
address to cpa and ignoring the error if the address wasn't
in the direct mapping.

Signed-off-by: Andi Kleen <>

Index: linux/arch/x86/mm/ioremap.c
--- linux.orig/arch/x86/mm/ioremap.c
+++ linux/arch/x86/mm/ioremap.c
@@ -104,6 +104,7 @@ static void __iomem *__ioremap(unsigned 
 	unsigned long pfn, offset, last_addr, vaddr;
 	struct vm_struct *area;
 	pgprot_t prot;
+	int err;
 	/* Don't allow wraparound or zero size */
 	last_addr = phys_addr + size - 1;
@@ -156,7 +157,12 @@ static void __iomem *__ioremap(unsigned 
 		return NULL;
-	if (ioremap_change_attr(vaddr, size, mode) < 0) {
+	/* Fix up the direct mapping for the new cache attributes */
+	err = ioremap_change_attr((unsigned long)__va(phys_addr),
+				size + offset, mode);
+	if (err == -EINVAL) {
+		/* Original address was partly unmapped. Valid condition; ignore. */
+	} else if (err < 0) {
 		return NULL;

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-14 11:59 Andi Kleen [this message]
2008-02-14 16:03 ` [PATCH] Fix direct mapping correctly in ioremap Ingo Molnar
2008-02-14 17:14   ` Andi Kleen

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \

* 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).