Re: [RFC PATCH v2 2/13] memory-hotplug : add physical memory hotplug code to acpi_memory_device_remove

2012-07-02 Thread Wen Congyang
At 07/03/2012 01:54 PM, Yasuaki Ishimatsu Wrote:
> acpi_memory_device_remove() has been prepared to remove physical memory.
> But, the function only frees acpi_memory_device currentlry.
> 
> The patch adds following functions into acpi_memory_device_remove():
>   - offline memory
>   - remove physical memory (only return -EBUSY)
>   - free acpi_memory_device
> 
> CC: David Rientjes 
> CC: Jiang Liu 
> CC: Len Brown 
> CC: Benjamin Herrenschmidt 
> CC: Paul Mackerras 
> CC: Christoph Lameter 
> Cc: Minchan Kim 
> CC: Andrew Morton 
> CC: KOSAKI Motohiro 
> Signed-off-by: Yasuaki Ishimatsu 
> 
> ---
>  drivers/acpi/acpi_memhotplug.c |   26 +-
>  drivers/base/memory.c  |   38 ++
>  include/linux/memory.h |5 +
>  include/linux/memory_hotplug.h |1 +
>  mm/memory_hotplug.c|8 
>  5 files changed, 77 insertions(+), 1 deletion(-)
> 
> Index: linux-3.5-rc4/drivers/acpi/acpi_memhotplug.c
> ===
> --- linux-3.5-rc4.orig/drivers/acpi/acpi_memhotplug.c 2012-07-03 
> 14:21:49.458374960 +0900
> +++ linux-3.5-rc4/drivers/acpi/acpi_memhotplug.c  2012-07-03 
> 14:21:58.329264059 +0900
> @@ -29,6 +29,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -452,12 +453,35 @@ static int acpi_memory_device_add(struct
>  static int acpi_memory_device_remove(struct acpi_device *device, int type)
>  {
>   struct acpi_memory_device *mem_device = NULL;
> -
> + struct acpi_memory_info *info, *tmp;
> + int result;
> + int node;
> 
>   if (!device || !acpi_driver_data(device))
>   return -EINVAL;
> 
>   mem_device = acpi_driver_data(device);
> +
> + node = acpi_get_node(mem_device->device->handle);
> +
> + list_for_each_entry_safe(info, tmp, &mem_device->res_list, list) {
> + if (!info->enabled)
> + continue;
> +
> + if (!is_memblk_offline(info->start_addr, info->length)) {
> + result = offline_memory(info->start_addr, info->length);
> + if (result)
> + return result;
> + }
> +
> + result = remove_memory(node, info->start_addr, info->length);
> + if (result)
> + return result;
> +
> + list_del(&info->list);
> + kfree(info);
> + }
> +
>   kfree(mem_device);

The caller does not care the return value, and after this function returns, the
memory device will be unbound from this driver, so we should free all memory
allocated for driver data.

> 
>   return 0;
> Index: linux-3.5-rc4/include/linux/memory_hotplug.h
> ===
> --- linux-3.5-rc4.orig/include/linux/memory_hotplug.h 2012-07-03 
> 14:21:49.471374796 +0900
> +++ linux-3.5-rc4/include/linux/memory_hotplug.h  2012-07-03 
> 14:21:58.330264047 +0900
> @@ -233,6 +233,7 @@ static inline int is_mem_section_removab
>  extern int mem_online_node(int nid);
>  extern int add_memory(int nid, u64 start, u64 size);
>  extern int arch_add_memory(int nid, u64 start, u64 size);
> +extern int remove_memory(int nid, u64 start, u64 size);
>  extern int offline_memory(u64 start, u64 size);
>  extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
>   int nr_pages);
> Index: linux-3.5-rc4/mm/memory_hotplug.c
> ===
> --- linux-3.5-rc4.orig/mm/memory_hotplug.c2012-07-03 14:21:49.466374860 
> +0900
> +++ linux-3.5-rc4/mm/memory_hotplug.c 2012-07-03 14:21:58.332264022 +0900
> @@ -659,6 +659,14 @@ out:
>  }
>  EXPORT_SYMBOL_GPL(add_memory);
> 
> +int remove_memory(int nid, u64 start, u64 size)
> +{
> + return -EBUSY;
> +
> +}
> +EXPORT_SYMBOL_GPL(remove_memory);
> +
> +
>  #ifdef CONFIG_MEMORY_HOTREMOVE
>  /*
>   * A free page on the buddy free lists (not the per-cpu lists) has PageBuddy
> Index: linux-3.5-rc4/drivers/base/memory.c
> ===
> --- linux-3.5-rc4.orig/drivers/base/memory.c  2012-07-03 14:21:49.459374948 
> +0900
> +++ linux-3.5-rc4/drivers/base/memory.c   2012-07-03 14:21:58.335263984 
> +0900
> @@ -70,6 +70,44 @@ void unregister_memory_isolate_notifier(
>  }
>  EXPORT_SYMBOL(unregister_memory_isolate_notifier);
> 
> +bool is_memblk_offline(unsigned long start, unsigned long size)
> +{
> + struct memory_block *mem = NULL;
> + struct mem_section *section;
> + unsigned long start_pfn, end_pfn;
> + unsigned long pfn, section_nr;
> +
> + start_pfn = PFN_DOWN(start);
> + end_pfn = start_pfn + PFN_DOWN(start);
> +
> + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
> + section_nr = pfn_to_section_nr(pfn

[PATCH v2] cpuidle: (POWER) Replace pseries_notify_cpuidle_add call with a notifier to fix lockdep problem in start_secondary

2012-07-02 Thread Deepthi Dharwar
cpuidle: (POWER) Replace pseries_notify_cpuidle_add call with a notifier to fix 
lockdep problem in start_secondary

From: Deepthi Dharwar 

Currently the call to pseries_notify_cpuidle_add(), that takes
action on the cpuidle front when a cpu is added/removed
is being made from smp_xics_setup_cpu().
This works fine when the cpus were hot added/removed once the
system is up but causes lockdep issues as
reported https://lkml.org/lkml/2012/5/17/2
during the time of boot.

During boot, on addition of each cpu,
resources were cleared and re-allocated each time, all in critical
section as part of start_secondary() which had interrupts disabled.
To resolve this issue, replacing the pseries_notify_cpuidle_add_cpu() call
with a hotplug notifier.  This would prevent cpuidle resources from being
released and allocated each time cpu is onlined during pseries bootup.

Signed-off-by: Deepthi Dharwar 
Reported-by: Paul E. McKenney 
Reviewed-by: Srivatsa S. Bhat 

---
This patch has in-corporated review comments
received on the earlier version posted.
v1 ->  https://lkml.org/lkml/2012/5/18/174
This applies on 3.5-rc5
---
 arch/powerpc/include/asm/processor.h|2 -
 arch/powerpc/platforms/pseries/processor_idle.c |   35 ---
 arch/powerpc/platforms/pseries/smp.c|1 -
 3 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/include/asm/processor.h 
b/arch/powerpc/include/asm/processor.h
index 413a5ea..53b6dfa 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -389,10 +389,8 @@ extern int powersave_nap;  /* set if nap mode can be used 
in idle loop */
 
 #ifdef CONFIG_PSERIES_IDLE
 extern void update_smt_snooze_delay(int snooze);
-extern int pseries_notify_cpuidle_add_cpu(int cpu);
 #else
 static inline void update_smt_snooze_delay(int snooze) {}
-static inline int pseries_notify_cpuidle_add_cpu(int cpu) { return 0; }
 #endif
 
 extern void flush_instruction_cache(void);
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c 
b/arch/powerpc/platforms/pseries/processor_idle.c
index e61483e..da245c0 100644
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ b/arch/powerpc/platforms/pseries/processor_idle.c
@@ -186,17 +186,40 @@ static struct cpuidle_state 
shared_states[MAX_IDLE_STATE_COUNT] = {
.enter = &shared_cede_loop },
 };
 
-int pseries_notify_cpuidle_add_cpu(int cpu)
+static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n,
+   unsigned long action, void *hcpu)
 {
+   int hotcpu = (unsigned long)hcpu;
struct cpuidle_device *dev =
-   per_cpu_ptr(pseries_cpuidle_devices, cpu);
+   per_cpu_ptr(pseries_cpuidle_devices, hotcpu);
+
if (dev && cpuidle_get_driver()) {
-   cpuidle_disable_device(dev);
-   cpuidle_enable_device(dev);
+   switch (action) {
+   case CPU_ONLINE:
+   case CPU_ONLINE_FROZEN:
+   cpuidle_pause_and_lock();
+   cpuidle_enable_device(dev);
+   cpuidle_resume_and_unlock();
+   break;
+
+   case CPU_DEAD:
+   case CPU_DEAD_FROZEN:
+   cpuidle_pause_and_lock();
+   cpuidle_disable_device(dev);
+   cpuidle_resume_and_unlock();
+   break;
+
+   default:
+   return NOTIFY_DONE;
+   }
}
-   return 0;
+   return NOTIFY_OK;
 }
 
+static struct notifier_block setup_hotplug_notifier = {
+   .notifier_call = pseries_cpuidle_add_cpu_notifier,
+};
+
 /*
  * pseries_cpuidle_driver_init()
  */
@@ -321,6 +344,7 @@ static int __init pseries_processor_idle_init(void)
return retval;
}
 
+   register_cpu_notifier(&setup_hotplug_notifier);
printk(KERN_DEBUG "pseries_idle_driver registered\n");
 
return 0;
@@ -329,6 +353,7 @@ static int __init pseries_processor_idle_init(void)
 static void __exit pseries_processor_idle_exit(void)
 {
 
+   unregister_cpu_notifier(&setup_hotplug_notifier);
pseries_idle_devices_uninit();
cpuidle_unregister_driver(&pseries_idle_driver);
 
diff --git a/arch/powerpc/platforms/pseries/smp.c 
b/arch/powerpc/platforms/pseries/smp.c
index e16bb8d..71706bc 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -147,7 +147,6 @@ static void __devinit smp_xics_setup_cpu(int cpu)
set_cpu_current_state(cpu, CPU_STATE_ONLINE);
set_default_offline_state(cpu);
 #endif
-   pseries_notify_cpuidle_add_cpu(cpu);
 }
 
 static int __devinit smp_pSeries_kick_cpu(int nr)

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH v2 4/13] memory-hotplug : remove /sys/firmware/memmap/X sysfs

2012-07-02 Thread Wen Congyang
At 07/03/2012 01:56 PM, Yasuaki Ishimatsu Wrote:
> When (hot)adding memory into system, /sys/firmware/memmap/X/{end, start, type}
> sysfs files are created. But there is no code to remove these files. The patch
> implements the function to remove them.
> 
> Note : The code does not free firmware_map_entry since there is no way to free
>memory which is allocated by bootmem.
> 
> CC: David Rientjes 
> CC: Jiang Liu 
> CC: Len Brown 
> CC: Benjamin Herrenschmidt 
> CC: Paul Mackerras 
> CC: Christoph Lameter 
> Cc: Minchan Kim 
> CC: Andrew Morton 
> CC: KOSAKI Motohiro 
> Signed-off-by: Yasuaki Ishimatsu 
> 
> ---
>  drivers/firmware/memmap.c|   70 
> +++
>  include/linux/firmware-map.h |6 +++
>  mm/memory_hotplug.c  |6 +++
>  3 files changed, 81 insertions(+), 1 deletion(-)
> 
> Index: linux-3.5-rc4/mm/memory_hotplug.c
> ===
> --- linux-3.5-rc4.orig/mm/memory_hotplug.c2012-07-03 14:22:00.190240794 
> +0900
> +++ linux-3.5-rc4/mm/memory_hotplug.c 2012-07-03 14:22:03.549198802 +0900
> @@ -661,7 +661,11 @@ EXPORT_SYMBOL_GPL(add_memory);
> 
>  int remove_memory(int nid, u64 start, u64 size)
>  {
> - return -EBUSY;
> + lock_memory_hotplug();
> + /* remove memmap entry */
> + firmware_map_remove(start, start + size - 1, "System RAM");
> + unlock_memory_hotplug();
> + return 0;
> 
>  }
>  EXPORT_SYMBOL_GPL(remove_memory);
> Index: linux-3.5-rc4/include/linux/firmware-map.h
> ===
> --- linux-3.5-rc4.orig/include/linux/firmware-map.h   2012-07-03 
> 14:21:45.766421116 +0900
> +++ linux-3.5-rc4/include/linux/firmware-map.h2012-07-03 
> 14:22:03.550198789 +0900
> @@ -25,6 +25,7 @@
> 
>  int firmware_map_add_early(u64 start, u64 end, const char *type);
>  int firmware_map_add_hotplug(u64 start, u64 end, const char *type);
> +int firmware_map_remove(u64 start, u64 end, const char *type);
> 
>  #else /* CONFIG_FIRMWARE_MEMMAP */
> 
> @@ -38,6 +39,11 @@ static inline int firmware_map_add_hotpl
>   return 0;
>  }
> 
> +static inline int firmware_map_remove(u64 start, u64 end, const char *type)
> +{
> + return 0;
> +}
> +
>  #endif /* CONFIG_FIRMWARE_MEMMAP */
> 
>  #endif /* _LINUX_FIRMWARE_MAP_H */
> Index: linux-3.5-rc4/drivers/firmware/memmap.c
> ===
> --- linux-3.5-rc4.orig/drivers/firmware/memmap.c  2012-07-03 
> 14:21:45.761421180 +0900
> +++ linux-3.5-rc4/drivers/firmware/memmap.c   2012-07-03 14:22:03.569198549 
> +0900
> @@ -79,7 +79,16 @@ static const struct sysfs_ops memmap_att
>   .show = memmap_attr_show,
>  };
> 
> +static void release_firmware_map_entry(struct kobject *kobj)
> +{
> + /*
> +  * FIXME : There is no idea.
> +  * How to free the entry which allocated bootmem?
> +  */

I find a function free_bootmem(), but I am not sure whether it can work here.
Another problem: how to check whether the entry uses bootmem?

Thanks
Wen Congyang

> +}
> +
>  static struct kobj_type memmap_ktype = {
> + .release= release_firmware_map_entry,
>   .sysfs_ops  = &memmap_attr_ops,
>   .default_attrs  = def_attrs,
>  };
> @@ -123,6 +132,16 @@ static int firmware_map_add_entry(u64 st
>   return 0;
>  }
> 
> +/**
> + * firmware_map_remove_entry() - Does the real work to remove a firmware
> + * memmap entry.
> + * @entry: removed entry.
> + **/
> +static inline void firmware_map_remove_entry(struct firmware_map_entry 
> *entry)
> +{
> + list_del(&entry->list);
> +}
> +
>  /*
>   * Add memmap entry on sysfs
>   */
> @@ -144,6 +163,31 @@ static int add_sysfs_fw_map_entry(struct
>   return 0;
>  }
> 
> +/*
> + * Remove memmap entry on sysfs
> + */
> +static inline void remove_sysfs_fw_map_entry(struct firmware_map_entry 
> *entry)
> +{
> + kobject_put(&entry->kobj);
> +}
> +
> +/*
> + * Search memmap entry
> + */
> +
> +struct firmware_map_entry * __meminit
> +find_firmware_map_entry(u64 start, u64 end, const char *type)
> +{
> + struct firmware_map_entry *entry;
> +
> + list_for_each_entry(entry, &map_entries, list)
> + if ((entry->start == start) && (entry->end == end) &&
> + (!strcmp(entry->type, type)))
> + return entry;
> +
> + return NULL;
> +}
> +
>  /**
>   * firmware_map_add_hotplug() - Adds a firmware mapping entry when we do
>   * memory hotplug.
> @@ -196,6 +240,32 @@ int __init firmware_map_add_early(u64 st
>   return firmware_map_add_entry(start, end, type, entry);
>  }
> 
> +/**
> + * firmware_map_remove() - remove a firmware mapping entry
> + * @start: Start of the memory range.
> + * @end:   End of the memory range (inclusive).
> + * @type:  Type of the memory range.
> + *
> + * removes a firmware mapping entry.
> + *
> + * Returns 0 on success, or -EINVAL if no entry.
> + **/
> 

[RFC PATCH v2 13/13] memory-hotplug : remove sysfs file of node

2012-07-02 Thread Yasuaki Ishimatsu
The patch adds node_set_offline() and unregister_one_node() to remove_memory()
for removing sysfs file of node.

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 mm/memory_hotplug.c |5 +
 1 file changed, 5 insertions(+)

Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:22:21.012982694 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:22:25.405925554 +0900
@@ -702,6 +702,11 @@ int remove_memory(int nid, u64 start, u6
/* remove memmap entry */
firmware_map_remove(start, start + size - 1, "System RAM");

+   if (!node_present_pages(nid)) {
+   node_set_offline(nid);
+   unregister_one_node(nid);
+   }
+
__remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT);
unlock_memory_hotplug();
return 0;

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v2 12/13] memory-hotplug : add node_device_release

2012-07-02 Thread Yasuaki Ishimatsu
When calling unregister_node(), the function shows following message at
device_release().

Device 'node2' does not have a release() function, it is broken and must be
fixed.

So the patch implements node_device_release()

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 drivers/base/node.c |7 +++
 1 file changed, 7 insertions(+)

Index: linux-3.5-rc4/drivers/base/node.c
===
--- linux-3.5-rc4.orig/drivers/base/node.c  2012-07-03 14:21:44.882432167 
+0900
+++ linux-3.5-rc4/drivers/base/node.c   2012-07-03 14:22:23.296951921 +0900
@@ -252,6 +252,12 @@ static inline void hugetlb_register_node
 static inline void hugetlb_unregister_node(struct node *node) {}
 #endif

+static void node_device_release(struct device *dev)
+{
+   struct node *node_dev = to_node(dev);
+
+   memset(node_dev, 0, sizeof(struct node));
+}

 /*
  * register_node - Setup a sysfs device for a node.
@@ -265,6 +271,7 @@ int register_node(struct node *node, int

node->dev.id = num;
node->dev.bus = &node_subsys;
+   node->dev.release = node_device_release;
error = device_register(&node->dev);

if (!error){

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v2 11/13] memory-hotplug : free memmap of sparse-vmemmap

2012-07-02 Thread Yasuaki Ishimatsu
I don't think that all pages of virtual mapping in removed memory can be
freed, since page which type is MIX_SECTION_INFO is difficult to free.
So, the patch only frees page which type is SECTION_INFO at first.

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 arch/x86/mm/init_64.c |   91 ++
 include/linux/mm.h|2 +
 mm/memory_hotplug.c   |5 ++
 mm/sparse.c   |5 +-
 4 files changed, 101 insertions(+), 2 deletions(-)

Index: linux-3.5-rc4/include/linux/mm.h
===
--- linux-3.5-rc4.orig/include/linux/mm.h   2012-07-03 14:22:18.530011567 
+0900
+++ linux-3.5-rc4/include/linux/mm.h2012-07-03 14:22:20.83872 +0900
@@ -1588,6 +1588,8 @@ int vmemmap_populate(struct page *start_
 void vmemmap_populate_print_last(void);
 void register_page_bootmem_memmap(unsigned long section_nr, struct page *map,
  unsigned long size);
+void vmemmap_kfree(struct page *memmpa, unsigned long nr_pages);
+void vmemmap_free_bootmem(struct page *memmpa, unsigned long nr_pages);

 enum mf_flags {
MF_COUNT_INCREASED = 1 << 0,
Index: linux-3.5-rc4/mm/sparse.c
===
--- linux-3.5-rc4.orig/mm/sparse.c  2012-07-03 14:21:45.071429805 +0900
+++ linux-3.5-rc4/mm/sparse.c   2012-07-03 14:22:21.000983767 +0900
@@ -614,12 +614,13 @@ static inline struct page *kmalloc_secti
/* This will make the necessary allocations eventually. */
return sparse_mem_map_populate(pnum, nid);
 }
-static void __kfree_section_memmap(struct page *memmap, unsigned long nr_pages)
+static void __kfree_section_memmap(struct page *page, unsigned long nr_pages)
 {
-   return; /* XXX: Not implemented yet */
+   vmemmap_kfree(page, nr_pages);
 }
 static void free_map_bootmem(struct page *page, unsigned long nr_pages)
 {
+   vmemmap_free_bootmem(page, nr_pages);
 }
 #else
 static struct page *__kmalloc_section_memmap(unsigned long nr_pages)
Index: linux-3.5-rc4/arch/x86/mm/init_64.c
===
--- linux-3.5-rc4.orig/arch/x86/mm/init_64.c2012-07-03 14:22:18.538011465 
+0900
+++ linux-3.5-rc4/arch/x86/mm/init_64.c 2012-07-03 14:22:21.007983103 +0900
@@ -978,6 +978,97 @@ vmemmap_populate(struct page *start_page
return 0;
 }

+unsigned long find_and_clear_pte_page(unsigned long addr, unsigned long end,
+ struct page **pp)
+{
+   pgd_t *pgd;
+   pud_t *pud;
+   pmd_t *pmd;
+   pte_t *pte;
+   unsigned long next;
+
+   *pp = NULL;
+
+   pgd = pgd_offset_k(addr);
+   if (pgd_none(*pgd))
+   return (addr + PAGE_SIZE) & PAGE_MASK;
+
+   pud = pud_offset(pgd, addr);
+   if (pud_none(*pud))
+   return (addr + PAGE_SIZE) & PAGE_MASK;
+
+   if (!cpu_has_pse) {
+   next = (addr + PAGE_SIZE) & PAGE_MASK;
+   pmd = pmd_offset(pud, addr);
+   if (pmd_none(*pmd))
+   return next;
+
+   pte = pte_offset_kernel(pmd, addr);
+   if (pte_none(*pte))
+   return next;
+
+   *pp = pte_page(*pte);
+   pte_clear(&init_mm, addr, pte);
+   } else {
+   next = pmd_addr_end(addr, end);
+
+   pmd = pmd_offset(pud, addr);
+   if (pmd_none(*pmd))
+   return next;
+
+   *pp = pmd_page(*pmd);
+   pmd_clear(pmd);
+   }
+
+   return next;
+}
+
+void __meminit
+vmemmap_kfree(struct page *memmap, unsigned long nr_pages)
+{
+   unsigned long addr = (unsigned long)memmap;
+   unsigned long end = (unsigned long)(memmap + nr_pages);
+   unsigned long next;
+   unsigned int order;
+   struct page *page;
+
+   for (; addr < end; addr = next) {
+   page = NULL;
+   next = find_and_clear_pte_page(addr, end, &page);
+   if (!page)
+   continue;
+
+   if (is_vmalloc_addr(page_address(page)))
+   vfree(page_address(page));
+   else {
+   order = next - addr;
+   free_pages((unsigned long)page_address(page),
+  get_order(order));
+   }
+   }
+}
+
+void __meminit
+vmemmap_free_bootmem(struct page *memmap, unsigned long nr_pages)
+{
+   unsigned long addr = (unsigned long)memmap;
+   unsigned long end = (unsigned long)(memmap + nr_pages);
+   unsigned long next;
+   struct page *page;
+   unsigned long magic;
+
+   for (; addr < end; addr = next) {
+   page = NULL;
+

[RFC PATCH v2 10/13] memory-hotplug : implement register_page_bootmem_info_section of sparse-vmemmap

2012-07-02 Thread Yasuaki Ishimatsu
For removing memmap region of sparse-vmemmap which is allocated bootmem,
memmap region of sparse-vmemmap needs to be registered by get_page_bootmem().
So the patch searches pages of virtual mapping and registers the pages by
get_page_bootmem().

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 arch/x86/mm/init_64.c  |   53 +
 include/linux/memory_hotplug.h |2 +
 include/linux/mm.h |3 +-
 mm/memory_hotplug.c|   23 +++--
 4 files changed, 77 insertions(+), 4 deletions(-)

Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:22:14.419062959 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:22:18.522011667 +0900
@@ -91,8 +91,8 @@ static void release_memory_resource(stru
 }

 #ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
-static void get_page_bootmem(unsigned long info,  struct page *page,
-unsigned long type)
+void get_page_bootmem(unsigned long info,  struct page *page,
+ unsigned long type)
 {
unsigned long page_type;

@@ -164,8 +164,25 @@ static void register_page_bootmem_info_s

 }
 #else
-static inline void register_page_bootmem_info_section(unsigned long start_pfn)
+static void register_page_bootmem_info_section(unsigned long start_pfn)
 {
+   unsigned long mapsize, section_nr;
+   struct mem_section *ms;
+   struct page *page, *memmap;
+
+   if (!pfn_valid(start_pfn))
+   return;
+
+   section_nr = pfn_to_section_nr(start_pfn);
+   ms = __nr_to_section(section_nr);
+
+   memmap = sparse_decode_mem_map(ms->section_mem_map, section_nr);
+
+   page = virt_to_page(memmap);
+   mapsize = sizeof(struct page) * PAGES_PER_SECTION;
+   mapsize = PAGE_ALIGN(mapsize) >> PAGE_SHIFT;
+
+   register_page_bootmem_memmap(section_nr, memmap, PAGES_PER_SECTION);
 }
 #endif

Index: linux-3.5-rc4/include/linux/mm.h
===
--- linux-3.5-rc4.orig/include/linux/mm.h   2012-07-03 14:21:45.223427904 
+0900
+++ linux-3.5-rc4/include/linux/mm.h2012-07-03 14:22:18.530011567 +0900
@@ -1586,7 +1586,8 @@ int vmemmap_populate_basepages(struct pa
unsigned long pages, int node);
 int vmemmap_populate(struct page *start_page, unsigned long pages, int node);
 void vmemmap_populate_print_last(void);
-
+void register_page_bootmem_memmap(unsigned long section_nr, struct page *map,
+ unsigned long size);

 enum mf_flags {
MF_COUNT_INCREASED = 1 << 0,
Index: linux-3.5-rc4/arch/x86/mm/init_64.c
===
--- linux-3.5-rc4.orig/arch/x86/mm/init_64.c2012-07-03 14:21:45.228427843 
+0900
+++ linux-3.5-rc4/arch/x86/mm/init_64.c 2012-07-03 14:22:18.538011465 +0900
@@ -978,6 +978,59 @@ vmemmap_populate(struct page *start_page
return 0;
 }

+void __meminit
+register_page_bootmem_memmap(unsigned long section_nr, struct page *start_page,
+unsigned long size)
+{
+   unsigned long addr = (unsigned long)start_page;
+   unsigned long end = (unsigned long)(start_page + size);
+   unsigned long next;
+   pgd_t *pgd;
+   pud_t *pud;
+   pmd_t *pmd;
+
+   for (; addr < end; addr = next) {
+   pte_t *pte = NULL;
+
+   pgd = pgd_offset_k(addr);
+   if (pgd_none(*pgd)) {
+   next = (addr + PAGE_SIZE) & PAGE_MASK;
+   continue;
+   }
+   get_page_bootmem(section_nr, pgd_page(*pgd), MIX_SECTION_INFO);
+
+   pud = pud_offset(pgd, addr);
+   if (pud_none(*pud)) {
+   next = (addr + PAGE_SIZE) & PAGE_MASK;
+   continue;
+   }
+   get_page_bootmem(section_nr, pud_page(*pud), MIX_SECTION_INFO);
+
+   if (!cpu_has_pse) {
+   next = (addr + PAGE_SIZE) & PAGE_MASK;
+   pmd = pmd_offset(pud, addr);
+   if (pmd_none(*pmd))
+   continue;
+   get_page_bootmem(section_nr, pmd_page(*pmd),
+MIX_SECTION_INFO);
+
+   pte = pte_offset_kernel(pmd, addr);
+   if (pte_none(*pte))
+   continue;
+   get_page_bootmem(section_nr, pte_page(*pte),
+SECTION_INFO);
+   } else {
+   next = pmd_addr_end(addr, end);
+
+ 

[RFC PATCH v2 9/13] memory-hotplug : move register_page_bootmem_info_node and put_page_bootmem for sparse-vmemmap

2012-07-02 Thread Yasuaki Ishimatsu
For implementing register_page_bootmem_info_node of sparse-vmemmap,
register_page_bootmem_info_node and put_page_bootmem are moved to
memory_hotplug.c

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 include/linux/memory_hotplug.h |9 -
 mm/memory_hotplug.c|8 ++--
 2 files changed, 6 insertions(+), 11 deletions(-)

Index: linux-3.5-rc4/include/linux/memory_hotplug.h
===
--- linux-3.5-rc4.orig/include/linux/memory_hotplug.h   2012-07-03 
14:22:10.170116406 +0900
+++ linux-3.5-rc4/include/linux/memory_hotplug.h2012-07-03 
14:22:14.409063086 +0900
@@ -160,17 +160,8 @@ static inline void arch_refresh_nodedata
 #endif /* CONFIG_NUMA */
 #endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */

-#ifdef CONFIG_SPARSEMEM_VMEMMAP
-static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
-{
-}
-static inline void put_page_bootmem(struct page *page)
-{
-}
-#else
 extern void register_page_bootmem_info_node(struct pglist_data *pgdat);
 extern void put_page_bootmem(struct page *page);
-#endif

 /*
  * Lock for memory hotplug guarantees 1) all callbacks for memory hotplug
Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:22:12.299089413 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:22:14.419062959 +0900
@@ -91,7 +91,6 @@ static void release_memory_resource(stru
 }

 #ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
-#ifndef CONFIG_SPARSEMEM_VMEMMAP
 static void get_page_bootmem(unsigned long info,  struct page *page,
 unsigned long type)
 {
@@ -127,6 +126,7 @@ void __ref put_page_bootmem(struct page

 }

+#ifndef CONFIG_SPARSEMEM_VMEMMAP
 static void register_page_bootmem_info_section(unsigned long start_pfn)
 {
unsigned long *usemap, mapsize, section_nr, i;
@@ -163,6 +163,11 @@ static void register_page_bootmem_info_s
get_page_bootmem(section_nr, page, MIX_SECTION_INFO);

 }
+#else
+static inline void register_page_bootmem_info_section(unsigned long start_pfn)
+{
+}
+#endif

 void register_page_bootmem_info_node(struct pglist_data *pgdat)
 {
@@ -198,7 +203,6 @@ void register_page_bootmem_info_node(str
register_page_bootmem_info_section(pfn);

 }
-#endif /* !CONFIG_SPARSEMEM_VMEMMAP */

 static void grow_zone_span(struct zone *zone, unsigned long start_pfn,
   unsigned long end_pfn)

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v2 8/13] memory-hotplug : check page type in get_page_bootmem

2012-07-02 Thread Yasuaki Ishimatsu
There is a possibility that get_page_bootmem() is called to the same page many
times. So when get_page_bootmem is called to the same page, the function only
increments page->_count.

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 mm/memory_hotplug.c |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:22:10.170116406 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:22:12.299089413 +0900
@@ -95,10 +95,17 @@ static void release_memory_resource(stru
 static void get_page_bootmem(unsigned long info,  struct page *page,
 unsigned long type)
 {
-   page->lru.next = (struct list_head *) type;
-   SetPagePrivate(page);
-   set_page_private(page, info);
-   atomic_inc(&page->_count);
+   unsigned long page_type;
+
+   page_type = (unsigned long) page->lru.next;
+   if (type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
+   type > MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE){
+   page->lru.next = (struct list_head *) type;
+   SetPagePrivate(page);
+   set_page_private(page, info);
+   atomic_inc(&page->_count);
+   } else
+   atomic_inc(&page->_count);
 }

 /* reference to __meminit __free_pages_bootmem is valid

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v2 7/13] memory-hotplug : remove_memory calls __remove_pages

2012-07-02 Thread Yasuaki Ishimatsu
The patch adds __remove_pages() to remove_memory(). Then the range of
phys_start_pfn argument and nr_pages argument in __remove_pagse() may
have different zone. So zone argument is removed from __remove_pages()
and __remove_pages() caluculates zone in each section.

When CONFIG_SPARSEMEM_VMEMMAP is defined, there is no way to remove a memmap.
So __remove_section only calls unregister_memory_section().

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 arch/powerpc/platforms/pseries/hotplug-memory.c |5 +
 include/linux/memory_hotplug.h  |3 +--
 mm/memory_hotplug.c |   20 +---
 3 files changed, 15 insertions(+), 13 deletions(-)

Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:22:05.919169458 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:22:10.170116406 +0900
@@ -275,11 +275,14 @@ static int __meminit __add_section(int n
 #ifdef CONFIG_SPARSEMEM_VMEMMAP
 static int __remove_section(struct zone *zone, struct mem_section *ms)
 {
-   /*
-* XXX: Freeing memmap with vmemmap is not implement yet.
-*  This should be removed later.
-*/
-   return -EBUSY;
+   int ret;
+
+   if (!valid_section(ms))
+   return ret;
+
+   ret = unregister_memory_section(ms);
+
+   return ret;
 }
 #else
 static int __remove_section(struct zone *zone, struct mem_section *ms)
@@ -346,11 +349,11 @@ EXPORT_SYMBOL_GPL(__add_pages);
  * sure that pages are marked reserved and zones are adjust properly by
  * calling offline_pages().
  */
-int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
-unsigned long nr_pages)
+int __remove_pages(unsigned long phys_start_pfn, unsigned long nr_pages)
 {
unsigned long i, ret = 0;
int sections_to_remove;
+   struct zone *zone;

/*
 * We can only remove entire sections
@@ -363,6 +366,7 @@ int __remove_pages(struct zone *zone, un
sections_to_remove = nr_pages / PAGES_PER_SECTION;
for (i = 0; i < sections_to_remove; i++) {
unsigned long pfn = phys_start_pfn + i*PAGES_PER_SECTION;
+   zone = page_zone(pfn_to_page(pfn));
ret = __remove_section(zone, __pfn_to_section(pfn));
if (ret)
break;
@@ -664,6 +668,8 @@ int remove_memory(int nid, u64 start, u6
lock_memory_hotplug();
/* remove memmap entry */
firmware_map_remove(start, start + size - 1, "System RAM");
+
+   __remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT);
unlock_memory_hotplug();
return 0;

Index: linux-3.5-rc4/include/linux/memory_hotplug.h
===
--- linux-3.5-rc4.orig/include/linux/memory_hotplug.h   2012-07-03 
14:21:58.330264047 +0900
+++ linux-3.5-rc4/include/linux/memory_hotplug.h2012-07-03 
14:22:10.170116406 +0900
@@ -89,8 +89,7 @@ extern bool is_pageblock_removable_noloc
 /* reasonably generic interface to expand the physical pages in a zone  */
 extern int __add_pages(int nid, struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages);
-extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
-   unsigned long nr_pages);
+extern int __remove_pages(unsigned long start_pfn, unsigned long nr_pages);

 #ifdef CONFIG_NUMA
 extern int memory_add_physaddr_to_nid(u64 start);
Index: linux-3.5-rc4/arch/powerpc/platforms/pseries/hotplug-memory.c
===
--- linux-3.5-rc4.orig/arch/powerpc/platforms/pseries/hotplug-memory.c  
2012-07-03 14:22:05.920169437
+0900
+++ linux-3.5-rc4/arch/powerpc/platforms/pseries/hotplug-memory.c   
2012-07-03 14:22:10.172116353 +0900
@@ -76,7 +76,6 @@ unsigned long memory_block_size_bytes(vo
 static int pseries_remove_memblock(unsigned long base, unsigned int 
memblock_size)
 {
unsigned long start, start_pfn;
-   struct zone *zone;
int i, ret;
int sections_to_remove;

@@ -87,8 +86,6 @@ static int pseries_remove_memblock(unsig
return 0;
}

-   zone = page_zone(pfn_to_page(start_pfn));
-
/*
 * Remove section mappings and sysfs entries for the
 * section of the memory we are removing.
@@ -101,7 +98,7 @@ static int pseries_remove_memblock(unsig
sections_to_remove = (memblock_size >> PAGE_SHIFT) / PAGES_PER_SECTION;
for (i = 0; i < sections_to_remove; i++) {
unsigned long pfn = start_pfn + i * PAGES_PER_SECTION;
-   ret = __remove_pages(zone, start_pfn,  PAGES_PER_SECTION);
+   ret = __remo

[RFC PATCH v2 6/13] memory-hotplug : add memory_block_release

2012-07-02 Thread Yasuaki Ishimatsu
When calling remove_memory_block(), the function shows following message at
device_release().

Device 'memory528' does not have a release() function, it is broken and must
be fixed.

remove_memory_block() calls kfree(mem). I think it shouled be called from
device_release(). So the patch implements memory_block_release()

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 drivers/base/memory.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Index: linux-3.5-rc4/drivers/base/memory.c
===
--- linux-3.5-rc4.orig/drivers/base/memory.c2012-07-03 14:21:58.335263984 
+0900
+++ linux-3.5-rc4/drivers/base/memory.c 2012-07-03 14:22:08.094141981 +0900
@@ -108,6 +108,15 @@ bool is_memblk_offline(unsigned long sta
 }
 EXPORT_SYMBOL(is_memblk_offline);

+#define to_memory_block(device) container_of(device, struct memory_block, dev)
+
+static void release_memory_block(struct device *dev)
+{
+   struct memory_block *mem = to_memory_block(dev);
+
+   kfree(mem);
+}
+
 /*
  * register_memory - Setup a sysfs device for a memory block
  */
@@ -118,6 +127,7 @@ int register_memory(struct memory_block

memory->dev.bus = &memory_subsys;
memory->dev.id = memory->start_section_nr / sections_per_block;
+   memory->dev.release = release_memory_block;

error = device_register(&memory->dev);
return error;
@@ -668,7 +678,6 @@ int remove_memory_block(unsigned long no
mem_remove_simple_file(mem, phys_device);
mem_remove_simple_file(mem, removable);
unregister_memory(mem);
-   kfree(mem);
} else
kobject_put(&mem->dev.kobj);


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v2 5/13] memory-hotplug : does not release memory region in PAGES_PER_SECTION chunks

2012-07-02 Thread Yasuaki Ishimatsu
Since applying a patch(de7f0cba96786c), release_mem_region() has been changed
as called in PAGES_PER_SECTION chunks because register_memory_resource() is
called in PAGES_PER_SECTION chunks by add_memory(). But it seems firmware
dependency. If CRS are written in the PAGES_PER_SECTION chunks in ACPI DSDT
Table, register_memory_resource() is called in PAGES_PER_SECTION chunks.
But if CRS are written in the DIMM unit in ACPI DSDT Table,
register_memory_resource() is called in DIMM unit. So release_mem_region()
should not be called in PAGES_PER_SECTION chunks. The patch fixes it.

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 arch/powerpc/platforms/pseries/hotplug-memory.c |   13 +
 mm/memory_hotplug.c |4 ++--
 2 files changed, 11 insertions(+), 6 deletions(-)

Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:22:03.549198802 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:22:05.919169458 +0900
@@ -358,11 +358,11 @@ int __remove_pages(struct zone *zone, un
BUG_ON(phys_start_pfn & ~PAGE_SECTION_MASK);
BUG_ON(nr_pages % PAGES_PER_SECTION);

+   release_mem_region(phys_start_pfn << PAGE_SHIFT,  nr_pages * PAGE_SIZE);
+
sections_to_remove = nr_pages / PAGES_PER_SECTION;
for (i = 0; i < sections_to_remove; i++) {
unsigned long pfn = phys_start_pfn + i*PAGES_PER_SECTION;
-   release_mem_region(pfn << PAGE_SHIFT,
-  PAGES_PER_SECTION << PAGE_SHIFT);
ret = __remove_section(zone, __pfn_to_section(pfn));
if (ret)
break;
Index: linux-3.5-rc4/arch/powerpc/platforms/pseries/hotplug-memory.c
===
--- linux-3.5-rc4.orig/arch/powerpc/platforms/pseries/hotplug-memory.c  
2012-07-03 14:21:45.641422678
+0900
+++ linux-3.5-rc4/arch/powerpc/platforms/pseries/hotplug-memory.c   
2012-07-03 14:22:05.920169437 +0900
@@ -77,7 +77,8 @@ static int pseries_remove_memblock(unsig
 {
unsigned long start, start_pfn;
struct zone *zone;
-   int ret;
+   int i, ret;
+   int sections_to_remove;

start_pfn = base >> PAGE_SHIFT;

@@ -97,9 +98,13 @@ static int pseries_remove_memblock(unsig
 * to sysfs "state" file and we can't remove sysfs entries
 * while writing to it. So we have to defer it to here.
 */
-   ret = __remove_pages(zone, start_pfn, memblock_size >> PAGE_SHIFT);
-   if (ret)
-   return ret;
+   sections_to_remove = (memblock_size >> PAGE_SHIFT) / PAGES_PER_SECTION;
+   for (i = 0; i < sections_to_remove; i++) {
+   unsigned long pfn = start_pfn + i * PAGES_PER_SECTION;
+   ret = __remove_pages(zone, start_pfn,  PAGES_PER_SECTION);
+   if (ret)
+   return ret;
+   }

/*
 * Update memory regions for memory remove

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v2 4/13] memory-hotplug : remove /sys/firmware/memmap/X sysfs

2012-07-02 Thread Yasuaki Ishimatsu
When (hot)adding memory into system, /sys/firmware/memmap/X/{end, start, type}
sysfs files are created. But there is no code to remove these files. The patch
implements the function to remove them.

Note : The code does not free firmware_map_entry since there is no way to free
   memory which is allocated by bootmem.

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 drivers/firmware/memmap.c|   70 +++
 include/linux/firmware-map.h |6 +++
 mm/memory_hotplug.c  |6 +++
 3 files changed, 81 insertions(+), 1 deletion(-)

Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:22:00.190240794 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:22:03.549198802 +0900
@@ -661,7 +661,11 @@ EXPORT_SYMBOL_GPL(add_memory);

 int remove_memory(int nid, u64 start, u64 size)
 {
-   return -EBUSY;
+   lock_memory_hotplug();
+   /* remove memmap entry */
+   firmware_map_remove(start, start + size - 1, "System RAM");
+   unlock_memory_hotplug();
+   return 0;

 }
 EXPORT_SYMBOL_GPL(remove_memory);
Index: linux-3.5-rc4/include/linux/firmware-map.h
===
--- linux-3.5-rc4.orig/include/linux/firmware-map.h 2012-07-03 
14:21:45.766421116 +0900
+++ linux-3.5-rc4/include/linux/firmware-map.h  2012-07-03 14:22:03.550198789 
+0900
@@ -25,6 +25,7 @@

 int firmware_map_add_early(u64 start, u64 end, const char *type);
 int firmware_map_add_hotplug(u64 start, u64 end, const char *type);
+int firmware_map_remove(u64 start, u64 end, const char *type);

 #else /* CONFIG_FIRMWARE_MEMMAP */

@@ -38,6 +39,11 @@ static inline int firmware_map_add_hotpl
return 0;
 }

+static inline int firmware_map_remove(u64 start, u64 end, const char *type)
+{
+   return 0;
+}
+
 #endif /* CONFIG_FIRMWARE_MEMMAP */

 #endif /* _LINUX_FIRMWARE_MAP_H */
Index: linux-3.5-rc4/drivers/firmware/memmap.c
===
--- linux-3.5-rc4.orig/drivers/firmware/memmap.c2012-07-03 
14:21:45.761421180 +0900
+++ linux-3.5-rc4/drivers/firmware/memmap.c 2012-07-03 14:22:03.569198549 
+0900
@@ -79,7 +79,16 @@ static const struct sysfs_ops memmap_att
.show = memmap_attr_show,
 };

+static void release_firmware_map_entry(struct kobject *kobj)
+{
+   /*
+* FIXME : There is no idea.
+* How to free the entry which allocated bootmem?
+*/
+}
+
 static struct kobj_type memmap_ktype = {
+   .release= release_firmware_map_entry,
.sysfs_ops  = &memmap_attr_ops,
.default_attrs  = def_attrs,
 };
@@ -123,6 +132,16 @@ static int firmware_map_add_entry(u64 st
return 0;
 }

+/**
+ * firmware_map_remove_entry() - Does the real work to remove a firmware
+ * memmap entry.
+ * @entry: removed entry.
+ **/
+static inline void firmware_map_remove_entry(struct firmware_map_entry *entry)
+{
+   list_del(&entry->list);
+}
+
 /*
  * Add memmap entry on sysfs
  */
@@ -144,6 +163,31 @@ static int add_sysfs_fw_map_entry(struct
return 0;
 }

+/*
+ * Remove memmap entry on sysfs
+ */
+static inline void remove_sysfs_fw_map_entry(struct firmware_map_entry *entry)
+{
+   kobject_put(&entry->kobj);
+}
+
+/*
+ * Search memmap entry
+ */
+
+struct firmware_map_entry * __meminit
+find_firmware_map_entry(u64 start, u64 end, const char *type)
+{
+   struct firmware_map_entry *entry;
+
+   list_for_each_entry(entry, &map_entries, list)
+   if ((entry->start == start) && (entry->end == end) &&
+   (!strcmp(entry->type, type)))
+   return entry;
+
+   return NULL;
+}
+
 /**
  * firmware_map_add_hotplug() - Adds a firmware mapping entry when we do
  * memory hotplug.
@@ -196,6 +240,32 @@ int __init firmware_map_add_early(u64 st
return firmware_map_add_entry(start, end, type, entry);
 }

+/**
+ * firmware_map_remove() - remove a firmware mapping entry
+ * @start: Start of the memory range.
+ * @end:   End of the memory range (inclusive).
+ * @type:  Type of the memory range.
+ *
+ * removes a firmware mapping entry.
+ *
+ * Returns 0 on success, or -EINVAL if no entry.
+ **/
+int __meminit firmware_map_remove(u64 start, u64 end, const char *type)
+{
+   struct firmware_map_entry *entry;
+
+   entry = find_firmware_map_entry(start, end, type);
+   if (!entry)
+   return -EINVAL;
+
+   /* remove the memmap entry */
+   remove_sysfs_fw_map_entry(entry);
+
+   firmware_map_remove_entry(entry);
+
+   return 0;
+}
+
 /*
  * Sysfs functions 
-
  */

[RFC PATCH v2 3/13] unify argument of firmware_map_add_early/hotplug

2012-07-02 Thread Yasuaki Ishimatsu
There are two ways to create /sys/firmware/memmap/X sysfs:

  - firmware_map_add_early
When the system starts, it is calledd from e820_reserve_resources()
  - firmware_map_add_hotplug
When the memory is hot plugged, it is called from add_memory()

But these functions are called without unifying value of end argument as below:

  - end argument of firmware_map_add_early()   : start + size - 1
  - end argument of firmware_map_add_hogplug() : start + size

The patch unifies them to "start + size - 1".

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 mm/memory_hotplug.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:21:58.332264022 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:22:00.190240794 +0900
@@ -642,7 +642,7 @@ int __ref add_memory(int nid, u64 start,
}

/* create new memmap entry */
-   firmware_map_add_hotplug(start, start + size, "System RAM");
+   firmware_map_add_hotplug(start, start + size - 1, "System RAM");

goto out;


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v2 2/13] memory-hotplug : add physical memory hotplug code to acpi_memory_device_remove

2012-07-02 Thread Yasuaki Ishimatsu
acpi_memory_device_remove() has been prepared to remove physical memory.
But, the function only frees acpi_memory_device currentlry.

The patch adds following functions into acpi_memory_device_remove():
  - offline memory
  - remove physical memory (only return -EBUSY)
  - free acpi_memory_device

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 drivers/acpi/acpi_memhotplug.c |   26 +-
 drivers/base/memory.c  |   38 ++
 include/linux/memory.h |5 +
 include/linux/memory_hotplug.h |1 +
 mm/memory_hotplug.c|8 
 5 files changed, 77 insertions(+), 1 deletion(-)

Index: linux-3.5-rc4/drivers/acpi/acpi_memhotplug.c
===
--- linux-3.5-rc4.orig/drivers/acpi/acpi_memhotplug.c   2012-07-03 
14:21:49.458374960 +0900
+++ linux-3.5-rc4/drivers/acpi/acpi_memhotplug.c2012-07-03 
14:21:58.329264059 +0900
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -452,12 +453,35 @@ static int acpi_memory_device_add(struct
 static int acpi_memory_device_remove(struct acpi_device *device, int type)
 {
struct acpi_memory_device *mem_device = NULL;
-
+   struct acpi_memory_info *info, *tmp;
+   int result;
+   int node;

if (!device || !acpi_driver_data(device))
return -EINVAL;

mem_device = acpi_driver_data(device);
+
+   node = acpi_get_node(mem_device->device->handle);
+
+   list_for_each_entry_safe(info, tmp, &mem_device->res_list, list) {
+   if (!info->enabled)
+   continue;
+
+   if (!is_memblk_offline(info->start_addr, info->length)) {
+   result = offline_memory(info->start_addr, info->length);
+   if (result)
+   return result;
+   }
+
+   result = remove_memory(node, info->start_addr, info->length);
+   if (result)
+   return result;
+
+   list_del(&info->list);
+   kfree(info);
+   }
+
kfree(mem_device);

return 0;
Index: linux-3.5-rc4/include/linux/memory_hotplug.h
===
--- linux-3.5-rc4.orig/include/linux/memory_hotplug.h   2012-07-03 
14:21:49.471374796 +0900
+++ linux-3.5-rc4/include/linux/memory_hotplug.h2012-07-03 
14:21:58.330264047 +0900
@@ -233,6 +233,7 @@ static inline int is_mem_section_removab
 extern int mem_online_node(int nid);
 extern int add_memory(int nid, u64 start, u64 size);
 extern int arch_add_memory(int nid, u64 start, u64 size);
+extern int remove_memory(int nid, u64 start, u64 size);
 extern int offline_memory(u64 start, u64 size);
 extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
int nr_pages);
Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:21:49.466374860 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:21:58.332264022 +0900
@@ -659,6 +659,14 @@ out:
 }
 EXPORT_SYMBOL_GPL(add_memory);

+int remove_memory(int nid, u64 start, u64 size)
+{
+   return -EBUSY;
+
+}
+EXPORT_SYMBOL_GPL(remove_memory);
+
+
 #ifdef CONFIG_MEMORY_HOTREMOVE
 /*
  * A free page on the buddy free lists (not the per-cpu lists) has PageBuddy
Index: linux-3.5-rc4/drivers/base/memory.c
===
--- linux-3.5-rc4.orig/drivers/base/memory.c2012-07-03 14:21:49.459374948 
+0900
+++ linux-3.5-rc4/drivers/base/memory.c 2012-07-03 14:21:58.335263984 +0900
@@ -70,6 +70,44 @@ void unregister_memory_isolate_notifier(
 }
 EXPORT_SYMBOL(unregister_memory_isolate_notifier);

+bool is_memblk_offline(unsigned long start, unsigned long size)
+{
+   struct memory_block *mem = NULL;
+   struct mem_section *section;
+   unsigned long start_pfn, end_pfn;
+   unsigned long pfn, section_nr;
+
+   start_pfn = PFN_DOWN(start);
+   end_pfn = start_pfn + PFN_DOWN(start);
+
+   for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
+   section_nr = pfn_to_section_nr(pfn);
+   if (!present_section_nr(section_nr));
+   continue;
+
+   section = __nr_to_section(section_nr);
+   /* same memblock? */
+   if (mem)
+   if((section_nr >= mem->start_section_nr) &&
+  (section_nr <= mem->end_section_nr))
+   continue;
+
+   mem = find_memory_block_hi

[RFC PATCH v2 1/13] memory-hotplug : rename remove_memory to offline_memory

2012-07-02 Thread Yasuaki Ishimatsu
remove_memory() does not remove memory but just offlines memory. The patch
changes name of it to offline_memory().

CC: David Rientjes 
CC: Jiang Liu 
CC: Len Brown 
CC: Benjamin Herrenschmidt 
CC: Paul Mackerras 
CC: Christoph Lameter 
Cc: Minchan Kim 
CC: Andrew Morton 
CC: KOSAKI Motohiro 
Signed-off-by: Yasuaki Ishimatsu 

---
 drivers/acpi/acpi_memhotplug.c |2 +-
 drivers/base/memory.c  |4 ++--
 include/linux/memory_hotplug.h |2 +-
 mm/memory_hotplug.c|6 +++---
 4 files changed, 7 insertions(+), 7 deletions(-)

Index: linux-3.5-rc4/drivers/acpi/acpi_memhotplug.c
===
--- linux-3.5-rc4.orig/drivers/acpi/acpi_memhotplug.c   2012-07-03 
14:21:46.102416917 +0900
+++ linux-3.5-rc4/drivers/acpi/acpi_memhotplug.c2012-07-03 
14:21:49.458374960 +0900
@@ -318,7 +318,7 @@ static int acpi_memory_disable_device(st
 */
list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
if (info->enabled) {
-   result = remove_memory(info->start_addr, info->length);
+   result = offline_memory(info->start_addr, info->length);
if (result)
return result;
}
Index: linux-3.5-rc4/drivers/base/memory.c
===
--- linux-3.5-rc4.orig/drivers/base/memory.c2012-07-03 14:21:46.095417003 
+0900
+++ linux-3.5-rc4/drivers/base/memory.c 2012-07-03 14:21:49.459374948 +0900
@@ -266,8 +266,8 @@ memory_block_action(unsigned long phys_i
break;
case MEM_OFFLINE:
start_paddr = page_to_pfn(first_page) << PAGE_SHIFT;
-   ret = remove_memory(start_paddr,
-   nr_pages << PAGE_SHIFT);
+   ret = offline_memory(start_paddr,
+nr_pages << PAGE_SHIFT);
break;
default:
WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: "
Index: linux-3.5-rc4/mm/memory_hotplug.c
===
--- linux-3.5-rc4.orig/mm/memory_hotplug.c  2012-07-03 14:21:46.102416917 
+0900
+++ linux-3.5-rc4/mm/memory_hotplug.c   2012-07-03 14:21:49.466374860 +0900
@@ -990,7 +990,7 @@ out:
return ret;
 }

-int remove_memory(u64 start, u64 size)
+int offline_memory(u64 start, u64 size)
 {
unsigned long start_pfn, end_pfn;

@@ -999,9 +999,9 @@ int remove_memory(u64 start, u64 size)
return offline_pages(start_pfn, end_pfn, 120 * HZ);
 }
 #else
-int remove_memory(u64 start, u64 size)
+int offline_memory(u64 start, u64 size)
 {
return -EINVAL;
 }
 #endif /* CONFIG_MEMORY_HOTREMOVE */
-EXPORT_SYMBOL_GPL(remove_memory);
+EXPORT_SYMBOL_GPL(offline_memory);
Index: linux-3.5-rc4/include/linux/memory_hotplug.h
===
--- linux-3.5-rc4.orig/include/linux/memory_hotplug.h   2012-07-03 
14:21:46.102416917 +0900
+++ linux-3.5-rc4/include/linux/memory_hotplug.h2012-07-03 
14:21:49.471374796 +0900
@@ -233,7 +233,7 @@ static inline int is_mem_section_removab
 extern int mem_online_node(int nid);
 extern int add_memory(int nid, u64 start, u64 size);
 extern int arch_add_memory(int nid, u64 start, u64 size);
-extern int remove_memory(u64 start, u64 size);
+extern int offline_memory(u64 start, u64 size);
 extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
int nr_pages);
 extern void sparse_remove_one_section(struct zone *zone, struct mem_section 
*ms);

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[RFC PATCH v2 0/13] memory-hotplug : hot-remove physical memory

2012-07-02 Thread Yasuaki Ishimatsu
This patch series aims to support physical memory hot-remove.

  [RFC PATCH v2 1/13] memory-hotplug : rename remove_memory to offline_memory
  [RFC PATCH v2 2/13] memory-hotplug : add physical memory hotplug code to 
acpi_memory_device_remove
  [RFC PATCH v2 3/13] memory-hotplug : unify argument of 
firmware_map_add_early/hotplug
  [RFC PATCH v2 4/13] memory-hotplug : remove /sys/firmware/memmap/X sysfs
  [RFC PATCH v2 5/13] memory-hotplug : does not release memory region in 
PAGES_PER_SECTION chunks
  [RFC PATCH v2 6/13] memory-hotplug : add memory_block_release
  [RFC PATCH v2 7/13] memory-hotplug : remove_memory calls __remove_pages
  [RFC PATCH v2 8/13] memory-hotplug : check page type in get_page_bootmem
  [RFC PATCH v2 9/13] memory-hotplug : move register_page_bootmem_info_node and 
put_page_bootmem for
sparse-vmemmap
  [RFC PATCH v2 10/13] memory-hotplug : implement 
register_page_bootmem_info_section of sparse-vmemmap
  [RFC PATCH v2 11/13] memory-hotplug : free memmap of sparse-vmemmap
  [RFC PATCH v2 12/13] memory-hotplug : add node_device_release
  [RFC PATCH v2 13/13] memory-hotplug : remove sysfs file of node

Even if you apply these patches, you cannot remove the physical memory
completely since these patches are still under development. I want you to
cooperate to improve the physical memory hot-remove. So please review these
patches and give your comment/idea.

The patches can free/remove following things:

  - acpi_memory_info  : [RFC PATCH 2/13]
  - /sys/firmware/memmap/X/{end, start, type} : [RFC PATCH 4/13]
  - iomem_resource: [RFC PATCH 5/13]
  - mem_section and related sysfs files   : [RFC PATCH 6-11/13]
  - node and related sysfs files  : [RFC PATCH 12-13/13]

The patches cannot do following things yet:

  - page table of removed memory

If you find lack of function for physical memory hot-remove, please let me
know.

change log of v2:
 [RFC PATCH v2 2/13]
   * check whether memory block is offline or not before calling 
offline_memory()
   * check whether section is valid or not in is_memblk_offline()
   * call kobject_put() for each memory_block in is_memblk_offline()

 [RFC PATCH v2 3/13]
   * unify the end argument of firmware_map_add_early/hotplug

 [RFC PATCH v2 4/13]
   * add release_firmware_map_entry() for freeing firmware_map_entry

 [RFC PATCH v2 6/13]
  * add release_memory_block() for freeing memory_block

 [RFC PATCH v2 11/13]
  * fix wrong arguments of free_pages()

---
 arch/powerpc/platforms/pseries/hotplug-memory.c |   16 +-
 arch/x86/mm/init_64.c   |  144 
 drivers/acpi/acpi_memhotplug.c  |   28 
 drivers/base/memory.c   |   53 
 drivers/base/node.c |7 +
 drivers/firmware/memmap.c   |   70 +++
 include/linux/firmware-map.h|6 +
 include/linux/memory.h  |5
 include/linux/memory_hotplug.h  |   17 --
 include/linux/mm.h  |5
 mm/memory_hotplug.c |   98 
 mm/sparse.c |5
 12 files changed, 406 insertions(+), 48 deletions(-)


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] mm: setup pageblock_order before it's used by sparse

2012-07-02 Thread Jiang Liu
>> Hi Yinghai,
>>
>> I'm afraid the v2 will break powerpc. Currently only IA64 and PowerPC
>> supports variable hugetlb size.
>>
>> HPAGE_SHIFT is a variable default to 0 on powerpc. But seems PowerPC
>> is doing something wrong here, according to it's mm initialization
>> sequence as below:
>> start_kernel()
>> setup_arch()
>> paging_init()
>> free_area_init_node()
>> set_pageblock_order()
>> refer to HPAGE_SHIFT (still 0)
>> init_rest()
>> do_initcalls()
>> hugetlbpage_init()
>> setup HPAGE_SHIFT
>> That means pageblock_order is always set to "MAX_ORDER - 1", not sure
>> whether this is intended. And it has the same issue as IA64 of wasting
>> memory if CONFIG_SPARSE is enabled.
> 
> adding BenH, need to know if it is powerpc intended.
> 
>>
>> So it would be better to keep function set_pageblock_order(), it will
>> fix the memory wasting on both IA64 and PowerPC.
> 
> Should setup pageblock_order as early as possible to avoid confusing.
OK, waiting response from PPC. If we could find some ways to set HPAGE_SIZE
early on PPC too, we can setup pageblock_order in arch instead of page_alloc.c
as early as possible.

Thanks!
Gerry

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] mm: setup pageblock_order before it's used by sparse

2012-07-02 Thread Jiang Liu
On 2012-7-3 4:43, Yinghai Lu wrote:
> On Sun, Jul 1, 2012 at 7:01 PM, Jiang Liu  wrote:
>> Hi Yinghai,
>> The patch fails compilation as below:
>> mm/page_alloc.c:151: error: initializer element is not constant
>> mm/page_alloc.c:151: error: expected ‘,’ or ‘;’ before ‘__attribute__’
>>
>> On IA64, HUGETLB_PAGE_ORDER has dependency on variable hpage_shift.
>> # define HUGETLB_PAGE_ORDER(HPAGE_SHIFT - PAGE_SHIFT)
>> # define HPAGE_SHIFT   hpage_shift
>>
>> And hpage_shift could be changed by early parameter "hugepagesz".
>> So seems will still need to keep function set_pageblock_order().
> 
> ah,  then use use _DEFAULT instead and later could update that in earlyparam.
> 
> So attached -v2 should  work.
Hi Yinghai,

I'm afraid the v2 will break powerpc. Currently only IA64 and PowerPC
supports variable hugetlb size. 

HPAGE_SHIFT is a variable default to 0 on powerpc. But seems PowerPC 
is doing something wrong here, according to it's mm initialization 
sequence as below:
start_kernel()
setup_arch()
paging_init()
free_area_init_node()
set_pageblock_order()
refer to HPAGE_SHIFT (still 0)
init_rest() 
do_initcalls()
hugetlbpage_init()
setup HPAGE_SHIFT
That means pageblock_order is always set to "MAX_ORDER - 1", not sure
whether this is intended. And it has the same issue as IA64 of wasting
memory if CONFIG_SPARSE is enabled.

So it would be better to keep function set_pageblock_order(), it will
fix the memory wasting on both IA64 and PowerPC.

Thanks!
Gerry

> 
> Thanks
> 
> Yinghai


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] mm: setup pageblock_order before it's used by sparse

2012-07-02 Thread Yinghai Lu
On Mon, Jul 2, 2012 at 7:54 PM, Jiang Liu  wrote:
> On 2012-7-3 4:43, Yinghai Lu wrote:
>> On Sun, Jul 1, 2012 at 7:01 PM, Jiang Liu  wrote:
>>> Hi Yinghai,
>>> The patch fails compilation as below:
>>> mm/page_alloc.c:151: error: initializer element is not constant
>>> mm/page_alloc.c:151: error: expected ‘,’ or ‘;’ before ‘__attribute__’
>>>
>>> On IA64, HUGETLB_PAGE_ORDER has dependency on variable hpage_shift.
>>> # define HUGETLB_PAGE_ORDER(HPAGE_SHIFT - PAGE_SHIFT)
>>> # define HPAGE_SHIFT   hpage_shift
>>>
>>> And hpage_shift could be changed by early parameter "hugepagesz".
>>> So seems will still need to keep function set_pageblock_order().
>>
>> ah,  then use use _DEFAULT instead and later could update that in earlyparam.
>>
>> So attached -v2 should  work.
> Hi Yinghai,
>
> I'm afraid the v2 will break powerpc. Currently only IA64 and PowerPC
> supports variable hugetlb size.
>
> HPAGE_SHIFT is a variable default to 0 on powerpc. But seems PowerPC
> is doing something wrong here, according to it's mm initialization
> sequence as below:
> start_kernel()
> setup_arch()
> paging_init()
> free_area_init_node()
> set_pageblock_order()
> refer to HPAGE_SHIFT (still 0)
> init_rest()
> do_initcalls()
> hugetlbpage_init()
> setup HPAGE_SHIFT
> That means pageblock_order is always set to "MAX_ORDER - 1", not sure
> whether this is intended. And it has the same issue as IA64 of wasting
> memory if CONFIG_SPARSE is enabled.

adding BenH, need to know if it is powerpc intended.

>
> So it would be better to keep function set_pageblock_order(), it will
> fix the memory wasting on both IA64 and PowerPC.

Should setup pageblock_order as early as possible to avoid confusing.

Thanks

Yinghai
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 5/5] usb: gadget: composite: parse dt overrides

2012-07-02 Thread Rob Herring
On 07/02/2012 02:35 AM, Felipe Balbi wrote:
> Hi,
> 
> On Tue, Jun 26, 2012 at 11:27:13AM -0300, Alexandre Pereira da Silva wrote:
>> Grab the devicetree node properties to override VendorId, ProductId,
>> bcdDevice, Manucacturer, Product and SerialNumber
>>
>> Signed-off-by: Alexandre Pereira da Silva 
> 
> I need Grant's acked-by to queue this one.
> 

Grant is pretty much offline for the next 2 months, so:

Acked-by: Rob Herring 

Rob
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [git pull] Please pull powerpc.git merge branch

2012-07-02 Thread Benjamin Herrenschmidt
On Mon, 2012-07-02 at 23:38 +0200, Gerhard Pircher wrote:
> 
> What about this fix:?
> 
> http://patchwork.ozlabs.org/patch/166346/
> 
> At least I can't see it in the log...

The module fix went in. The ftrace patch, well, it's untested and we
don't even know if we have a problem with mcount yet, so no, I haven't
merged it yet.

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [git pull] Please pull powerpc.git merge branch

2012-07-02 Thread Gerhard Pircher

 Original-Nachricht 
> Datum: Mon, 02 Jul 2012 14:57:39 +1000
> Von: Benjamin Herrenschmidt 
> An: Linus Torvalds 
> CC: linuxppc-dev list , Andrew Morton 
> , Linux Kernel list 
> Betreff: [git pull] Please pull powerpc.git merge branch

> Hi Linus 
> 
> Here are two more fixes that I "missed" when scrubbing patchwork last
> week which are worth still having in 3.5.

What about this fix:?

http://patchwork.ozlabs.org/patch/166346/

At least I can't see it in the log...

br,
Gerhard
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] PPC: use CURRENT_THREAD_INFO instead of open coded assembly

2012-07-02 Thread Alexander Graf

On 02.07.2012, at 23:31, Scott Wood wrote:

> On 07/02/2012 04:27 PM, Alexander Graf wrote:
>> 
>> On 02.07.2012, at 23:26, Benjamin Herrenschmidt wrote:
>> 
>>> On Mon, 2012-07-02 at 22:59 +0200, Alexander Graf wrote:
 This should go into an #ifdef __ASSEMBLY__ block, right? :)
>>> 
>>> We almost never use #ifdef __ASSEMBLY__, we use it the other way
>>> around, to prevent C stuff from being included in assembly. The
>>> other way around is legit since things might be used in inline asm
>>> for example.
>> 
>> I'm not sure I want to see this bit of code used as is in inline asm
>> :). I don't even think it's possible, since it's a full statement.
>> Either way, it's safer with the guard.
> 
> Safer from what?  It won't be expanded unless referenced.  How is this
> better than putting ifdefs on #includes, prototypes, struct definitions,
> etc.?  The ifdef is just clutter.

Well, it'd make it easier to read the errors resulting of it. Calling 
CURRENT_THREAD_INFO from within C code would throw random compiler errors at 
you that are quite unintelligible, while a missing definition would be a 
reasonably obvious thing to fix, no?

Either way, not married to this. I just find it cleaner to not expose something 
as a define that wouldn't work in the first place.


Alex

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] PPC: use CURRENT_THREAD_INFO instead of open coded assembly

2012-07-02 Thread Scott Wood
On 07/02/2012 04:27 PM, Alexander Graf wrote:
> 
> On 02.07.2012, at 23:26, Benjamin Herrenschmidt wrote:
> 
>> On Mon, 2012-07-02 at 22:59 +0200, Alexander Graf wrote:
>>> This should go into an #ifdef __ASSEMBLY__ block, right? :)
>> 
>> We almost never use #ifdef __ASSEMBLY__, we use it the other way
>> around, to prevent C stuff from being included in assembly. The
>> other way around is legit since things might be used in inline asm
>> for example.
> 
> I'm not sure I want to see this bit of code used as is in inline asm
> :). I don't even think it's possible, since it's a full statement.
> Either way, it's safer with the guard.

Safer from what?  It won't be expanded unless referenced.  How is this
better than putting ifdefs on #includes, prototypes, struct definitions,
etc.?  The ifdef is just clutter.

-Scott

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] PPC: use CURRENT_THREAD_INFO instead of open coded assembly

2012-07-02 Thread Alexander Graf

On 02.07.2012, at 23:26, Benjamin Herrenschmidt wrote:

> On Mon, 2012-07-02 at 22:59 +0200, Alexander Graf wrote:
>> This should go into an #ifdef __ASSEMBLY__ block, right? :)
> 
> We almost never use #ifdef __ASSEMBLY__, we use it the other way around,
> to prevent C stuff from being included in assembly. The other way around
> is legit since things might be used in inline asm for example.

I'm not sure I want to see this bit of code used as is in inline asm :). I 
don't even think it's possible, since it's a full statement. Either way, it's 
safer with the guard.


Alex

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH][v2] PPC: use CURRENT_THREAD_INFO instead of open coded assembly

2012-07-02 Thread Benjamin Herrenschmidt
On Mon, 2012-07-02 at 16:14 -0500, Stuart Yoder wrote:
> -v2
>-moved CURRENT_THREAD_INFO under assembly only
> #ifdef 

Nak, invert the two cases to avoid the if_n_def, but don't move it
inside __ASSEMBLY__ only.

IE. Address Alex other comment :-)

Cheers,
Ben.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] PPC: use CURRENT_THREAD_INFO instead of open coded assembly

2012-07-02 Thread Benjamin Herrenschmidt
On Mon, 2012-07-02 at 22:59 +0200, Alexander Graf wrote:
> This should go into an #ifdef __ASSEMBLY__ block, right? :)

We almost never use #ifdef __ASSEMBLY__, we use it the other way around,
to prevent C stuff from being included in assembly. The other way around
is legit since things might be used in inline asm for example.

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH][v2] PPC: use CURRENT_THREAD_INFO instead of open coded assembly

2012-07-02 Thread Alexander Graf

On 02.07.2012, at 23:14, Stuart Yoder wrote:

> From: Stuart Yoder 
> 
> Signed-off-by: Stuart Yoder 
> ---
> 
> -this patch is a pre-requisite for the idle hcall which I
> am trying to get into Alex's KVM tree, so ideally would like
> Ben's ack and get this applied to Alex's tree
> 
> -built/tested with a 32-bit booke kernel, built a 64-bit
> booke kernel
> 
> -v2
>   -moved CURRENT_THREAD_INFO under assembly only
>#ifdef
> 
> arch/powerpc/include/asm/exception-64s.h |4 ++--
> arch/powerpc/include/asm/thread_info.h   |8 
> arch/powerpc/kernel/entry_32.S   |   24 
> arch/powerpc/kernel/entry_64.S   |   14 +++---
> arch/powerpc/kernel/exceptions-64e.S |2 +-
> arch/powerpc/kernel/exceptions-64s.S |2 +-
> arch/powerpc/kernel/head_fsl_booke.S |2 +-
> arch/powerpc/kernel/idle_6xx.S   |4 ++--
> arch/powerpc/kernel/idle_book3e.S|2 +-
> arch/powerpc/kernel/idle_e500.S  |4 ++--
> arch/powerpc/kernel/idle_power4.S|2 +-
> arch/powerpc/kernel/misc_32.S|4 ++--
> arch/powerpc/kvm/bookehv_interrupts.S|6 +-
> arch/powerpc/mm/hash_low_32.S|8 
> arch/powerpc/sysdev/6xx-suspend.S|2 +-
> 15 files changed, 46 insertions(+), 42 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/exception-64s.h 
> b/arch/powerpc/include/asm/exception-64s.h
> index d58fc4e..5dbd00d 100644
> --- a/arch/powerpc/include/asm/exception-64s.h
> +++ b/arch/powerpc/include/asm/exception-64s.h
> @@ -293,7 +293,7 @@ label##_hv:   
> \
> 
> #define RUNLATCH_ON   \
> BEGIN_FTR_SECTION \
> - clrrdi  r3,r1,THREAD_SHIFT; \
> + CURRENT_THREAD_INFO(r3, r1) \
>   ld  r4,TI_LOCAL_FLAGS(r3);  \
>   andi.   r0,r4,_TLF_RUNLATCH;\
>   beqlppc64_runlatch_on_trampoline;   \
> @@ -332,7 +332,7 @@ label##_common:   
> \
> #ifdef CONFIG_PPC_970_NAP
> #define FINISH_NAP\
> BEGIN_FTR_SECTION \
> - clrrdi  r11,r1,THREAD_SHIFT;\
> + CURRENT_THREAD_INFO(r11, r1)\
>   ld  r9,TI_LOCAL_FLAGS(r11); \
>   andi.   r10,r9,_TLF_NAPPING;\
>   bnelpower4_fixup_nap;   \
> diff --git a/arch/powerpc/include/asm/thread_info.h 
> b/arch/powerpc/include/asm/thread_info.h
> index 68831e9..3760620 100644
> --- a/arch/powerpc/include/asm/thread_info.h
> +++ b/arch/powerpc/include/asm/thread_info.h
> @@ -74,6 +74,14 @@ static inline struct thread_info *current_thread_info(void)
>   return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
> }
> 
> +#else
> +
> +#ifndef CONFIG_PPC64

Oh no! The logic is still backwards :(

> +#define CURRENT_THREAD_INFO(dest, sp)rlwinm dest, sp, 0, 0, 
> 31-THREAD_SHIFT
> +#else
> +#define CURRENT_THREAD_INFO(dest, sp)clrrdi dest, sp, THREAD_SHIFT
> +#endif


Alex

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH][v2] PPC: use CURRENT_THREAD_INFO instead of open coded assembly

2012-07-02 Thread Stuart Yoder
From: Stuart Yoder 

Signed-off-by: Stuart Yoder 
---

-this patch is a pre-requisite for the idle hcall which I
am trying to get into Alex's KVM tree, so ideally would like
Ben's ack and get this applied to Alex's tree

-built/tested with a 32-bit booke kernel, built a 64-bit
 booke kernel

-v2
   -moved CURRENT_THREAD_INFO under assembly only
#ifdef

 arch/powerpc/include/asm/exception-64s.h |4 ++--
 arch/powerpc/include/asm/thread_info.h   |8 
 arch/powerpc/kernel/entry_32.S   |   24 
 arch/powerpc/kernel/entry_64.S   |   14 +++---
 arch/powerpc/kernel/exceptions-64e.S |2 +-
 arch/powerpc/kernel/exceptions-64s.S |2 +-
 arch/powerpc/kernel/head_fsl_booke.S |2 +-
 arch/powerpc/kernel/idle_6xx.S   |4 ++--
 arch/powerpc/kernel/idle_book3e.S|2 +-
 arch/powerpc/kernel/idle_e500.S  |4 ++--
 arch/powerpc/kernel/idle_power4.S|2 +-
 arch/powerpc/kernel/misc_32.S|4 ++--
 arch/powerpc/kvm/bookehv_interrupts.S|6 +-
 arch/powerpc/mm/hash_low_32.S|8 
 arch/powerpc/sysdev/6xx-suspend.S|2 +-
 15 files changed, 46 insertions(+), 42 deletions(-)

diff --git a/arch/powerpc/include/asm/exception-64s.h 
b/arch/powerpc/include/asm/exception-64s.h
index d58fc4e..5dbd00d 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -293,7 +293,7 @@ label##_hv: 
\
 
 #define RUNLATCH_ON\
 BEGIN_FTR_SECTION  \
-   clrrdi  r3,r1,THREAD_SHIFT; \
+   CURRENT_THREAD_INFO(r3, r1) \
ld  r4,TI_LOCAL_FLAGS(r3);  \
andi.   r0,r4,_TLF_RUNLATCH;\
beqlppc64_runlatch_on_trampoline;   \
@@ -332,7 +332,7 @@ label##_common: 
\
 #ifdef CONFIG_PPC_970_NAP
 #define FINISH_NAP \
 BEGIN_FTR_SECTION  \
-   clrrdi  r11,r1,THREAD_SHIFT;\
+   CURRENT_THREAD_INFO(r11, r1)\
ld  r9,TI_LOCAL_FLAGS(r11); \
andi.   r10,r9,_TLF_NAPPING;\
bnelpower4_fixup_nap;   \
diff --git a/arch/powerpc/include/asm/thread_info.h 
b/arch/powerpc/include/asm/thread_info.h
index 68831e9..3760620 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -74,6 +74,14 @@ static inline struct thread_info *current_thread_info(void)
return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
 }
 
+#else
+
+#ifndef CONFIG_PPC64
+#define CURRENT_THREAD_INFO(dest, sp)  rlwinm dest, sp, 0, 0, 31-THREAD_SHIFT
+#else
+#define CURRENT_THREAD_INFO(dest, sp)  clrrdi dest, sp, THREAD_SHIFT
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 #define PREEMPT_ACTIVE 0x1000
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index ba3aeb4..bad42e3 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -92,7 +92,7 @@ crit_transfer_to_handler:
mfspr   r8,SPRN_SPRG_THREAD
lwz r0,KSP_LIMIT(r8)
stw r0,SAVED_KSP_LIMIT(r11)
-   rlwimi  r0,r1,0,0,(31-THREAD_SHIFT)
+   CURRENT_THREAD_INFO(r0, r1)
stw r0,KSP_LIMIT(r8)
/* fall through */
 #endif
@@ -112,7 +112,7 @@ crit_transfer_to_handler:
mfspr   r8,SPRN_SPRG_THREAD
lwz r0,KSP_LIMIT(r8)
stw r0,saved_ksp_limit@l(0)
-   rlwimi  r0,r1,0,0,(31-THREAD_SHIFT)
+   CURRENT_THREAD_INFO(r0, r1)
stw r0,KSP_LIMIT(r8)
/* fall through */
 #endif
@@ -158,7 +158,7 @@ transfer_to_handler:
tophys(r11,r11)
addir11,r11,global_dbcr0@l
 #ifdef CONFIG_SMP
-   rlwinm  r9,r1,0,0,(31-THREAD_SHIFT)
+   CURRENT_THREAD_INFO(r9, r1)
lwz r9,TI_CPU(r9)
slwir9,r9,3
add r11,r11,r9
@@ -179,7 +179,7 @@ transfer_to_handler:
ble-stack_ovf   /* then the kernel stack overflowed */
 5:
 #if defined(CONFIG_6xx) || defined(CONFIG_E500)
-   rlwinm  r9,r1,0,0,31-THREAD_SHIFT
+   CURRENT_THREAD_INFO(r9, r1)
tophys(r9,r9)   /* check local flags */
lwz r12,TI_LOCAL_FLAGS(r9)
mtcrf   0x01,r12
@@ -333,7 +333,7 @@ _GLOBAL(DoSyscall)
mtmsr   r11
 1:
 #endif /* CONFIG_TRACE_IRQFLAGS */
-   rlwinm  r10,r1,0,0,(31-THREAD_SHIFT)/* current_thread_info() */
+   CURRENT_THREAD_INFO(r10, r1)
lwz r11,TI_FLAGS(r10)
andi.   r11,r11,_TIF_SYSCALL_T_OR_A
bne-syscall_dotrace
@@ -354,7 +354,7 @@ ret_from_syscall:
bl  do_show_syscall_exit
 #endif
mr  r6,r3
-   rlwinm  r12,r1,0,0,(31-THREAD_SHIFT)/* current_thread_info() */
+   CURRENT_THREAD_INFO(r12, r1

Re: [PATCH] PPC: use CURRENT_THREAD_INFO instead of open coded assembly

2012-07-02 Thread Alexander Graf

On 02.07.2012, at 22:56, Stuart Yoder wrote:

> From: Stuart Yoder 
> 
> Signed-off-by: Stuart Yoder 
> ---
> 
> -this patch is a pre-requisite for the idle hcall which I
> am trying to get into Alex's KVM tree, so ideally would like
> Ben's ack and get this applied to Alex's tree
> 
> -built/tested with a 32-bit booke kernel, built a 64-bit
> booke kernel
> 
> arch/powerpc/include/asm/exception-64s.h |4 ++--
> arch/powerpc/include/asm/thread_info.h   |6 ++
> arch/powerpc/kernel/entry_32.S   |   24 
> arch/powerpc/kernel/entry_64.S   |   14 +++---
> arch/powerpc/kernel/exceptions-64e.S |2 +-
> arch/powerpc/kernel/exceptions-64s.S |2 +-
> arch/powerpc/kernel/head_fsl_booke.S |2 +-
> arch/powerpc/kernel/idle_6xx.S   |4 ++--
> arch/powerpc/kernel/idle_book3e.S|2 +-
> arch/powerpc/kernel/idle_e500.S  |4 ++--
> arch/powerpc/kernel/idle_power4.S|2 +-
> arch/powerpc/kernel/misc_32.S|4 ++--
> arch/powerpc/kvm/bookehv_interrupts.S|6 +-
> arch/powerpc/mm/hash_low_32.S|8 
> arch/powerpc/sysdev/6xx-suspend.S|2 +-
> 15 files changed, 44 insertions(+), 42 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/exception-64s.h 
> b/arch/powerpc/include/asm/exception-64s.h
> index d58fc4e..5dbd00d 100644
> --- a/arch/powerpc/include/asm/exception-64s.h
> +++ b/arch/powerpc/include/asm/exception-64s.h
> @@ -293,7 +293,7 @@ label##_hv:   
> \
> 
> #define RUNLATCH_ON   \
> BEGIN_FTR_SECTION \
> - clrrdi  r3,r1,THREAD_SHIFT; \
> + CURRENT_THREAD_INFO(r3, r1) \
>   ld  r4,TI_LOCAL_FLAGS(r3);  \
>   andi.   r0,r4,_TLF_RUNLATCH;\
>   beqlppc64_runlatch_on_trampoline;   \
> @@ -332,7 +332,7 @@ label##_common:   
> \
> #ifdef CONFIG_PPC_970_NAP
> #define FINISH_NAP\
> BEGIN_FTR_SECTION \
> - clrrdi  r11,r1,THREAD_SHIFT;\
> + CURRENT_THREAD_INFO(r11, r1)\
>   ld  r9,TI_LOCAL_FLAGS(r11); \
>   andi.   r10,r9,_TLF_NAPPING;\
>   bnelpower4_fixup_nap;   \
> diff --git a/arch/powerpc/include/asm/thread_info.h 
> b/arch/powerpc/include/asm/thread_info.h
> index 68831e9..2e7bc3c 100644
> --- a/arch/powerpc/include/asm/thread_info.h
> +++ b/arch/powerpc/include/asm/thread_info.h
> @@ -22,6 +22,12 @@
> 
> #define THREAD_SIZE   (1 << THREAD_SHIFT)
> 
> +#ifndef CONFIG_PPC64

I usually way prefer positive to negative logic. So if you could swap the 2 
cases, I'd be a lot happier ;)

> +#define CURRENT_THREAD_INFO(dest, sp)rlwinm dest, sp, 0, 0, 
> 31-THREAD_SHIFT
> +#else
> +#define CURRENT_THREAD_INFO(dest, sp)clrrdi dest, sp, THREAD_SHIFT
> +#endif

This should go into an #ifdef __ASSEMBLY__ block, right? :)

The rest looks great :)


Alex

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] PPC: use CURRENT_THREAD_INFO instead of open coded assembly

2012-07-02 Thread Stuart Yoder
From: Stuart Yoder 

Signed-off-by: Stuart Yoder 
---

-this patch is a pre-requisite for the idle hcall which I
am trying to get into Alex's KVM tree, so ideally would like
Ben's ack and get this applied to Alex's tree

-built/tested with a 32-bit booke kernel, built a 64-bit
 booke kernel

 arch/powerpc/include/asm/exception-64s.h |4 ++--
 arch/powerpc/include/asm/thread_info.h   |6 ++
 arch/powerpc/kernel/entry_32.S   |   24 
 arch/powerpc/kernel/entry_64.S   |   14 +++---
 arch/powerpc/kernel/exceptions-64e.S |2 +-
 arch/powerpc/kernel/exceptions-64s.S |2 +-
 arch/powerpc/kernel/head_fsl_booke.S |2 +-
 arch/powerpc/kernel/idle_6xx.S   |4 ++--
 arch/powerpc/kernel/idle_book3e.S|2 +-
 arch/powerpc/kernel/idle_e500.S  |4 ++--
 arch/powerpc/kernel/idle_power4.S|2 +-
 arch/powerpc/kernel/misc_32.S|4 ++--
 arch/powerpc/kvm/bookehv_interrupts.S|6 +-
 arch/powerpc/mm/hash_low_32.S|8 
 arch/powerpc/sysdev/6xx-suspend.S|2 +-
 15 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/arch/powerpc/include/asm/exception-64s.h 
b/arch/powerpc/include/asm/exception-64s.h
index d58fc4e..5dbd00d 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -293,7 +293,7 @@ label##_hv: 
\
 
 #define RUNLATCH_ON\
 BEGIN_FTR_SECTION  \
-   clrrdi  r3,r1,THREAD_SHIFT; \
+   CURRENT_THREAD_INFO(r3, r1) \
ld  r4,TI_LOCAL_FLAGS(r3);  \
andi.   r0,r4,_TLF_RUNLATCH;\
beqlppc64_runlatch_on_trampoline;   \
@@ -332,7 +332,7 @@ label##_common: 
\
 #ifdef CONFIG_PPC_970_NAP
 #define FINISH_NAP \
 BEGIN_FTR_SECTION  \
-   clrrdi  r11,r1,THREAD_SHIFT;\
+   CURRENT_THREAD_INFO(r11, r1)\
ld  r9,TI_LOCAL_FLAGS(r11); \
andi.   r10,r9,_TLF_NAPPING;\
bnelpower4_fixup_nap;   \
diff --git a/arch/powerpc/include/asm/thread_info.h 
b/arch/powerpc/include/asm/thread_info.h
index 68831e9..2e7bc3c 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -22,6 +22,12 @@
 
 #define THREAD_SIZE(1 << THREAD_SHIFT)
 
+#ifndef CONFIG_PPC64
+#define CURRENT_THREAD_INFO(dest, sp)  rlwinm dest, sp, 0, 0, 31-THREAD_SHIFT
+#else
+#define CURRENT_THREAD_INFO(dest, sp)  clrrdi dest, sp, THREAD_SHIFT
+#endif
+
 #ifndef __ASSEMBLY__
 #include 
 #include 
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index ba3aeb4..bad42e3 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -92,7 +92,7 @@ crit_transfer_to_handler:
mfspr   r8,SPRN_SPRG_THREAD
lwz r0,KSP_LIMIT(r8)
stw r0,SAVED_KSP_LIMIT(r11)
-   rlwimi  r0,r1,0,0,(31-THREAD_SHIFT)
+   CURRENT_THREAD_INFO(r0, r1)
stw r0,KSP_LIMIT(r8)
/* fall through */
 #endif
@@ -112,7 +112,7 @@ crit_transfer_to_handler:
mfspr   r8,SPRN_SPRG_THREAD
lwz r0,KSP_LIMIT(r8)
stw r0,saved_ksp_limit@l(0)
-   rlwimi  r0,r1,0,0,(31-THREAD_SHIFT)
+   CURRENT_THREAD_INFO(r0, r1)
stw r0,KSP_LIMIT(r8)
/* fall through */
 #endif
@@ -158,7 +158,7 @@ transfer_to_handler:
tophys(r11,r11)
addir11,r11,global_dbcr0@l
 #ifdef CONFIG_SMP
-   rlwinm  r9,r1,0,0,(31-THREAD_SHIFT)
+   CURRENT_THREAD_INFO(r9, r1)
lwz r9,TI_CPU(r9)
slwir9,r9,3
add r11,r11,r9
@@ -179,7 +179,7 @@ transfer_to_handler:
ble-stack_ovf   /* then the kernel stack overflowed */
 5:
 #if defined(CONFIG_6xx) || defined(CONFIG_E500)
-   rlwinm  r9,r1,0,0,31-THREAD_SHIFT
+   CURRENT_THREAD_INFO(r9, r1)
tophys(r9,r9)   /* check local flags */
lwz r12,TI_LOCAL_FLAGS(r9)
mtcrf   0x01,r12
@@ -333,7 +333,7 @@ _GLOBAL(DoSyscall)
mtmsr   r11
 1:
 #endif /* CONFIG_TRACE_IRQFLAGS */
-   rlwinm  r10,r1,0,0,(31-THREAD_SHIFT)/* current_thread_info() */
+   CURRENT_THREAD_INFO(r10, r1)
lwz r11,TI_FLAGS(r10)
andi.   r11,r11,_TIF_SYSCALL_T_OR_A
bne-syscall_dotrace
@@ -354,7 +354,7 @@ ret_from_syscall:
bl  do_show_syscall_exit
 #endif
mr  r6,r3
-   rlwinm  r12,r1,0,0,(31-THREAD_SHIFT)/* current_thread_info() */
+   CURRENT_THREAD_INFO(r12, r1)
/* disable interrupts so current_thread_info()->flags can't change */
LOAD_MSR_KERNEL(r10,MSR_KERNEL) /* doesn't include MSR_EE */
/* Note: We don't b

Re: 3.5.0-rc5: BUG: soft lockup - CPU#0 stuck for 22s

2012-07-02 Thread Christian Kujau
On Mon, 2 Jul 2012 at 09:45, Paul E. McKenney wrote:
> On Sun, Jul 01, 2012 at 11:30:40PM -0700, Christian Kujau wrote:
> > On Mon, 2 Jul 2012 at 14:50, Benjamin Herrenschmidt wrote:
> > > Interesting... I observed something roughly similar on a dual G4
> > > the other day associated with a 30s to 1mn pause during boot. RCU
> > > was complaining loudly.
> > > 
> > > In my case, it did continue booting normally, is that the case for you ?
> > 
> > No, in my case it stopped booting, though there was no "panic" message.
> > 
> > > Also if I compile the kernel without CONFIG_SMP, it did go away as well,
> > > do you observe that too ?
> > 
> > This PoweBook G4 is UP anyway and I'm always building w/o CONFIG_SMP.
> > 
> > > I don't have a spare cycle to investigate this problem this week I'm
> > > afraid, it might help if you could try a bisection though.
> > 
> > Yes, I've started a bisection already and will report back.
> > 
> > FYI, I've put a netconsole-log below from another boot (in the 
> > middle of a bisection), the instruction dump is slightly more complete.
> 
> Li Zhong posted a patch to fix this (async_synchronize_full() below):
> 
>   https://lkml.org/lkml/2012/7/2/32
> 
> This gets rid of this problem on my UP testing.  If it works for you,
> please give Li Zhong a Tested-by.

Great! When applied to -rc5 Li's patch fixes it for my powerpc UP system 
as well.

  Tested-by: Christian Kujau 

Many thanks!
Christian.

> > [   40.345973] BUG: soft lockup - CPU#0 stuck for 22s! [modprobe:691]
> > [   40.347737] Modules linked in: sd_mod arc4 firewire_sbp2 scsi_mod b43 
> > mac80211 cfg80211
> > [   40.349443] irq event stamp: 65779272
> > [   40.351156] hardirqs last  enabled at (65779271): [] 
> > _raw_spin_unlock_irqrestore+0x40/0x9c
> > [   40.352911] hardirqs last disabled at (65779272): [] 
> > reenable_mmu+0x40/0x98
> > [   40.354649] softirqs last  enabled at (65769864): [] 
> > call_do_softirq+0x14/0x24
> > [   40.356386] softirqs last disabled at (65769857): [] 
> > call_do_softirq+0x14/0x24
> > [   40.358098] NIP: c005ee64 LR: c005ee54 CTR: c009c578
> > [   40.359788] REGS: eece3d70 TRAP: 0901   Not tainted  
> > (3.4.0-05609-gc80ddb5)
> > [   40.361517] MSR: 9032   CR: 24042482  XER: 
> > [   40.363261] TASK = eec30b80[691] 'modprobe' THREAD: eece2000#012
> > [   40.363261] GPR00: c005ee54 eece3e20 eec30b80  0002 c005edd0 
> >   #012
> > [   40.363261] GPR08:  eece2000  0001 24042488 
> > [   40.368310] NIP [c005ee64] async_synchronize_cookie_domain+0x70/0x1f4
> > [   40.369978] LR [c005ee54] async_synchronize_cookie_domain+0x60/0x1f4
> > [   40.371614] Call Trace:
> > [   40.373226] [eece3e20] [c005ee54] 
> > async_synchronize_cookie_domain+0x60/0x1f4 (unreliable)
> > [   40.374884] [eece3e70] [c005f034] async_synchronize_full+0x3c/0x74
> > [   40.376524] [eece3e90] [c0082790] sys_init_module+0x178/0x1164
> > [   40.378151] [eece3f40] [c00117a8] ret_from_syscall+0x0/0x38
> > [   40.379783] --- Exception: c01 at 0xff5d694#012[   40.379783] LR = 
> > 0x100041c0
> > [   40.382928] Instruction dump:
> > [   40.384489] 93a10044 419e0014 3d20c06f 8009d020 2f80 419e017c 
> > 7fc3f378 4bfffed9 
> > [   40.386081] 7f9f1840 419d0060 7f9f1800 419e0050 <881bf008> 2f80 
> > 419e0014 3d20c06f

-- 
BOFH excuse #280:

Traceroute says that there is a routing problem in the backbone.  It's not our 
problem.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] P1021: set IReady in QE Microcode Upload

2012-07-02 Thread Timur Tabi
Kumar Gala wrote:
>> > No, I forgot all about it.  I'll try it today, assuming the lone 8323
>> > board in the board farm still works.

> Do you remember if you ever tested this?

Well, I tried to test it.  We have an 83xx board that has a QE UART that
needs firmware uploaded, but I don't know how to connect that QE to an
actual RS232 port.  It needs a riser which I don't think we have.

I can verify that the QE UART driver does not hang which this patch, and
that it appears to still be sending data, but I have no way of knowing for
sure.

-- 
Timur Tabi
Linux kernel developer at Freescale

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/2] powerpc/mpc85xx: p1022ds support the MTD for NOR and NAND flash

2012-07-02 Thread Kumar Gala

On Apr 16, 2012, at 8:42 PM,  
 wrote:

> From: Jerry Huang 
> 
> The compatilbe 'simple-bus' is removed from the latest DTS for NAND and
> NOR flash partition, so we must add the new compatilbe support for p1022ds,
> otherwise, the kernel can't parse the partition of NOR and NAND flash.
> 
> Signed-off-by: Jerry Huang 
> ---
> arch/powerpc/platforms/85xx/p1022_ds.c |1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)

If this is still relevant, please resubmit against my powerpc.git 'next' branch.

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: 3.5.0-rc5: BUG: soft lockup - CPU#0 stuck for 22s

2012-07-02 Thread Paul E. McKenney
On Sun, Jul 01, 2012 at 11:30:40PM -0700, Christian Kujau wrote:
> On Mon, 2 Jul 2012 at 14:50, Benjamin Herrenschmidt wrote:
> > Interesting... I observed something roughly similar on a dual G4
> > the other day associated with a 30s to 1mn pause during boot. RCU
> > was complaining loudly.
> > 
> > In my case, it did continue booting normally, is that the case for you ?
> 
> No, in my case it stopped booting, though there was no "panic" message.
> 
> > Also if I compile the kernel without CONFIG_SMP, it did go away as well,
> > do you observe that too ?
> 
> This PoweBook G4 is UP anyway and I'm always building w/o CONFIG_SMP.
> 
> > I don't have a spare cycle to investigate this problem this week I'm
> > afraid, it might help if you could try a bisection though.
> 
> Yes, I've started a bisection already and will report back.
> 
> FYI, I've put a netconsole-log below from another boot (in the 
> middle of a bisection), the instruction dump is slightly more complete.

Li Zhong posted a patch to fix this (async_synchronize_full() below):

https://lkml.org/lkml/2012/7/2/32

This gets rid of this problem on my UP testing.  If it works for you,
please give Li Zhong a Tested-by.

Thanx, Paul

> Thanks!
> Christian.
> 
> [   40.345973] BUG: soft lockup - CPU#0 stuck for 22s! [modprobe:691]
> [   40.347737] Modules linked in: sd_mod arc4 firewire_sbp2 scsi_mod b43 
> mac80211 cfg80211
> [   40.349443] irq event stamp: 65779272
> [   40.351156] hardirqs last  enabled at (65779271): [] 
> _raw_spin_unlock_irqrestore+0x40/0x9c
> [   40.352911] hardirqs last disabled at (65779272): [] 
> reenable_mmu+0x40/0x98
> [   40.354649] softirqs last  enabled at (65769864): [] 
> call_do_softirq+0x14/0x24
> [   40.356386] softirqs last disabled at (65769857): [] 
> call_do_softirq+0x14/0x24
> [   40.358098] NIP: c005ee64 LR: c005ee54 CTR: c009c578
> [   40.359788] REGS: eece3d70 TRAP: 0901   Not tainted  (3.4.0-05609-gc80ddb5)
> [   40.361517] MSR: 9032   CR: 24042482  XER: 
> [   40.363261] TASK = eec30b80[691] 'modprobe' THREAD: eece2000#012
> [   40.363261] GPR00: c005ee54 eece3e20 eec30b80  0002 c005edd0 
>   #012
> [   40.363261] GPR08:  eece2000  0001 24042488 
> [   40.368310] NIP [c005ee64] async_synchronize_cookie_domain+0x70/0x1f4
> [   40.369978] LR [c005ee54] async_synchronize_cookie_domain+0x60/0x1f4
> [   40.371614] Call Trace:
> [   40.373226] [eece3e20] [c005ee54] 
> async_synchronize_cookie_domain+0x60/0x1f4 (unreliable)
> [   40.374884] [eece3e70] [c005f034] async_synchronize_full+0x3c/0x74
> [   40.376524] [eece3e90] [c0082790] sys_init_module+0x178/0x1164
> [   40.378151] [eece3f40] [c00117a8] ret_from_syscall+0x0/0x38
> [   40.379783] --- Exception: c01 at 0xff5d694#012[   40.379783] LR = 
> 0x100041c0
> [   40.382928] Instruction dump:
> [   40.384489] 93a10044 419e0014 3d20c06f 8009d020 2f80 419e017c 7fc3f378 
> 4bfffed9 
> [   40.386081] 7f9f1840 419d0060 7f9f1800 419e0050 <881bf008> 2f80 
> 419e0014 3d20c06f
> 
> 
> -- 
> BOFH excuse #241:
> 
> _Rosin_ core solder? But...
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: MPC5200b jffs2 memcpy alignment problem

2012-07-02 Thread Stephan Gatzka

Hi!


This problem has been discussed several times [1], [2], but wasn't
resolved yet. The clean solution suggested was to implement a custom
mapping driver [3].


Then I'll do that. It doesn't look terribly complicated.

It would be helpful if someone can test the first version if it's available.

Regards,

Stephan




smime.p7s
Description: S/MIME Cryptographic Signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 2/2] powerpc/p1022ds/DTS: Add RTC support

2012-07-02 Thread Kumar Gala

On Apr 16, 2012, at 8:42 PM,  
 wrote:

> From: Jerry Huang 
> 
> Add the RTC support for p1022ds
> 
> Signed-off-by: Jerry Huang 
> ---
> arch/powerpc/boot/dts/p1022ds.dtsi |4 
> 1 files changed, 4 insertions(+), 0 deletions(-)

applied

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: 3.5.0-rc5: BUG: soft lockup - CPU#0 stuck for 22s

2012-07-02 Thread Christian Kujau
On Mon, 2 Jul 2012 at 14:50, Benjamin Herrenschmidt wrote:
> > while trying to upgrade from 3.4.0 to 3.5.0-rc5 on this Powerbook G4 
> > (powerpc 32 bit), this happens during booting:
> > 
> > --
> > usb 2-1: new full-speed USB device number 4 using ohci_hcd
> > SCSI subsystem initialized
> > scsi0 : SBP-2 IEEE-1394
> > scsi1 : SBP-2 IEEE-1394
> > firewire_sbp2 fw1.0: logged in to LUN  (0 retries)
> > scsi 0:0:0:0: Direct-Access Ext Hard  DiskPQ: 0 ANSI: 4
> 
> Interesting... I observed something roughly similar on a dual G4
> the other day associated with a 30s to 1mn pause during boot. RCU
> was complaining loudly.
> 
> In my case, it did continue booting normally, is that the case for you ?
> 
> Also if I compile the kernel without CONFIG_SMP, it did go away as well,
> do you observe that too ?
> 
> I don't have a spare cycle to investigate this problem this week I'm
> afraid, it might help if you could try a bisection though.

OK, after a git-bisect, the following commit has been identified as bad:

---
a7a20d103994fd760766e6c9d494daa569cbfe06 is the first bad commit
commit a7a20d103994fd760766e6c9d494daa569cbfe06
Author: Dan Williams 
Date:   Thu Mar 22 17:05:11 2012 -0700

[SCSI] sd: limit the scope of the async probe domain
---

Unfortunately it's not possible to "git revert" just this single commit:


$ git revert a7a20d103994fd760766e6c9d494daa569cbfe06
error: could not revert a7a20d1... [SCSI] sd: limit the scope of the async 
probe domain
hint: after resolving the conflicts, mark the corrected paths  
hint: with 'git add ' or 'git rm '
hint: and commit the result with 'git commit'


I _guess_ this is probably due to:


commit ea80dadec7a06889562b478cf0b87afbe62b7ac8
Author: James Bottomley 
Date:   Wed Jun 6 14:54:13 2012 +0900

[SCSI] Fix sd_probe_domain config problem


The whole git-bisect log, dmesg, .config and so on is here:

  http://nerdbynature.de/bits/3.5.0-rc5/soft_lockup/

Anyone got an idea how to go from here?

Thanks,
Christian.
-- 
BOFH excuse #380:

Operators killed when huge stack of backup tapes fell over.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] [powerpc] Export memory limit via device tree

2012-07-02 Thread Suzuki K. Poulose
The powerpc kernel doesn't export the memory limit enforced by 'mem='
kernel parameter. This is required for building the ELF header in
kexec-tools to limit the vmcore to capture only the used memory. On
powerpc the kexec-tools depends on the device-tree for memory related
information, unlike /proc/iomem on the x86.

Without this information, the kexec-tools assumes the entire System
RAM and vmcore creates an unnecessarily larger dump.

This patch exports the memory limit, if present, via chosen/linux,memory-limit
property, so that the vmcore can be limited to the memory limit.

The prom_init seems to export this value in the same node. But doesn't really
appear there.  Also the memory_limit gets adjusted with the processing of
crashkernel= parameter. This patch makes sure we get the actual limit.

The kexec-tools will use the value to limit the 'end' of the memory
regions.

Tested this patch on ppc64 and ppc32(ppc440) with a kexec-tools
patch by Mahesh.

Signed-off-by: Suzuki K. Poulose 
Tested-by: Mahesh J. Salgaonkar 
---

 arch/powerpc/kernel/machine_kexec.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/machine_kexec.c 
b/arch/powerpc/kernel/machine_kexec.c
index c957b12..0c9695d 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -207,6 +207,12 @@ static struct property crashk_size_prop = {
.value = &crashk_size,
 };
 
+static struct property memory_limit_prop = {
+   .name = "linux,memory-limit",
+   .length = sizeof(phys_addr_t),
+   .value = &memory_limit,
+};
+
 static void __init export_crashk_values(struct device_node *node)
 {
struct property *prop;
@@ -226,6 +232,15 @@ static void __init export_crashk_values(struct device_node 
*node)
crashk_size = resource_size(&crashk_res);
prom_add_property(node, &crashk_size_prop);
}
+
+   /* memory-limit is needed for constructing the crash regions */
+   prop = of_find_property(node, memory_limit_prop.name, NULL);
+   if (prop)
+   prom_remove_property(node, prop);
+
+   if (memory_limit)
+   prom_add_property(node, &memory_limit_prop);
+
 }
 
 static int __init kexec_setup(void)

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH v6 1/5] powerpc/85xx: implement hardware timebase sync

2012-07-02 Thread Zhao Chenhui
On Thu, Jun 28, 2012 at 08:50:51PM +1000, Benjamin Herrenschmidt wrote:
> On Thu, 2012-06-28 at 11:38 +0800, Zhao Chenhui wrote:
> > 
> > 
> > The bootloader have done a timebase sync. If we do not need KEXEC or
> > HOTPLUG_CPU feature, it is unnecessary to do it again at boot time of
> > kernel. I only compile the timebase sync routines
> > when users enable KEXEC or HOTPLUG_CPU. 
> 
> Still, how much are you really saving ? Is it worth the added mess and
> loss of test coverage ?
> 
> We have too many conditional stuff like that already.
> 
> Cheers,
> Ben.

OK. I will remove this config option.

-Chenhui

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: MPC5200b jffs2 memcpy alignment problem

2012-07-02 Thread Anatolij Gustschin
Hi Stephan,

On Sun, 01 Jul 2012 08:47:01 +0200
Stephan Gatzka  wrote:

> Hi Albrecht,
> 
>  > I don't recall who proposed this patch, but exactly this solution is
>  > around for a longer time (mayby you search archives...).  On my board, I
>  > have a flash chip attached to the LocalBus in 16-bit mode.  Based on
>  > 3.2.16, the patch is:
> 
> Thanks for your answer and yes, this patch will definitely work. But I 
> want to have a solution in the mainline kernel, that's why I'm asking 
> how to deal best with this problem.

This problem has been discussed several times [1], [2], but wasn't
resolved yet. The clean solution suggested was to implement a custom
mapping driver [3].

Thanks,
Anatolij

[1] http://thread.gmane.org/gmane.linux.drivers.mtd/21521
[2] http://thread.gmane.org/gmane.linux.ports.ppc.embedded/36324
[3] http://thread.gmane.org/gmane.linux.ports.ppc.embedded/36324/focus=36608
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH v6 1/5] powerpc/85xx: implement hardware timebase sync

2012-07-02 Thread Zhao Chenhui
On Fri, Jun 29, 2012 at 10:39:24AM -0500, Tabi Timur-B04825 wrote:
> On Tue, Jun 26, 2012 at 5:25 AM, Zhao Chenhui
>  wrote:
> > Do hardware timebase sync. Firstly, stop all timebases, and transfer
> > the timebase value of the boot core to the other core. Finally,
> > start all timebases.
> >
> > Only apply to dual-core chips, such as MPC8572, P2020, etc.
> >
> > Signed-off-by: Zhao Chenhui 
> > Signed-off-by: Li Yang 
> > ---
> > Changes for v6:
> >  * added 85xx_TB_SYNC
> >  * added isync() after set_tb()
> >  * removed extra entries from mpc85xx_smp_guts_ids
> >
> >  arch/powerpc/include/asm/fsl_guts.h |    2 +
> >  arch/powerpc/platforms/85xx/Kconfig |    5 ++
> >  arch/powerpc/platforms/85xx/smp.c   |   84 
> > +++
> >  3 files changed, 91 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/powerpc/platforms/85xx/smp.c 
> > b/arch/powerpc/platforms/85xx/smp.c
> > index ff42490..edb0cad 100644
> > --- a/arch/powerpc/platforms/85xx/smp.c
> > +++ b/arch/powerpc/platforms/85xx/smp.c
> > @@ -24,6 +24,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include 
> >  #include 
> > @@ -42,6 +43,69 @@ extern void __early_start(void);
> >  #define NUM_BOOT_ENTRY         8
> >  #define SIZE_BOOT_ENTRY                (NUM_BOOT_ENTRY * sizeof(u32))
> >
> > +#ifdef CONFIG_85xx_TB_SYNC
> > +static struct ccsr_guts __iomem *guts;
> > +static u64 timebase;
> > +static int tb_req;
> > +static int tb_valid;
> > +
> > +static void mpc85xx_timebase_freeze(int freeze)
> > +{
> > +       unsigned int mask;
> 
> 'mask' should be uint32_t

OK.

> 
> > +
> > +       if (!guts)
> > +               return;
> 
> This function should never be called if guts is NULL, so this check
> should be unnecessary.

OK.

> 
> > +
> > +       mask = CCSR_GUTS_DEVDISR_TB0 | CCSR_GUTS_DEVDISR_TB1;
> > +       if (freeze)
> > +               setbits32(&guts->devdisr, mask);
> > +       else
> > +               clrbits32(&guts->devdisr, mask);
> > +
> > +       in_be32(&guts->devdisr);
> > +}
> > +
> > @@ -249,6 +323,16 @@ void __init mpc85xx_smp_init(void)
> >                smp_85xx_ops.cause_ipi = doorbell_cause_ipi;
> >        }
> >
> > +       np = of_find_matching_node(NULL, mpc85xx_smp_guts_ids);
> > +       if (np) {
> > +#ifdef CONFIG_85xx_TB_SYNC
> > +               guts = of_iomap(np, 0);
> 
> You need to test the return value of of_iomap().  smp_85xx_ops should
> be set only if guts is not NULL.

Yes. Thanks.

> 
> > +               smp_85xx_ops.give_timebase = mpc85xx_give_timebase;
> > +               smp_85xx_ops.take_timebase = mpc85xx_take_timebase;
> > +#endif
> > +               of_node_put(np);
> > +       }
> > +
> >        smp_ops = &smp_85xx_ops;
> >
> >  #ifdef CONFIG_KEXEC
> > --
> > 1.6.4.1

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 5/5] usb: gadget: composite: parse dt overrides

2012-07-02 Thread Felipe Balbi
Hi,

On Tue, Jun 26, 2012 at 11:27:13AM -0300, Alexandre Pereira da Silva wrote:
> Grab the devicetree node properties to override VendorId, ProductId,
> bcdDevice, Manucacturer, Product and SerialNumber
> 
> Signed-off-by: Alexandre Pereira da Silva 

I need Grant's acked-by to queue this one.

-- 
balbi


signature.asc
Description: Digital signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev