Skip to contentSkip to conversation

Amazon's Annapurna Labs Fabric Interrupt Controller

PATCH Superseded Talel Shenhar 3 participants 10 messages Jun 5, 2019 – Jun 6, 2019

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Talel Shenhar

author maintainer
#0 lore raw

cover Amazon's Annapurna Labs Fabric Interrupt Controller

This series introduces support for Amazon's Annapurna Labs Fabric Interrupt Controller.

The Amazon's Annapurna Labs FIC (Fabric Interrupt Controller) has 32 inputs/sources. The output of this interrupt controller can be legacy-wired output or, in case embedded inside PCIe devices, msi-x message. This FIC may be cascaded into another FIC or connected directly to the main CPU Interrupt Controller (e.g. GIC).

The FIC is a flexible HW unit that is embedded inside different parts of the Amazon's Annapurna Labs chips. It can be a simple level 2 interrupt controller which is then configured as a wired interrupt controller that aggregates events from different units, or, while embedded inside PCIe device, it can generate MSI-X messages based on the tables configured to that PCIe device or can be configured to generate wired interrupt.

Talel Shenhar (3):
dt-bindings: interrupt-controller: Amazon's Annapurna Labs FIC
irqchip: al-fic: Introduce Amazon's Annapurna Labs Fabric Interrupt
Controller Driver
irqchip: al-fic: Introducing support for MSI-X

 .../interrupt-controller/amazon,al-fic.txt         |  22 ++
 MAINTAINERS                                        |   7 +
 drivers/irqchip/Kconfig                            |  11 +
 drivers/irqchip/Makefile                           |   1 +
 drivers/irqchip/irq-al-fic.c                       | 388 +++++++++++++++++++++
 include/linux/irqchip/al-fic.h                     |  23 ++
 6 files changed, 452 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/amazon,al-fic.txt
 create mode 100644 drivers/irqchip/irq-al-fic.c
 create mode 100644 include/linux/irqchip/al-fic.h
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH 1/3 dt-bindings: interrupt-controller: Amazon's Annapurna Labs FIC

Document Amazon's Annapurna Labs Fabric Interrupt Controller SoC binding.

---
 .../interrupt-controller/amazon,al-fic.txt         | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/amazon,al-fic.txt
Documentation/devicetree/bindings/interrupt-controller/amazon,al-fic.txt new file +22 -0
new file mode 100644
index 0000000..a2f31a6
@@ -0,0 +1,22 @@
+Amazon's Annapurna Labs Fabric Interrupt Controller
+
+Required properties:
+
+- compatible: should be "amazon,al-fic"
+- reg: physical base address and size of the registers
+- interrupt-controller: identifies the node as an interrupt controller
+- #interrupt-cells: must be 2.
+- interrupt-parent: specifies the parent interrupt controller.
+- interrupts: describes which input line in the interrupt parent, this
+  fic's output is connected to.
+
+Example:
+
+amazon_fic: amazon_fic {
+	compatible = "amazon,al-fic";
+	interrupt-controller;
+	#interrupt-cells = <1>;
+	reg = <0x0 0xfd8a8500 0x0 0x1000>;
+	interrupt-parent = <&gic>;
+	interrupts = <GIC_SPI 0x0 IRQ_TYPE_LEVEL_HIGH>;
+};
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

PATCH 2/3 irqchip: al-fic: Introduce Amazon's Annapurna Labs Fabric Interrupt Controller Driver

In reply to Talel Shenhar

The Amazon's Annapurna Labs Fabric Interrupt Controller has 32 inputs lines. A FIC (Fabric Interrupt Controller) may be cascaded into another FIC or directly to the main CPU Interrupt Controller (e.g. GIC).

This driver introduces support for initialization based on device-tree compatibility and run-time for dynamically added FICs (e.g. FICs embedded to PCIe devices).

---
 MAINTAINERS                    |   7 +
 drivers/irqchip/Kconfig        |  11 ++
 drivers/irqchip/Makefile       |   1 +
 drivers/irqchip/irq-al-fic.c   | 346 +++++++++++++++++++++++++++++++++++++++++
 include/linux/irqchip/al-fic.h |  21 +++
 5 files changed, 386 insertions(+)
 create mode 100644 drivers/irqchip/irq-al-fic.c
 create mode 100644 include/linux/irqchip/al-fic.h
MAINTAINERS +7 -0
index f485597..c28a97f 100644
@@ -1209,6 +1209,13 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/interrupt-controller/arm,vic.txt
 F:	drivers/irqchip/irq-vic.c
 
+AMAZON ANNAPURNA LABS FIC DRIVER
+M:	Talel Shenhar <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/interrupt-controller/amazon,al-fic.txt
+F:	drivers/irqchip/irq-al-fic.c
+F:	include/linux/irqchip/al-fic.h
+
 ARM SMMU DRIVERS
 M:	Will Deacon <[email protected]>
 R:	Robin Murphy <[email protected]>
drivers/irqchip/Kconfig +11 -0
index 51a5ef0..1e51f0f 100644
@@ -89,6 +89,17 @@ config ALPINE_MSI
 	select PCI_MSI
 	select GENERIC_IRQ_CHIP
 
+config AL_FIC
+	bool "Amazon's Annapurna Labs Fabric Interrupt Controller"
+	depends on OF || COMPILE_TEST
+	select GENERIC_IRQ_CHIP
+	select IRQ_DOMAIN
+	select GENERIC_IRQ_MULTI_HANDLER
+	select IRQ_DOMAIN_HIERARCHY
+	select SPARSE_IRQ
+	help
+	  Support Amazon's Annapurna Labs Fabric Interrupt Controller.
+
 config ATMEL_AIC_IRQ
 	bool
 	select GENERIC_IRQ_CHIP
drivers/irqchip/Makefile +1 -0
index 794c13d..a20eba5 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_IRQCHIP)			+= irqchip.o
 
+obj-$(CONFIG_AL_FIC)			+= irq-al-fic.o
 obj-$(CONFIG_ALPINE_MSI)		+= irq-alpine-msi.o
 obj-$(CONFIG_ATH79)			+= irq-ath79-cpu.o
 obj-$(CONFIG_ATH79)			+= irq-ath79-misc.o
drivers/irqchip/irq-al-fic.c new file +346 -0

346 lines not on this page · raw message

include/linux/irqchip/al-fic.h new file +21 -0
new file mode 100644
index 0000000..0833749
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/**
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ */
+
+#ifndef _AL_FIC_H_
+#define _AL_FIC_H_
+
+#include <linux/irqdomain.h>
+
+struct al_fic;
+
+struct irq_domain *al_fic_wire_get_domain(struct al_fic *fic);
+
+struct al_fic *al_fic_wire_init(struct device_node *node,
+				void __iomem *base,
+				const char *name,
+				unsigned int parent_irq);
+int al_fic_cleanup(struct al_fic *fic);
+
+#endif
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH 2/3] irqchip: al-fic: Introduce Amazon's Annapurna Labs Fabric Interrupt Controller Driver

Quoted 12 lines · Talel Shenhar
include/linux/irqchip/al-fic.h new file +9 -0
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/**
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ */
+
+#ifndef _AL_FIC_H_
+#define _AL_FIC_H_
+
+#include <linux/irqdomain.h>

include/linux/irqchip/al-fic.h line 19

Quoted 10 lines
include/linux/irqchip/al-fic.h new file +10 -0
+
+struct al_fic;
+
+struct irq_domain *al_fic_wire_get_domain(struct al_fic *fic);
+
+struct al_fic *al_fic_wire_init(struct device_node *node,
+				void __iomem *base,
+				const char *name,
+				unsigned int parent_irq);
+int al_fic_cleanup(struct al_fic *fic);

Who is using these new functions? We don't add new apis that no one uses :(

thanks,

greg k-h

#4 lore raw

Re: [PATCH 2/3] irqchip: al-fic: Introduce Amazon's Annapurna Labs Fabric Interrupt Controller Driver

Quoted 11 lines · Greg KH

include/linux/irqchip/al-fic.h line 19

Quoted 8 lines
include/linux/irqchip/al-fic.h new file +7 -0
+struct irq_domain *al_fic_wire_get_domain(struct al_fic *fic);
+
+struct al_fic *al_fic_wire_init(struct device_node *node,
+				void __iomem *base,
+				const char *name,
+				unsigned int parent_irq);
+int al_fic_cleanup(struct al_fic *fic);

Who is using these new functions? We don't add new apis that no one uses :(

They will be used by subsequent driver submissions but those aren't quite ready yet, so we can hold onto patch 3 for now until they are.

Cheers,
Ben.

#5 lore raw

Re: [PATCH 2/3] irqchip: al-fic: Introduce Amazon's Annapurna Labs Fabric Interrupt Controller Driver

Quoted 13 lines · Benjamin Herrenschmidt
Quoted 11 lines · Greg KH

include/linux/irqchip/al-fic.h line 19

Quoted 8 lines
include/linux/irqchip/al-fic.h new file +7 -0
+struct irq_domain *al_fic_wire_get_domain(struct al_fic *fic);
+
+struct al_fic *al_fic_wire_init(struct device_node *node,
+				void __iomem *base,
+				const char *name,
+				unsigned int parent_irq);
+int al_fic_cleanup(struct al_fic *fic);

Who is using these new functions? We don't add new apis that no one uses :(

Quoted 2 lines

They will be used by subsequent driver submissions but those aren't quite ready yet, so we can hold onto patch 3 for now until they are.

Patch 2 also should have these removed :)

You know we don't add new apis until we have a real, in-kernel user for them...

thanks,

greg k-h

#6 lore raw

Re: [PATCH 2/3] irqchip: al-fic: Introduce Amazon's Annapurna Labs Fabric Interrupt Controller Driver

Quoted 14 lines · Greg KH
Quoted 13 lines · Benjamin Herrenschmidt
Quoted 11 lines · Greg KH

include/linux/irqchip/al-fic.h line 19

Quoted 8 lines
include/linux/irqchip/al-fic.h new file +7 -0
+struct irq_domain *al_fic_wire_get_domain(struct al_fic *fic);
+
+struct al_fic *al_fic_wire_init(struct device_node *node,
+				void __iomem *base,
+				const char *name,
+				unsigned int parent_irq);
+int al_fic_cleanup(struct al_fic *fic);

Who is using these new functions? We don't add new apis that no one uses :(

Quoted 4 lines
Quoted 2 lines

They will be used by subsequent driver submissions but those aren't quite ready yet, so we can hold onto patch 3 for now until they are.

Patch 2 also should have these removed :)

That's a mistake, that export should have been in patch3. Talel, pls fix that in your next spin.

Quoted 2 lines

You know we don't add new apis until we have a real, in-kernel user for them...

Yup, the user are going to be drivers in other subsystems, so coordination is a bit tricky, which is I think why Talel wanted to submit that now, but the patches for those other drivers aren't quite ready yet so we can hold onto that one for the time being.

It's nothing nefarious :-) Just coordination issues.

Cheers,
Ben.

Quoted 3 lines

thanks,

greg k-h

#7 lore raw

Re: [PATCH 2/3] irqchip: al-fic: Introduce Amazon's Annapurna Labs Fabric Interrupt Controller Driver

Quoted 15 lines · Benjamin Herrenschmidt
Quoted 14 lines · Greg KH
Quoted 13 lines · Benjamin Herrenschmidt
Quoted 11 lines · Greg KH

include/linux/irqchip/al-fic.h line 19

Quoted 8 lines
include/linux/irqchip/al-fic.h new file +7 -0
+struct irq_domain *al_fic_wire_get_domain(struct al_fic *fic);
+
+struct al_fic *al_fic_wire_init(struct device_node *node,
+				void __iomem *base,
+				const char *name,
+				unsigned int parent_irq);
+int al_fic_cleanup(struct al_fic *fic);

Who is using these new functions? We don't add new apis that no one uses :(

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

They will be used by subsequent driver submissions but those aren't quite ready yet, so we can hold onto patch 3 for now until they are.

Patch 2 also should have these removed :)

That's a mistake, that export should have been in patch3. Talel, pls fix that in your next spin.

Actually that's already fixed in v2 of the series. The API have been removed for now.

Cheers,
Ben.

author maintainer
#8 lore raw

PATCH 3/3 irqchip: al-fic: Introducing support for MSI-X

In reply to Talel Shenhar

The FIC supports either a (single) wired output, or generation of an MSI-X interrupt per input (for cases where it is embedded in a PCIe device, hence, allowing the PCIe drivers to call this API).
This patch introduces the support for allowing the configuration of MSI-X instead of a wire interrupt.

---
 drivers/irqchip/irq-al-fic.c   | 48 +++++++++++++++++++++++++++++++++++++++---
 include/linux/irqchip/al-fic.h |  2 ++
 2 files changed, 47 insertions(+), 3 deletions(-)
drivers/irqchip/irq-al-fic.c +45 -3
index d881d42..e49b912 100644
@@ -19,6 +19,7 @@
 #define AL_FIC_MASK		0x10
 #define AL_FIC_CONTROL		0x28
 
+#define CONTROL_AUTO_CLEAR	BIT(2)
 #define CONTROL_TRIGGER_RISING	BIT(3)
 #define CONTROL_MASK_MSI_X	BIT(5)
 
@@ -193,9 +194,11 @@ struct irq_domain *al_fic_wire_get_domain(struct al_fic *fic)
 }
 EXPORT_SYMBOL_GPL(al_fic_wire_get_domain);
 
-static void al_fic_hw_init(struct al_fic *fic)
+static void al_fic_hw_init(struct al_fic *fic,
+			   int use_msi)
 {
-	u32 control = CONTROL_MASK_MSI_X;
+	u32 control = (use_msi ? (CONTROL_AUTO_CLEAR | CONTROL_TRIGGER_RISING) :
+		       CONTROL_MASK_MSI_X);
 
 	/* mask out all interrupts */
 	writel(0xFFFFFFFF, fic->base + AL_FIC_MASK);
@@ -240,7 +243,7 @@ struct al_fic *al_fic_wire_init(struct device_node *node,
 	fic->parent_irq = parent_irq;
 	fic->name = (name ?: "al-fic-wire");
 
-	al_fic_hw_init(fic);
+	al_fic_hw_init(fic, false);
 
 	ret = al_fic_register(node, fic);
 	if (ret) {
@@ -260,6 +263,45 @@ struct al_fic *al_fic_wire_init(struct device_node *node,
 EXPORT_SYMBOL_GPL(al_fic_wire_init);
 
 /**
+ * al_fic_msi_x_init() - initialize and configure fic in msi-x mode
+ * @base: mmio to fic register
+ * @name: name of the fic
+ *
+ * This API will configure the fic hardware to to work in msi-x mode.
+ * msi-x fic is to be configured for fics that are embedded inside AL PCIE EP.
+ * Those kind of fic are aware of the fact that they live inside PCIE and
+ * familiar with the MSI-X table which is configured as part of
+ * pci_enable_msix_range() and friends.
+ * Interrupt can be generated based on a positive edge or level - configuration
+ * is to be determined based on connected hardware to this fic.
+ *
+ * Returns pointer to fic context or ERR_PTR in case of error.
+ */
+struct al_fic *al_fic_msi_x_init(void __iomem *base,
+				 const char *name)
+{
+	struct al_fic *fic;
+
+	if (!base)
+		return ERR_PTR(-EINVAL);
+
+	fic = kzalloc(sizeof(*fic), GFP_KERNEL);
+	if (!fic)
+		return ERR_PTR(-ENOMEM);
+
+	fic->base = base;
+	fic->name = (name ?: "al-fic-full-fledged");
+
+	al_fic_hw_init(fic, true);
+
+	pr_debug("%s initialized successfully in Full-Fledged mode\n",
+		 fic->name);
+
+	return fic;
+}
+EXPORT_SYMBOL_GPL(al_fic_msi_x_init);
+
+/**
  * al_fic_cleanup() - free all resources allocated by fic
  * @fic: pointer to fic context
  *
include/linux/irqchip/al-fic.h +2 -0
index 0833749..a2e89ff 100644
@@ -16,6 +16,8 @@ struct al_fic *al_fic_wire_init(struct device_node *node,
 				void __iomem *base,
 				const char *name,
 				unsigned int parent_irq);
+struct al_fic *al_fic_msi_x_init(void __iomem *base,
+				 const char *name);
 int al_fic_cleanup(struct al_fic *fic);
 
 #endif
Signature · 1 line
2.7.4
#9 lore raw

Re: [PATCH 3/3] irqchip: al-fic: Introducing support for MSI-X

Quoted 98 lines · Talel Shenhar

The FIC supports either a (single) wired output, or generation of an MSI-X interrupt per input (for cases where it is embedded in a PCIe device, hence, allowing the PCIe drivers to call this API).
This patch introduces the support for allowing the configuration of MSI-X instead of a wire interrupt.

---
 drivers/irqchip/irq-al-fic.c   | 48 +++++++++++++++++++++++++++++++++++++++---
 include/linux/irqchip/al-fic.h |  2 ++
 2 files changed, 47 insertions(+), 3 deletions(-)
drivers/irqchip/irq-al-fic.c +45 -3
index d881d42..e49b912 100644
@@ -19,6 +19,7 @@
 #define AL_FIC_MASK		0x10
 #define AL_FIC_CONTROL		0x28
 
+#define CONTROL_AUTO_CLEAR	BIT(2)
 #define CONTROL_TRIGGER_RISING	BIT(3)
 #define CONTROL_MASK_MSI_X	BIT(5)
 
@@ -193,9 +194,11 @@ struct irq_domain *al_fic_wire_get_domain(struct al_fic *fic)
 }
 EXPORT_SYMBOL_GPL(al_fic_wire_get_domain);
 
-static void al_fic_hw_init(struct al_fic *fic)
+static void al_fic_hw_init(struct al_fic *fic,
+			   int use_msi)
 {
-	u32 control = CONTROL_MASK_MSI_X;
+	u32 control = (use_msi ? (CONTROL_AUTO_CLEAR | CONTROL_TRIGGER_RISING) :
+		       CONTROL_MASK_MSI_X);
 
 	/* mask out all interrupts */
 	writel(0xFFFFFFFF, fic->base + AL_FIC_MASK);
@@ -240,7 +243,7 @@ struct al_fic *al_fic_wire_init(struct device_node *node,
 	fic->parent_irq = parent_irq;
 	fic->name = (name ?: "al-fic-wire");
 
-	al_fic_hw_init(fic);
+	al_fic_hw_init(fic, false);
 
 	ret = al_fic_register(node, fic);
 	if (ret) {
@@ -260,6 +263,45 @@ struct al_fic *al_fic_wire_init(struct device_node *node,
 EXPORT_SYMBOL_GPL(al_fic_wire_init);
 
 /**
+ * al_fic_msi_x_init() - initialize and configure fic in msi-x mode
+ * @base: mmio to fic register
+ * @name: name of the fic
+ *
+ * This API will configure the fic hardware to to work in msi-x mode.
+ * msi-x fic is to be configured for fics that are embedded inside AL PCIE EP.
+ * Those kind of fic are aware of the fact that they live inside PCIE and
+ * familiar with the MSI-X table which is configured as part of
+ * pci_enable_msix_range() and friends.
+ * Interrupt can be generated based on a positive edge or level - configuration
+ * is to be determined based on connected hardware to this fic.
+ *
+ * Returns pointer to fic context or ERR_PTR in case of error.
+ */
+struct al_fic *al_fic_msi_x_init(void __iomem *base,
+				 const char *name)
+{
+	struct al_fic *fic;
+
+	if (!base)
+		return ERR_PTR(-EINVAL);
+
+	fic = kzalloc(sizeof(*fic), GFP_KERNEL);
+	if (!fic)
+		return ERR_PTR(-ENOMEM);
+
+	fic->base = base;
+	fic->name = (name ?: "al-fic-full-fledged");
+
+	al_fic_hw_init(fic, true);
+
+	pr_debug("%s initialized successfully in Full-Fledged mode\n",
+		 fic->name);
+
+	return fic;
+}
+EXPORT_SYMBOL_GPL(al_fic_msi_x_init);
+
+/**
  * al_fic_cleanup() - free all resources allocated by fic
  * @fic: pointer to fic context
  *
include/linux/irqchip/al-fic.h +0 -0
index 0833749..a2e89ff 100644

include/linux/irqchip/al-fic.h struct al_fic *al_fic_wire_init(struct device_node *node, · line 20

Quoted 5 lines
include/linux/irqchip/al-fic.h +2 -0
@@ -16,6 +16,8 @@ struct al_fic *al_fic_wire_init(struct device_node *node,
 				void __iomem *base,
 				const char *name,
 				unsigned int parent_irq);
+struct al_fic *al_fic_msi_x_init(void __iomem *base,
+				 const char *name);

Who uses this new function?

thanks,

greg k-h