This set of patches moves some OF code that has been living
in the pseries tree over to the generic OF code base. The
functionality being migrated over is something that, I believe,
should live in the generic code base. The specific functionality
being migrated to generic OF code is;
o Updating the device tree in /proc when adding/removing a node.
o Adding a notification chain for adding/removing nodes and
properties of the device tree.
o Re-naming the base OF code prom_* routines to of_* to better go
with the naming used for OF code.
-Nathan
When adding or removing a device tree node we should also update
the device tree in /proc/device-tree. This action is already done in the
generic OF code for adding/removing properties of a node. This patch adds
this functionality for nodes.
Signed-off-by: Nathan Fontenot <redacted>
---
arch/powerpc/platforms/pseries/dlpar.c | 24 -------------
arch/powerpc/platforms/pseries/reconfig.c | 47 -------------------------
drivers/of/base.c | 55 +++++++++++++++++++++++++++---
3 files changed, 51 insertions(+), 75 deletions(-)
Index: dt-next/arch/powerpc/platforms/pseries/dlpar.c
===================================================================
This patch moves the definition of the of_drconf_cell struct to asm/prom.h
to make it available for all powerpc/pseries code.
Signed-off-by: Nathan Fontenot <redacted>
---
arch/powerpc/include/asm/prom.h | 16 ++++++++++++++++
arch/powerpc/mm/numa.c | 12 ------------
2 files changed, 16 insertions(+), 12 deletions(-)
Index: dt-next/arch/powerpc/mm/numa.c
===================================================================
@@ -58,6 +58,22 @@externvoidof_instantiate_rtc(void);+/* The of_drconf_cell struct defines the layout of the LMB array+*specifiedinthedevicetreeproperty+*ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory+*/+structof_drconf_cell{+u64base_addr;+u32drc_index;+u32reserved;+u32aa_index;+u32flags;+};++#define DRCONF_MEM_ASSIGNED 0x00000008+#define DRCONF_MEM_AI_INVALID 0x00000040+#define DRCONF_MEM_RESERVED 0x00000080+/* These includes are put at the bottom because they may contain things*thatareoverriddenbythisfile.Ideallytheyshouldn'tbeincluded*bythisfile,butthereareabunchof.cfilesthatcurrentlydepend
This patch moves the notification chain for updates to the device tree
from the powerpc/pseries code to the base OF code. This makes this
functionality available to all architectures.
Additionally the notification chain is updated to allow notifications
for property add/remove/update. To make this work a pointer to a new
struct (of_prop_reconfig) is passed to the routines in the notification chain.
The of_prop_reconfig property contains a pointer to the node containing the
property and a pointer to the property itself. In the case of property
updates, the property pointer refers to the new property.
Signed-off-by: Nathan Fontenot <redacted>
---
arch/powerpc/include/asm/pSeries_reconfig.h | 32 ----------
arch/powerpc/kernel/prom.c | 6 -
arch/powerpc/platforms/pseries/dlpar.c | 14 ++--
arch/powerpc/platforms/pseries/hotplug-cpu.c | 8 +-
arch/powerpc/platforms/pseries/hotplug-memory.c | 60 +++++++++++++------
arch/powerpc/platforms/pseries/iommu.c | 6 -
arch/powerpc/platforms/pseries/reconfig.c | 65 ---------------------
arch/powerpc/platforms/pseries/setup.c | 6 -
drivers/of/base.c | 74 ++++++++++++++++++++++--
include/linux/of.h | 20 +++++-
10 files changed, 154 insertions(+), 137 deletions(-)
Index: dt-next/arch/powerpc/platforms/pseries/reconfig.c
===================================================================
@@ -100,13 +78,12 @@gotoout_err;}-err=pSeries_reconfig_notify(PSERIES_RECONFIG_ADD,np);+err=of_attach_node(np);if(err){printk(KERN_ERR"Failed to add device node %s\n",path);gotoout_err;}-of_attach_node(np);of_node_put(np->parent);return0;
@@ -134,9 +111,7 @@return-EBUSY;}-pSeries_reconfig_notify(PSERIES_RECONFIG_REMOVE,np);of_detach_node(np);-of_node_put(parent);of_node_put(np);/* Must decrement the refcount */return0;
@@ -410,41 +384,8 @@return-ENODEV;}-upd_value.node=np;-upd_value.property=newprop;-pSeries_reconfig_notify(PSERIES_UPDATE_PROPERTY,&upd_value);-rc=prom_update_property(np,newprop,oldprop);-if(rc)-returnrc;--/* For memory under the ibm,dynamic-reconfiguration-memory node-*ofthedevicetree,addingandremovingmemoryisjustanupdate-*totheibm,dynamic-memorypropertyinsteadofadding/removinga-*memorynodeinthedevicetree.Forthesecaseswestillneedto-*involvethenotifierchain.-*/-if(!strcmp(name,"ibm,dynamic-memory")){-intaction;--next_prop=parse_next_property(next_prop,end,&name,-&length,&value);-if(!next_prop)-return-EINVAL;--if(!strcmp(name,"add"))-action=PSERIES_DRCONF_MEM_ADD;-else-action=PSERIES_DRCONF_MEM_REMOVE;--rc=pSeries_reconfig_notify(action,value);-if(rc){-prom_update_property(np,oldprop,newprop);-returnrc;-}-}--return0;+returnrc;}/**
@@ -2,43 +2,11 @@#define _PPC64_PSERIES_RECONFIG_H#ifdef __KERNEL__-#include<linux/notifier.h>--/*-*UsethisAPIifyourcodeneedstoknowaboutOFdevicenodesbeing-*addedorremovedonpSeriessystems.-*/--#define PSERIES_RECONFIG_ADD 0x0001-#define PSERIES_RECONFIG_REMOVE 0x0002-#define PSERIES_DRCONF_MEM_ADD 0x0003-#define PSERIES_DRCONF_MEM_REMOVE 0x0004-#define PSERIES_UPDATE_PROPERTY 0x0005--/**-*pSeries_reconfig_notify-NotifiervaluestructureforOFDTpropertyupdates-*-*@node:Devicetreenodewhichownsthepropertybeingupdated-*@property:Updatedproperty-*/-structpSeries_reconfig_prop_update{-structdevice_node*node;-structproperty*property;-};-#ifdef CONFIG_PPC_PSERIES-externintpSeries_reconfig_notifier_register(structnotifier_block*);-externvoidpSeries_reconfig_notifier_unregister(structnotifier_block*);-externintpSeries_reconfig_notify(unsignedlongaction,void*p);/* Not the best place to put this, will be fixed when we move some*ofthertassuspend-mestufftopseries*/externvoidpSeries_coalesce_init(void);#else /* !CONFIG_PPC_PSERIES */-staticinlineintpSeries_reconfig_notifier_register(structnotifier_block*nb)-{-return0;-}-staticinlinevoidpSeries_reconfig_notifier_unregister(structnotifier_block*nb){}staticinlinevoidpSeries_coalesce_init(void){}#endif /* CONFIG_PPC_PSERIES */
@@ -399,7 +399,7 @@/* Processors can be added/removed only on LPAR */if(firmware_has_feature(FW_FEATURE_LPAR)){-pSeries_reconfig_notifier_register(&pseries_smp_nb);+of_reconfig_notifier_register(&pseries_smp_nb);cpu_maps_update_begin();if(cede_offline_enabled&&parse_cede_parameters()==0){default_offline_state=CPU_STATE_INACTIVE;
@@ -181,42 +180,69 @@return(ret<0)?-EINVAL:0;}-staticintpseries_drconf_memory(unsignedlong*base,unsignedintaction)+staticintpseries_update_drconf_memory(structof_prop_reconfig*pr){+structof_drconf_cell*new_drmem,*old_drmem;unsignedlongmemblock_size;-intrc;+u32entries;+u32*p;+inti,rc=-EINVAL;memblock_size=get_memblock_size();if(!memblock_size)return-EINVAL;-if(action==PSERIES_DRCONF_MEM_ADD){-rc=memblock_add(*base,memblock_size);-rc=(rc<0)?-EINVAL:0;-}elseif(action==PSERIES_DRCONF_MEM_REMOVE){-rc=pseries_remove_memblock(*base,memblock_size);-}else{-rc=-EINVAL;+p=(u32*)of_get_property(pr->dn,"ibm,dynamic-memory",NULL);+if(!p)+return-EINVAL;++/* The first int of the property is the number of lmb's described+*bytheproperty.Thisisfollowedbyanarrayofof_drconf_cell+*entries.Gettheniumberofentriesandskiptothearrayof+*of_drconf_cell's.+*/+entries=*p++;+old_drmem=(structof_drconf_cell*)p;++p=(u32*)pr->prop->value;+p++;+new_drmem=(structof_drconf_cell*)p;++for(i=0;i<entries;i++){+if((old_drmem[i].flags&DRCONF_MEM_ASSIGNED)&&+(!(new_drmem[i].flags&DRCONF_MEM_ASSIGNED))){+rc=pseries_remove_memblock(old_drmem[i].base_addr,+memblock_size);+break;+}elseif((!(old_drmem[i].flags&DRCONF_MEM_ASSIGNED))&&+(new_drmem[i].flags&DRCONF_MEM_ASSIGNED)){+rc=memblock_add(old_drmem[i].base_addr,+memblock_size);+rc=(rc<0)?-EINVAL:0;+break;+}}returnrc;}staticintpseries_memory_notifier(structnotifier_block*nb,-unsignedlongaction,void*node)+unsignedlongaction,void*node){+structof_prop_reconfig*pr;interr=0;switch(action){-casePSERIES_RECONFIG_ADD:+caseOF_RECONFIG_ATTACH_NODE:err=pseries_add_memory(node);break;-casePSERIES_RECONFIG_REMOVE:+caseOF_RECONFIG_DETACH_NODE:err=pseries_remove_memory(node);break;-casePSERIES_DRCONF_MEM_ADD:-casePSERIES_DRCONF_MEM_REMOVE:-err=pseries_drconf_memory(node,action);+caseOF_RECONFIG_UPDATE_PROPERTY:+pr=(structof_prop_reconfig*)node;+if(!strcmp(pr->prop->name,"ibm,dynamic-memory"))+err=pseries_update_drconf_memory(pr);break;}returnnotifier_from_errno(err);
@@ -262,24 +262,26 @@if(!dn->parent)return-ENOMEM;-rc=pSeries_reconfig_notify(PSERIES_RECONFIG_ADD,dn);+rc=of_attach_node(dn);if(rc){printk(KERN_ERR"Failed to add device node %s\n",dn->full_name);returnrc;}-of_attach_node(dn);of_node_put(dn->parent);return0;}intdlpar_detach_node(structdevice_node*dn){-pSeries_reconfig_notify(PSERIES_RECONFIG_REMOVE,dn);-of_detach_node(dn);-of_node_put(dn);/* Must decrement the refcount */+intrc;+rc=of_detach_node(dn);+if(rc)+returnrc;++of_node_put(dn);/* Must decrement the refcount */return0;}
Rename the prom_*_property routines of the generic OF code to of_*_property.
This brings them in line with the naming used by the rest of the OF code.
Signed-off-by: Nathan Fontenot <redacted>
---
arch/powerpc/kernel/machine_kexec.c | 12 ++++++------
arch/powerpc/kernel/machine_kexec_64.c | 8 ++++----
arch/powerpc/kernel/pci_32.c | 2 +-
arch/powerpc/platforms/ps3/os-area.c | 6 +++---
arch/powerpc/platforms/pseries/iommu.c | 4 ++--
arch/powerpc/platforms/pseries/mobility.c | 6 +++---
arch/powerpc/platforms/pseries/reconfig.c | 8 ++++----
drivers/macintosh/smu.c | 2 +-
drivers/of/base.c | 15 +++++++--------
include/linux/of.h | 9 ++++-----
10 files changed, 35 insertions(+), 37 deletions(-)
Index: dt-next/include/linux/of.h
===================================================================
@@ -263,11 +263,10 @@externintof_machine_is_compatible(constchar*compat);-externintprom_add_property(structdevice_node*np,structproperty*prop);-externintprom_remove_property(structdevice_node*np,structproperty*prop);-externintprom_update_property(structdevice_node*np,-structproperty*newprop,-structproperty*oldprop);+externintof_add_property(structdevice_node*np,structproperty*prop);+externintof_remove_property(structdevice_node*np,structproperty*prop);+externintof_update_property(structdevice_node*np,structproperty*newprop,+structproperty*oldprop);#if defined(CONFIG_OF_DYNAMIC)/* For updating the device tree at runtime */
@@ -237,11 +237,11 @@/* remove any stale properties so ours can be found */prop=of_find_property(node,kernel_end_prop.name,NULL);if(prop)-prom_remove_property(node,prop);+of_remove_property(node,prop);/* information needed by userspace when using default_machine_kexec */kernel_end=__pa(_end);-prom_add_property(node,&kernel_end_prop);+of_add_property(node,&kernel_end_prop);export_crashk_values(node);
@@ -389,14 +389,14 @@/* remove any stale propertys so ours can be found */prop=of_find_property(node,htab_base_prop.name,NULL);if(prop)-prom_remove_property(node,prop);+of_remove_property(node,prop);prop=of_find_property(node,htab_size_prop.name,NULL);if(prop)-prom_remove_property(node,prop);+of_remove_property(node,prop);htab_base=__pa(htab_address);-prom_add_property(node,&htab_base_prop);-prom_add_property(node,&htab_size_prop);+of_add_property(node,&htab_base_prop);+of_add_property(node,&htab_size_prop);of_node_put(node);return0;
Remove the pSeries_reconfig.h header file. At this point there is only one
definition in the file, pSeries_coalesce_init(), which can be
moved to rtas.h.
Signed-off-by: Nathan Fontenot <redacted>
---
arch/powerpc/include/asm/pSeries_reconfig.h | 15 ---------------
arch/powerpc/include/asm/rtas.h | 5 +++++
arch/powerpc/kernel/rtas.c | 1 -
arch/powerpc/platforms/pseries/smp.c | 1 -
4 files changed, 5 insertions(+), 17 deletions(-)
Index: dt-next/arch/powerpc/include/asm/pSeries_reconfig.h
===================================================================
@@ -1,15 +0,0 @@-#ifndef _PPC64_PSERIES_RECONFIG_H-#define _PPC64_PSERIES_RECONFIG_H-#ifdef __KERNEL__--#ifdef CONFIG_PPC_PSERIES-/* Not the best place to put this, will be fixed when we move some- * of the rtas suspend-me stuff to pseries */-extern void pSeries_coalesce_init(void);-#else /* !CONFIG_PPC_PSERIES */-static inline void pSeries_coalesce_init(void) { }-#endif /* CONFIG_PPC_PSERIES */---#endif /* __KERNEL__ */-#endif /* _PPC64_PSERIES_RECONFIG_H */
@@ -353,8 +353,13 @@return1;return0;}++/* Not the best place to put pSeries_coalesce_init, will be fixed when we+*movesomeofthertassuspend-mestufftopseries*/+externvoidpSeries_coalesce_init(void);#elsestaticinlineintpage_is_rtas_user_buf(unsignedlongpfn){return0;}+staticinlinevoidpSeries_coalesce_init(void){}#endifexternintcall_rtas(constchar*,int,int,unsignedlong*,...);
On Tue, 2012-10-02 at 21:58 -0500, Nathan Fontenot wrote:
Rename the prom_*_property routines of the generic OF code to of_*_property.
This brings them in line with the naming used by the rest of the OF code.
Signed-off-by: Nathan Fontenot <redacted>
---
arch/powerpc/platforms/ps3/os-area.c | 6 +++---
10 files changed, 35 insertions(+), 37 deletions(-)
The ps3 part looks OK. Please do build test with ps3_defconfig.
Acked-by: Geoff Levand <geoff@infradead.org>
From: Michael Ellerman <hidden> Date: 2012-10-08 23:54:25
On Tue, 2012-10-02 at 13:11 -0500, Nathan Fontenot wrote:
This set of patches moves some OF code that has been living
in the pseries tree over to the generic OF code base. The
functionality being migrated over is something that, I believe,
should live in the generic code base. The specific functionality
being migrated to generic OF code is;
From: Grant Likely <hidden> Date: 2012-11-14 14:38:48
On Tue, 02 Oct 2012 21:55:01 -0500, Nathan Fontenot [off-list ref] wrote:
When adding or removing a device tree node we should also update
the device tree in /proc/device-tree. This action is already done in the
generic OF code for adding/removing properties of a node. This patch adds
this functionality for nodes.
Signed-off-by: Nathan Fontenot <redacted>
For the whole series:
Acked-by: Grant Likely <redacted>