From: Tyrel Datwyler <tyreld@linux.ibm.com> To: mpe@ellerman.id.au Cc: nathanl@linux.ibm.com, linuxppc-dev@lists.ozlabs.org, Tyrel Datwyler <tyreld@linux.ibm.com> Subject: [PATCH 2/9] powerpc/pseries: Fix drc-info mappings of logical cpus to drc-index Date: Tue, 5 Nov 2019 09:24:06 -0600 Message-ID: <1572967453-9586-3-git-send-email-tyreld@linux.ibm.com> (raw) In-Reply-To: <1572967453-9586-1-git-send-email-tyreld@linux.ibm.com> There are a couple subtle errors in the mapping between cpu-ids and a cpus associated drc-index when using the new ibm,drc-info property. The first is that while drc-info may have been a supported firmware feature at boot it is possible we have migrated to a CEC with older firmware that doesn't support the ibm,drc-info property. In that case the device tree would have been updated after migration to remove the ibm,drc-info property and replace it with the older style ibm,drc-* properties for types, indexes, names, and power-domains. The second is that the first value of the ibm,drc-info property is the int encoded count of drc-info entries. As such "value" returned by of_prop_next_u32() is pointing at that count, and not the first element of the first drc-info entry as is expected by the of_read_drc_info_cell() helper. Fix the first by ignoring DRC-INFO firmware feature and instead testing directly for ibm,drc-info, and then falling back to the old style ibm,drc-indexes in the case it doesn't exit. Fix the second by incrementing value to the next element prior to parsing drc-info entries. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> --- arch/powerpc/platforms/pseries/pseries_energy.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c index a96874f..09e98d3 100644 --- a/arch/powerpc/platforms/pseries/pseries_energy.c +++ b/arch/powerpc/platforms/pseries/pseries_energy.c @@ -36,6 +36,7 @@ static int sysfs_entries; static u32 cpu_to_drc_index(int cpu) { struct device_node *dn = NULL; + struct property *info; int thread_index; int rc = 1; u32 ret = 0; @@ -47,20 +48,18 @@ static u32 cpu_to_drc_index(int cpu) /* Convert logical cpu number to core number */ thread_index = cpu_core_index_of_thread(cpu); - if (firmware_has_feature(FW_FEATURE_DRC_INFO)) { - struct property *info = NULL; + info = of_find_property(dn, "ibm,drc-info", NULL); + if (info) { struct of_drc_info drc; int j; u32 num_set_entries; const __be32 *value; - info = of_find_property(dn, "ibm,drc-info", NULL); - if (info == NULL) - goto err_of_node_put; - value = of_prop_next_u32(info, NULL, &num_set_entries); if (!value) goto err_of_node_put; + else + value++; for (j = 0; j < num_set_entries; j++) { @@ -110,6 +109,7 @@ static u32 cpu_to_drc_index(int cpu) static int drc_index_to_cpu(u32 drc_index) { struct device_node *dn = NULL; + struct property *info; const int *indexes; int thread_index = 0, cpu = 0; int rc = 1; @@ -117,21 +117,18 @@ static int drc_index_to_cpu(u32 drc_index) dn = of_find_node_by_path("/cpus"); if (dn == NULL) goto err; - - if (firmware_has_feature(FW_FEATURE_DRC_INFO)) { - struct property *info = NULL; + info = of_find_property(dn, "ibm,drc-info", NULL); + if (info) { struct of_drc_info drc; int j; u32 num_set_entries; const __be32 *value; - info = of_find_property(dn, "ibm,drc-info", NULL); - if (info == NULL) - goto err_of_node_put; - value = of_prop_next_u32(info, NULL, &num_set_entries); if (!value) goto err_of_node_put; + else + value++; for (j = 0; j < num_set_entries; j++) { -- 2.7.4
next prev parent reply index Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-05 15:24 [PATCH 0/9] Fixes and Enablement of ibm,drc-info property Tyrel Datwyler 2019-11-05 15:24 ` [PATCH 1/9] powerpc/pseries: Fix bad drc_index_start value parsing of drc-info entry Tyrel Datwyler 2019-11-05 15:24 ` Tyrel Datwyler [this message] 2019-11-05 15:24 ` [PATCH 3/9] powerpc/pseries: Add cpu DLPAR support for drc-info property Tyrel Datwyler 2019-11-05 16:55 ` Thomas Falcon 2019-11-06 20:15 ` Tyrel Datwyler 2019-11-07 11:35 ` Michael Ellerman 2019-11-05 15:24 ` [PATCH 4/9] PCI: rpaphp: Fix up pointer to first drc-info entry Tyrel Datwyler 2019-11-05 15:24 ` [PATCH 5/9] PCI: rpaphp: Don't rely on firmware feature to imply drc-info support Tyrel Datwyler 2019-11-05 15:24 ` [PATCH 6/9] PCI: rpaphp: Add drc-info support for hotplug slot registration Tyrel Datwyler 2019-11-05 15:24 ` [PATCH 7/9] PCI: rpaphp: annotate and correctly byte swap DRC properties Tyrel Datwyler 2019-11-07 11:40 ` Michael Ellerman 2019-11-05 15:24 ` [PATCH 8/9] PCI: rpaphp: Correctly match ibm, my-drc-index to drc-name when using drc-info Tyrel Datwyler 2019-11-05 15:24 ` [PATCH 9/9] powerpc/pseries: Enable support for ibm, drc-info property Tyrel Datwyler 2019-11-07 11:38 ` Michael Ellerman 2019-11-05 17:03 ` [PATCH 0/9] Fixes and Enablement of ibm,drc-info property Thomas Falcon 2019-11-06 20:12 ` Tyrel Datwyler 2019-11-07 11:26 ` Michael Ellerman
Reply instructions: You may reply publically to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1572967453-9586-3-git-send-email-tyreld@linux.ibm.com \ --to=tyreld@linux.ibm.com \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mpe@ellerman.id.au \ --cc=nathanl@linux.ibm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
LinuxPPC-Dev Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linuxppc-dev/0 linuxppc-dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linuxppc-dev linuxppc-dev/ https://lore.kernel.org/linuxppc-dev \ linuxppc-dev@lists.ozlabs.org linuxppc-dev@ozlabs.org public-inbox-index linuxppc-dev Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.ozlabs.lists.linuxppc-dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git