All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: rpurdie@rpsys.net, lenz@cs.wisc.edu,
	kernel list <linux-kernel@vger.kernel.org>,
	Russell King <rmk@arm.linux.org.uk>,
	kamezawa.hiroyu@jp.fujitsu.com
Subject: include/asm-arm/memory.h changes break zaurus sl-5500 boot
Date: Sun, 2 Apr 2006 23:00:03 +0200	[thread overview]
Message-ID: <20060402210003.GA11979@elf.ucw.cz> (raw)

Hi!

This reverts this (and one more) patch, and fixes boot on
collie. Without this patch, I get some fairly strange warnings about
shift bigger than page size in pfn_to_page().

								Pavel

commit 7eb98a2f3b605d8a11434d855b58d828393ea533
tree 4643bb90d8fe3e48ca8d042286ca3d55b8560d45
parent 1c05dda2b6f025267ab79a267e0a84628a3760e1
author KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Mon, 27 Mar
2006 01:15:37 -0800
committer Linus Torvalds <torvalds@g5.osdl.org> Mon, 27 Mar 2006
08:44:44 -0800

    [PATCH] unify pfn_to_page: arm pfn_to_page

    ARM can use generic funcs.
    PFN_TO_NID, LOCAL_MAP_NR are defined by sub-archs.

    Signed-off-by: KAMEZAWA Hirotuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: Russell King <rmk@arm.linux.org.uk>
    Signed-off-by: Andrew Morton <akpm@osdl.org>
    Signed-off-by: Linus Torvalds <torvalds@osdl.org>


diff --git a/include/asm-alpha/mmzone.h b/include/asm-alpha/mmzone.h
index 192d80c..c900439 100644
--- a/include/asm-alpha/mmzone.h
+++ b/include/asm-alpha/mmzone.h
@@ -83,7 +83,8 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, 
 	pte_t pte;                                                           \
 	unsigned long pfn;                                                   \
 									     \
-	pfn = page_to_pfn(page) << 32; \
+	pfn = ((unsigned long)((page)-page_zone(page)->zone_mem_map)) << 32; \
+	pfn += page_zone(page)->zone_start_pfn << 32;			     \
 	pte_val(pte) = pfn | pgprot_val(pgprot);			     \
 									     \
 	pte;								     \
diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h
index afa5c3e..b4e1146 100644
--- a/include/asm-arm/memory.h
+++ b/include/asm-arm/memory.h
@@ -172,7 +172,9 @@ static inline __deprecated void *bus_to_
  *  virt_addr_valid(k)	indicates whether a virtual address is valid
  */
 #ifndef CONFIG_DISCONTIGMEM
-#define ARCH_PFN_OFFSET		(PHYS_PFN_OFFSET)
+
+#define page_to_pfn(page)	(((page) - mem_map) + PHYS_PFN_OFFSET)
+#define pfn_to_page(pfn)	((mem_map + (pfn)) - PHYS_PFN_OFFSET)
 #define pfn_valid(pfn)		((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
 
 #define virt_to_page(kaddr)	(pfn_to_page(__pa(kaddr) >> PAGE_SHIFT))
@@ -187,8 +189,13 @@ static inline __deprecated void *bus_to_
  * around in memory.
  */
 #include <linux/numa.h>
-#define arch_pfn_to_nid(pfn)	(PFN_TO_NID(pfn))
-#define arch_local_page_offset(pfn, nid) (LOCAL_MAP_NR((pfn) << PAGE_OFFSET))
+
+#define page_to_pfn(page)					\
+	(( (page) - page_zone(page)->zone_mem_map)		\
+	  + page_zone(page)->zone_start_pfn)
+
+#define pfn_to_page(pfn)					\
+	(PFN_TO_MAPBASE(pfn) + LOCAL_MAP_NR((pfn) << PAGE_SHIFT))
 
 #define pfn_valid(pfn)						\
 	({							\
@@ -236,6 +243,4 @@ static inline __deprecated void *bus_to_
 
 #endif
 
-#include <asm-generic/memory_model.h>
-
 #endif
diff --git a/include/asm-generic/memory_model.h b/include/asm-generic/memory_model.h
index 0cfb086..a7bb497 100644
--- a/include/asm-generic/memory_model.h
+++ b/include/asm-generic/memory_model.h
@@ -45,11 +45,11 @@ extern unsigned long page_to_pfn(struct 
 	NODE_DATA(__nid)->node_mem_map + arch_local_page_offset(__pfn, __nid);\
 })
 
-#define page_to_pfn(pg)							\
-({	struct page *__pg = (pg);					\
-	struct pglist_data *__pgdat = NODE_DATA(page_to_nid(__pg));	\
-	(unsigned long)(__pg - __pgdat->node_mem_map) +			\
-	 __pgdat->node_start_pfn;					\
+#define page_to_pfn(pg)			\
+({	struct page *__pg = (pg);		\
+	struct zone *__zone = page_zone(__pg);	\
+	(unsigned long)(__pg - __zone->zone_mem_map) +	\
+	 __zone->zone_start_pfn;			\
 })
 
 #elif defined(CONFIG_SPARSEMEM)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index b5c2112..9d2b23e 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -226,6 +226,7 @@ struct zone {
 	 * Discontig memory support fields.
 	 */
 	struct pglist_data	*zone_pgdat;
+	struct page		*zone_mem_map;
 	/* zone_start_pfn == zone_start_paddr >> PAGE_SHIFT */
 	unsigned long		zone_start_pfn;
 
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index dc523a1..519724d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2041,6 +2041,7 @@ static __meminit void init_currently_emp
 	zone_wait_table_init(zone, size);
 	pgdat->nr_zones = zone_idx(zone) + 1;
 
+	zone->zone_mem_map = pfn_to_page(zone_start_pfn);
 	zone->zone_start_pfn = zone_start_pfn;
 
 	memmap_init(size, pgdat->node_id, zone_idx(zone), zone_start_pfn);
@@ -2767,8 +2768,9 @@ struct page *pfn_to_page(unsigned long p
 }
 unsigned long page_to_pfn(struct page *page)
 {
-	struct pglist_data *pgdat = NODE_DATA(page_to_nid(page));
-	return (page - pgdat->node_mem_map) + pgdat->node_start_pfn;
+	struct zone *zone = page_zone(page);
+	return (page - zone->zone_mem_map) + zone->zone_start_pfn;
+
 }
 #elif defined(CONFIG_SPARSEMEM)
 struct page *pfn_to_page(unsigned long pfn)

-- 
Picture of sleeping (Linux) penguin wanted...

             reply	other threads:[~2006-04-02 21:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-02 21:00 Pavel Machek [this message]
2006-04-02 22:08 ` include/asm-arm/memory.h changes break zaurus sl-5500 boot Russell King
2006-04-02 22:23   ` Pavel Machek
2006-04-02 23:53     ` KAMEZAWA Hiroyuki
2006-04-03  0:15     ` KAMEZAWA Hiroyuki
2006-04-03  7:36       ` Russell King
2006-04-03  7:44         ` KAMEZAWA Hiroyuki
2006-04-03  8:56           ` KAMEZAWA Hiroyuki
2006-04-03  9:02             ` Russell King
2006-04-03  9:08               ` KAMEZAWA Hiroyuki

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=20060402210003.GA11979@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=lenz@cs.wisc.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=rpurdie@rpsys.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.