From: Nathan Lynch <nathanl@linux.ibm.com>
To: Tyrel Datwyler <tyreld@linux.ibm.com>
Cc: linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
mpe@ellerman.id.au, bhelgaas@google.com
Subject: Re: [RFC PATCH 1/9] powerpc/pseries: add cpu DLPAR support for drc-info property
Date: Thu, 10 Oct 2019 13:56:28 -0500 [thread overview]
Message-ID: <871rvkjuoz.fsf@linux.ibm.com> (raw)
In-Reply-To: <1569910334-5972-2-git-send-email-tyreld@linux.ibm.com>
Hi Tyrel,
Tyrel Datwyler <tyreld@linux.ibm.com> writes:
> +static bool valid_cpu_drc_index(struct device_node *parent, u32 drc_index)
> +{
> + const __be32 *indexes;
> + int i;
> +
> + if (of_find_property(parent, "ibm,drc-info", NULL))
> + return drc_info_valid_index(parent, drc_index);
> +
> + indexes = of_get_property(parent, "ibm,drc-indexes", NULL);
> + if (!indexes)
> + return false;
> +
> + for (i = 0; i < indexes[0]; i++) {
should this be:
for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
?
> + if (be32_to_cpu(indexes[i + 1]) == drc_index)
> + return true;
> + }
> +
> + return false;
> }
It looks like this rewrites valid_cpu_drc_index()'s existing code for
parsing ibm,drc-indexes but I don't see the need for this.
This patch would be easier to review if that were dropped or split out.
>
> static ssize_t dlpar_cpu_add(u32 drc_index)
> @@ -720,8 +756,11 @@ static int dlpar_cpu_remove_by_count(u32 cpus_to_remove)
> static int find_dlpar_cpus_to_add(u32 *cpu_drcs, u32 cpus_to_add)
> {
> struct device_node *parent;
> + struct property *info;
> + const __be32 *indexes;
> int cpus_found = 0;
> - int index, rc;
> + int i, j;
> + u32 drc_index;
>
> parent = of_find_node_by_path("/cpus");
> if (!parent) {
> @@ -730,24 +769,46 @@ static int find_dlpar_cpus_to_add(u32 *cpu_drcs, u32 cpus_to_add)
> return -1;
> }
>
> - /* Search the ibm,drc-indexes array for possible CPU drcs to
> - * add. Note that the format of the ibm,drc-indexes array is
> - * the number of entries in the array followed by the array
> - * of drc values so we start looking at index = 1.
> - */
> - index = 1;
> - while (cpus_found < cpus_to_add) {
> - u32 drc;
> + info = of_find_property(parent, "ibm,drc-info", NULL);
> + if (info) {
> + struct of_drc_info drc;
> + const __be32 *value;
> + int count;
>
> - rc = of_property_read_u32_index(parent, "ibm,drc-indexes",
> - index++, &drc);
> - if (rc)
> - break;
> + value = of_prop_next_u32(info, NULL, &count);
> + if (value)
> + value++;
>
> - if (dlpar_cpu_exists(parent, drc))
> - continue;
> + for (i = 0; i < count; i++) {
> + of_read_drc_info_cell(&info, &value, &drc);
> + if (strncmp(drc.drc_type, "CPU", 3))
> + break;
> +
> + for (j = 0; j < drc.num_sequential_elems; j++) {
> + drc_index = drc.drc_index_start + (drc.sequential_inc * j);
> +
> + if (dlpar_cpu_exists(parent, drc_index))
> + continue;
>
> - cpu_drcs[cpus_found++] = drc;
> + cpu_drcs[cpus_found++] = drc_index;
I am failing to see how this loop is limited by the cpus_to_add
parameter as it was before this change. It looks like this will overflow
the cpu_drcs array when cpus_to_add is less than the number of cpus
found.
As an aside I don't understand how the add_by_count()/dlpar_cpu_exists()
algorithm could be correct as it currently stands. It seems to pick the
first X indexes for which a corresponding cpu node is absent, but that
set of indexes does not necessarily match the set that is available to
configure. Something to address separately I suppose.
> + }
> + }
> + } else {
> + indexes = of_get_property(parent, "ibm,drc-indexes", NULL);
> +
> + /* Search the ibm,drc-indexes array for possible CPU drcs to
> + * add. Note that the format of the ibm,drc-indexes array is
> + * the number of entries in the array followed by the array
> + * of drc values so we start looking at index = 1.
> + */
> + for (i = 1; i < indexes[0]; i++) {
> + drc_index = be32_to_cpu(indexes[i]);
> +
> + if (dlpar_cpu_exists(parent, drc_index))
> + continue;
> +
> + cpu_drcs[cpus_found++] = drc_index;
> + }
> }
As above, not sure why this was rewritten, and similar comments as
before apply.
WARNING: multiple messages have this Message-ID (diff)
From: Nathan Lynch <nathanl@linux.ibm.com>
To: Tyrel Datwyler <tyreld@linux.ibm.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [RFC PATCH 1/9] powerpc/pseries: add cpu DLPAR support for drc-info property
Date: Thu, 10 Oct 2019 13:56:28 -0500 [thread overview]
Message-ID: <871rvkjuoz.fsf@linux.ibm.com> (raw)
In-Reply-To: <1569910334-5972-2-git-send-email-tyreld@linux.ibm.com>
Hi Tyrel,
Tyrel Datwyler <tyreld@linux.ibm.com> writes:
> +static bool valid_cpu_drc_index(struct device_node *parent, u32 drc_index)
> +{
> + const __be32 *indexes;
> + int i;
> +
> + if (of_find_property(parent, "ibm,drc-info", NULL))
> + return drc_info_valid_index(parent, drc_index);
> +
> + indexes = of_get_property(parent, "ibm,drc-indexes", NULL);
> + if (!indexes)
> + return false;
> +
> + for (i = 0; i < indexes[0]; i++) {
should this be:
for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
?
> + if (be32_to_cpu(indexes[i + 1]) == drc_index)
> + return true;
> + }
> +
> + return false;
> }
It looks like this rewrites valid_cpu_drc_index()'s existing code for
parsing ibm,drc-indexes but I don't see the need for this.
This patch would be easier to review if that were dropped or split out.
>
> static ssize_t dlpar_cpu_add(u32 drc_index)
> @@ -720,8 +756,11 @@ static int dlpar_cpu_remove_by_count(u32 cpus_to_remove)
> static int find_dlpar_cpus_to_add(u32 *cpu_drcs, u32 cpus_to_add)
> {
> struct device_node *parent;
> + struct property *info;
> + const __be32 *indexes;
> int cpus_found = 0;
> - int index, rc;
> + int i, j;
> + u32 drc_index;
>
> parent = of_find_node_by_path("/cpus");
> if (!parent) {
> @@ -730,24 +769,46 @@ static int find_dlpar_cpus_to_add(u32 *cpu_drcs, u32 cpus_to_add)
> return -1;
> }
>
> - /* Search the ibm,drc-indexes array for possible CPU drcs to
> - * add. Note that the format of the ibm,drc-indexes array is
> - * the number of entries in the array followed by the array
> - * of drc values so we start looking at index = 1.
> - */
> - index = 1;
> - while (cpus_found < cpus_to_add) {
> - u32 drc;
> + info = of_find_property(parent, "ibm,drc-info", NULL);
> + if (info) {
> + struct of_drc_info drc;
> + const __be32 *value;
> + int count;
>
> - rc = of_property_read_u32_index(parent, "ibm,drc-indexes",
> - index++, &drc);
> - if (rc)
> - break;
> + value = of_prop_next_u32(info, NULL, &count);
> + if (value)
> + value++;
>
> - if (dlpar_cpu_exists(parent, drc))
> - continue;
> + for (i = 0; i < count; i++) {
> + of_read_drc_info_cell(&info, &value, &drc);
> + if (strncmp(drc.drc_type, "CPU", 3))
> + break;
> +
> + for (j = 0; j < drc.num_sequential_elems; j++) {
> + drc_index = drc.drc_index_start + (drc.sequential_inc * j);
> +
> + if (dlpar_cpu_exists(parent, drc_index))
> + continue;
>
> - cpu_drcs[cpus_found++] = drc;
> + cpu_drcs[cpus_found++] = drc_index;
I am failing to see how this loop is limited by the cpus_to_add
parameter as it was before this change. It looks like this will overflow
the cpu_drcs array when cpus_to_add is less than the number of cpus
found.
As an aside I don't understand how the add_by_count()/dlpar_cpu_exists()
algorithm could be correct as it currently stands. It seems to pick the
first X indexes for which a corresponding cpu node is absent, but that
set of indexes does not necessarily match the set that is available to
configure. Something to address separately I suppose.
> + }
> + }
> + } else {
> + indexes = of_get_property(parent, "ibm,drc-indexes", NULL);
> +
> + /* Search the ibm,drc-indexes array for possible CPU drcs to
> + * add. Note that the format of the ibm,drc-indexes array is
> + * the number of entries in the array followed by the array
> + * of drc values so we start looking at index = 1.
> + */
> + for (i = 1; i < indexes[0]; i++) {
> + drc_index = be32_to_cpu(indexes[i]);
> +
> + if (dlpar_cpu_exists(parent, drc_index))
> + continue;
> +
> + cpu_drcs[cpus_found++] = drc_index;
> + }
> }
As above, not sure why this was rewritten, and similar comments as
before apply.
next prev parent reply other threads:[~2019-10-10 18:56 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 6:12 [RFC PATCH 0/9] Fixes and Enablement of ibm,drc-info property Tyrel Datwyler
2019-10-01 6:12 ` Tyrel Datwyler
2019-10-01 6:12 ` [RFC PATCH 1/9] powerpc/pseries: add cpu DLPAR support for drc-info property Tyrel Datwyler
2019-10-01 6:12 ` Tyrel Datwyler
2019-10-10 18:56 ` Nathan Lynch [this message]
2019-10-10 18:56 ` Nathan Lynch
2019-10-30 23:35 ` Tyrel Datwyler
2019-10-30 23:35 ` Tyrel Datwyler
2019-10-31 17:14 ` Nathan Lynch
2019-10-31 17:14 ` Nathan Lynch
2019-10-01 6:12 ` [RFC PATCH 2/9] powerpc/pseries: fix bad drc_index_start value parsing of drc-info entry Tyrel Datwyler
2019-10-01 6:12 ` Tyrel Datwyler
2019-10-10 19:04 ` Nathan Lynch
2019-10-10 19:04 ` Nathan Lynch
2019-10-10 20:16 ` powerpc/405GP, cuImage and PCI support Carlo Pisani
2019-10-10 20:16 ` Carlo Pisani
2019-10-31 0:15 ` [RFC PATCH 2/9] powerpc/pseries: fix bad drc_index_start value parsing of drc-info entry Tyrel Datwyler
2019-10-31 0:15 ` Tyrel Datwyler
2019-10-01 6:12 ` [RFC PATCH 3/9] powerpc/pseries: fix drc-info mappings of logical cpus to drc-index Tyrel Datwyler
2019-10-01 6:12 ` Tyrel Datwyler
2019-10-01 6:12 ` [RFC PATCH 4/9] PCI: rpaphp: fix up pointer to first drc-info entry Tyrel Datwyler
2019-10-01 6:12 ` Tyrel Datwyler
2019-10-01 6:12 ` [RFC PATCH 5/9] PCI: rpaphp: don't rely on firmware feature to imply drc-info support Tyrel Datwyler
2019-10-01 6:12 ` Tyrel Datwyler
2019-10-01 6:12 ` [RFC PATCH 6/9] PCI: rpaphp: add drc-info support for hotplug slot registration Tyrel Datwyler
2019-10-01 6:12 ` Tyrel Datwyler
2019-10-01 6:12 ` [RFC PATCH 7/9] PCI: rpaphp: annotate and correctly byte swap DRC properties Tyrel Datwyler
2019-10-01 6:12 ` Tyrel Datwyler
2019-10-01 6:12 ` [RFC PATCH 8/9] PCI: rpaphp: correctly match ibm,my-drc-index to drc-name when using drc-info Tyrel Datwyler
2019-10-01 6:12 ` [RFC PATCH 8/9] PCI: rpaphp: correctly match ibm, my-drc-index " Tyrel Datwyler
2019-10-01 6:12 ` [RFC PATCH 9/9] powerpc: Enable support for ibm,drc-info property Tyrel Datwyler
2019-10-01 6:12 ` Tyrel Datwyler
2019-10-01 20:02 ` [RFC PATCH 0/9] Fixes and Enablement of " Bjorn Helgaas
2019-10-01 20:02 ` Bjorn Helgaas
2019-10-31 0:15 ` Tyrel Datwyler
2019-10-31 0:15 ` Tyrel Datwyler
Reply instructions:
You may reply publicly 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=871rvkjuoz.fsf@linux.ibm.com \
--to=nathanl@linux.ibm.com \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=tyreld@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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.