linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: Hanjun Guo <hanjun.guo@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	Will Deacon <Will.Deacon@arm.com>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Mark Rutland <Mark.Rutland@arm.com>,
	Matthew Garrett <mjg59@srcf.ucam.org>,
	"linaro-kernel@lists.linaro.org" <linaro-kernel@lists.linaro.org>,
	"patches@linaro.org" <patches@linaro.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Olof Johansson <olof@lixom.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"rob.herring@calxeda.com" <rob.herring@calxeda.com>,
	"linaro-acpi@lists.linaro.org" <linaro-acpi@lists.linaro.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	Jon Masters <jonathan@jonmasters.org>,
	"grant.likely@linaro.org" <grant.likely@linaro.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-arm-kernel@lists.infradead.or
Subject: Re: [RFC part2 PATCH 9/9] ACPI / GIC: Initialize GIC using the information in MADT
Date: Tue, 03 Dec 2013 17:26:27 +0000	[thread overview]
Message-ID: <529E1443.9040509@arm.com> (raw)
In-Reply-To: <1386088753-2850-10-git-send-email-hanjun.guo@linaro.org>

Hi Hanjun,

On 03/12/13 16:39, Hanjun Guo wrote:
> In MADT table, there are GIC cpu interface base address and
> GIC distributor base address, use them to convert GIC to ACPI.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/kernel/irq.c      |    5 ++++
>  drivers/acpi/plat/arm-core.c |   66 ++++++++++++++++++++++++++++++++++++------
>  include/linux/acpi.h         |    6 ++++
>  3 files changed, 68 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
> index 473e5db..a9e68bf 100644
> --- a/arch/arm64/kernel/irq.c
> +++ b/arch/arm64/kernel/irq.c
> @@ -25,6 +25,7 @@
>  #include <linux/irq.h>
>  #include <linux/smp.h>
>  #include <linux/init.h>
> +#include <linux/acpi.h>
>  #include <linux/irqchip.h>
>  #include <linux/seq_file.h>
>  #include <linux/ratelimit.h>
> @@ -78,6 +79,10 @@ void __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
>  void __init init_IRQ(void)
>  {
>  	irqchip_init();
> +
> +	if (!handle_arch_irq)
> +		acpi_gic_init();
> +

Why is the GIC hardcoded? How are you going to support other interrupt
controllers?

>  	if (!handle_arch_irq)
>  		panic("No interrupt controller found.");
>  }
> diff --git a/drivers/acpi/plat/arm-core.c b/drivers/acpi/plat/arm-core.c
> index 17c99e1..509b847 100644
> --- a/drivers/acpi/plat/arm-core.c
> +++ b/drivers/acpi/plat/arm-core.c
> @@ -29,6 +29,7 @@
>  #include <linux/module.h>
>  #include <linux/irq.h>
>  #include <linux/irqdomain.h>
> +#include <linux/irqchip/arm-gic.h>
>  #include <linux/slab.h>
>  #include <linux/bootmem.h>
>  #include <linux/ioport.h>
> @@ -211,11 +212,21 @@ acpi_parse_gic(struct acpi_subtable_header *header, const unsigned long end)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_ARM_GIC
> +/*
> + * Hard code here, we can not get memory size from MADT (but FDT does),
> + * this size is described in ARMv8 foudation model's User Guide
> + */
> +#define GIC_DISTRIBUTOR_MEMORY_SIZE (SZ_8K)
> +#define GIC_CPU_INTERFACE_MEMORY_SIZE (SZ_4K)

Aside from the incorrect sizes, how do you plan to address the other
regions that the GICv2 specification describes?

>  static int __init
>  acpi_parse_gic_distributor(struct acpi_subtable_header *header,
>  				const unsigned long end)
>  {
>  	struct acpi_madt_generic_distributor *distributor = NULL;
> +	void __iomem *dist_base = NULL;
> +	void __iomem *cpu_base = NULL;
>  
>  	distributor = (struct acpi_madt_generic_distributor *)header;
>  
> @@ -224,8 +235,43 @@ acpi_parse_gic_distributor(struct acpi_subtable_header *header,
>  
>  	acpi_table_print_madt_entry(header);
>  
> +	/* GIC is initialised after page_init(), no need for early_ioremap */
> +	dist_base = ioremap(distributor->base_address,
> +				GIC_CPU_INTERFACE_MEMORY_SIZE);
> +	if (!dist_base) {
> +		pr_warn(PREFIX "unable to map gic dist registers\n");
> +		return -ENOMEM;
> +	}
> +
> +	/*
> +	 * acpi_lapic_addr is stored in acpi_parse_madt(),
> +	 * so we can use it here for GIC init
> +	 */
> +	if (acpi_lapic_addr) {
> +		iounmap(dist_base);
> +		pr_warn(PREFIX "Invalid GIC cpu interface base address\n");
> +		return -EINVAL;
> +	}
> +
> +	cpu_base = ioremap(acpi_lapic_addr, GIC_CPU_INTERFACE_MEMORY_SIZE);
> +	if (!cpu_base) {
> +		iounmap(dist_base);
> +		pr_warn(PREFIX "unable to map gic cpu registers\n");
> +		return -ENOMEM;
> +	}
> +
> +	gic_init(distributor->gic_id, -1, dist_base, cpu_base);
> +
>  	return 0;
>  }
> +#else
> +static int __init
> +acpi_parse_gic_distributor(struct acpi_subtable_header *header,
> +				const unsigned long end)
> +{
> +	return -ENODEV;
> +}
> +#endif /* CONFIG_ARM_GIC */
>  
>  /*
>   * Parse GIC cpu interface related entries in MADT
> @@ -234,7 +280,7 @@ acpi_parse_gic_distributor(struct acpi_subtable_header *header,
>  static int __init acpi_parse_madt_gic_entries(void)
>  {
>  	int count;
> -
> + 
>  	/*
>  	 * do a partial walk of MADT to determine how many CPUs
>  	 * we have including disabled CPUs
> @@ -468,19 +514,21 @@ static void __init acpi_process_madt(void)
>  		 * Parse MADT GIC cpu interface entries
>  		 */
>  		error = acpi_parse_madt_gic_entries();
> -		if (!error) {
> -			/*
> -			 * Parse MADT GIC distributor entries
> -			 */
> -			acpi_parse_madt_gic_distributor_entries();
> -		}
> +		if (!error)
> +			pr_info("Using ACPI for processor (GIC) configuration information\n");
>  	}
>  
> -	pr_info("Using ACPI for processor (GIC) configuration information\n");
> -
>  	return;
>  }
>  
> +int __init acpi_gic_init(void)
> +{
> +	/*
> +	 * Parse MADT GIC distributor entries
> +	 */
> +	return acpi_parse_madt_gic_distributor_entries();
> +}
> +

Why can't you do the GIC init in the GIC code? We've tried hard to make
interrupt controllers discoverable and self contained. What are you
going to do when ACPI adds GICv3 to the mix? I don't really think this
model (shoving everything into the core ACPI code) is sustainable in the
long run...

Cheers,

	M.
-- 
Jazz is not dead. It just smells funny...


  parent reply	other threads:[~2013-12-03 17:26 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 16:39 [RFC part2 PATCH 0/9] Using ACPI MADT table to initialise SMP and GIC Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 1/9] ARM64 / ACPI: Implement core functions for parsing MADT table Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 2/9] ARM64 / ACPI: Prefill cpu possible/present maps and map logical cpu id to APIC id Hanjun Guo
2013-12-03 16:57   ` One Thousand Gnomes
2013-12-04 14:21     ` Hanjun Guo
2013-12-04 15:40       ` Rob Herring
2013-12-04 15:47   ` Rob Herring
2013-12-05 13:24     ` Mark Brown
2013-12-05 13:34     ` Hanjun Guo
2013-12-05 23:09     ` Arnd Bergmann
2013-12-09  8:06       ` Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 3/9] ARM64 / ACPI: Introduce map_gic_id() to get apic id from MADT or _MAT method Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 4/9] ARM64 / ACPI: Use Parked Address in GIC structure for spin table SMP initialisation Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 5/9] ACPI: Define ACPI_IRQ_MODEL_GIC needed for arm Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 6/9] Irqchip / gic: Set as default domain so we can access from ACPI Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 7/9] irqdomain: Add a new API irq_create_acpi_mapping() Hanjun Guo
2013-12-03 17:25   ` Rob Herring
2013-12-04 15:38     ` Hanjun Guo
2013-12-10 10:06       ` Linus Walleij
2013-12-03 16:39 ` [RFC part2 PATCH 8/9] ACPI / ARM64: Update acpi_register_gsi to register with the core IRQ subsystem Hanjun Guo
2013-12-05  3:48   ` Arnd Bergmann
2013-12-05 14:01     ` Hanjun Guo
2013-12-03 16:39 ` [RFC part2 PATCH 9/9] ACPI / GIC: Initialize GIC using the information in MADT Hanjun Guo
2013-12-03 17:09   ` Rob Herring
2013-12-04 14:58     ` Hanjun Guo
2013-12-03 17:26   ` Marc Zyngier [this message]
2013-12-04 15:32     ` Hanjun Guo
2013-12-04 15:50       ` Marc Zyngier
2013-12-05 13:41         ` Hanjun Guo
2013-12-09 18:54         ` Olof Johansson

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=529E1443.9040509@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=Mark.Rutland@arm.com \
    --cc=Will.Deacon@arm.com \
    --cc=bhelgaas@google.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=grant.likely@linaro.org \
    --cc=hanjun.guo@linaro.org \
    --cc=jonathan@jonmasters.org \
    --cc=linaro-acpi@lists.linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.or \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mjg59@srcf.ucam.org \
    --cc=olof@lixom.net \
    --cc=patches@linaro.org \
    --cc=rjw@rjwysocki.net \
    --cc=rob.herring@calxeda.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 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).