From: Hanjun Guo <hanjun.guo@linaro.org> To: 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> Cc: Jiang Liu <jiang.liu@linux.intel.com>, Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>, Arnd Bergmann <arnd@arndb.de>, Tomasz Nowicki <tomasz.nowicki@linaro.org>, Grant Likely <grant.likely@linaro.org>, Thomas Gleixner <tglx@linutronix.de>, Olof Johansson <olof@lixom.net>, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Hanjun Guo <hanjun.guo@linaro.org> Subject: [PATCH 02/11] ACPI / irqchip: Add self-probe infrastructure to initialize IRQ controller Date: Mon, 18 May 2015 20:59:12 +0800 [thread overview] Message-ID: <1431953961-22706-3-git-send-email-hanjun.guo@linaro.org> (raw) In-Reply-To: <1431953961-22706-1-git-send-email-hanjun.guo@linaro.org> From: Tomasz Nowicki <tomasz.nowicki@linaro.org> This self-probe infrastructure works in the similar way as OF, but there is some different in the mechanism: For OF, the init fn will be called once it finds comptiable strings in DT, but for ACPI, we init irqchips by static tables, and in static ACPI tables, there are no comptiable strings to indicate irqchips, so every init function with IRQCHIP_ACPI_DECLARE in the same table will be called, but thanks to the GIC version presented in ACPI table, we can init different GIC irqchips with this framework. This mechanism can also be used for clock declare and may also works on x86 for some table parsing too. Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org> [hj: introduce struct acpi_table_id instead of acpi_device_id] [hj: rework it more generic to all ACPI tables and fix some issues] Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org> --- drivers/acpi/Makefile | 1 + drivers/acpi/irq.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/irqchip/irqchip.h | 12 ++++++++++++ include/asm-generic/vmlinux.lds.h | 13 +++++++++++++ include/linux/acpi.h | 14 ++++++++++++++ include/linux/mod_devicetable.h | 7 +++++++ 6 files changed, 84 insertions(+) create mode 100644 drivers/acpi/irq.c diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 8a063e2..3e4aec3 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -80,6 +80,7 @@ obj-$(CONFIG_ACPI_HED) += hed.o obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o obj-$(CONFIG_ACPI_BGRT) += bgrt.o +obj-$(CONFIG_IRQCHIP) += irq.o # processor has its own "processor." module_param namespace processor-y := processor_driver.o processor_throttling.o diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c new file mode 100644 index 0000000..65d6b93 --- /dev/null +++ b/drivers/acpi/irq.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015, Linaro Ltd. + * Author: Tomasz Nowicki <tomasz.nowicki@linaro.org> + * Hanjun Guo <hanjun.guo@linaro.org> + * + * Inspired by drivers/irqchip/irqchip.c + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + */ + +#include <linux/init.h> +#include <linux/acpi.h> + +/* + * This special acpi_table_id is the sentinel at the end of the + * acpi_table_id[] array of all irqchips. It is automatically placed at + * the end of the array by the linker, thanks to being part of a + * special section. + */ +static const struct acpi_table_id +irqchip_acpi_match_end __used __section(__irqchip_acpi_table_end); + +extern struct acpi_table_id __irqchip_acpi_table[]; + +void __init acpi_irqchip_init(void) +{ + struct acpi_table_id *id; + + if (acpi_disabled) + return; + + for (id = __irqchip_acpi_table; id->id[0]; id++) + acpi_table_parse(id->id, (acpi_tbl_table_handler)id->data); +} diff --git a/drivers/irqchip/irqchip.h b/drivers/irqchip/irqchip.h index 0f6486d..1949546 100644 --- a/drivers/irqchip/irqchip.h +++ b/drivers/irqchip/irqchip.h @@ -11,6 +11,7 @@ #ifndef _IRQCHIP_H #define _IRQCHIP_H +#include <linux/acpi.h> #include <linux/of.h> /* @@ -25,4 +26,15 @@ */ #define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn) +/* + * This macro must be used by the different irqchip drivers to declare + * the association between their ACPI table and their initialization function. + * + * @name: name that must be unique accross all IRQCHIP_ACPI_DECLARE of the + * same file. + * @table_id: name of the ACPI table signature + * @fn: initialization function + */ +#define IRQCHIP_ACPI_DECLARE(name, table_id, fn) \ + ACPI_DECLARE(irqchip, name, table_id, fn) #endif diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 8bd374d..625776c 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -181,6 +181,18 @@ #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method) #define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) +#ifdef CONFIG_ACPI +#define ACPI_TABLE(name) \ + . = ALIGN(8); \ + VMLINUX_SYMBOL(__##name##_acpi_table) = .; \ + *(__##name##_acpi_table) \ + *(__##name##_acpi_table_end) + +#define IRQCHIP_ACPI_MATCH_TABLE() ACPI_TABLE(irqchip) +#else +#define IRQCHIP_ACPI_MATCH_TABLE() +#endif + #define KERNEL_DTB() \ STRUCT_ALIGN(); \ VMLINUX_SYMBOL(__dtb_start) = .; \ @@ -516,6 +528,7 @@ CPUIDLE_METHOD_OF_TABLES() \ KERNEL_DTB() \ IRQCHIP_OF_MATCH_TABLE() \ + IRQCHIP_ACPI_MATCH_TABLE() \ EARLYCON_TABLE() \ EARLYCON_OF_TABLES() diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 90e4ed1e..b904af3 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -820,4 +820,18 @@ static inline struct acpi_device *acpi_get_next_child(struct device *dev, #endif +#ifdef CONFIG_ACPI +#define ACPI_DECLARE(table, name, table_id, fn) \ + static const struct acpi_table_id __acpi_table_##name \ + __used __section(__##table##_acpi_table) \ + = { .id = table_id, \ + .data = (void *)fn } +#else +#define ACPI_DECLARE(table, name, table_id, fn) \ + static const struct acpi_table_id __acpi_table_##name \ + __attribute__((unused)) \ + = { .id = table_id, \ + .data = (void*)fn } +#endif + #endif /*_LINUX_ACPI_H*/ diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 3bfd567..47c1ea1 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -199,6 +199,13 @@ struct pnp_device_id { kernel_ulong_t driver_data; }; +#define ACPI_TABLE_ID_LEN 5 + +struct acpi_table_id { + __u8 id[ACPI_TABLE_ID_LEN]; + const void *data; +}; + struct pnp_card_device_id { __u8 id[PNP_ID_LEN]; kernel_ulong_t driver_data; -- 1.9.1
WARNING: multiple messages have this Message-ID (diff)
From: hanjun.guo@linaro.org (Hanjun Guo) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 02/11] ACPI / irqchip: Add self-probe infrastructure to initialize IRQ controller Date: Mon, 18 May 2015 20:59:12 +0800 [thread overview] Message-ID: <1431953961-22706-3-git-send-email-hanjun.guo@linaro.org> (raw) In-Reply-To: <1431953961-22706-1-git-send-email-hanjun.guo@linaro.org> From: Tomasz Nowicki <tomasz.nowicki@linaro.org> This self-probe infrastructure works in the similar way as OF, but there is some different in the mechanism: For OF, the init fn will be called once it finds comptiable strings in DT, but for ACPI, we init irqchips by static tables, and in static ACPI tables, there are no comptiable strings to indicate irqchips, so every init function with IRQCHIP_ACPI_DECLARE in the same table will be called, but thanks to the GIC version presented in ACPI table, we can init different GIC irqchips with this framework. This mechanism can also be used for clock declare and may also works on x86 for some table parsing too. Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org> [hj: introduce struct acpi_table_id instead of acpi_device_id] [hj: rework it more generic to all ACPI tables and fix some issues] Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org> --- drivers/acpi/Makefile | 1 + drivers/acpi/irq.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/irqchip/irqchip.h | 12 ++++++++++++ include/asm-generic/vmlinux.lds.h | 13 +++++++++++++ include/linux/acpi.h | 14 ++++++++++++++ include/linux/mod_devicetable.h | 7 +++++++ 6 files changed, 84 insertions(+) create mode 100644 drivers/acpi/irq.c diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 8a063e2..3e4aec3 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -80,6 +80,7 @@ obj-$(CONFIG_ACPI_HED) += hed.o obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o obj-$(CONFIG_ACPI_BGRT) += bgrt.o +obj-$(CONFIG_IRQCHIP) += irq.o # processor has its own "processor." module_param namespace processor-y := processor_driver.o processor_throttling.o diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c new file mode 100644 index 0000000..65d6b93 --- /dev/null +++ b/drivers/acpi/irq.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015, Linaro Ltd. + * Author: Tomasz Nowicki <tomasz.nowicki@linaro.org> + * Hanjun Guo <hanjun.guo@linaro.org> + * + * Inspired by drivers/irqchip/irqchip.c + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + */ + +#include <linux/init.h> +#include <linux/acpi.h> + +/* + * This special acpi_table_id is the sentinel at the end of the + * acpi_table_id[] array of all irqchips. It is automatically placed at + * the end of the array by the linker, thanks to being part of a + * special section. + */ +static const struct acpi_table_id +irqchip_acpi_match_end __used __section(__irqchip_acpi_table_end); + +extern struct acpi_table_id __irqchip_acpi_table[]; + +void __init acpi_irqchip_init(void) +{ + struct acpi_table_id *id; + + if (acpi_disabled) + return; + + for (id = __irqchip_acpi_table; id->id[0]; id++) + acpi_table_parse(id->id, (acpi_tbl_table_handler)id->data); +} diff --git a/drivers/irqchip/irqchip.h b/drivers/irqchip/irqchip.h index 0f6486d..1949546 100644 --- a/drivers/irqchip/irqchip.h +++ b/drivers/irqchip/irqchip.h @@ -11,6 +11,7 @@ #ifndef _IRQCHIP_H #define _IRQCHIP_H +#include <linux/acpi.h> #include <linux/of.h> /* @@ -25,4 +26,15 @@ */ #define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn) +/* + * This macro must be used by the different irqchip drivers to declare + * the association between their ACPI table and their initialization function. + * + * @name: name that must be unique accross all IRQCHIP_ACPI_DECLARE of the + * same file. + * @table_id: name of the ACPI table signature + * @fn: initialization function + */ +#define IRQCHIP_ACPI_DECLARE(name, table_id, fn) \ + ACPI_DECLARE(irqchip, name, table_id, fn) #endif diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 8bd374d..625776c 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -181,6 +181,18 @@ #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method) #define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) +#ifdef CONFIG_ACPI +#define ACPI_TABLE(name) \ + . = ALIGN(8); \ + VMLINUX_SYMBOL(__##name##_acpi_table) = .; \ + *(__##name##_acpi_table) \ + *(__##name##_acpi_table_end) + +#define IRQCHIP_ACPI_MATCH_TABLE() ACPI_TABLE(irqchip) +#else +#define IRQCHIP_ACPI_MATCH_TABLE() +#endif + #define KERNEL_DTB() \ STRUCT_ALIGN(); \ VMLINUX_SYMBOL(__dtb_start) = .; \ @@ -516,6 +528,7 @@ CPUIDLE_METHOD_OF_TABLES() \ KERNEL_DTB() \ IRQCHIP_OF_MATCH_TABLE() \ + IRQCHIP_ACPI_MATCH_TABLE() \ EARLYCON_TABLE() \ EARLYCON_OF_TABLES() diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 90e4ed1e..b904af3 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -820,4 +820,18 @@ static inline struct acpi_device *acpi_get_next_child(struct device *dev, #endif +#ifdef CONFIG_ACPI +#define ACPI_DECLARE(table, name, table_id, fn) \ + static const struct acpi_table_id __acpi_table_##name \ + __used __section(__##table##_acpi_table) \ + = { .id = table_id, \ + .data = (void *)fn } +#else +#define ACPI_DECLARE(table, name, table_id, fn) \ + static const struct acpi_table_id __acpi_table_##name \ + __attribute__((unused)) \ + = { .id = table_id, \ + .data = (void*)fn } +#endif + #endif /*_LINUX_ACPI_H*/ diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 3bfd567..47c1ea1 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -199,6 +199,13 @@ struct pnp_device_id { kernel_ulong_t driver_data; }; +#define ACPI_TABLE_ID_LEN 5 + +struct acpi_table_id { + __u8 id[ACPI_TABLE_ID_LEN]; + const void *data; +}; + struct pnp_card_device_id { __u8 id[PNP_ID_LEN]; kernel_ulong_t driver_data; -- 1.9.1
next prev parent reply other threads:[~2015-05-18 12:59 UTC|newest] Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-05-18 12:59 [PATCH 00/11] Add self-probe infrastructure and stacked irqdomain support for ACPI based GICv2/3 init Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-05-18 12:59 ` [PATCH 01/11] ACPICA: Introduce GIC version for arm based system Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo [this message] 2015-05-18 12:59 ` [PATCH 02/11] ACPI / irqchip: Add self-probe infrastructure to initialize IRQ controller Hanjun Guo 2015-06-10 15:33 ` Marc Zyngier 2015-06-10 15:33 ` Marc Zyngier 2015-06-10 15:33 ` Marc Zyngier 2015-06-11 12:55 ` Hanjun Guo 2015-06-11 12:55 ` Hanjun Guo 2015-06-11 12:55 ` Hanjun Guo 2015-05-18 12:59 ` [PATCH 03/11] irqchip / GIC: Add GIC version support in ACPI MADT Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-05-20 20:02 ` Thomas Gleixner 2015-05-20 20:02 ` Thomas Gleixner 2015-05-21 14:19 ` Hanjun Guo 2015-05-21 14:19 ` Hanjun Guo 2015-05-21 14:19 ` Hanjun Guo 2015-05-21 14:39 ` Thomas Gleixner 2015-05-21 14:39 ` Thomas Gleixner 2015-05-21 15:04 ` Hanjun Guo 2015-05-21 15:04 ` Hanjun Guo 2015-05-21 15:04 ` Hanjun Guo 2015-05-18 12:59 ` [PATCH 04/11] irqchip / GIC / ACPI: Use IRQCHIP_ACPI_DECLARE to simplify GICv2 init code Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-05-18 12:59 ` [PATCH 05/11] irqchip / gic: Add stacked irqdomain support for ACPI based GICv2 init Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-06-10 16:27 ` Marc Zyngier 2015-06-10 16:27 ` Marc Zyngier 2015-06-10 16:27 ` Marc Zyngier 2015-06-11 13:22 ` Hanjun Guo 2015-06-11 13:22 ` Hanjun Guo 2015-06-11 13:22 ` Hanjun Guo 2015-06-18 23:25 ` Hanjun Guo 2015-06-18 23:25 ` Hanjun Guo 2015-06-18 23:25 ` Hanjun Guo 2015-05-18 12:59 ` [PATCH 06/11] ACPI / gsi: Add gsi_mutex to synchronize acpi_register_gsi()/acpi_unregister_gsi() Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-06-10 15:58 ` Marc Zyngier 2015-06-10 15:58 ` Marc Zyngier 2015-06-10 15:58 ` Marc Zyngier 2015-06-11 13:16 ` Hanjun Guo 2015-06-11 13:16 ` Hanjun Guo 2015-06-11 13:16 ` Hanjun Guo 2015-06-19 7:31 ` Hanjun Guo 2015-06-19 7:31 ` Hanjun Guo 2015-06-19 7:31 ` Hanjun Guo 2015-06-19 9:49 ` Marc Zyngier 2015-06-19 9:49 ` Marc Zyngier 2015-06-19 9:49 ` Marc Zyngier 2015-05-18 12:59 ` [PATCH 07/11] irqchip / GICv3: Refactor gic_of_init() for GICv3 driver Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-05-18 12:59 ` [PATCH 08/11] irqchip / GICv3: Add ACPI support for GICv3+ initialization Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-05-18 12:59 ` [PATCH 09/11] irqchip / GICv3: Add stacked irqdomain support for ACPI based init Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-05-18 12:59 ` [PATCH 10/11] irqchip / GICv2 / ACPI: Consolidate GICv2 ACPI related init code Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-05-20 20:44 ` Tomasz Nowicki 2015-05-20 20:44 ` Tomasz Nowicki 2015-05-21 14:27 ` Hanjun Guo 2015-05-21 14:27 ` Hanjun Guo 2015-05-21 14:27 ` Hanjun Guo 2015-06-10 16:29 ` Marc Zyngier 2015-06-10 16:29 ` Marc Zyngier 2015-06-10 16:29 ` Marc Zyngier 2015-06-11 13:25 ` Hanjun Guo 2015-06-11 13:25 ` Hanjun Guo 2015-06-11 13:25 ` Hanjun Guo 2015-05-18 12:59 ` [PATCH 11/11] irqchip / GICv3 / ACPI: Consolidate GICv3 " Hanjun Guo 2015-05-18 12:59 ` Hanjun Guo 2015-06-02 12:24 ` [PATCH 00/11] Add self-probe infrastructure and stacked irqdomain support for ACPI based GICv2/3 init Hanjun Guo 2015-06-02 12:24 ` Hanjun Guo 2015-06-02 12:24 ` 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=1431953961-22706-3-git-send-email-hanjun.guo@linaro.org \ --to=hanjun.guo@linaro.org \ --cc=Lorenzo.Pieralisi@arm.com \ --cc=arnd@arndb.de \ --cc=catalin.marinas@arm.com \ --cc=grant.likely@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=marc.zyngier@arm.com \ --cc=olof@lixom.net \ --cc=rjw@rjwysocki.net \ --cc=tglx@linutronix.de \ --cc=tomasz.nowicki@linaro.org \ --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: linkBe 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.