summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2017-10-17 12:55:56 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2017-10-19 06:22:39 -0400
commit558b01654d92332d3b7b17bf773cdce8ce16ef46 (patch)
tree52c1a98cbd4cc0e950801328a92404ce6db85b50
parent9d111d49106b61f5a652d5418e85d8741b1a0427 (diff)
irqchip/gic-v3: Add workaround for Synquacer pre-ITS
The Socionext Synquacer SoC's implementation of GICv3 has a so-called 'pre-ITS', which maps 32-bit writes targeted at a separate window of size '4 << device_id_bits' onto writes to GITS_TRANSLATER with device ID taken from bits [device_id_bits + 1:2] of the window offset. Writes that target GITS_TRANSLATER directly are reported as originating from device ID #0. So add a workaround for this. Given that this breaks isolation, clear the IRQ_DOMAIN_FLAG_MSI_REMAP flag as well. Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt4
-rw-r--r--arch/arm64/Kconfig8
-rw-r--r--drivers/irqchip/irq-gic-v3-its.c72
3 files changed, 82 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt b/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt
index 4c29cdab0ea5..c3e6092f3add 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt
@@ -75,6 +75,10 @@ These nodes must have the following properties:
75- reg: Specifies the base physical address and size of the ITS 75- reg: Specifies the base physical address and size of the ITS
76 registers. 76 registers.
77 77
78Optional:
79- socionext,synquacer-pre-its: (u32, u32) tuple describing the untranslated
80 address and size of the pre-ITS window.
81
78The main GIC node must contain the appropriate #address-cells, 82The main GIC node must contain the appropriate #address-cells,
79#size-cells and ranges properties for the reg property of all ITS 83#size-cells and ranges properties for the reg property of all ITS
80nodes. 84nodes.
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 0df64a6a56d4..c4361dff2b74 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -539,6 +539,14 @@ config QCOM_QDF2400_ERRATUM_0065
539 539
540 If unsure, say Y. 540 If unsure, say Y.
541 541
542config SOCIONEXT_SYNQUACER_PREITS
543 bool "Socionext Synquacer: Workaround for GICv3 pre-ITS"
544 default y
545 help
546 Socionext Synquacer SoCs implement a separate h/w block to generate
547 MSI doorbell writes with non-zero values for the device ID.
548
549 If unsure, say Y.
542endmenu 550endmenu
543 551
544 552
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 4d432804c2bc..54ea4e26c7a9 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -83,6 +83,8 @@ struct its_baser {
83 u32 psz; 83 u32 psz;
84}; 84};
85 85
86struct its_device;
87
86/* 88/*
87 * The ITS structure - contains most of the infrastructure, with the 89 * The ITS structure - contains most of the infrastructure, with the
88 * top-level MSI domain, the command queue, the collections, and the 90 * top-level MSI domain, the command queue, the collections, and the
@@ -97,11 +99,15 @@ struct its_node {
97 struct its_cmd_block *cmd_write; 99 struct its_cmd_block *cmd_write;
98 struct its_baser tables[GITS_BASER_NR_REGS]; 100 struct its_baser tables[GITS_BASER_NR_REGS];
99 struct its_collection *collections; 101 struct its_collection *collections;
102 struct fwnode_handle *fwnode_handle;
103 u64 (*get_msi_base)(struct its_device *its_dev);
100 struct list_head its_device_list; 104 struct list_head its_device_list;
101 u64 flags; 105 u64 flags;
102 u32 ite_size; 106 u32 ite_size;
103 u32 device_ids; 107 u32 device_ids;
104 int numa_node; 108 int numa_node;
109 unsigned int msi_domain_flags;
110 u32 pre_its_base; /* for Socionext Synquacer */
105 bool is_v4; 111 bool is_v4;
106}; 112};
107 113
@@ -1095,6 +1101,13 @@ static int its_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
1095 return IRQ_SET_MASK_OK_DONE; 1101 return IRQ_SET_MASK_OK_DONE;
1096} 1102}
1097 1103
1104static u64 its_irq_get_msi_base(struct its_device *its_dev)
1105{
1106 struct its_node *its = its_dev->its;
1107
1108 return its->phys_base + GITS_TRANSLATER;
1109}
1110
1098static void its_irq_compose_msi_msg(struct irq_data *d, struct msi_msg *msg) 1111static void its_irq_compose_msi_msg(struct irq_data *d, struct msi_msg *msg)
1099{ 1112{
1100 struct its_device *its_dev = irq_data_get_irq_chip_data(d); 1113 struct its_device *its_dev = irq_data_get_irq_chip_data(d);
@@ -1102,7 +1115,7 @@ static void its_irq_compose_msi_msg(struct irq_data *d, struct msi_msg *msg)
1102 u64 addr; 1115 u64 addr;
1103 1116
1104 its = its_dev->its; 1117 its = its_dev->its;
1105 addr = its->phys_base + GITS_TRANSLATER; 1118 addr = its->get_msi_base(its_dev);
1106 1119
1107 msg->address_lo = lower_32_bits(addr); 1120 msg->address_lo = lower_32_bits(addr);
1108 msg->address_hi = upper_32_bits(addr); 1121 msg->address_hi = upper_32_bits(addr);
@@ -2760,6 +2773,45 @@ static bool __maybe_unused its_enable_quirk_qdf2400_e0065(void *data)
2760 return true; 2773 return true;
2761} 2774}
2762 2775
2776static u64 its_irq_get_msi_base_pre_its(struct its_device *its_dev)
2777{
2778 struct its_node *its = its_dev->its;
2779
2780 /*
2781 * The Socionext Synquacer SoC has a so-called 'pre-ITS',
2782 * which maps 32-bit writes targeted at a separate window of
2783 * size '4 << device_id_bits' onto writes to GITS_TRANSLATER
2784 * with device ID taken from bits [device_id_bits + 1:2] of
2785 * the window offset.
2786 */
2787 return its->pre_its_base + (its_dev->device_id << 2);
2788}
2789
2790static bool __maybe_unused its_enable_quirk_socionext_synquacer(void *data)
2791{
2792 struct its_node *its = data;
2793 u32 pre_its_window[2];
2794 u32 ids;
2795
2796 if (!fwnode_property_read_u32_array(its->fwnode_handle,
2797 "socionext,synquacer-pre-its",
2798 pre_its_window,
2799 ARRAY_SIZE(pre_its_window))) {
2800
2801 its->pre_its_base = pre_its_window[0];
2802 its->get_msi_base = its_irq_get_msi_base_pre_its;
2803
2804 ids = ilog2(pre_its_window[1]) - 2;
2805 if (its->device_ids > ids)
2806 its->device_ids = ids;
2807
2808 /* the pre-ITS breaks isolation, so disable MSI remapping */
2809 its->msi_domain_flags &= ~IRQ_DOMAIN_FLAG_MSI_REMAP;
2810 return true;
2811 }
2812 return false;
2813}
2814
2763static const struct gic_quirk its_quirks[] = { 2815static const struct gic_quirk its_quirks[] = {
2764#ifdef CONFIG_CAVIUM_ERRATUM_22375 2816#ifdef CONFIG_CAVIUM_ERRATUM_22375
2765 { 2817 {
@@ -2785,6 +2837,19 @@ static const struct gic_quirk its_quirks[] = {
2785 .init = its_enable_quirk_qdf2400_e0065, 2837 .init = its_enable_quirk_qdf2400_e0065,
2786 }, 2838 },
2787#endif 2839#endif
2840#ifdef CONFIG_SOCIONEXT_SYNQUACER_PREITS
2841 {
2842 /*
2843 * The Socionext Synquacer SoC incorporates ARM's own GIC-500
2844 * implementation, but with a 'pre-ITS' added that requires
2845 * special handling in software.
2846 */
2847 .desc = "ITS: Socionext Synquacer pre-ITS",
2848 .iidr = 0x0001143b,
2849 .mask = 0xffffffff,
2850 .init = its_enable_quirk_socionext_synquacer,
2851 },
2852#endif
2788 { 2853 {
2789 } 2854 }
2790}; 2855};
@@ -2813,7 +2878,7 @@ static int its_init_domain(struct fwnode_handle *handle, struct its_node *its)
2813 2878
2814 inner_domain->parent = its_parent; 2879 inner_domain->parent = its_parent;
2815 irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS); 2880 irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS);
2816 inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_REMAP; 2881 inner_domain->flags |= its->msi_domain_flags;
2817 info->ops = &its_msi_domain_ops; 2882 info->ops = &its_msi_domain_ops;
2818 info->data = its; 2883 info->data = its;
2819 inner_domain->host_data = info; 2884 inner_domain->host_data = info;
@@ -2967,6 +3032,9 @@ static int __init its_probe_one(struct resource *res,
2967 goto out_free_its; 3032 goto out_free_its;
2968 } 3033 }
2969 its->cmd_write = its->cmd_base; 3034 its->cmd_write = its->cmd_base;
3035 its->fwnode_handle = handle;
3036 its->get_msi_base = its_irq_get_msi_base;
3037 its->msi_domain_flags = IRQ_DOMAIN_FLAG_MSI_REMAP;
2970 3038
2971 its_enable_quirks(its); 3039 its_enable_quirks(its);
2972 3040