All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ganapatrao Kulkarni <gpkulkarni@gmail.com>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>,
	linux-acpi@vger.kernel.org, devel@acpica.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Lv Zheng <lv.zheng@intel.com>,
	Robert Moore <robert.moore@intel.com>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Hanjun Guo <hanjun.guo@linaro.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	Jason Cooper <jason@lakedaemon.net>,
	Jayachandran C <jnair@caviumnetworks.com>
Subject: Re: [PATCH v3 2/2] acpi, gicv3-its, numa: Adding numa node mapping for gic-its units
Date: Wed, 21 Jun 2017 15:36:21 +0530	[thread overview]
Message-ID: <CAFpQJXVXQq_cFYxxamStN4aRktL_o6wvQWfK1KVU1SEYXpOORA@mail.gmail.com> (raw)
In-Reply-To: <20170621092853.GA31599@red-moon>

On Wed, Jun 21, 2017 at 2:58 PM, Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
> On Wed, Jun 21, 2017 at 11:45:43AM +0530, Ganapatrao Kulkarni wrote:
>> Add code to parse SRAT ITS Affinity sub table as defined in ACPI 6.2
>> Later in per device probe, ITS devices are mapped to
>> numa node using ITS id to proximity domain mapping.
>>
>> Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
>> ---
>>  drivers/irqchip/irq-gic-v3-its.c | 80 +++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 79 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
>> index 45ea1933..88cfb32 100644
>> --- a/drivers/irqchip/irq-gic-v3-its.c
>> +++ b/drivers/irqchip/irq-gic-v3-its.c
>> @@ -1833,6 +1833,82 @@ static int __init its_of_probe(struct device_node *node)
>>
>>  #define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K)
>>
>> +#ifdef CONFIG_ACPI_NUMA
>> +struct its_srat_map {
>> +     u32     numa_node;  /* numa node id */
>> +     u32     its_id;  /* GIC ITS ID */
>> +};
>> +
>> +static struct its_srat_map its_srat_maps[MAX_NUMNODES] __initdata = {
>> +     [0 ... MAX_NUMNODES - 1] = {NUMA_NO_NODE, UINT_MAX} };
>
> Nit: UINT_MAX is as valid as 0 as its_id (but the intent here is to make
> it look like an invalid value), given that the its_in_srat counter
> defines what entries are valid I do not necessarily see the point in
> initializing with something that is a valid value != 0.

ok, this array may not need any init,

>
>> +static int its_in_srat __initdata;
>> +
>> +static int __init
>> +acpi_get_its_numa_node(u32 its_id)
>> +{
>> +     int i;
>> +
>> +     for (i = 0; i < its_in_srat; i++) {
>> +             if (its_id == its_srat_maps[i].its_id)
>> +                     return its_srat_maps[i].numa_node;
>> +     }
>> +     return NUMA_NO_NODE;
>> +}
>> +
>> +static int __init
>> +gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
>> +                      const unsigned long end)
>> +{
>> +     int pxm, node;
>> +     struct acpi_srat_its_affinity *its_affinity;
>> +
>> +     its_affinity = (struct acpi_srat_its_affinity *)header;
>> +     if (!its_affinity)
>> +             return -EINVAL;
>> +
>> +     if (its_affinity->header.length <
>> +                     sizeof(struct acpi_srat_its_affinity)) {
>> +             pr_err("SRAT:ITS: Invalid SRAT header length: %d\n",
>> +                     its_affinity->header.length);
>> +             return -EINVAL;
>> +     }
>> +
>> +     if (its_in_srat >= MAX_NUMNODES) {
>> +             pr_err("SRAT:ITS: ITS devices exceeding max count[%d]\n",
>> +                             MAX_NUMNODES);
>> +             return -EINVAL;
>> +     }
>> +
>> +     pxm = its_affinity->proximity_domain;
>> +     node = acpi_map_pxm_to_node(pxm);
>> +
>> +     if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) {
>> +             pr_err("SRAT:ITS: Invalid numa node %d\n", node);
>> +             return -EINVAL;
>
> As Marc mentioned you should bail out here but continue parsing entries,
> aka "return 0";

agreed.
>
> Thanks,
> Lorenzo
>
>> +     }
>> +
>> +     its_srat_maps[its_in_srat].numa_node = node;
>> +     its_srat_maps[its_in_srat].its_id = its_affinity->its_id;
>> +     its_in_srat++;
>> +     pr_info("ACPI: NUMA: SRAT: ITS: PXM %d -> ITS_ID %d -> NODE %d\n",
>> +             pxm, its_affinity->its_id, node);
>> +
>> +     return 0;
>> +}
>> +
>> +static int __init acpi_table_parse_srat_its(void)
>> +{
>> +     return acpi_table_parse_entries(ACPI_SIG_SRAT,
>> +                                     sizeof(struct acpi_table_srat),
>> +                                     ACPI_SRAT_TYPE_GIC_ITS_AFFINITY,
>> +                                     gic_acpi_parse_srat_its, 0);
>> +}
>> +#else
>> +#define acpi_table_parse_srat_its()  do { } while (0)
>> +#define acpi_get_its_numa_node(its_id)       NUMA_NO_NODE
>> +#endif
>> +
>>  static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
>>                                         const unsigned long end)
>>  {
>> @@ -1861,7 +1937,8 @@ static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
>>               goto dom_err;
>>       }
>>
>> -     err = its_probe_one(&res, dom_handle, NUMA_NO_NODE);
>> +     err = its_probe_one(&res, dom_handle,
>> +                     acpi_get_its_numa_node(its_entry->translation_id));
>>       if (!err)
>>               return 0;
>>
>> @@ -1873,6 +1950,7 @@ static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
>>
>>  static void __init its_acpi_probe(void)
>>  {
>> +     acpi_table_parse_srat_its();
>>       acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
>>                             gic_acpi_parse_madt_its, 0);
>>  }
>> --
>> 1.8.1.4
>>

thanks
Ganapat

WARNING: multiple messages have this Message-ID (diff)
From: gpkulkarni@gmail.com (Ganapatrao Kulkarni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/2] acpi, gicv3-its, numa: Adding numa node mapping for gic-its units
Date: Wed, 21 Jun 2017 15:36:21 +0530	[thread overview]
Message-ID: <CAFpQJXVXQq_cFYxxamStN4aRktL_o6wvQWfK1KVU1SEYXpOORA@mail.gmail.com> (raw)
In-Reply-To: <20170621092853.GA31599@red-moon>

On Wed, Jun 21, 2017 at 2:58 PM, Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
> On Wed, Jun 21, 2017 at 11:45:43AM +0530, Ganapatrao Kulkarni wrote:
>> Add code to parse SRAT ITS Affinity sub table as defined in ACPI 6.2
>> Later in per device probe, ITS devices are mapped to
>> numa node using ITS id to proximity domain mapping.
>>
>> Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
>> ---
>>  drivers/irqchip/irq-gic-v3-its.c | 80 +++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 79 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
>> index 45ea1933..88cfb32 100644
>> --- a/drivers/irqchip/irq-gic-v3-its.c
>> +++ b/drivers/irqchip/irq-gic-v3-its.c
>> @@ -1833,6 +1833,82 @@ static int __init its_of_probe(struct device_node *node)
>>
>>  #define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K)
>>
>> +#ifdef CONFIG_ACPI_NUMA
>> +struct its_srat_map {
>> +     u32     numa_node;  /* numa node id */
>> +     u32     its_id;  /* GIC ITS ID */
>> +};
>> +
>> +static struct its_srat_map its_srat_maps[MAX_NUMNODES] __initdata = {
>> +     [0 ... MAX_NUMNODES - 1] = {NUMA_NO_NODE, UINT_MAX} };
>
> Nit: UINT_MAX is as valid as 0 as its_id (but the intent here is to make
> it look like an invalid value), given that the its_in_srat counter
> defines what entries are valid I do not necessarily see the point in
> initializing with something that is a valid value != 0.

ok, this array may not need any init,

>
>> +static int its_in_srat __initdata;
>> +
>> +static int __init
>> +acpi_get_its_numa_node(u32 its_id)
>> +{
>> +     int i;
>> +
>> +     for (i = 0; i < its_in_srat; i++) {
>> +             if (its_id == its_srat_maps[i].its_id)
>> +                     return its_srat_maps[i].numa_node;
>> +     }
>> +     return NUMA_NO_NODE;
>> +}
>> +
>> +static int __init
>> +gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
>> +                      const unsigned long end)
>> +{
>> +     int pxm, node;
>> +     struct acpi_srat_its_affinity *its_affinity;
>> +
>> +     its_affinity = (struct acpi_srat_its_affinity *)header;
>> +     if (!its_affinity)
>> +             return -EINVAL;
>> +
>> +     if (its_affinity->header.length <
>> +                     sizeof(struct acpi_srat_its_affinity)) {
>> +             pr_err("SRAT:ITS: Invalid SRAT header length: %d\n",
>> +                     its_affinity->header.length);
>> +             return -EINVAL;
>> +     }
>> +
>> +     if (its_in_srat >= MAX_NUMNODES) {
>> +             pr_err("SRAT:ITS: ITS devices exceeding max count[%d]\n",
>> +                             MAX_NUMNODES);
>> +             return -EINVAL;
>> +     }
>> +
>> +     pxm = its_affinity->proximity_domain;
>> +     node = acpi_map_pxm_to_node(pxm);
>> +
>> +     if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) {
>> +             pr_err("SRAT:ITS: Invalid numa node %d\n", node);
>> +             return -EINVAL;
>
> As Marc mentioned you should bail out here but continue parsing entries,
> aka "return 0";

agreed.
>
> Thanks,
> Lorenzo
>
>> +     }
>> +
>> +     its_srat_maps[its_in_srat].numa_node = node;
>> +     its_srat_maps[its_in_srat].its_id = its_affinity->its_id;
>> +     its_in_srat++;
>> +     pr_info("ACPI: NUMA: SRAT: ITS: PXM %d -> ITS_ID %d -> NODE %d\n",
>> +             pxm, its_affinity->its_id, node);
>> +
>> +     return 0;
>> +}
>> +
>> +static int __init acpi_table_parse_srat_its(void)
>> +{
>> +     return acpi_table_parse_entries(ACPI_SIG_SRAT,
>> +                                     sizeof(struct acpi_table_srat),
>> +                                     ACPI_SRAT_TYPE_GIC_ITS_AFFINITY,
>> +                                     gic_acpi_parse_srat_its, 0);
>> +}
>> +#else
>> +#define acpi_table_parse_srat_its()  do { } while (0)
>> +#define acpi_get_its_numa_node(its_id)       NUMA_NO_NODE
>> +#endif
>> +
>>  static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
>>                                         const unsigned long end)
>>  {
>> @@ -1861,7 +1937,8 @@ static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
>>               goto dom_err;
>>       }
>>
>> -     err = its_probe_one(&res, dom_handle, NUMA_NO_NODE);
>> +     err = its_probe_one(&res, dom_handle,
>> +                     acpi_get_its_numa_node(its_entry->translation_id));
>>       if (!err)
>>               return 0;
>>
>> @@ -1873,6 +1950,7 @@ static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
>>
>>  static void __init its_acpi_probe(void)
>>  {
>> +     acpi_table_parse_srat_its();
>>       acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
>>                             gic_acpi_parse_madt_its, 0);
>>  }
>> --
>> 1.8.1.4
>>

thanks
Ganapat

WARNING: multiple messages have this Message-ID (diff)
From: Ganapatrao Kulkarni <gpkulkarni at gmail.com>
To: devel@acpica.org
Subject: Re: [Devel] [PATCH v3 2/2] acpi, gicv3-its, numa: Adding numa node mapping for gic-its units
Date: Wed, 21 Jun 2017 15:36:21 +0530	[thread overview]
Message-ID: <CAFpQJXVXQq_cFYxxamStN4aRktL_o6wvQWfK1KVU1SEYXpOORA@mail.gmail.com> (raw)
In-Reply-To: 20170621092853.GA31599@red-moon

[-- Attachment #1: Type: text/plain, Size: 4950 bytes --]

On Wed, Jun 21, 2017 at 2:58 PM, Lorenzo Pieralisi
<lorenzo.pieralisi(a)arm.com> wrote:
> On Wed, Jun 21, 2017 at 11:45:43AM +0530, Ganapatrao Kulkarni wrote:
>> Add code to parse SRAT ITS Affinity sub table as defined in ACPI 6.2
>> Later in per device probe, ITS devices are mapped to
>> numa node using ITS id to proximity domain mapping.
>>
>> Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni(a)cavium.com>
>> ---
>>  drivers/irqchip/irq-gic-v3-its.c | 80 +++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 79 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
>> index 45ea1933..88cfb32 100644
>> --- a/drivers/irqchip/irq-gic-v3-its.c
>> +++ b/drivers/irqchip/irq-gic-v3-its.c
>> @@ -1833,6 +1833,82 @@ static int __init its_of_probe(struct device_node *node)
>>
>>  #define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K)
>>
>> +#ifdef CONFIG_ACPI_NUMA
>> +struct its_srat_map {
>> +     u32     numa_node;  /* numa node id */
>> +     u32     its_id;  /* GIC ITS ID */
>> +};
>> +
>> +static struct its_srat_map its_srat_maps[MAX_NUMNODES] __initdata = {
>> +     [0 ... MAX_NUMNODES - 1] = {NUMA_NO_NODE, UINT_MAX} };
>
> Nit: UINT_MAX is as valid as 0 as its_id (but the intent here is to make
> it look like an invalid value), given that the its_in_srat counter
> defines what entries are valid I do not necessarily see the point in
> initializing with something that is a valid value != 0.

ok, this array may not need any init,

>
>> +static int its_in_srat __initdata;
>> +
>> +static int __init
>> +acpi_get_its_numa_node(u32 its_id)
>> +{
>> +     int i;
>> +
>> +     for (i = 0; i < its_in_srat; i++) {
>> +             if (its_id == its_srat_maps[i].its_id)
>> +                     return its_srat_maps[i].numa_node;
>> +     }
>> +     return NUMA_NO_NODE;
>> +}
>> +
>> +static int __init
>> +gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
>> +                      const unsigned long end)
>> +{
>> +     int pxm, node;
>> +     struct acpi_srat_its_affinity *its_affinity;
>> +
>> +     its_affinity = (struct acpi_srat_its_affinity *)header;
>> +     if (!its_affinity)
>> +             return -EINVAL;
>> +
>> +     if (its_affinity->header.length <
>> +                     sizeof(struct acpi_srat_its_affinity)) {
>> +             pr_err("SRAT:ITS: Invalid SRAT header length: %d\n",
>> +                     its_affinity->header.length);
>> +             return -EINVAL;
>> +     }
>> +
>> +     if (its_in_srat >= MAX_NUMNODES) {
>> +             pr_err("SRAT:ITS: ITS devices exceeding max count[%d]\n",
>> +                             MAX_NUMNODES);
>> +             return -EINVAL;
>> +     }
>> +
>> +     pxm = its_affinity->proximity_domain;
>> +     node = acpi_map_pxm_to_node(pxm);
>> +
>> +     if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) {
>> +             pr_err("SRAT:ITS: Invalid numa node %d\n", node);
>> +             return -EINVAL;
>
> As Marc mentioned you should bail out here but continue parsing entries,
> aka "return 0";

agreed.
>
> Thanks,
> Lorenzo
>
>> +     }
>> +
>> +     its_srat_maps[its_in_srat].numa_node = node;
>> +     its_srat_maps[its_in_srat].its_id = its_affinity->its_id;
>> +     its_in_srat++;
>> +     pr_info("ACPI: NUMA: SRAT: ITS: PXM %d -> ITS_ID %d -> NODE %d\n",
>> +             pxm, its_affinity->its_id, node);
>> +
>> +     return 0;
>> +}
>> +
>> +static int __init acpi_table_parse_srat_its(void)
>> +{
>> +     return acpi_table_parse_entries(ACPI_SIG_SRAT,
>> +                                     sizeof(struct acpi_table_srat),
>> +                                     ACPI_SRAT_TYPE_GIC_ITS_AFFINITY,
>> +                                     gic_acpi_parse_srat_its, 0);
>> +}
>> +#else
>> +#define acpi_table_parse_srat_its()  do { } while (0)
>> +#define acpi_get_its_numa_node(its_id)       NUMA_NO_NODE
>> +#endif
>> +
>>  static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
>>                                         const unsigned long end)
>>  {
>> @@ -1861,7 +1937,8 @@ static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
>>               goto dom_err;
>>       }
>>
>> -     err = its_probe_one(&res, dom_handle, NUMA_NO_NODE);
>> +     err = its_probe_one(&res, dom_handle,
>> +                     acpi_get_its_numa_node(its_entry->translation_id));
>>       if (!err)
>>               return 0;
>>
>> @@ -1873,6 +1950,7 @@ static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
>>
>>  static void __init its_acpi_probe(void)
>>  {
>> +     acpi_table_parse_srat_its();
>>       acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
>>                             gic_acpi_parse_madt_its, 0);
>>  }
>> --
>> 1.8.1.4
>>

thanks
Ganapat

  reply	other threads:[~2017-06-21 10:06 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21  6:15 [PATCH v3 0/2] acpi, gicv3-its, numa: Adding numa node mapping for ITS Ganapatrao Kulkarni
2017-06-21  6:15 ` [Devel] " Ganapatrao Kulkarni
2017-06-21  6:15 ` Ganapatrao Kulkarni
2017-06-21  6:15 ` [PATCH v3 1/2] ACPICA: ACPI 6.2: Add support for new SRAT subtable Ganapatrao Kulkarni
2017-06-21  6:15   ` [Devel] " Ganapatrao Kulkarni
2017-06-21  6:15   ` Ganapatrao Kulkarni
2017-06-21  6:15 ` [PATCH v3 2/2] acpi, gicv3-its, numa: Adding numa node mapping for gic-its units Ganapatrao Kulkarni
2017-06-21  6:15   ` [Devel] " Ganapatrao Kulkarni
2017-06-21  6:15   ` Ganapatrao Kulkarni
2017-06-21  7:09   ` Jayachandran C
2017-06-21  7:09     ` Jayachandran C
2017-06-21  8:44     ` Marc Zyngier
2017-06-21  8:44       ` [Devel] " Marc Zyngier
2017-06-21  8:44       ` Marc Zyngier
2017-06-21 15:25       ` Jayachandran C
2017-06-21 15:25         ` Jayachandran C
2017-06-21 15:25         ` Jayachandran C
2017-06-21  8:58   ` Marc Zyngier
2017-06-21  8:58     ` [Devel] " Marc Zyngier
2017-06-21  8:58     ` Marc Zyngier
2017-06-21  9:56     ` Ganapatrao Kulkarni
2017-06-21  9:56       ` [Devel] " Ganapatrao Kulkarni
2017-06-21  9:56       ` Ganapatrao Kulkarni
2017-06-21  9:56       ` Ganapatrao Kulkarni
2017-06-21  9:28   ` Lorenzo Pieralisi
2017-06-21  9:28     ` [Devel] " Lorenzo Pieralisi
2017-06-21  9:28     ` Lorenzo Pieralisi
2017-06-21 10:06     ` Ganapatrao Kulkarni [this message]
2017-06-21 10:06       ` [Devel] " Ganapatrao Kulkarni
2017-06-21 10:06       ` Ganapatrao Kulkarni
2017-06-21 10:06       ` Ganapatrao Kulkarni

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=CAFpQJXVXQq_cFYxxamStN4aRktL_o6wvQWfK1KVU1SEYXpOORA@mail.gmail.com \
    --to=gpkulkarni@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=devel@acpica.org \
    --cc=ganapatrao.kulkarni@cavium.com \
    --cc=hanjun.guo@linaro.org \
    --cc=jason@lakedaemon.net \
    --cc=jnair@caviumnetworks.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=lv.zheng@intel.com \
    --cc=marc.zyngier@arm.com \
    --cc=robert.moore@intel.com \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.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.