Re: Resend: [PATCH V5 3/4] hotplug/drc-info: Add code to search ibm,drc-info property
See below. On 11/30/2017 01:51 PM, Nathan Fontenot wrote: > > > On 11/28/2017 05:07 PM, Michael Bringmann wrote: >> rpadlpar_core.c: Provide parallel routines to search the older device- >> tree properties ("ibm,drc-indexes", "ibm,drc-names", "ibm,drc-types" >> and "ibm,drc-power-domains"), or the new property "ibm,drc-info". >> >> The interface to examine the DRC information is changed from a "get" >> function that returns values for local verification elsewhere, to a >> "check" function that validates the 'name' and/or 'type' of a device >> node. This update hides the format of the underlying device-tree >> properties, and concentrates the value checks into a single function >> without requiring the user to verify whether a search was successful. >> >> Signed-off-by: Michael Bringmann >> --- >> Changes in V5: >> -- Simplify of_prop_next_u32 invocation >> -- Fix some spacing within arguments >> --- >> drivers/pci/hotplug/rpadlpar_core.c | 13 ++-- >> drivers/pci/hotplug/rpaphp.h|4 + >> drivers/pci/hotplug/rpaphp_core.c | 109 >> +++ >> 3 files changed, 91 insertions(+), 35 deletions(-) >> >> diff --git a/drivers/pci/hotplug/rpadlpar_core.c >> b/drivers/pci/hotplug/rpadlpar_core.c >> index a3449d7..fc01d7d 100644 >> --- a/drivers/pci/hotplug/rpadlpar_core.c >> +++ b/drivers/pci/hotplug/rpadlpar_core.c >> @@ -27,6 +27,7 @@ >> #include >> #include >> #include >> +#include >> >> #include "../pci.h" >> #include "rpaphp.h" >> @@ -44,15 +45,14 @@ static struct device_node *find_vio_slot_node(char >> *drc_name) >> { >> struct device_node *parent = of_find_node_by_name(NULL, "vdevice"); >> struct device_node *dn = NULL; >> -char *name; >> int rc; >> >> if (!parent) >> return NULL; >> >> while ((dn = of_get_next_child(parent, dn))) { >> -rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); >> -if ((rc == 0) && (!strcmp(drc_name, name))) >> +rc = rpaphp_check_drc_props(dn, drc_name, NULL); >> +if (rc == 0) >> break; >> } >> >> @@ -64,15 +64,12 @@ static struct device_node *find_php_slot_pci_node(char >> *drc_name, >>char *drc_type) >> { >> struct device_node *np = NULL; >> -char *name; >> -char *type; >> int rc; >> >> while ((np = of_find_node_by_name(np, "pci"))) { >> -rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL); >> +rc = rpaphp_check_drc_props(np, drc_name, drc_type); >> if (rc == 0) >> -if (!strcmp(drc_name, name) && !strcmp(drc_type, type)) >> -break; >> +break; >> } >> >> return np; >> diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h >> index 7db024e..8db5f2e 100644 >> --- a/drivers/pci/hotplug/rpaphp.h >> +++ b/drivers/pci/hotplug/rpaphp.h >> @@ -91,8 +91,8 @@ struct slot { >> >> /* rpaphp_core.c */ >> int rpaphp_add_slot(struct device_node *dn); >> -int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, >> -char **drc_name, char **drc_type, int *drc_power_domain); >> +int rpaphp_check_drc_props(struct device_node *dn, char *drc_name, >> +char *drc_type); >> >> /* rpaphp_slot.c */ >> void dealloc_slot_struct(struct slot *slot); >> diff --git a/drivers/pci/hotplug/rpaphp_core.c >> b/drivers/pci/hotplug/rpaphp_core.c >> index 1e29aba..6da613a 100644 >> --- a/drivers/pci/hotplug/rpaphp_core.c >> +++ b/drivers/pci/hotplug/rpaphp_core.c >> @@ -30,6 +30,7 @@ >> #include >> #include >> #include >> +#include >> #include/* for eeh_add_device() */ >> #include/* rtas_call */ >> #include /* for pci_controller */ >> @@ -196,25 +197,21 @@ static int get_children_props(struct device_node *dn, >> const int **drc_indexes, >> return 0; >> } >> >> -/* To get the DRC props describing the current node, first obtain it's >> - * my-drc-index property. Next obtain the DRC list from it's parent. Use >> - * the my-drc-index for correlation, and obtain the requested properties. >> + >> +/* Verify the existence of 'drc_name' and/or 'drc_type' within the >> + * current node. First obtain it's my-drc-index property. Next, >> + * obtain the DRC info from it's parent. Use the my-drc-index for >> + * correlation, and obtain/validate the requested properties. >> */ >> -int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, >> -char **drc_name, char **drc_type, int *drc_power_domain) >> + >> +static int rpaphp_check_drc_props_v1(struct device_node *dn, char *drc_name, >> +char *drc_type, unsigned int my_index) >> { >> +char *name_tmp, *type_tmp; >> const int *indexes, *names; >> const int *types, *domains; >> -const unsigned int *my_index; >> -char *name_tmp, *type_tmp; >>
Re: Resend: [PATCH V5 3/4] hotplug/drc-info: Add code to search ibm,drc-info property
See below. On 11/30/2017 01:51 PM, Nathan Fontenot wrote: > > > On 11/28/2017 05:07 PM, Michael Bringmann wrote: >> rpadlpar_core.c: Provide parallel routines to search the older device- >> tree properties ("ibm,drc-indexes", "ibm,drc-names", "ibm,drc-types" >> and "ibm,drc-power-domains"), or the new property "ibm,drc-info". >> >> The interface to examine the DRC information is changed from a "get" >> function that returns values for local verification elsewhere, to a >> "check" function that validates the 'name' and/or 'type' of a device >> node. This update hides the format of the underlying device-tree >> properties, and concentrates the value checks into a single function >> without requiring the user to verify whether a search was successful. >> >> Signed-off-by: Michael Bringmann >> --- >> Changes in V5: >> -- Simplify of_prop_next_u32 invocation >> -- Fix some spacing within arguments >> --- >> drivers/pci/hotplug/rpadlpar_core.c | 13 ++-- >> drivers/pci/hotplug/rpaphp.h|4 + >> drivers/pci/hotplug/rpaphp_core.c | 109 >> +++ >> 3 files changed, 91 insertions(+), 35 deletions(-) >> >> diff --git a/drivers/pci/hotplug/rpadlpar_core.c >> b/drivers/pci/hotplug/rpadlpar_core.c >> index a3449d7..fc01d7d 100644 >> --- a/drivers/pci/hotplug/rpadlpar_core.c >> +++ b/drivers/pci/hotplug/rpadlpar_core.c >> @@ -27,6 +27,7 @@ >> #include >> #include >> #include >> +#include >> >> #include "../pci.h" >> #include "rpaphp.h" >> @@ -44,15 +45,14 @@ static struct device_node *find_vio_slot_node(char >> *drc_name) >> { >> struct device_node *parent = of_find_node_by_name(NULL, "vdevice"); >> struct device_node *dn = NULL; >> -char *name; >> int rc; >> >> if (!parent) >> return NULL; >> >> while ((dn = of_get_next_child(parent, dn))) { >> -rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); >> -if ((rc == 0) && (!strcmp(drc_name, name))) >> +rc = rpaphp_check_drc_props(dn, drc_name, NULL); >> +if (rc == 0) >> break; >> } >> >> @@ -64,15 +64,12 @@ static struct device_node *find_php_slot_pci_node(char >> *drc_name, >>char *drc_type) >> { >> struct device_node *np = NULL; >> -char *name; >> -char *type; >> int rc; >> >> while ((np = of_find_node_by_name(np, "pci"))) { >> -rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL); >> +rc = rpaphp_check_drc_props(np, drc_name, drc_type); >> if (rc == 0) >> -if (!strcmp(drc_name, name) && !strcmp(drc_type, type)) >> -break; >> +break; >> } >> >> return np; >> diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h >> index 7db024e..8db5f2e 100644 >> --- a/drivers/pci/hotplug/rpaphp.h >> +++ b/drivers/pci/hotplug/rpaphp.h >> @@ -91,8 +91,8 @@ struct slot { >> >> /* rpaphp_core.c */ >> int rpaphp_add_slot(struct device_node *dn); >> -int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, >> -char **drc_name, char **drc_type, int *drc_power_domain); >> +int rpaphp_check_drc_props(struct device_node *dn, char *drc_name, >> +char *drc_type); >> >> /* rpaphp_slot.c */ >> void dealloc_slot_struct(struct slot *slot); >> diff --git a/drivers/pci/hotplug/rpaphp_core.c >> b/drivers/pci/hotplug/rpaphp_core.c >> index 1e29aba..6da613a 100644 >> --- a/drivers/pci/hotplug/rpaphp_core.c >> +++ b/drivers/pci/hotplug/rpaphp_core.c >> @@ -30,6 +30,7 @@ >> #include >> #include >> #include >> +#include >> #include/* for eeh_add_device() */ >> #include/* rtas_call */ >> #include /* for pci_controller */ >> @@ -196,25 +197,21 @@ static int get_children_props(struct device_node *dn, >> const int **drc_indexes, >> return 0; >> } >> >> -/* To get the DRC props describing the current node, first obtain it's >> - * my-drc-index property. Next obtain the DRC list from it's parent. Use >> - * the my-drc-index for correlation, and obtain the requested properties. >> + >> +/* Verify the existence of 'drc_name' and/or 'drc_type' within the >> + * current node. First obtain it's my-drc-index property. Next, >> + * obtain the DRC info from it's parent. Use the my-drc-index for >> + * correlation, and obtain/validate the requested properties. >> */ >> -int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, >> -char **drc_name, char **drc_type, int *drc_power_domain) >> + >> +static int rpaphp_check_drc_props_v1(struct device_node *dn, char *drc_name, >> +char *drc_type, unsigned int my_index) >> { >> +char *name_tmp, *type_tmp; >> const int *indexes, *names; >> const int *types, *domains; >> -const unsigned int *my_index; >> -char *name_tmp, *type_tmp; >>
Re: Resend: [PATCH V5 3/4] hotplug/drc-info: Add code to search ibm,drc-info property
On 11/28/2017 05:07 PM, Michael Bringmann wrote: > rpadlpar_core.c: Provide parallel routines to search the older device- > tree properties ("ibm,drc-indexes", "ibm,drc-names", "ibm,drc-types" > and "ibm,drc-power-domains"), or the new property "ibm,drc-info". > > The interface to examine the DRC information is changed from a "get" > function that returns values for local verification elsewhere, to a > "check" function that validates the 'name' and/or 'type' of a device > node. This update hides the format of the underlying device-tree > properties, and concentrates the value checks into a single function > without requiring the user to verify whether a search was successful. > > Signed-off-by: Michael Bringmann > --- > Changes in V5: > -- Simplify of_prop_next_u32 invocation > -- Fix some spacing within arguments > --- > drivers/pci/hotplug/rpadlpar_core.c | 13 ++-- > drivers/pci/hotplug/rpaphp.h|4 + > drivers/pci/hotplug/rpaphp_core.c | 109 > +++ > 3 files changed, 91 insertions(+), 35 deletions(-) > > diff --git a/drivers/pci/hotplug/rpadlpar_core.c > b/drivers/pci/hotplug/rpadlpar_core.c > index a3449d7..fc01d7d 100644 > --- a/drivers/pci/hotplug/rpadlpar_core.c > +++ b/drivers/pci/hotplug/rpadlpar_core.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > > #include "../pci.h" > #include "rpaphp.h" > @@ -44,15 +45,14 @@ static struct device_node *find_vio_slot_node(char > *drc_name) > { > struct device_node *parent = of_find_node_by_name(NULL, "vdevice"); > struct device_node *dn = NULL; > - char *name; > int rc; > > if (!parent) > return NULL; > > while ((dn = of_get_next_child(parent, dn))) { > - rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); > - if ((rc == 0) && (!strcmp(drc_name, name))) > + rc = rpaphp_check_drc_props(dn, drc_name, NULL); > + if (rc == 0) > break; > } > > @@ -64,15 +64,12 @@ static struct device_node *find_php_slot_pci_node(char > *drc_name, > char *drc_type) > { > struct device_node *np = NULL; > - char *name; > - char *type; > int rc; > > while ((np = of_find_node_by_name(np, "pci"))) { > - rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL); > + rc = rpaphp_check_drc_props(np, drc_name, drc_type); > if (rc == 0) > - if (!strcmp(drc_name, name) && !strcmp(drc_type, type)) > - break; > + break; > } > > return np; > diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h > index 7db024e..8db5f2e 100644 > --- a/drivers/pci/hotplug/rpaphp.h > +++ b/drivers/pci/hotplug/rpaphp.h > @@ -91,8 +91,8 @@ struct slot { > > /* rpaphp_core.c */ > int rpaphp_add_slot(struct device_node *dn); > -int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, > - char **drc_name, char **drc_type, int *drc_power_domain); > +int rpaphp_check_drc_props(struct device_node *dn, char *drc_name, > + char *drc_type); > > /* rpaphp_slot.c */ > void dealloc_slot_struct(struct slot *slot); > diff --git a/drivers/pci/hotplug/rpaphp_core.c > b/drivers/pci/hotplug/rpaphp_core.c > index 1e29aba..6da613a 100644 > --- a/drivers/pci/hotplug/rpaphp_core.c > +++ b/drivers/pci/hotplug/rpaphp_core.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > #include/* for eeh_add_device() */ > #include /* rtas_call */ > #include /* for pci_controller */ > @@ -196,25 +197,21 @@ static int get_children_props(struct device_node *dn, > const int **drc_indexes, > return 0; > } > > -/* To get the DRC props describing the current node, first obtain it's > - * my-drc-index property. Next obtain the DRC list from it's parent. Use > - * the my-drc-index for correlation, and obtain the requested properties. > + > +/* Verify the existence of 'drc_name' and/or 'drc_type' within the > + * current node. First obtain it's my-drc-index property. Next, > + * obtain the DRC info from it's parent. Use the my-drc-index for > + * correlation, and obtain/validate the requested properties. > */ > -int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, > - char **drc_name, char **drc_type, int *drc_power_domain) > + > +static int rpaphp_check_drc_props_v1(struct device_node *dn, char *drc_name, > + char *drc_type, unsigned int my_index) > { > + char *name_tmp, *type_tmp; > const int *indexes, *names; > const int *types, *domains; > - const unsigned int *my_index; > - char *name_tmp, *type_tmp; > int i, rc; > > - my_index = of_get_property(dn, "ibm,my-drc-index", NULL); > - if (!my_index) { > - /* Node isn't DLPAR/
Resend: [PATCH V5 3/4] hotplug/drc-info: Add code to search ibm,drc-info property
rpadlpar_core.c: Provide parallel routines to search the older device- tree properties ("ibm,drc-indexes", "ibm,drc-names", "ibm,drc-types" and "ibm,drc-power-domains"), or the new property "ibm,drc-info". The interface to examine the DRC information is changed from a "get" function that returns values for local verification elsewhere, to a "check" function that validates the 'name' and/or 'type' of a device node. This update hides the format of the underlying device-tree properties, and concentrates the value checks into a single function without requiring the user to verify whether a search was successful. Signed-off-by: Michael Bringmann --- Changes in V5: -- Simplify of_prop_next_u32 invocation -- Fix some spacing within arguments --- drivers/pci/hotplug/rpadlpar_core.c | 13 ++-- drivers/pci/hotplug/rpaphp.h|4 + drivers/pci/hotplug/rpaphp_core.c | 109 +++ 3 files changed, 91 insertions(+), 35 deletions(-) diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index a3449d7..fc01d7d 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "../pci.h" #include "rpaphp.h" @@ -44,15 +45,14 @@ static struct device_node *find_vio_slot_node(char *drc_name) { struct device_node *parent = of_find_node_by_name(NULL, "vdevice"); struct device_node *dn = NULL; - char *name; int rc; if (!parent) return NULL; while ((dn = of_get_next_child(parent, dn))) { - rc = rpaphp_get_drc_props(dn, NULL, &name, NULL, NULL); - if ((rc == 0) && (!strcmp(drc_name, name))) + rc = rpaphp_check_drc_props(dn, drc_name, NULL); + if (rc == 0) break; } @@ -64,15 +64,12 @@ static struct device_node *find_php_slot_pci_node(char *drc_name, char *drc_type) { struct device_node *np = NULL; - char *name; - char *type; int rc; while ((np = of_find_node_by_name(np, "pci"))) { - rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL); + rc = rpaphp_check_drc_props(np, drc_name, drc_type); if (rc == 0) - if (!strcmp(drc_name, name) && !strcmp(drc_type, type)) - break; + break; } return np; diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h index 7db024e..8db5f2e 100644 --- a/drivers/pci/hotplug/rpaphp.h +++ b/drivers/pci/hotplug/rpaphp.h @@ -91,8 +91,8 @@ struct slot { /* rpaphp_core.c */ int rpaphp_add_slot(struct device_node *dn); -int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, - char **drc_name, char **drc_type, int *drc_power_domain); +int rpaphp_check_drc_props(struct device_node *dn, char *drc_name, + char *drc_type); /* rpaphp_slot.c */ void dealloc_slot_struct(struct slot *slot); diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 1e29aba..6da613a 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c @@ -30,6 +30,7 @@ #include #include #include +#include #include/* for eeh_add_device() */ #include /* rtas_call */ #include /* for pci_controller */ @@ -196,25 +197,21 @@ static int get_children_props(struct device_node *dn, const int **drc_indexes, return 0; } -/* To get the DRC props describing the current node, first obtain it's - * my-drc-index property. Next obtain the DRC list from it's parent. Use - * the my-drc-index for correlation, and obtain the requested properties. + +/* Verify the existence of 'drc_name' and/or 'drc_type' within the + * current node. First obtain it's my-drc-index property. Next, + * obtain the DRC info from it's parent. Use the my-drc-index for + * correlation, and obtain/validate the requested properties. */ -int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, - char **drc_name, char **drc_type, int *drc_power_domain) + +static int rpaphp_check_drc_props_v1(struct device_node *dn, char *drc_name, + char *drc_type, unsigned int my_index) { + char *name_tmp, *type_tmp; const int *indexes, *names; const int *types, *domains; - const unsigned int *my_index; - char *name_tmp, *type_tmp; int i, rc; - my_index = of_get_property(dn, "ibm,my-drc-index", NULL); - if (!my_index) { - /* Node isn't DLPAR/hotplug capable */ - return -EINVAL; - } - rc = get_children_props(dn->parent, &indexes, &names, &types, &domains); if (rc < 0) { return -EINVAL; @@ -225,24 +222,86 @@ int rpap