From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Hanjun Guo <hanjun.guo@linaro.org>
Cc: Marc Zyngier <Marc.Zyngier@arm.com>,
Jason Cooper <jason@lakedaemon.net>,
Will Deacon <Will.Deacon@arm.com>,
Catalin Marinas <Catalin.Marinas@arm.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Thomas Gleixner <tglx@linutronix.de>,
Jiang Liu <jiang.liu@linux.intel.com>,
Arnd Bergmann <arnd@arndb.de>,
Tomasz Nowicki <tomasz.nowicki@linaro.org>,
"grant.likely@linaro.org" <grant.likely@linaro.org>,
Olof Johansson <olof@lixom.net>, Wei Huang <wei@redhat.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linaro-acpi@lists.linaro.org" <linaro-acpi@lists.linaro.org>
Subject: Re: [PATCH v2 3/9] irqchip / GIC: Add GIC version support in ACPI MADT
Date: Mon, 22 Jun 2015 17:45:20 +0100 [thread overview]
Message-ID: <20150622164520.GA26129@red-moon> (raw)
In-Reply-To: <1434703572-26221-4-git-send-email-hanjun.guo@linaro.org>
On Fri, Jun 19, 2015 at 09:46:06AM +0100, Hanjun Guo wrote:
[...]
> +
> +static int __init
> +match_gic_redist(struct acpi_subtable_header *header, const unsigned long end)
> +{
> + return 0;
> +}
> +static bool __init acpi_gic_redist_is_present(void)
> +{
> + int count;
> +
> + /* scan MADT table to find if we have redistributor entries */
> + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
> + match_gic_redist, 0);
> +
> + /* has at least one GIC redistributor entry */
> + if (count > 0)
> + return true;
> + else
> + return false;
> +}
return count > 0;
What about systems where the redistributor data is in the GICC subtable ? Do
you treat them as GIC V2 :) ?
On a side note, having to define an empty function like match_gic_redist is
horrible.
I wonder whether it is not better to refactor map_madt_entry(), create
a MADT subtable iterator out of it and make that code generic, instead
of being forced to add these useless MADT handlers just to count
entries, it is not the first I noticed.
> +static int __init acpi_gic_version_init(void)
> +{
> + int count;
> + void __iomem *dist_base;
> + u32 reg;
> +
> + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR,
> + acpi_gic_parse_distributor, 0);
> +
> + if (count <= 0) {
> + pr_err("No valid GIC distributor entry exists\n");
> + return -ENODEV;
> + }
> +
> + if (gic_version >= ACPI_MADT_GIC_VERSION_RESERVED) {
> + pr_err("Invalid GIC version %d in MADT\n", gic_version);
> + return -EINVAL;
> + }
> +
> + /*
> + * when the GIC version is 0, we fallback to hardware discovery.
> + * this is also needed to keep compatiable with ACPI 5.1,
> + * which has no gic_version field in distributor structure and
> + * reserved as 0.
> + *
> + * For hardware discovery, the offset for GICv1/2 and GICv3/4 to
> + * get the GIC version is different (0xFE8 for GICv1/2 and 0xFFE8
> + * for GICv3/4), so we need to handle it separately.
> + */
> + if (gic_version == ACPI_MADT_GIC_VERSION_NONE) {
> + /* it's GICv3/v4 if redistributor is present */
> + if (acpi_gic_redist_is_present()) {
See above, IIUC you might have systems with GIC v3 where this call
would fail, and we do not want to fall back to GIC v2.
Lorenzo
> + dist_base = ioremap(dist_phy_base,
> + ACPI_GICV3_DIST_MEM_SIZE);
> + if (!dist_base)
> + return -ENOMEM;
> +
> + reg = readl_relaxed(dist_base + GICD_PIDR2) &
> + GIC_PIDR2_ARCH_MASK;
> + if (reg == GIC_PIDR2_ARCH_GICv3)
> + gic_version = ACPI_MADT_GIC_VERSION_V3;
> + else
> + gic_version = ACPI_MADT_GIC_VERSION_V4;
> +
> + iounmap(dist_base);
> + } else {
> + gic_version = ACPI_MADT_GIC_VERSION_V2;
> + }
> + }
> +
> + return 0;
> +}
> diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h
> index de3419e..13bc676 100644
> --- a/include/linux/irqchip/arm-gic-acpi.h
> +++ b/include/linux/irqchip/arm-gic-acpi.h
> @@ -19,6 +19,7 @@
> */
> #define ACPI_GICV2_DIST_MEM_SIZE (SZ_4K)
> #define ACPI_GIC_CPU_IF_MEM_SIZE (SZ_8K)
> +#define ACPI_GICV3_DIST_MEM_SIZE (SZ_64K)
>
> struct acpi_table_header;
>
> --
> 1.9.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
WARNING: multiple messages have this Message-ID (diff)
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/9] irqchip / GIC: Add GIC version support in ACPI MADT
Date: Mon, 22 Jun 2015 17:45:20 +0100 [thread overview]
Message-ID: <20150622164520.GA26129@red-moon> (raw)
In-Reply-To: <1434703572-26221-4-git-send-email-hanjun.guo@linaro.org>
On Fri, Jun 19, 2015 at 09:46:06AM +0100, Hanjun Guo wrote:
[...]
> +
> +static int __init
> +match_gic_redist(struct acpi_subtable_header *header, const unsigned long end)
> +{
> + return 0;
> +}
> +static bool __init acpi_gic_redist_is_present(void)
> +{
> + int count;
> +
> + /* scan MADT table to find if we have redistributor entries */
> + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
> + match_gic_redist, 0);
> +
> + /* has at least one GIC redistributor entry */
> + if (count > 0)
> + return true;
> + else
> + return false;
> +}
return count > 0;
What about systems where the redistributor data is in the GICC subtable ? Do
you treat them as GIC V2 :) ?
On a side note, having to define an empty function like match_gic_redist is
horrible.
I wonder whether it is not better to refactor map_madt_entry(), create
a MADT subtable iterator out of it and make that code generic, instead
of being forced to add these useless MADT handlers just to count
entries, it is not the first I noticed.
> +static int __init acpi_gic_version_init(void)
> +{
> + int count;
> + void __iomem *dist_base;
> + u32 reg;
> +
> + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR,
> + acpi_gic_parse_distributor, 0);
> +
> + if (count <= 0) {
> + pr_err("No valid GIC distributor entry exists\n");
> + return -ENODEV;
> + }
> +
> + if (gic_version >= ACPI_MADT_GIC_VERSION_RESERVED) {
> + pr_err("Invalid GIC version %d in MADT\n", gic_version);
> + return -EINVAL;
> + }
> +
> + /*
> + * when the GIC version is 0, we fallback to hardware discovery.
> + * this is also needed to keep compatiable with ACPI 5.1,
> + * which has no gic_version field in distributor structure and
> + * reserved as 0.
> + *
> + * For hardware discovery, the offset for GICv1/2 and GICv3/4 to
> + * get the GIC version is different (0xFE8 for GICv1/2 and 0xFFE8
> + * for GICv3/4), so we need to handle it separately.
> + */
> + if (gic_version == ACPI_MADT_GIC_VERSION_NONE) {
> + /* it's GICv3/v4 if redistributor is present */
> + if (acpi_gic_redist_is_present()) {
See above, IIUC you might have systems with GIC v3 where this call
would fail, and we do not want to fall back to GIC v2.
Lorenzo
> + dist_base = ioremap(dist_phy_base,
> + ACPI_GICV3_DIST_MEM_SIZE);
> + if (!dist_base)
> + return -ENOMEM;
> +
> + reg = readl_relaxed(dist_base + GICD_PIDR2) &
> + GIC_PIDR2_ARCH_MASK;
> + if (reg == GIC_PIDR2_ARCH_GICv3)
> + gic_version = ACPI_MADT_GIC_VERSION_V3;
> + else
> + gic_version = ACPI_MADT_GIC_VERSION_V4;
> +
> + iounmap(dist_base);
> + } else {
> + gic_version = ACPI_MADT_GIC_VERSION_V2;
> + }
> + }
> +
> + return 0;
> +}
> diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h
> index de3419e..13bc676 100644
> --- a/include/linux/irqchip/arm-gic-acpi.h
> +++ b/include/linux/irqchip/arm-gic-acpi.h
> @@ -19,6 +19,7 @@
> */
> #define ACPI_GICV2_DIST_MEM_SIZE (SZ_4K)
> #define ACPI_GIC_CPU_IF_MEM_SIZE (SZ_8K)
> +#define ACPI_GICV3_DIST_MEM_SIZE (SZ_64K)
>
> struct acpi_table_header;
>
> --
> 1.9.1
>
WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Hanjun Guo <hanjun.guo@linaro.org>
Cc: Marc Zyngier <Marc.Zyngier@arm.com>,
Jason Cooper <jason@lakedaemon.net>,
Will Deacon <Will.Deacon@arm.com>,
Catalin Marinas <Catalin.Marinas@arm.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Thomas Gleixner <tglx@linutronix.de>,
Jiang Liu <jiang.liu@linux.intel.com>,
Arnd Bergmann <arnd@arndb.de>,
Tomasz Nowicki <tomasz.nowicki@linaro.org>,
"grant.likely@linaro.org" <grant.likely@linaro.org>,
Olof Johansson <olof@lixom.net>, Wei Huang <wei@redhat.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linaro-acpi@lists.linaro.org" <linaro-acpi@lists.linaro.org>
Subject: Re: [PATCH v2 3/9] irqchip / GIC: Add GIC version support in ACPI MADT
Date: Mon, 22 Jun 2015 17:45:20 +0100 [thread overview]
Message-ID: <20150622164520.GA26129@red-moon> (raw)
In-Reply-To: <1434703572-26221-4-git-send-email-hanjun.guo@linaro.org>
On Fri, Jun 19, 2015 at 09:46:06AM +0100, Hanjun Guo wrote:
[...]
> +
> +static int __init
> +match_gic_redist(struct acpi_subtable_header *header, const unsigned long end)
> +{
> + return 0;
> +}
> +static bool __init acpi_gic_redist_is_present(void)
> +{
> + int count;
> +
> + /* scan MADT table to find if we have redistributor entries */
> + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
> + match_gic_redist, 0);
> +
> + /* has at least one GIC redistributor entry */
> + if (count > 0)
> + return true;
> + else
> + return false;
> +}
return count > 0;
What about systems where the redistributor data is in the GICC subtable ? Do
you treat them as GIC V2 :) ?
On a side note, having to define an empty function like match_gic_redist is
horrible.
I wonder whether it is not better to refactor map_madt_entry(), create
a MADT subtable iterator out of it and make that code generic, instead
of being forced to add these useless MADT handlers just to count
entries, it is not the first I noticed.
> +static int __init acpi_gic_version_init(void)
> +{
> + int count;
> + void __iomem *dist_base;
> + u32 reg;
> +
> + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR,
> + acpi_gic_parse_distributor, 0);
> +
> + if (count <= 0) {
> + pr_err("No valid GIC distributor entry exists\n");
> + return -ENODEV;
> + }
> +
> + if (gic_version >= ACPI_MADT_GIC_VERSION_RESERVED) {
> + pr_err("Invalid GIC version %d in MADT\n", gic_version);
> + return -EINVAL;
> + }
> +
> + /*
> + * when the GIC version is 0, we fallback to hardware discovery.
> + * this is also needed to keep compatiable with ACPI 5.1,
> + * which has no gic_version field in distributor structure and
> + * reserved as 0.
> + *
> + * For hardware discovery, the offset for GICv1/2 and GICv3/4 to
> + * get the GIC version is different (0xFE8 for GICv1/2 and 0xFFE8
> + * for GICv3/4), so we need to handle it separately.
> + */
> + if (gic_version == ACPI_MADT_GIC_VERSION_NONE) {
> + /* it's GICv3/v4 if redistributor is present */
> + if (acpi_gic_redist_is_present()) {
See above, IIUC you might have systems with GIC v3 where this call
would fail, and we do not want to fall back to GIC v2.
Lorenzo
> + dist_base = ioremap(dist_phy_base,
> + ACPI_GICV3_DIST_MEM_SIZE);
> + if (!dist_base)
> + return -ENOMEM;
> +
> + reg = readl_relaxed(dist_base + GICD_PIDR2) &
> + GIC_PIDR2_ARCH_MASK;
> + if (reg == GIC_PIDR2_ARCH_GICv3)
> + gic_version = ACPI_MADT_GIC_VERSION_V3;
> + else
> + gic_version = ACPI_MADT_GIC_VERSION_V4;
> +
> + iounmap(dist_base);
> + } else {
> + gic_version = ACPI_MADT_GIC_VERSION_V2;
> + }
> + }
> +
> + return 0;
> +}
> diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h
> index de3419e..13bc676 100644
> --- a/include/linux/irqchip/arm-gic-acpi.h
> +++ b/include/linux/irqchip/arm-gic-acpi.h
> @@ -19,6 +19,7 @@
> */
> #define ACPI_GICV2_DIST_MEM_SIZE (SZ_4K)
> #define ACPI_GIC_CPU_IF_MEM_SIZE (SZ_8K)
> +#define ACPI_GICV3_DIST_MEM_SIZE (SZ_64K)
>
> struct acpi_table_header;
>
> --
> 1.9.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2015-06-22 16:45 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-19 8:46 [PATCH v2 0/9] Add self-probe infrastructure and stacked irqdomain support for ACPI based GICv2/3 init Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
2015-06-19 8:46 ` [PATCH v2 1/9] ACPICA: ACPI 6.0: Add changes for MADT table Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
2015-06-19 8:46 ` [PATCH v2 2/9] ACPICA: ACPI 6.0: Add values for MADT GIC version field Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
2015-06-19 8:46 ` [PATCH v2 3/9] irqchip / GIC: Add GIC version support in ACPI MADT Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
2015-06-22 16:45 ` Lorenzo Pieralisi [this message]
2015-06-22 16:45 ` Lorenzo Pieralisi
2015-06-22 16:45 ` Lorenzo Pieralisi
2015-06-23 11:18 ` Hanjun Guo
2015-06-23 11:18 ` Hanjun Guo
2015-06-27 6:07 ` Hanjun Guo
2015-06-27 6:07 ` Hanjun Guo
2015-06-19 8:46 ` [PATCH v2 4/9] ACPI / irqchip: Add self-probe infrastructure to initialize IRQ controller Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
2015-06-19 8:46 ` [PATCH v2 5/9] irqchip / GIC / ACPI: Use IRQCHIP_ACPI_DECLARE to simplify GICv2 init code Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
2015-06-19 8:46 ` [PATCH v2 6/9] irqchip / gic: Add stacked irqdomain support for ACPI based GICv2 init Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
2015-06-22 17:20 ` Lorenzo Pieralisi
2015-06-22 17:20 ` Lorenzo Pieralisi
2015-06-22 17:20 ` Lorenzo Pieralisi
2015-06-23 15:11 ` Hanjun Guo
2015-06-23 15:11 ` Hanjun Guo
2015-06-23 17:38 ` Lorenzo Pieralisi
2015-06-23 17:38 ` Lorenzo Pieralisi
2015-06-27 3:52 ` Hanjun Guo
2015-06-27 3:52 ` Hanjun Guo
2015-06-29 8:39 ` Marc Zyngier
2015-06-29 8:39 ` Marc Zyngier
2015-06-30 11:50 ` Hanjun Guo
2015-06-30 11:50 ` Hanjun Guo
2015-06-30 12:17 ` Marc Zyngier
2015-06-30 12:17 ` Marc Zyngier
2015-06-30 15:07 ` Graeme Gregory
2015-06-30 15:07 ` Graeme Gregory
2015-07-03 8:47 ` Hanjun Guo
2015-07-03 8:47 ` Hanjun Guo
2015-07-08 3:40 ` Hanjun Guo
2015-07-08 3:40 ` Hanjun Guo
2015-07-08 3:40 ` Hanjun Guo
2015-07-10 9:41 ` Marc Zyngier
2015-07-10 9:41 ` Marc Zyngier
2015-06-19 8:46 ` [PATCH v2 7/9] irqchip / GICv3: Refactor gic_of_init() for GICv3 driver Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
2015-06-19 8:46 ` [PATCH v2 8/9] irqchip / GICv3: Add ACPI support for GICv3+ initialization Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
2015-06-19 8:46 ` [PATCH v2 9/9] irqchip / GICv3: Add stacked irqdomain support for ACPI based init Hanjun Guo
2015-06-19 8:46 ` Hanjun Guo
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=20150622164520.GA26129@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=Catalin.Marinas@arm.com \
--cc=Marc.Zyngier@arm.com \
--cc=Will.Deacon@arm.com \
--cc=arnd@arndb.de \
--cc=grant.likely@linaro.org \
--cc=hanjun.guo@linaro.org \
--cc=jason@lakedaemon.net \
--cc=jiang.liu@linux.intel.com \
--cc=linaro-acpi@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=tomasz.nowicki@linaro.org \
--cc=wei@redhat.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.