Level-triggered MSI support
Subsystems (9)
v2 cover Level-triggered MSI support
This series is a first shot at teaching the kernel about the oxymoron expressed in $SUBJECT. Over the past couple of years, we've seen some SoCs coming up with ways of signalling level interrupts using a new flavor of MSIs, where the MSI controller uses two distinct messages:
one that raises a virtual line, and one that lowers it. The target MSI controller is in charge of maintaining the state of the line.
This allows for a much simplified HW signal routing (no need to have hundreds of discrete lines to signal level interrupts if you already have a memory bus), but results in a departure from the current idea the kernel has of MSIs.
This series takes a minimal approach to the problem, which is to allow MSI controllers to use not only one, but up to two messages at a time. This is controlled by a flag exposed at MSI irq domain creation, and is only supported with platform MSI.
The rest of the series repaints the Marvell ICU/GICP drivers which already make use of this feature with a side-channel, and adds support for the same feature in GICv3. A side effect of the last GICv3 patch is that you can also use SPIs to signal PCI MSIs. This is a last resort measure for SoCs where the ITS is unusable for unspeakable reasons.
* From v1:
- irq_find_host now defaults to DOMAIN_BUS_WIRED
- Introduced a new irqchip flag indicating support for Level MSI
- Turned GICv3 MBI allocator spinlock into a mutex
- Exclude fsl-mc from Level MSI
Marc Zyngier (9):
genirq/msi: Allow level-triggered MSIs to be exposed by MSI providers genirq/msi: Limit level-triggered MSI to platform devices irqchip/mvebu-gicp: Use level-triggered MSIs between ICU and GICP
dma-iommu: Fix compilation when !CONFIG_IOMMU_DMA
irqdomain: Let irq_find_host default to DOMAIN_BUS_WIRED irqchip/gic-v3: Mark the base irq domain as DOMAIN_BUS_WIRED irqchip/gic-v3: Add support for Message Based Interrupts as an MSI
controller
irqchip/gic-v3: Add PCI/MSI support to the GICv3 MBI sub-driver dt-bindings/gic-v3: Add documentation for MBI support
.../bindings/interrupt-controller/arm,gic-v3.txt | 17 ++ drivers/base/platform-msi.c | 3 + drivers/bus/fsl-mc/fsl-mc-msi.c | 2 + drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-gic-v3-mbi.c | 331 +++++++++++++++++++++ drivers/irqchip/irq-gic-v3.c | 7 + drivers/irqchip/irq-mvebu-gicp.c | 38 +-- drivers/irqchip/irq-mvebu-gicp.h | 12 - drivers/irqchip/irq-mvebu-icu.c | 33 +- drivers/pci/msi.c | 3 + include/linux/dma-iommu.h | 1 + include/linux/irq.h | 1 + include/linux/irqchip/arm-gic-v3.h | 1 + include/linux/irqdomain.h | 8 +- include/linux/msi.h | 2 + kernel/irq/msi.c | 33 +- 16 files changed, 428 insertions(+), 66 deletions(-) create mode 100644 drivers/irqchip/irq-gic-v3-mbi.c delete mode 100644 drivers/irqchip/irq-mvebu-gicp.h
Signature · 1 line
2.14.2
PATCH v2 1/9 genirq/msi: Allow level-triggered MSIs to be exposed by MSI providers
So far, MSIs have been used to signal edge-triggered interrupts, as a write is a good model for an edge (you can't "unwrite" something). On the other hand, routing zillions of wires in an SoC because you need level interrupts is a bit extreme.
People have come up with a variety of schemes to support this, which involves sending two messages: one to signal the interrupt, and one to clear it. Since the kernel cannot represent this, we've ended up with side-band mechanisms that are pretty awful.
Instead, let's acknoledge the requirement, and ensure that, under the right circumstances, the irq_compose_msg and irq_write_msg can take as a parameter an array of two messages instead of a pointer to a single one. We also add some checking that the compose method only clobbers the second message if the MSI domain has been created with the MSI_FLAG_LEVEL_CAPABLE flags.
--- include/linux/msi.h | 2 ++ kernel/irq/msi.c | 33 ++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-)
include/linux/msi.h +2 -0
@@ -289,6 +289,8 @@ enum {* MSI_FLAG_ACTIVATE_EARLY has been set. */ MSI_FLAG_MUST_REACTIVATE = (1 <<5 ), +/* Is level-triggered capable, using two messages */ + MSI_FLAG_LEVEL_CAPABLE = (1 << 6), }; int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask,
kernel/irq/msi.c +24 -9
@@ -76,6 +76,19 @@ static inline void irq_chip_write_msi_msg(struct irq_data *data, data->chip->irq_write_msi_msg (data, msg); } +static void msi_check_level (struct irq_domain *domain,struct msi_msg *msg) +{ +struct msi_domain_info *info = domain->host_data; + +/* +* If the MSI provider has messed with the second message and +* not advertized that it is level-capable, signal the breakage. +*/ +WARN_ON (!((info->flags &MSI_FLAG_LEVEL_CAPABLE ) && + (info->chip->flags &IRQCHIP_SUPPORTS_LEVEL_MSI )) && + (msg[1 ].address_lo || msg[1 ].address_hi || msg[1 ].data)); +} +/** * msi_domain_set_affinity - Generic affinity setter function for MSI domains * @irq_data: The irq data associated to the interrupt
@@ -89,13 +102,14 @@ int msi_domain_set_affinity(struct irq_data *irq_data, const struct cpumask *mask, bool force) {struct irq_data *parent = irq_data->parent_data; -struct msi_msg msg; +struct msi_msg msg[2 ] = { [1 ] = { }, };int ret; ret = parent->chip->irq_set_affinity (parent, mask, force);if (ret >=0 && ret !=IRQ_SET_MASK_OK_DONE ) { -BUG_ON (irq_chip_compose_msi_msg (irq_data, &msg)); -irq_chip_write_msi_msg (irq_data, &msg); +BUG_ON (irq_chip_compose_msi_msg (irq_data, msg)); +msi_check_level (irq_data->domain, msg); +irq_chip_write_msi_msg (irq_data, msg); }return ret;
@@ -104,20 +118,21 @@ int msi_domain_set_affinity(struct irq_data *irq_data,static int msi_domain_activate (struct irq_domain *domain,struct irq_data *irq_data,bool early) { -struct msi_msg msg; +struct msi_msg msg[2 ] = { [1 ] = { }, }; -BUG_ON (irq_chip_compose_msi_msg (irq_data, &msg)); -irq_chip_write_msi_msg (irq_data, &msg); +BUG_ON (irq_chip_compose_msi_msg (irq_data, msg)); +msi_check_level (irq_data->domain, msg); +irq_chip_write_msi_msg (irq_data, msg);return 0 ; }static void msi_domain_deactivate (struct irq_domain *domain,struct irq_data *irq_data) { -struct msi_msg msg; +struct msi_msg msg[2 ]; -memset (&msg,0 ,sizeof (msg)); -irq_chip_write_msi_msg (irq_data, &msg); +memset (msg,0 ,sizeof (msg)); +irq_chip_write_msi_msg (irq_data, msg); } static int msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
Signature · 1 line
2.14.2
tip-bot for Marc Zyngier
merge bot[tip:irq/core] genirq/msi: Allow level-triggered MSIs to be exposed by MSI providers
genirq/msi: Allow level-triggered MSIs to be exposed by MSI providers
Commit-ID: 0be8153cbc2af9a96e9ab8631fc3ba23bb52dbe3 Gitweb: https://git.kernel.org/tip/0be8153cbc2af9a96e9ab8631fc3ba23bb52dbe3 Author: Marc Zyngier <[email protected]> AuthorDate: Tue, 8 May 2018 13:14:30 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 13 May 2018 15:58:59 +0200
genirq/msi: Allow level-triggered MSIs to be exposed by MSI providers
So far, MSIs have been used to signal edge-triggered interrupts, as a write is a good model for an edge (you can't "unwrite" something). On the other hand, routing zillions of wires in an SoC because you need level interrupts is a bit extreme.
People have come up with a variety of schemes to support this, which involves sending two messages: one to signal the interrupt, and one to clear it. Since the kernel cannot represent this, we've ended up with side-band mechanisms that are pretty awful.
Instead, let's acknoledge the requirement, and ensure that, under the right circumstances, the irq_compose_msg and irq_write_msg can take as a parameter an array of two messages instead of a pointer to a single one. We also add some checking that the compose method only clobbers the second message if the MSI domain has been created with the MSI_FLAG_LEVEL_CAPABLE flags.
--- include/linux/msi.h | 2 ++ kernel/irq/msi.c | 33 ++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-)
include/linux/msi.h +2 -0
@@ -289,6 +289,8 @@ enum {* MSI_FLAG_ACTIVATE_EARLY has been set. */ MSI_FLAG_MUST_REACTIVATE = (1 <<5 ), +/* Is level-triggered capable, using two messages */ + MSI_FLAG_LEVEL_CAPABLE = (1 << 6), }; int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask,
kernel/irq/msi.c +24 -9
@@ -76,6 +76,19 @@ static inline void irq_chip_write_msi_msg(struct irq_data *data, data->chip->irq_write_msi_msg (data, msg); } +static void msi_check_level (struct irq_domain *domain,struct msi_msg *msg) +{ +struct msi_domain_info *info = domain->host_data; + +/* +* If the MSI provider has messed with the second message and +* not advertized that it is level-capable, signal the breakage. +*/ +WARN_ON (!((info->flags &MSI_FLAG_LEVEL_CAPABLE ) && + (info->chip->flags &IRQCHIP_SUPPORTS_LEVEL_MSI )) && + (msg[1 ].address_lo || msg[1 ].address_hi || msg[1 ].data)); +} +/** * msi_domain_set_affinity - Generic affinity setter function for MSI domains * @irq_data: The irq data associated to the interrupt
@@ -89,13 +102,14 @@ int msi_domain_set_affinity(struct irq_data *irq_data, const struct cpumask *mask, bool force) {struct irq_data *parent = irq_data->parent_data; -struct msi_msg msg; +struct msi_msg msg[2 ] = { [1 ] = { }, };int ret; ret = parent->chip->irq_set_affinity (parent, mask, force);if (ret >=0 && ret !=IRQ_SET_MASK_OK_DONE ) { -BUG_ON (irq_chip_compose_msi_msg (irq_data, &msg)); -irq_chip_write_msi_msg (irq_data, &msg); +BUG_ON (irq_chip_compose_msi_msg (irq_data, msg)); +msi_check_level (irq_data->domain, msg); +irq_chip_write_msi_msg (irq_data, msg); }return ret;
@@ -104,20 +118,21 @@ int msi_domain_set_affinity(struct irq_data *irq_data,static int msi_domain_activate (struct irq_domain *domain,struct irq_data *irq_data,bool early) { -struct msi_msg msg; +struct msi_msg msg[2 ] = { [1 ] = { }, }; -BUG_ON (irq_chip_compose_msi_msg (irq_data, &msg)); -irq_chip_write_msi_msg (irq_data, &msg); +BUG_ON (irq_chip_compose_msi_msg (irq_data, msg)); +msi_check_level (irq_data->domain, msg); +irq_chip_write_msi_msg (irq_data, msg);return 0 ; }static void msi_domain_deactivate (struct irq_domain *domain,struct irq_data *irq_data) { -struct msi_msg msg; +struct msi_msg msg[2 ]; -memset (&msg,0 ,sizeof (msg)); -irq_chip_write_msi_msg (irq_data, &msg); +memset (msg,0 ,sizeof (msg)); +irq_chip_write_msi_msg (irq_data, msg); } static int msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
PATCH v2 2/9 genirq/msi: Limit level-triggered MSI to platform devices
In reply to Marc ZyngierNobody would be insane enough to try and use level triggered MSIs on PCI, but let's make sure it doesn't happen. Also, let's mandate that the irqchip backing the platform MSI domain is providing the IRQCHIP_SUPPORTS_LEVEL_MSI flag.
--- drivers/base/platform-msi.c | 3 +++ drivers/bus/fsl-mc/fsl-mc-msi.c | 2 ++ drivers/pci/msi.c | 3 +++ include/linux/irq.h | 1 + 4 files changed, 9 insertions(+)
drivers/base/platform-msi.c +3 -0
@@ -101,6 +101,9 @@ static void platform_msi_update_chip_ops(struct msi_domain_info *info) chip->irq_set_affinity = msi_domain_set_affinity;if (!chip->irq_write_msi_msg) chip->irq_write_msi_msg = platform_msi_write_msg; +if (WARN_ON ((info->flags &MSI_FLAG_LEVEL_CAPABLE ) && + !(chip->flags &IRQCHIP_SUPPORTS_LEVEL_MSI ))) + info->flags &= ~MSI_FLAG_LEVEL_CAPABLE ; }static void platform_msi_free_descs (struct device *dev,int base,int nvec)
drivers/bus/fsl-mc/fsl-mc-msi.c +2 -0
@@ -163,6 +163,8 @@ struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode, {struct irq_domain *domain; +if (WARN_ON ((info->flags &MSI_FLAG_LEVEL_CAPABLE ))) + info->flags &= ~MSI_FLAG_LEVEL_CAPABLE ;if (info->flags &MSI_FLAG_USE_DEF_DOM_OPS )fsl_mc_msi_update_dom_ops (info);if (info->flags &MSI_FLAG_USE_DEF_CHIP_OPS )
drivers/pci/msi.c +3 -0
@@ -1434,6 +1434,9 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode, {struct irq_domain *domain; +if (WARN_ON (info->flags &MSI_FLAG_LEVEL_CAPABLE )) + info->flags &= ~MSI_FLAG_LEVEL_CAPABLE ; +if (info->flags &MSI_FLAG_USE_DEF_DOM_OPS )pci_msi_domain_update_dom_ops (info);if (info->flags &MSI_FLAG_USE_DEF_CHIP_OPS )
include/linux/irq.h +1 -0
@@ -512,6 +512,7 @@ enum {IRQCHIP_SKIP_SET_WAKE = (1 <<4 ),IRQCHIP_ONESHOT_SAFE = (1 <<5 ),IRQCHIP_EOI_THREADED = (1 <<6 ), + IRQCHIP_SUPPORTS_LEVEL_MSI = (1 << 7), };#include <linux/irqdesc.h>
Signature · 1 line
2.14.2
tip-bot for Marc Zyngier
merge bot[tip:irq/core] genirq/msi: Limit level-triggered MSI to platform devices
genirq/msi: Limit level-triggered MSI to platform devices
Commit-ID: 6988e0e0d28328467e218f59589b2770675a9ebd Gitweb: https://git.kernel.org/tip/6988e0e0d28328467e218f59589b2770675a9ebd Author: Marc Zyngier <[email protected]> AuthorDate: Tue, 8 May 2018 13:14:31 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 13 May 2018 15:58:59 +0200
genirq/msi: Limit level-triggered MSI to platform devices
Nobody would be insane enough to try and use level triggered MSIs on PCI, but let's make sure it doesn't happen. Also, let's mandate that the irqchip backing the platform MSI domain is providing the IRQCHIP_SUPPORTS_LEVEL_MSI flag.
--- drivers/base/platform-msi.c | 3 +++ drivers/bus/fsl-mc/fsl-mc-msi.c | 2 ++ drivers/pci/msi.c | 3 +++ include/linux/irq.h | 1 + 4 files changed, 9 insertions(+)
drivers/base/platform-msi.c +3 -0
@@ -101,6 +101,9 @@ static void platform_msi_update_chip_ops(struct msi_domain_info *info) chip->irq_set_affinity = msi_domain_set_affinity;if (!chip->irq_write_msi_msg) chip->irq_write_msi_msg = platform_msi_write_msg; +if (WARN_ON ((info->flags &MSI_FLAG_LEVEL_CAPABLE ) && + !(chip->flags &IRQCHIP_SUPPORTS_LEVEL_MSI ))) + info->flags &= ~MSI_FLAG_LEVEL_CAPABLE ; }static void platform_msi_free_descs (struct device *dev,int base,int nvec)
drivers/bus/fsl-mc/fsl-mc-msi.c +2 -0
@@ -163,6 +163,8 @@ struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode, {struct irq_domain *domain; +if (WARN_ON ((info->flags &MSI_FLAG_LEVEL_CAPABLE ))) + info->flags &= ~MSI_FLAG_LEVEL_CAPABLE ;if (info->flags &MSI_FLAG_USE_DEF_DOM_OPS )fsl_mc_msi_update_dom_ops (info);if (info->flags &MSI_FLAG_USE_DEF_CHIP_OPS )
drivers/pci/msi.c +3 -0
@@ -1434,6 +1434,9 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode, {struct irq_domain *domain; +if (WARN_ON (info->flags &MSI_FLAG_LEVEL_CAPABLE )) + info->flags &= ~MSI_FLAG_LEVEL_CAPABLE ; +if (info->flags &MSI_FLAG_USE_DEF_DOM_OPS )pci_msi_domain_update_dom_ops (info);if (info->flags &MSI_FLAG_USE_DEF_CHIP_OPS )
include/linux/irq.h +1 -0
@@ -512,6 +512,7 @@ enum {IRQCHIP_SKIP_SET_WAKE = (1 <<4 ),IRQCHIP_ONESHOT_SAFE = (1 <<5 ),IRQCHIP_EOI_THREADED = (1 <<6 ), + IRQCHIP_SUPPORTS_LEVEL_MSI = (1 << 7), };#include <linux/irqdesc.h>
PATCH v2 3/9 irqchip/mvebu-gicp: Use level-triggered MSIs between ICU and GICP
In reply to Marc ZyngierThe ICU and GICP drivers are using an ugly side-band mechanism to find out about the "clear" doorbell when using level interrupts.
Let's convert it to level-triggered MSIs, which result in a nice cleanup.
--- drivers/irqchip/irq-mvebu-gicp.c | 38 +++++++++++--------------------------- drivers/irqchip/irq-mvebu-gicp.h | 12 ------------ drivers/irqchip/irq-mvebu-icu.c | 33 +++++++++++++++++---------------- 3 files changed, 28 insertions(+), 55 deletions(-) delete mode 100644 drivers/irqchip/irq-mvebu-gicp.h
drivers/irqchip/irq-mvebu-gicp.c +11 -27
@@ -19,8 +19,6 @@#include <dt-bindings/interrupt-controller/arm-gic.h> -#include "irq-mvebu-gicp.h" -#define GICP_SETSPI_NSR_OFFSET 0x0#define GICP_CLRSPI_NSR_OFFSET 0x8
@@ -55,34 +53,18 @@ static int gicp_idx_to_spi(struct mvebu_gicp *gicp, int idx)return -EINVAL ; } -int mvebu_gicp_get_doorbells (struct device_node *dn,phys_addr_t *setspi, -phys_addr_t *clrspi) -{ -struct platform_device *pdev; -struct mvebu_gicp *gicp; - - pdev =of_find_device_by_node (dn); -if (!pdev) -return -ENODEV ; - - gicp =platform_get_drvdata (pdev); -if (!gicp) -return -ENODEV ; - - *setspi = gicp->res->start +GICP_SETSPI_NSR_OFFSET ; - *clrspi = gicp->res->start +GICP_CLRSPI_NSR_OFFSET ; - -return 0 ; -} -static void gicp_compose_msi_msg (struct irq_data *data,struct msi_msg *msg) {struct mvebu_gicp *gicp = data->chip_data;phys_addr_t setspi = gicp->res->start +GICP_SETSPI_NSR_OFFSET ; - - msg->data = data->hwirq; - msg->address_lo =lower_32_bits (setspi); - msg->address_hi =upper_32_bits (setspi); +phys_addr_t clrspi = gicp->res->start +GICP_CLRSPI_NSR_OFFSET ; + + msg[0 ].data = data->hwirq; + msg[0 ].address_lo =lower_32_bits (setspi); + msg[0 ].address_hi =upper_32_bits (setspi); + msg[1 ].data = data->hwirq; + msg[1 ].address_lo =lower_32_bits (clrspi); + msg[1 ].address_hi =upper_32_bits (clrspi); }static struct irq_chip gicp_irq_chip = {
@@ -170,13 +152,15 @@ static const struct irq_domain_ops gicp_domain_ops = {static struct irq_chip gicp_msi_irq_chip = { .name ="GICP" , .irq_set_type = irq_chip_set_type_parent, + .flags =IRQCHIP_SUPPORTS_LEVEL_MSI , };static struct msi_domain_ops gicp_msi_ops = { };static struct msi_domain_info gicp_msi_domain_info = { - .flags = (MSI_FLAG_USE_DEF_DOM_OPS |MSI_FLAG_USE_DEF_CHIP_OPS ), + .flags = (MSI_FLAG_USE_DEF_DOM_OPS |MSI_FLAG_USE_DEF_CHIP_OPS | +MSI_FLAG_LEVEL_CAPABLE ), .ops = &gicp_msi_ops, .chip = &gicp_msi_irq_chip, };
drivers/irqchip/irq-mvebu-gicp.h deleted +0 -12
@@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __MVEBU_GICP_H__ -#define __MVEBU_GICP_H__ - -#include <linux/types.h> - -struct device_node ; - -int mvebu_gicp_get_doorbells (struct device_node *dn,phys_addr_t *setspi, -phys_addr_t *clrspi); - -#endif /* __MVEBU_GICP_H__ */
drivers/irqchip/irq-mvebu-icu.c +17 -16
@@ -21,8 +21,6 @@#include <dt-bindings/interrupt-controller/mvebu-icu.h> -#include "irq-mvebu-gicp.h" -/* ICU registers */ #define ICU_SETSPI_NSR_AL 0x10#define ICU_SETSPI_NSR_AH 0x14
@@ -43,6 +41,7 @@ struct mvebu_icu {void __iomem *base;struct irq_domain *domain;struct device *dev; +atomic_t initialized; };struct mvebu_icu_irq_data {
@@ -51,6 +50,18 @@ struct mvebu_icu_irq_data {unsigned int type; }; +static void mvebu_icu_init (struct mvebu_icu *icu,struct msi_msg *msg) +{ +if (atomic_cmpxchg (&icu->initialized, false, true)) +return ; + +/* Set Clear/Set ICU SPI message address in AP */ +writel_relaxed (msg[0 ].address_hi, icu->base +ICU_SETSPI_NSR_AH ); +writel_relaxed (msg[0 ].address_lo, icu->base +ICU_SETSPI_NSR_AL ); +writel_relaxed (msg[1 ].address_hi, icu->base +ICU_CLRSPI_NSR_AH ); +writel_relaxed (msg[1 ].address_lo, icu->base +ICU_CLRSPI_NSR_AL ); +} +static void mvebu_icu_write_msg (struct msi_desc *desc,struct msi_msg *msg) {struct irq_data *d =irq_get_irq_data (desc->irq);
@@ -59,6 +70,8 @@ static void mvebu_icu_write_msg(struct msi_desc *desc, struct msi_msg *msg)unsigned int icu_int;if (msg->address_lo || msg->address_hi) { +/* One off initialization */ +mvebu_icu_init (icu, msg);/* Configure the ICU with irq number & type */ icu_int = msg->data |ICU_INT_ENABLE ;if (icu_irqd->type &IRQ_TYPE_EDGE_RISING )
@@ -197,9 +210,7 @@ static int mvebu_icu_probe(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;struct device_node *gicp_dn;struct resource *res; -phys_addr_t setspi, clrspi; -u32 i, icu_int; -int ret; +int i; icu =devm_kzalloc (&pdev->dev,sizeof (struct mvebu_icu ),GFP_KERNEL );
@@ -242,22 +253,12 @@ static int mvebu_icu_probe(struct platform_device *pdev)if (!gicp_dn)return -ENODEV ; - ret =mvebu_gicp_get_doorbells (gicp_dn, &setspi, &clrspi); -if (ret) -return ret; - -/* Set Clear/Set ICU SPI message address in AP */ -writel_relaxed (upper_32_bits (setspi), icu->base +ICU_SETSPI_NSR_AH ); -writel_relaxed (lower_32_bits (setspi), icu->base +ICU_SETSPI_NSR_AL ); -writel_relaxed (upper_32_bits (clrspi), icu->base +ICU_CLRSPI_NSR_AH ); -writel_relaxed (lower_32_bits (clrspi), icu->base +ICU_CLRSPI_NSR_AL ); -/* * Clean all ICU interrupts with type SPI_NSR, required to * avoid unpredictable SPI assignments done by firmware. */ for (i =0 ; i <ICU_MAX_IRQS ; i++) { - icu_int =readl (icu->base +ICU_INT_CFG (i)); +u32 icu_int =readl_relaxed (icu->base +ICU_INT_CFG (i));if ((icu_int >>ICU_GROUP_SHIFT ) ==ICU_GRP_NSR )writel_relaxed (0x0 , icu->base +ICU_INT_CFG (i)); }
Signature · 1 line
2.14.2
tip-bot for Marc Zyngier
merge bot[tip:irq/core] irqchip/mvebu-gicp: Use level-triggered MSIs between ICU and GICP
irqchip/mvebu-gicp: Use level-triggered MSIs between ICU and GICP
Commit-ID: 25eaaabb51c9925dc65f5b54fd9a362bf118e70a Gitweb: https://git.kernel.org/tip/25eaaabb51c9925dc65f5b54fd9a362bf118e70a Author: Marc Zyngier <[email protected]> AuthorDate: Tue, 8 May 2018 13:14:32 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 13 May 2018 15:59:00 +0200
irqchip/mvebu-gicp: Use level-triggered MSIs between ICU and GICP
The ICU and GICP drivers are using an ugly side-band mechanism to find out about the "clear" doorbell when using level interrupts.
Let's convert it to level-triggered MSIs, which result in a nice cleanup.
--- drivers/irqchip/irq-mvebu-gicp.c | 38 +++++++++++--------------------------- drivers/irqchip/irq-mvebu-gicp.h | 12 ------------ drivers/irqchip/irq-mvebu-icu.c | 33 +++++++++++++++++---------------- 3 files changed, 28 insertions(+), 55 deletions(-)
drivers/irqchip/irq-mvebu-gicp.c +11 -27
@@ -19,8 +19,6 @@#include <dt-bindings/interrupt-controller/arm-gic.h> -#include "irq-mvebu-gicp.h" -#define GICP_SETSPI_NSR_OFFSET 0x0#define GICP_CLRSPI_NSR_OFFSET 0x8
@@ -55,34 +53,18 @@ static int gicp_idx_to_spi(struct mvebu_gicp *gicp, int idx)return -EINVAL ; } -int mvebu_gicp_get_doorbells (struct device_node *dn,phys_addr_t *setspi, -phys_addr_t *clrspi) -{ -struct platform_device *pdev; -struct mvebu_gicp *gicp; - - pdev =of_find_device_by_node (dn); -if (!pdev) -return -ENODEV ; - - gicp =platform_get_drvdata (pdev); -if (!gicp) -return -ENODEV ; - - *setspi = gicp->res->start +GICP_SETSPI_NSR_OFFSET ; - *clrspi = gicp->res->start +GICP_CLRSPI_NSR_OFFSET ; - -return 0 ; -} -static void gicp_compose_msi_msg (struct irq_data *data,struct msi_msg *msg) {struct mvebu_gicp *gicp = data->chip_data;phys_addr_t setspi = gicp->res->start +GICP_SETSPI_NSR_OFFSET ; - - msg->data = data->hwirq; - msg->address_lo =lower_32_bits (setspi); - msg->address_hi =upper_32_bits (setspi); +phys_addr_t clrspi = gicp->res->start +GICP_CLRSPI_NSR_OFFSET ; + + msg[0 ].data = data->hwirq; + msg[0 ].address_lo =lower_32_bits (setspi); + msg[0 ].address_hi =upper_32_bits (setspi); + msg[1 ].data = data->hwirq; + msg[1 ].address_lo =lower_32_bits (clrspi); + msg[1 ].address_hi =upper_32_bits (clrspi); }static struct irq_chip gicp_irq_chip = {
@@ -170,13 +152,15 @@ static const struct irq_domain_ops gicp_domain_ops = {static struct irq_chip gicp_msi_irq_chip = { .name ="GICP" , .irq_set_type = irq_chip_set_type_parent, + .flags =IRQCHIP_SUPPORTS_LEVEL_MSI , };static struct msi_domain_ops gicp_msi_ops = { };static struct msi_domain_info gicp_msi_domain_info = { - .flags = (MSI_FLAG_USE_DEF_DOM_OPS |MSI_FLAG_USE_DEF_CHIP_OPS ), + .flags = (MSI_FLAG_USE_DEF_DOM_OPS |MSI_FLAG_USE_DEF_CHIP_OPS | +MSI_FLAG_LEVEL_CAPABLE ), .ops = &gicp_msi_ops, .chip = &gicp_msi_irq_chip, };
drivers/irqchip/irq-mvebu-gicp.h deleted +0 -12
@@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __MVEBU_GICP_H__ -#define __MVEBU_GICP_H__ - -#include <linux/types.h> - -struct device_node ; - -int mvebu_gicp_get_doorbells (struct device_node *dn,phys_addr_t *setspi, -phys_addr_t *clrspi); - -#endif /* __MVEBU_GICP_H__ */
drivers/irqchip/irq-mvebu-icu.c +17 -16
@@ -21,8 +21,6 @@#include <dt-bindings/interrupt-controller/mvebu-icu.h> -#include "irq-mvebu-gicp.h" -/* ICU registers */ #define ICU_SETSPI_NSR_AL 0x10#define ICU_SETSPI_NSR_AH 0x14
@@ -43,6 +41,7 @@ struct mvebu_icu {void __iomem *base;struct irq_domain *domain;struct device *dev; +atomic_t initialized; };struct mvebu_icu_irq_data {
@@ -51,6 +50,18 @@ struct mvebu_icu_irq_data {unsigned int type; }; +static void mvebu_icu_init (struct mvebu_icu *icu,struct msi_msg *msg) +{ +if (atomic_cmpxchg (&icu->initialized, false, true)) +return ; + +/* Set Clear/Set ICU SPI message address in AP */ +writel_relaxed (msg[0 ].address_hi, icu->base +ICU_SETSPI_NSR_AH ); +writel_relaxed (msg[0 ].address_lo, icu->base +ICU_SETSPI_NSR_AL ); +writel_relaxed (msg[1 ].address_hi, icu->base +ICU_CLRSPI_NSR_AH ); +writel_relaxed (msg[1 ].address_lo, icu->base +ICU_CLRSPI_NSR_AL ); +} +static void mvebu_icu_write_msg (struct msi_desc *desc,struct msi_msg *msg) {struct irq_data *d =irq_get_irq_data (desc->irq);
@@ -59,6 +70,8 @@ static void mvebu_icu_write_msg(struct msi_desc *desc, struct msi_msg *msg)unsigned int icu_int;if (msg->address_lo || msg->address_hi) { +/* One off initialization */ +mvebu_icu_init (icu, msg);/* Configure the ICU with irq number & type */ icu_int = msg->data |ICU_INT_ENABLE ;if (icu_irqd->type &IRQ_TYPE_EDGE_RISING )
@@ -197,9 +210,7 @@ static int mvebu_icu_probe(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;struct device_node *gicp_dn;struct resource *res; -phys_addr_t setspi, clrspi; -u32 i, icu_int; -int ret; +int i; icu =devm_kzalloc (&pdev->dev,sizeof (struct mvebu_icu ),GFP_KERNEL );
@@ -242,22 +253,12 @@ static int mvebu_icu_probe(struct platform_device *pdev)if (!gicp_dn)return -ENODEV ; - ret =mvebu_gicp_get_doorbells (gicp_dn, &setspi, &clrspi); -if (ret) -return ret; - -/* Set Clear/Set ICU SPI message address in AP */ -writel_relaxed (upper_32_bits (setspi), icu->base +ICU_SETSPI_NSR_AH ); -writel_relaxed (lower_32_bits (setspi), icu->base +ICU_SETSPI_NSR_AL ); -writel_relaxed (upper_32_bits (clrspi), icu->base +ICU_CLRSPI_NSR_AH ); -writel_relaxed (lower_32_bits (clrspi), icu->base +ICU_CLRSPI_NSR_AL ); -/* * Clean all ICU interrupts with type SPI_NSR, required to * avoid unpredictable SPI assignments done by firmware. */ for (i =0 ; i <ICU_MAX_IRQS ; i++) { - icu_int =readl (icu->base +ICU_INT_CFG (i)); +u32 icu_int =readl_relaxed (icu->base +ICU_INT_CFG (i));if ((icu_int >>ICU_GROUP_SHIFT ) ==ICU_GRP_NSR )writel_relaxed (0x0 , icu->base +ICU_INT_CFG (i)); }
PATCH v2 4/9 dma-iommu: Fix compilation when !CONFIG_IOMMU_DMA
In reply to Marc ZyngierInclusion of include/dma-iommu.h when CONFIG_IOMMU_DMA is not selected results in the following splat:
In file included from drivers/irqchip/irq-gic-v3-mbi.c:20:0:./include/linux/dma-iommu.h:95:69: error: unknown type name ‘dma_addr_t’
static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
^~~~~~~~~~
./include/linux/dma-iommu.h:108:74: warning: ‘struct list_head’ declared inside parameter list will not be visible outside of this definition or declaration
static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
^~~~~~~~~scripts/Makefile.build:312: recipe for target 'drivers/irqchip/irq-gic-v3-mbi.o' failed
Fix it by including linux/types.h.
--- include/linux/dma-iommu.h | 1 + 1 file changed, 1 insertion(+)
include/linux/dma-iommu.h +1 -0
@@ -17,6 +17,7 @@#define __DMA_IOMMU_H#ifdef __KERNEL__ +#include <linux/types.h> #include <asm/errno.h> #ifdef CONFIG_IOMMU_DMA
Signature · 1 line
2.14.2
tip-bot for Marc Zyngier
merge bot[tip:irq/core] dma-iommu: Fix compilation when !CONFIG_IOMMU_DMA
dma-iommu: Fix compilation when !CONFIG_IOMMU_DMA
Commit-ID: 8a22a3e1e768c309b718f99bd86f9f25a453e0dc Gitweb: https://git.kernel.org/tip/8a22a3e1e768c309b718f99bd86f9f25a453e0dc Author: Marc Zyngier <[email protected]> AuthorDate: Tue, 8 May 2018 13:14:33 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 13 May 2018 15:59:00 +0200
dma-iommu: Fix compilation when !CONFIG_IOMMU_DMA
Inclusion of include/dma-iommu.h when CONFIG_IOMMU_DMA is not selected results in the following splat:
In file included from drivers/irqchip/irq-gic-v3-mbi.c:20:0:./include/linux/dma-iommu.h:95:69: error: unknown type name ‘dma_addr_t’
static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
^~~~~~~~~~
./include/linux/dma-iommu.h:108:74: warning: ‘struct list_head’ declared inside parameter list will not be visible outside of this definition or declaration
static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
^~~~~~~~~scripts/Makefile.build:312: recipe for target 'drivers/irqchip/irq-gic-v3-mbi.o' failed
Fix it by including linux/types.h.
--- include/linux/dma-iommu.h | 1 + 1 file changed, 1 insertion(+)
include/linux/dma-iommu.h +1 -0
@@ -17,6 +17,7 @@#define __DMA_IOMMU_H#ifdef __KERNEL__ +#include <linux/types.h> #include <asm/errno.h> #ifdef CONFIG_IOMMU_DMA
PATCH v2 5/9 irqdomain: Let irq_find_host default to DOMAIN_BUS_WIRED
In reply to Marc ZyngierAt the beginning of times, irq_find_host() was simple. Each device node implemented at most one irq domain, and we were happy. Over time, things have become more complex, and we now have nodes implementing a plurality of domains, tagged by "bus_token".
Crutially, users of irq_find_host() all expect the most basic domain to be returned, and not any other domain such as a bus-specific MSI domain.
So let's change irq_find_host() to first look for a DOMAIN_BUS_WIRED domain, and only if this fails fallback to DOMAIN_BUS_ANY. Note that this is consistent with what irq_create_fwspec_mapping is already doing, see 530cbe100ef7 ("irqdomain: Allow domain lookup with DOMAIN_BUS_WIRED token").
--- include/linux/irqdomain.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/irqdomain.h +7 -1
@@ -301,7 +301,13 @@ static inline struct irq_domain *irq_find_matching_host(struct device_node *nodestatic inline struct irq_domain *irq_find_host (struct device_node *node) { -return irq_find_matching_host (node,DOMAIN_BUS_ANY ); +struct irq_domain *d; + + d =irq_find_matching_host (node,DOMAIN_BUS_WIRED ); +if (!d) + d =irq_find_matching_host (node,DOMAIN_BUS_ANY ); + +return d; }/**
Signature · 1 line
2.14.2
tip-bot for Marc Zyngier
merge bot[tip:irq/core] irqdomain: Let irq_find_host default to DOMAIN_BUS_WIRED
irqdomain: Let irq_find_host default to DOMAIN_BUS_WIRED
Commit-ID: 6461934371bfc1bfe6b424b197a546b4effd0a32 Gitweb: https://git.kernel.org/tip/6461934371bfc1bfe6b424b197a546b4effd0a32 Author: Marc Zyngier <[email protected]> AuthorDate: Tue, 8 May 2018 13:14:34 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 13 May 2018 15:59:00 +0200
irqdomain: Let irq_find_host default to DOMAIN_BUS_WIRED
At the beginning of times, irq_find_host() was simple. Each device node implemented at most one irq domain, and we were happy. Over time, things have become more complex, and we now have nodes implementing a plurality of domains, tagged by "bus_token".
Crutially, users of irq_find_host() all expect the most basic domain to be returned, and not any other domain such as a bus-specific MSI domain.
So let's change irq_find_host() to first look for a DOMAIN_BUS_WIRED domain, and only if this fails fallback to DOMAIN_BUS_ANY. Note that this is consistent with what irq_create_fwspec_mapping is already doing, see 530cbe100ef7 ("irqdomain: Allow domain lookup with DOMAIN_BUS_WIRED token").
--- include/linux/irqdomain.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/irqdomain.h +7 -1
@@ -301,7 +301,13 @@ static inline struct irq_domain *irq_find_matching_host(struct device_node *nodestatic inline struct irq_domain *irq_find_host (struct device_node *node) { -return irq_find_matching_host (node,DOMAIN_BUS_ANY ); +struct irq_domain *d; + + d =irq_find_matching_host (node,DOMAIN_BUS_WIRED ); +if (!d) + d =irq_find_matching_host (node,DOMAIN_BUS_ANY ); + +return d; }/**
PATCH v2 6/9 irqchip/gic-v3: Mark the base irq domain as DOMAIN_BUS_WIRED
In reply to Marc ZyngierAs we're about to introduce MSI domains based on top of the GICv3 domain, we must make sure nothing the new domains do not alias with the core domain.
So let's tag that core domain with the DOMAIN_BUS_WIRED attribute, ensuring it gets picked up by other drivers that use irq_find_host().
--- drivers/irqchip/irq-gic-v3.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/irq-gic-v3.c +1 -0
@@ -1099,6 +1099,7 @@ static int __init gic_init_bases(void __iomem *dist_base, gic_data.domain =irq_domain_create_tree (handle, &gic_irq_domain_ops, &gic_data); +irq_domain_update_bus_token (gic_data.domain,DOMAIN_BUS_WIRED ); gic_data.rdists.rdist =alloc_percpu (typeof (*gic_data.rdists.rdist)); gic_data.rdists.has_vlpis = true; gic_data.rdists.has_direct_lpi = true;
Signature · 1 line
2.14.2
tip-bot for Marc Zyngier
merge bot[tip:irq/core] irqchip/gic-v3: Mark the base irq domain as DOMAIN_BUS_WIRED
irqchip/gic-v3: Mark the base irq domain as DOMAIN_BUS_WIRED
Commit-ID: b2425b51bed7437c08c11ce71bb0f308f4516451 Gitweb: https://git.kernel.org/tip/b2425b51bed7437c08c11ce71bb0f308f4516451 Author: Marc Zyngier <[email protected]> AuthorDate: Tue, 8 May 2018 13:14:35 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 13 May 2018 15:59:01 +0200
irqchip/gic-v3: Mark the base irq domain as DOMAIN_BUS_WIRED
As we're about to introduce MSI domains based on top of the GICv3 domain, we must make sure nothing the new domains do not alias with the core domain.
So let's tag that core domain with the DOMAIN_BUS_WIRED attribute, ensuring it gets picked up by other drivers that use irq_find_host().
--- drivers/irqchip/irq-gic-v3.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/irq-gic-v3.c +1 -0
@@ -1099,6 +1099,7 @@ static int __init gic_init_bases(void __iomem *dist_base, gic_data.domain =irq_domain_create_tree (handle, &gic_irq_domain_ops, &gic_data); +irq_domain_update_bus_token (gic_data.domain,DOMAIN_BUS_WIRED ); gic_data.rdists.rdist =alloc_percpu (typeof (*gic_data.rdists.rdist)); gic_data.rdists.has_vlpis = true; gic_data.rdists.has_direct_lpi = true;
PATCH v2 7/9 irqchip/gic-v3: Add support for Message Based Interrupts as an MSI controller
In reply to Marc ZyngierGICv3 offers the possibility to signal SPIs using a pair of doorbells (SETPI, CLRSPI) under the name of Message Based Interrupts (MBI). They can be used as either traditional (edge) MSIs, or the more exotic level-triggered flavour.
Let's implement support for platform MSI, which is the original intent for this feature.
--- drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-gic-v3-mbi.c | 275 +++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic-v3.c | 6 + include/linux/irqchip/arm-gic-v3.h | 1 + 4 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-gic-v3-mbi.c
drivers/irqchip/Makefile +1 -1
@@ -27,7 +27,7 @@ obj-$(CONFIG_ARM_GIC) += irq-gic.o irq-gic-common.o obj-$(CONFIG_ARM_GIC_PM) += irq-gic-pm.o obj-$(CONFIG_ARCH_REALVIEW) += irq-gic-realview.o obj-$(CONFIG_ARM_GIC_V2M) += irq-gic-v2m.o -obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-common.o +obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-v3-mbi.o irq-gic-common.o obj-$(CONFIG_ARM_GIC_V3_ITS) += irq-gic-v3-its.o irq-gic-v3-its-platform-msi.o irq-gic-v4.o obj-$(CONFIG_ARM_GIC_V3_ITS_PCI) += irq-gic-v3-its-pci-msi.o obj-$(CONFIG_ARM_GIC_V3_ITS_FSL_MC) += irq-gic-v3-its-fsl-mc-msi.o
drivers/irqchip/irq-gic-v3-mbi.c new file +275 -0
275 lines not on this page · raw message
drivers/irqchip/irq-gic-v3.c +6 -0
@@ -1113,6 +1113,12 @@ static int __init gic_init_bases(void __iomem *dist_base,pr_info ("Distributor has %sRange Selector support\n" , gic_data.has_rss ?"" :"no " ); +if (typer &GICD_TYPER_MBIS ) { + err =mbi_init (handle, gic_data.domain); +if (err) +pr_err ("Failed to initialize MBIs\n" ); + } +set_handle_irq (gic_handle_irq);gic_update_vlpi_properties ();
include/linux/irqchip/arm-gic-v3.h +1 -0
@@ -587,6 +587,7 @@ struct fwnode_handle;int its_cpu_init (void );int its_init (struct fwnode_handle *handle,struct rdists *rdists,struct irq_domain *domain); +int mbi_init (struct fwnode_handle *fwnode,struct irq_domain *parent);static inline bool gic_enable_sre (void ) {
Signature · 1 line
2.14.2
tip-bot for Marc Zyngier
merge bot[tip:irq/core] irqchip/gic-v3: Add support for Message Based Interrupts as an MSI controller
irqchip/gic-v3: Add support for Message Based Interrupts as an MSI controller
Commit-ID: 505287525c24d5c78b662fd73721ad9900b91fcc Gitweb: https://git.kernel.org/tip/505287525c24d5c78b662fd73721ad9900b91fcc Author: Marc Zyngier <[email protected]> AuthorDate: Tue, 8 May 2018 13:14:36 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 13 May 2018 15:59:01 +0200
irqchip/gic-v3: Add support for Message Based Interrupts as an MSI controller
GICv3 offers the possibility to signal SPIs using a pair of doorbells (SETPI, CLRSPI) under the name of Message Based Interrupts (MBI). They can be used as either traditional (edge) MSIs, or the more exotic level-triggered flavour.
Let's implement support for platform MSI, which is the original intent for this feature.
--- drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-gic-v3-mbi.c | 275 +++++++++++++++++++++++++++++++++++++ drivers/irqchip/irq-gic-v3.c | 6 + include/linux/irqchip/arm-gic-v3.h | 1 + 4 files changed, 283 insertions(+), 1 deletion(-)
drivers/irqchip/Makefile +1 -1
@@ -27,7 +27,7 @@ obj-$(CONFIG_ARM_GIC) += irq-gic.o irq-gic-common.o obj-$(CONFIG_ARM_GIC_PM) += irq-gic-pm.o obj-$(CONFIG_ARCH_REALVIEW) += irq-gic-realview.o obj-$(CONFIG_ARM_GIC_V2M) += irq-gic-v2m.o -obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-common.o +obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-v3-mbi.o irq-gic-common.o obj-$(CONFIG_ARM_GIC_V3_ITS) += irq-gic-v3-its.o irq-gic-v3-its-platform-msi.o irq-gic-v4.o obj-$(CONFIG_ARM_GIC_V3_ITS_PCI) += irq-gic-v3-its-pci-msi.o obj-$(CONFIG_ARM_GIC_V3_ITS_FSL_MC) += irq-gic-v3-its-fsl-mc-msi.o
drivers/irqchip/irq-gic-v3-mbi.c new file +275 -0
275 lines not on this page · raw message
drivers/irqchip/irq-gic-v3.c +6 -0
@@ -1113,6 +1113,12 @@ static int __init gic_init_bases(void __iomem *dist_base,pr_info ("Distributor has %sRange Selector support\n" , gic_data.has_rss ?"" :"no " ); +if (typer &GICD_TYPER_MBIS ) { + err =mbi_init (handle, gic_data.domain); +if (err) +pr_err ("Failed to initialize MBIs\n" ); + } +set_handle_irq (gic_handle_irq);gic_update_vlpi_properties ();
include/linux/irqchip/arm-gic-v3.h +1 -0
@@ -587,6 +587,7 @@ struct fwnode_handle;int its_cpu_init (void );int its_init (struct fwnode_handle *handle,struct rdists *rdists,struct irq_domain *domain); +int mbi_init (struct fwnode_handle *fwnode,struct irq_domain *parent);static inline bool gic_enable_sre (void ) {
PATCH v2 8/9 irqchip/gic-v3: Add PCI/MSI support to the GICv3 MBI sub-driver
In reply to Marc ZyngierYou would hope that if you have a GICv3 in your system, you'd use the ITS, as it provides a large interrupt ID space and device isolation. Sadly, some SoC integrations are less than perfect, and the ITS is not usesable on those.
The only solution for these systems is to use the MBI interface, and rely on a very small number of possible vectors.
This patch thus adds minimal support for PCI/MSI on top of the GICv3 MBI driver. Please don't use it if you can avoid it.
--- drivers/irqchip/irq-gic-v3-mbi.c | 62 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-)
drivers/irqchip/irq-gic-v3-mbi.c +59 -3
@@ -12,6 +12,7 @@#include <linux/kernel.h> #include <linux/msi.h> #include <linux/of_address.h> +#include <linux/of_pci.h> #include <linux/slab.h> #include <linux/spinlock.h>
@@ -144,6 +145,55 @@ static void mbi_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)iommu_dma_map_msi_msg (data->irq, msg); } +#ifdef CONFIG_PCI_MSI +/* PCI-specific irqchip */ +static void mbi_mask_msi_irq (struct irq_data *d) +{ +pci_msi_mask_irq (d); +irq_chip_mask_parent (d); +} + +static void mbi_unmask_msi_irq (struct irq_data *d) +{ +pci_msi_unmask_irq (d); +irq_chip_unmask_parent (d); +} + +static struct irq_chip mbi_msi_irq_chip = { + .name ="MSI" , + .irq_mask = mbi_mask_msi_irq, + .irq_unmask = mbi_unmask_msi_irq, + .irq_eoi = irq_chip_eoi_parent, + .irq_compose_msi_msg = mbi_compose_msi_msg, + .irq_write_msi_msg = pci_msi_domain_write_msg, +}; + +static struct msi_domain_info mbi_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS |MSI_FLAG_USE_DEF_CHIP_OPS | +MSI_FLAG_PCI_MSIX |MSI_FLAG_MULTI_PCI_MSI ), + .chip = &mbi_msi_irq_chip, +}; + +static int mbi_allocate_pci_domain (struct irq_domain *nexus_domain, +struct irq_domain **pci_domain) +{ + *pci_domain =pci_msi_create_irq_domain (nexus_domain->parent->fwnode, + &mbi_msi_domain_info, + nexus_domain); +if (!*pci_domain) +return -ENOMEM ; + +return 0 ; +} +#else +static int mbi_allocate_pci_domain (struct irq_domain *nexus_domain, +struct irq_domain **pci_domain) +{ + *pci_domain =NULL ; +return 0 ; +} +#endif +static void mbi_compose_mbi_msg (struct irq_data *data,struct msi_msg *msg) {mbi_compose_msi_msg (data, msg);
@@ -175,7 +225,8 @@ static struct msi_domain_info mbi_pmsi_domain_info = {static int mbi_allocate_domains (struct irq_domain *parent) { -struct irq_domain *nexus_domain, *plat_domain; +struct irq_domain *nexus_domain, *pci_domain, *plat_domain; +int err; nexus_domain =irq_domain_create_tree (parent->fwnode, &mbi_domain_ops,NULL );
@@ -185,12 +236,17 @@ static int mbi_allocate_domains(struct irq_domain *parent)irq_domain_update_bus_token (nexus_domain,DOMAIN_BUS_NEXUS ); nexus_domain->parent = parent; + err =mbi_allocate_pci_domain (nexus_domain, &pci_domain); + plat_domain =platform_msi_create_irq_domain (parent->fwnode, &mbi_pmsi_domain_info, nexus_domain); -if (!plat_domain) { -irq_domain_remove (plat_domain); +if (err || !plat_domain) { +if (plat_domain) +irq_domain_remove (plat_domain); +if (pci_domain) +irq_domain_remove (pci_domain);irq_domain_remove (nexus_domain);return -ENOMEM ; }
Signature · 1 line
2.14.2
tip-bot for Marc Zyngier
merge bot[tip:irq/core] irqchip/gic-v3: Add PCI/MSI support to the GICv3 MBI sub-driver
irqchip/gic-v3: Add PCI/MSI support to the GICv3 MBI sub-driver
Commit-ID: 38985351492b4ef2f63ffe527ef7cdfa66680f94 Gitweb: https://git.kernel.org/tip/38985351492b4ef2f63ffe527ef7cdfa66680f94 Author: Marc Zyngier <[email protected]> AuthorDate: Tue, 8 May 2018 13:14:37 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 13 May 2018 15:59:01 +0200
irqchip/gic-v3: Add PCI/MSI support to the GICv3 MBI sub-driver
You would hope that if you have a GICv3 in your system, you'd use the ITS, as it provides a large interrupt ID space and device isolation. Sadly, some SoC integrations are less than perfect, and the ITS is not usesable on those.
The only solution for these systems is to use the MBI interface, and rely on a very small number of possible vectors.
This patch thus adds minimal support for PCI/MSI on top of the GICv3 MBI driver. Please don't use it if you can avoid it.
--- drivers/irqchip/irq-gic-v3-mbi.c | 62 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-)
drivers/irqchip/irq-gic-v3-mbi.c +59 -3
@@ -12,6 +12,7 @@#include <linux/kernel.h> #include <linux/msi.h> #include <linux/of_address.h> +#include <linux/of_pci.h> #include <linux/slab.h> #include <linux/spinlock.h>
@@ -144,6 +145,55 @@ static void mbi_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)iommu_dma_map_msi_msg (data->irq, msg); } +#ifdef CONFIG_PCI_MSI +/* PCI-specific irqchip */ +static void mbi_mask_msi_irq (struct irq_data *d) +{ +pci_msi_mask_irq (d); +irq_chip_mask_parent (d); +} + +static void mbi_unmask_msi_irq (struct irq_data *d) +{ +pci_msi_unmask_irq (d); +irq_chip_unmask_parent (d); +} + +static struct irq_chip mbi_msi_irq_chip = { + .name ="MSI" , + .irq_mask = mbi_mask_msi_irq, + .irq_unmask = mbi_unmask_msi_irq, + .irq_eoi = irq_chip_eoi_parent, + .irq_compose_msi_msg = mbi_compose_msi_msg, + .irq_write_msi_msg = pci_msi_domain_write_msg, +}; + +static struct msi_domain_info mbi_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS |MSI_FLAG_USE_DEF_CHIP_OPS | +MSI_FLAG_PCI_MSIX |MSI_FLAG_MULTI_PCI_MSI ), + .chip = &mbi_msi_irq_chip, +}; + +static int mbi_allocate_pci_domain (struct irq_domain *nexus_domain, +struct irq_domain **pci_domain) +{ + *pci_domain =pci_msi_create_irq_domain (nexus_domain->parent->fwnode, + &mbi_msi_domain_info, + nexus_domain); +if (!*pci_domain) +return -ENOMEM ; + +return 0 ; +} +#else +static int mbi_allocate_pci_domain (struct irq_domain *nexus_domain, +struct irq_domain **pci_domain) +{ + *pci_domain =NULL ; +return 0 ; +} +#endif +static void mbi_compose_mbi_msg (struct irq_data *data,struct msi_msg *msg) {mbi_compose_msi_msg (data, msg);
@@ -175,7 +225,8 @@ static struct msi_domain_info mbi_pmsi_domain_info = {static int mbi_allocate_domains (struct irq_domain *parent) { -struct irq_domain *nexus_domain, *plat_domain; +struct irq_domain *nexus_domain, *pci_domain, *plat_domain; +int err; nexus_domain =irq_domain_create_tree (parent->fwnode, &mbi_domain_ops,NULL );
@@ -185,12 +236,17 @@ static int mbi_allocate_domains(struct irq_domain *parent)irq_domain_update_bus_token (nexus_domain,DOMAIN_BUS_NEXUS ); nexus_domain->parent = parent; + err =mbi_allocate_pci_domain (nexus_domain, &pci_domain); + plat_domain =platform_msi_create_irq_domain (parent->fwnode, &mbi_pmsi_domain_info, nexus_domain); -if (!plat_domain) { -irq_domain_remove (plat_domain); +if (err || !plat_domain) { +if (plat_domain) +irq_domain_remove (plat_domain); +if (pci_domain) +irq_domain_remove (pci_domain);irq_domain_remove (nexus_domain);return -ENOMEM ; }
PATCH v2 9/9 dt-bindings/gic-v3: Add documentation for MBI support
In reply to Marc ZyngierAdd the required properties to support the MBI feature on GICv3.
--- .../bindings/interrupt-controller/arm,gic-v3.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt +17 -0
@@ -57,6 +57,20 @@ Optional occupied by the redistributors. Required if more than one such region is present. +- msi-controller: Boolean property. Identifies the node as an MSI + controller. Only present if the Message Based Interrupt + functionnality is being exposed by the HW, and the mbi-ranges + property present. + +- mbi-ranges: A list of pairs <intid span>, where "intid" is the first + SPI of a range that can be used an MBI, and "span" the size of that + range. Multiple ranges can be provided. Requires "msi-controller" to + be set. + +- mbi-alias: Address property. Base address of an alias of the GICD + region containing only the {SET,CLR}SPI registers to be used if + isolation is required, and if supported by the HW. + Sub-nodes: PPI affinity can be expressed as a single "ppi-partitions" node,
@@ -99,6 +113,9 @@ Examples: <0x0 0x2c020000 0 0x2000>; // GICV interrupts = <1 9 4>; + msi-controller; + mbi-ranges = <256 128>; + gic-its@2c200000 { compatible = "arm,gic-v3-its"; msi-controller;
Signature · 1 line
2.14.2
tip-bot for Marc Zyngier
merge bot[tip:irq/core] dt-bindings/gic-v3: Add documentation for MBI support
dt-bindings/gic-v3: Add documentation for MBI support
Commit-ID: 53667c670fe00d63246fb3cfb4480bb1ba247bcc Gitweb: https://git.kernel.org/tip/53667c670fe00d63246fb3cfb4480bb1ba247bcc Author: Marc Zyngier <[email protected]> AuthorDate: Tue, 8 May 2018 13:14:38 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 13 May 2018 15:59:02 +0200
dt-bindings/gic-v3: Add documentation for MBI support
Add the required properties to support the MBI feature on GICv3.
--- .../bindings/interrupt-controller/arm,gic-v3.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt +17 -0
@@ -57,6 +57,20 @@ Optional occupied by the redistributors. Required if more than one such region is present. +- msi-controller: Boolean property. Identifies the node as an MSI + controller. Only present if the Message Based Interrupt + functionnality is being exposed by the HW, and the mbi-ranges + property present. + +- mbi-ranges: A list of pairs <intid span>, where "intid" is the first + SPI of a range that can be used an MBI, and "span" the size of that + range. Multiple ranges can be provided. Requires "msi-controller" to + be set. + +- mbi-alias: Address property. Base address of an alias of the GICD + region containing only the {SET,CLR}SPI registers to be used if + isolation is required, and if supported by the HW. + Sub-nodes: PPI affinity can be expressed as a single "ppi-partitions" node,
@@ -99,6 +113,9 @@ Examples: <0x0 0x2c020000 0 0x2000>; // GICV interrupts = <1 9 4>; + msi-controller; + mbi-ranges = <256 128>; + gic-its@2c200000 { compatible = "arm,gic-v3-its"; msi-controller;