* [PATCH] PCI/hotplug/rphahp: Fix endianess issues
@ 2014-04-10 13:02 Laurent Dufour
2014-04-25 17:50 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: Laurent Dufour @ 2014-04-10 13:02 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci, linuxppc-dev; +Cc: mdroth
Numerical values stored in the device tree are encoded in Big Endian and
should be byte swapped when running in Little Endian.
RPA hot plug module should convert those values as well.
Note that in rpaphp_get_drc_props the comparison between indexes[i+1] and
*index is done using the BE values (whatever is the current endianess).
This doesn't matter since we are checking for equality here. This way only
the returned value is byte swapped.
RPA also made RTAS calls which implies BE values to be used. According to
the patch done in RTAS (http://patchwork.ozlabs.org/patch/336865), no
additional conversion is required in RPA.
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
---
drivers/pci/hotplug/rpaphp_core.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 4796c15..984d708 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -223,16 +223,16 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
type_tmp = (char *) &types[1];
/* Iterate through parent properties, looking for my-drc-index */
- for (i = 0; i < indexes[0]; i++) {
+ for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
if ((unsigned int) indexes[i + 1] == *my_index) {
if (drc_name)
*drc_name = name_tmp;
if (drc_type)
*drc_type = type_tmp;
if (drc_index)
- *drc_index = *my_index;
+ *drc_index = be32_to_cpu(*my_index);
if (drc_power_domain)
- *drc_power_domain = domains[i+1];
+ *drc_power_domain = be32_to_cpu(domains[i+1]);
return 0;
}
name_tmp += (strlen(name_tmp) + 1);
@@ -321,16 +321,19 @@ int rpaphp_add_slot(struct device_node *dn)
/* register PCI devices */
name = (char *) &names[1];
type = (char *) &types[1];
- for (i = 0; i < indexes[0]; i++) {
+ for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
+ int index;
- slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]);
+ index = be32_to_cpu(indexes[i + 1]);
+ slot = alloc_slot_struct(dn, index, name,
+ be32_to_cpu(power_domains[i + 1]));
if (!slot)
return -ENOMEM;
slot->type = simple_strtoul(type, NULL, 10);
dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n",
- indexes[i + 1], name, type);
+ index, name, type);
retval = rpaphp_enable_slot(slot);
if (!retval)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI/hotplug/rphahp: Fix endianess issues
2014-04-10 13:02 [PATCH] PCI/hotplug/rphahp: Fix endianess issues Laurent Dufour
@ 2014-04-25 17:50 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2014-04-25 17:50 UTC (permalink / raw)
To: Laurent Dufour; +Cc: linux-pci, linuxppc-dev, mdroth
On Thu, Apr 10, 2014 at 03:02:13PM +0200, Laurent Dufour wrote:
> Numerical values stored in the device tree are encoded in Big Endian and
> should be byte swapped when running in Little Endian.
>
> RPA hot plug module should convert those values as well.
>
> Note that in rpaphp_get_drc_props the comparison between indexes[i+1] and
> *index is done using the BE values (whatever is the current endianess).
> This doesn't matter since we are checking for equality here. This way only
> the returned value is byte swapped.
>
> RPA also made RTAS calls which implies BE values to be used. According to
> the patch done in RTAS (http://patchwork.ozlabs.org/patch/336865), no
> additional conversion is required in RPA.
>
> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
I applied this to pci/hotplug for v3.16, thanks!
> ---
> drivers/pci/hotplug/rpaphp_core.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
> index 4796c15..984d708 100644
> --- a/drivers/pci/hotplug/rpaphp_core.c
> +++ b/drivers/pci/hotplug/rpaphp_core.c
> @@ -223,16 +223,16 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
> type_tmp = (char *) &types[1];
>
> /* Iterate through parent properties, looking for my-drc-index */
> - for (i = 0; i < indexes[0]; i++) {
> + for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
> if ((unsigned int) indexes[i + 1] == *my_index) {
> if (drc_name)
> *drc_name = name_tmp;
> if (drc_type)
> *drc_type = type_tmp;
> if (drc_index)
> - *drc_index = *my_index;
> + *drc_index = be32_to_cpu(*my_index);
> if (drc_power_domain)
> - *drc_power_domain = domains[i+1];
> + *drc_power_domain = be32_to_cpu(domains[i+1]);
> return 0;
> }
> name_tmp += (strlen(name_tmp) + 1);
> @@ -321,16 +321,19 @@ int rpaphp_add_slot(struct device_node *dn)
> /* register PCI devices */
> name = (char *) &names[1];
> type = (char *) &types[1];
> - for (i = 0; i < indexes[0]; i++) {
> + for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
> + int index;
>
> - slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]);
> + index = be32_to_cpu(indexes[i + 1]);
> + slot = alloc_slot_struct(dn, index, name,
> + be32_to_cpu(power_domains[i + 1]));
> if (!slot)
> return -ENOMEM;
>
> slot->type = simple_strtoul(type, NULL, 10);
>
> dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n",
> - indexes[i + 1], name, type);
> + index, name, type);
>
> retval = rpaphp_enable_slot(slot);
> if (!retval)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-04-25 17:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-10 13:02 [PATCH] PCI/hotplug/rphahp: Fix endianess issues Laurent Dufour
2014-04-25 17:50 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).