public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RFC [PATCH] x86: try to remove arch_get_ram_range
@ 2008-06-17  3:10 Yinghai Lu
  2008-06-18 14:07 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Yinghai Lu @ 2008-06-17  3:10 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton,
	Keshavamurthy, Anil S, Jan Engelhardt
  Cc: linux-kernel@vger.kernel.org

want to remove arch_get_ram_range, and use early_node_map instead.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

Index: linux-2.6/arch/x86/mm/init_32.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/init_32.c
+++ linux-2.6/arch/x86/mm/init_32.c
@@ -298,7 +298,7 @@ struct add_highpages_data {
 	unsigned long end_pfn;
 };
 
-static void __init add_highpages_work_fn(unsigned long start_pfn,
+static int __init add_highpages_work_fn(unsigned long start_pfn,
 					 unsigned long end_pfn, void *datax)
 {
 	int node_pfn;
@@ -311,7 +311,7 @@ static void __init add_highpages_work_fn
 	final_start_pfn = max(start_pfn, data->start_pfn);
 	final_end_pfn = min(end_pfn, data->end_pfn);
 	if (final_start_pfn >= final_end_pfn)
-		return;
+		return 0;
 
 	for (node_pfn = final_start_pfn; node_pfn < final_end_pfn;
 	     node_pfn++) {
@@ -321,6 +321,8 @@ static void __init add_highpages_work_fn
 		add_one_highpage_init(page, node_pfn);
 	}
 
+	return 0;
+
 }
 
 void __init add_highpages_with_active_regions(int nid, unsigned long start_pfn,
Index: linux-2.6/drivers/pci/intel-iommu.c
===================================================================
--- linux-2.6.orig/drivers/pci/intel-iommu.c
+++ linux-2.6/drivers/pci/intel-iommu.c
@@ -1637,12 +1637,43 @@ static inline int iommu_prepare_rmrr_dev
 }
 
 #ifdef CONFIG_DMAR_GFX_WA
-extern int arch_get_ram_range(int slot, u64 *addr, u64 *size);
+struct iommu_prepare_data {
+	struct pci_dev *pdev;
+	int ret;
+};
+
+static int __init iommu_prepare_work_fn(unsigned long start_pfn,
+					 unsigned long end_pfn, void *datax)
+{
+	struct iommu_prepare_data *data;
+
+	data = (struct iommu_prepare_data *)datax;
+
+	data->ret = iommu_prepare_identity_map(data->pdev,
+				start_pfn<<PAGE_SHIFT, end_pfn<<PAGE_SHIFT);
+	return data->ret;
+
+}
+
+static int __init iommu_prepare_with_active_regions(struct pci_dev *pdev)
+{
+	int nid;
+	struct iommu_prepare_data data;
+
+	data.pdev = pdev;
+	data.ret = 0;
+
+	for_each_online_node(nid) {
+		work_with_active_regions(nid, iommu_prepare_work_fn, &data);
+		if (data.ret)
+			return data.ret;
+	}
+	return data.ret;
+}
+
 static void __init iommu_prepare_gfx_mapping(void)
 {
 	struct pci_dev *pdev = NULL;
-	u64 base, size;
-	int slot;
 	int ret;
 
 	for_each_pci_dev(pdev) {
@@ -1651,17 +1682,9 @@ static void __init iommu_prepare_gfx_map
 			continue;
 		printk(KERN_INFO "IOMMU: gfx device %s 1-1 mapping\n",
 			pci_name(pdev));
-		slot = arch_get_ram_range(0, &base, &size);
-		while (slot >= 0) {
-			ret = iommu_prepare_identity_map(pdev,
-					base, base + size);
-			if (ret)
-				goto error;
-			slot = arch_get_ram_range(slot, &base, &size);
-		}
-		continue;
-error:
-		printk(KERN_ERR "IOMMU: mapping reserved region failed\n");
+		ret = iommu_prepare_with_active_regions(pdev);
+		if (ret)
+			printk(KERN_ERR "IOMMU: mapping reserved region failed\n");
 	}
 }
 #endif
Index: linux-2.6/include/linux/mm.h
===================================================================
--- linux-2.6.orig/include/linux/mm.h
+++ linux-2.6/include/linux/mm.h
@@ -1011,7 +1011,7 @@ extern unsigned long find_min_pfn_with_a
 extern unsigned long find_max_pfn_with_active_regions(void);
 extern void free_bootmem_with_active_regions(int nid,
 						unsigned long max_low_pfn);
-typedef void (*work_fn_t)(unsigned long, unsigned long, void *);
+typedef int (*work_fn_t)(unsigned long, unsigned long, void *);
 extern void work_with_active_regions(int nid, work_fn_t work_fn, void *data);
 extern void sparse_memory_present_with_active_regions(int nid);
 #ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c
+++ linux-2.6/mm/page_alloc.c
@@ -2942,10 +2942,14 @@ void __init free_bootmem_with_active_reg
 void __init work_with_active_regions(int nid, work_fn_t work_fn, void *data)
 {
 	int i;
+	int ret;
 
-	for_each_active_range_index_in_nid(i, nid)
-		work_fn(early_node_map[i].start_pfn, early_node_map[i].end_pfn,
-			data);
+	for_each_active_range_index_in_nid(i, nid) {
+		ret = work_fn(early_node_map[i].start_pfn,
+			      early_node_map[i].end_pfn, data);
+		if (ret)
+			break;
+	}
 }
 /**
  * sparse_memory_present_with_active_regions - Call memory_present for each active range

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC [PATCH] x86: try to remove arch_get_ram_range
  2008-06-17  3:10 RFC [PATCH] x86: try to remove arch_get_ram_range Yinghai Lu
@ 2008-06-18 14:07 ` Ingo Molnar
  2008-06-18 15:48   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2008-06-18 14:07 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Thomas Gleixner, H. Peter Anvin, Andrew Morton,
	Keshavamurthy, Anil S, Jan Engelhardt,
	linux-kernel@vger.kernel.org


* Yinghai Lu <yhlu.kernel@gmail.com> wrote:

> want to remove arch_get_ram_range, and use early_node_map instead.

(small request: please include diffstat output in your patches in the 
future if possible: "quilt refresh --diffstat" will do that - this way 
people will know why they were Cc:-ed)

this touches the MM:

 arch/x86/mm/init_32.c     |    6 +++--
 drivers/pci/intel-iommu.c |   51 +++++++++++++++++++++++++++++++++-------------
 include/linux/mm.h        |    2 -
 mm/page_alloc.c           |   10 ++++++---
 4 files changed, 49 insertions(+), 20 deletions(-)

but has many dependencies on ongoing arch/x86 work. Andrew, is this 
change fine with with you?

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC [PATCH] x86: try to remove arch_get_ram_range
  2008-06-18 14:07 ` Ingo Molnar
@ 2008-06-18 15:48   ` Andrew Morton
  2008-06-18 16:20     ` Yinghai Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2008-06-18 15:48 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Yinghai Lu, Thomas Gleixner, H. Peter Anvin,
	Keshavamurthy, Anil S, Jan Engelhardt,
	linux-kernel@vger.kernel.org

On Wed, 18 Jun 2008 16:07:26 +0200 Ingo Molnar <mingo@elte.hu> wrote:

> 
> * Yinghai Lu <yhlu.kernel@gmail.com> wrote:
> 
> > want to remove arch_get_ram_range, and use early_node_map instead.
> 
> (small request: please include diffstat output in your patches in the 
> future if possible: "quilt refresh --diffstat" will do that - this way 
> people will know why they were Cc:-ed)
> 
> this touches the MM:
> 
>  arch/x86/mm/init_32.c     |    6 +++--
>  drivers/pci/intel-iommu.c |   51 +++++++++++++++++++++++++++++++++-------------
>  include/linux/mm.h        |    2 -
>  mm/page_alloc.c           |   10 ++++++---
>  4 files changed, 49 insertions(+), 20 deletions(-)
> 
> but has many dependencies on ongoing arch/x86 work. Andrew, is this 
> change fine with with you?
> 

Beats me - I don't even have a mm/page_alloc.c:work_with_active_regions()
in my tree.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC [PATCH] x86: try to remove arch_get_ram_range
  2008-06-18 15:48   ` Andrew Morton
@ 2008-06-18 16:20     ` Yinghai Lu
  0 siblings, 0 replies; 4+ messages in thread
From: Yinghai Lu @ 2008-06-18 16:20 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
	Keshavamurthy, Anil S, Jan Engelhardt,
	linux-kernel@vger.kernel.org

On Wed, Jun 18, 2008 at 8:48 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Wed, 18 Jun 2008 16:07:26 +0200 Ingo Molnar <mingo@elte.hu> wrote:
>
>>
>> * Yinghai Lu <yhlu.kernel@gmail.com> wrote:
>>
>> > want to remove arch_get_ram_range, and use early_node_map instead.
>>
>> (small request: please include diffstat output in your patches in the
>> future if possible: "quilt refresh --diffstat" will do that - this way
>> people will know why they were Cc:-ed)
>>
>> this touches the MM:
>>
>>  arch/x86/mm/init_32.c     |    6 +++--
>>  drivers/pci/intel-iommu.c |   51 +++++++++++++++++++++++++++++++++-------------
>>  include/linux/mm.h        |    2 -
>>  mm/page_alloc.c           |   10 ++++++---
>>  4 files changed, 49 insertions(+), 20 deletions(-)
>>
>> but has many dependencies on ongoing arch/x86 work. Andrew, is this
>> change fine with with you?
>>
>
> Beats me - I don't even have a mm/page_alloc.c:work_with_active_regions()
> in my tree.
>

i cut and paste from tip...

commit a6b01b5fe51a99ecc0844a9e646819941227fd25
Author: Yinghai Lu <yhlu.kernel@gmail.com>
Date:   Mon Jun 16 20:10:55 2008 -0700

    RFC x86: try to remove arch_get_ram_range

    want to remove arch_get_ram_range, and use early_node_map instead.

    Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 67f8f6a..017ac56 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2933,10 +2933,14 @@ void __init free_bootmem_with_active_regions(int nid,
 void __init work_with_active_regions(int nid, work_fn_t work_fn, void *data)
 {
        int i;
+       int ret;

-       for_each_active_range_index_in_nid(i, nid)
-               work_fn(early_node_map[i].start_pfn, early_node_map[i].end_pfn,
-                       data);
+       for_each_active_range_index_in_nid(i, nid) {
+               ret = work_fn(early_node_map[i].start_pfn,
+                             early_node_map[i].end_pfn, data);
+               if (ret)
+                       break;
+       }
 }
 /**
  * sparse_memory_present_with_active_regions - Call memory_present
for each active range

commit e827df2898d988698e5b829009255579638a0110
Author: Yinghai Lu <yhlu.kernel@gmail.com>
Date:   Sat Jun 14 18:32:52 2008 -0700

    x86, mm: use add_highpages_with_active_regions() for high pages init v2

    use early_node_map to init high pages, so we can remove page_is_ram() and
    page_is_reserved_early() in the big loop with add_one_highpage

    also remove page_is_reserved_early(), it is not needed anymore.

    v2: fix the build of other platforms

    Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 26a028c..8548eea 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2955,6 +2955,14 @@ void __init free_bootmem_with_active_regions(int nid,
        }
 }

+void __init work_with_active_regions(int nid, work_fn_t work_fn, void *data)
+{
+       int i;
+
+       for_each_active_range_index_in_nid(i, nid)
+               work_fn(early_node_map[i].start_pfn, early_node_map[i].end_pfn,
+                       data);
+}
 /**
  * sparse_memory_present_with_active_regions - Call memory_present
for each active range
  * @nid: The node to call memory_present for. If MAX_NUMNODES, all
nodes will be used.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-06-18 16:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-17  3:10 RFC [PATCH] x86: try to remove arch_get_ram_range Yinghai Lu
2008-06-18 14:07 ` Ingo Molnar
2008-06-18 15:48   ` Andrew Morton
2008-06-18 16:20     ` Yinghai Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox