irqchip: v4.18-rc1 fixes
Subsystems (3)
cover irqchip: v4.18-rc1 fixes
Hi all,
Here's a handful of patches I've accumulated over the merge window. The only interesting thing is the issue that Yang found on a bizarrely configured NUMA system, which prompted me to add more code to detect similar situations (just in case). The rest is pretty dull.
Thanks,
M.
Marc Zyngier (5):
genirq/debugfs: Add missing IRQCHIP_SUPPORTS_LEVEL_MSI debug irqchip/ls-scfg-msi: Fix MSI affinity handling irqchip/gic-v2m: Fix SPI release on error path irqchip/gic-v3-its: Only emit SYNC if targetting a valid collection irqchip/gic-v3-its: Only emit VSYNC if targetting a valid collection
Yang Yingliang (1):
irqchip/gic-v3-its: Don't bind LPI to unavailable NUMA node
drivers/irqchip/irq-gic-v2m.c | 2 +- drivers/irqchip/irq-gic-v3-its.c | 52 ++++++++++++++++++++++++------- drivers/irqchip/irq-ls-scfg-msi.c | 3 +- include/linux/irq.h | 1 + kernel/irq/debugfs.c | 1 + 5 files changed, 45 insertions(+), 14 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/6 genirq/debugfs: Add missing IRQCHIP_SUPPORTS_LEVEL_MSI debug
We're missing the IRQCHIP_SUPPORTS_LEVEL_MSI debug entry, making debugfs slightly less useful. Take this opportunity to also add a missing comment in the definition of IRQCHIP_SUPPORTS_LEVEL_MSI.
--- include/linux/irq.h | 1 + kernel/irq/debugfs.c | 1 + 2 files changed, 2 insertions(+)
include/linux/irq.h +1 -0
@@ -503,6 +503,7 @@ struct irq_chip {* IRQCHIP_SKIP_SET_WAKE: Skip chip.irq_set_wake(), for this irq chip * IRQCHIP_ONESHOT_SAFE: One shot does not require mask/unmask * IRQCHIP_EOI_THREADED: Chip requires eoi() on unmask in threaded mode +* IRQCHIP_SUPPORTS_LEVEL_MSI Chip can provide two doorbells for Level MSIs */ enum {IRQCHIP_SET_TYPE_MASKED = (1 <<0 ),
kernel/irq/debugfs.c +1 -0
@@ -55,6 +55,7 @@ static const struct irq_bit_descr irqchip_flags[] = {BIT_MASK_DESCR (IRQCHIP_SKIP_SET_WAKE ),BIT_MASK_DESCR (IRQCHIP_ONESHOT_SAFE ),BIT_MASK_DESCR (IRQCHIP_EOI_THREADED ), + BIT_MASK_DESCR(IRQCHIP_SUPPORTS_LEVEL_MSI), }; static void
Signature · 1 line
2.17.1
PATCH 2/6 irqchip/ls-scfg-msi: Fix MSI affinity handling
In reply to Marc ZyngierThe ls-scfs-msi driver is not dealing with the effective affinity as it should. Let's fix that, and make it clear that the effective affinity is restricted to a single CPU.
--- drivers/irqchip/irq-ls-scfg-msi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/irqchip/irq-ls-scfg-msi.c +2 -1
@@ -121,7 +121,8 @@ static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,return -EINVAL ; } -cpumask_copy (irq_data->common->affinity, mask); +cpumask_copy (irq_data->common->affinity,cpumask_of (cpu)); +irq_data_update_effective_affinity (irq_data,cpumask_of (cpu));return IRQ_SET_MASK_OK ; }
Signature · 1 line
2.17.1
Re: [PATCH 2/6] irqchip/ls-scfg-msi: Fix MSI affinity handling
Quoted 15 lines · Marc Zyngier
The ls-scfs-msi driver is not dealing with the effective affinity as it should. Let's fix that, and make it clear that the effective affinity is restricted to a single CPU.
Reported-by Alexandre Belloni <[email protected]>Signed-off-by Marc Zyngier <[email protected]>--- drivers/irqchip/irq-ls-scfg-msi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/irqchip/irq-ls-scfg-msi.c +0
-0
drivers/irqchip/irq-ls-scfg-msi.c static int ls_scfg_msi_set_affinity(struct irq_data *irq_data, · line 124
Quoted 5 lines
drivers/irqchip/irq-ls-scfg-msi.c +1
-1@@ -121,7 +121,8 @@ static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,return -EINVAL ; } -cpumask_copy (irq_data->common->affinity, mask); +cpumask_copy (irq_data->common->affinity,cpumask_of (cpu));
That's wrong. The driver should not fiddle with the affinity mask at all and just store the effective mask.
drivers/irqchip/irq-ls-scfg-msi.c static int ls_scfg_msi_set_affinity(struct irq_data *irq_data, · line 127
Quoted 3 lines
drivers/irqchip/irq-ls-scfg-msi.c +1
-0+irq_data_update_effective_affinity (irq_data,cpumask_of (cpu));return IRQ_SET_MASK_OK ;
If yuo look at the call site, then you'll notice that it will do:
case IRQ_SET_MASK_OK:
case IRQ_SET_MASK_OK_DONE:
cpumask_copy(desc->irq_common_data.affinity, mask);So the cpumask_copy() can just go away.
Thanks,
tglx
Re: [PATCH 2/6] irqchip/ls-scfg-msi: Fix MSI affinity handling
Quoted 20 lines · Thomas Gleixner
Quoted 18 lines · Marc Zyngier
The ls-scfs-msi driver is not dealing with the effective affinity as it should. Let's fix that, and make it clear that the effective affinity is restricted to a single CPU.
Reported-by Alexandre Belloni <[email protected]>Signed-off-by Marc Zyngier <[email protected]>--- drivers/irqchip/irq-ls-scfg-msi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/irqchip/irq-ls-scfg-msi.c +0
-0@@ -121,7 +121,8 @@ static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,return -EINVAL ; }
Quoted 5 lines
drivers/irqchip/irq-ls-scfg-msi.c static int ls_scfg_msi_set_affinity(struct irq_data *irq_data, · line 124
Quoted 2 lines
drivers/irqchip/irq-ls-scfg-msi.c +1
-1-cpumask_copy (irq_data->common->affinity, mask); +cpumask_copy (irq_data->common->affinity,cpumask_of (cpu));That's wrong. The driver should not fiddle with the affinity mask at all and just store the effective mask.
Ah, very good point. The ls_scfg_msi_compose_msg callback is also pretty dodgy in that respect...
Quoted 7 lines
drivers/irqchip/irq-ls-scfg-msi.c static int ls_scfg_msi_set_affinity(struct irq_data *irq_data, · line 127
Quoted 4 lines
drivers/irqchip/irq-ls-scfg-msi.c +1
-0+irq_data_update_effective_affinity (irq_data,cpumask_of (cpu));return IRQ_SET_MASK_OK ;If yuo look at the call site, then you'll notice that it will do:
Quoted 5 lines
case IRQ_SET_MASK_OK: case IRQ_SET_MASK_OK_DONE: cpumask_copy(desc->irq_common_data.affinity, mask);So the
cpumask_copy()can just go away.
Thanks for noticing that. I've fixed it up as follow:
drivers/irqchip/irq-ls-scfg-msi.c +6 -3
@@ -93,8 +93,12 @@ static void ls_scfg_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) msg->address_lo =lower_32_bits (msi_data->msiir_addr); msg->data = data->hwirq; -if (msi_affinity_flag) - msg->data |=cpumask_first (data->common->affinity); +if (msi_affinity_flag) { +const struct cpumask *mask; + + mask =irq_data_get_effective_affinity_mask (data); + msg->data |=cpumask_first (mask); + }iommu_dma_map_msi_msg (data->irq, msg); }
@@ -121,7 +125,6 @@ static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,return -EINVAL ; } -cpumask_copy (irq_data->common->affinity,cpumask_of (cpu));irq_data_update_effective_affinity (irq_data,cpumask_of (cpu));return IRQ_SET_MASK_OK ;
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [PATCH 2/6] irqchip/ls-scfg-msi: Fix MSI affinity handling
Quoted 20 lines · Marc Zyngier
drivers/irqchip/irq-ls-scfg-msi.c +6
-2@@ -93,8 +93,12 @@ static void ls_scfg_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) msg->address_lo =lower_32_bits (msi_data->msiir_addr); msg->data = data->hwirq; -if (msi_affinity_flag) - msg->data |=cpumask_first (data->common->affinity); +if (msi_affinity_flag) { +const struct cpumask *mask; + + mask =irq_data_get_effective_affinity_mask (data); + msg->data |=cpumask_first (mask); + }iommu_dma_map_msi_msg (data->irq, msg); }
drivers/irqchip/irq-ls-scfg-msi.c static int ls_scfg_msi_set_affinity(struct irq_data *irq_data, · line 130
Quoted 7 lines
drivers/irqchip/irq-ls-scfg-msi.c +0
-1@@ -121,7 +125,6 @@ static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,return -EINVAL ; } -cpumask_copy (irq_data->common->affinity,cpumask_of (cpu));irq_data_update_effective_affinity (irq_data,cpumask_of (cpu));return IRQ_SET_MASK_OK ;
Looks good!
PATCH 3/6 irqchip/gic-v2m: Fix SPI release on error path
In reply to Marc ZyngierOn failing to allocate the required SPIs, we should free the actual number of interrupts, and not its log2 value.
--- drivers/irqchip/irq-gic-v2m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v2m.c +1 -1
@@ -199,7 +199,7 @@ static int gicv2m_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, fail:irq_domain_free_irqs_parent (domain, virq, nr_irqs); -gicv2m_unalloc_msi (v2m, hwirq,get_count_order (nr_irqs)); +gicv2m_unalloc_msi (v2m, hwirq, nr_irqs);return err; }
Signature · 1 line
2.17.1
PATCH 4/6 irqchip/gic-v3-its: Don't bind LPI to unavailable NUMA node
In reply to Marc ZyngierFrom: Yang Yingliang <[email protected]>
On a NUMA system, if an ITS is local to an offline node, the ITS driver may pick an offline CPU to bind the LPI. In this case, we need to pick an online CPU (and the first one will do).
But on some systems, binding an LPI to non-local node CPU may cause deadlock (see Cavium erratum 23144). In this case, we just fail the activate and return an error code.
--- drivers/irqchip/irq-gic-v3-its.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +8 -1
@@ -2310,7 +2310,14 @@ static int its_irq_domain_activate(struct irq_domain *domain, cpu_mask =cpumask_of_node (its_dev->its->numa_node);/* Bind the LPI to the first possible CPU */ - cpu =cpumask_first (cpu_mask); + cpu =cpumask_first_and (cpu_mask, cpu_online_mask); +if (cpu >= nr_cpu_ids) { +if (its_dev->its->flags &ITS_FLAGS_WORKAROUND_CAVIUM_23144 ) +return -EINVAL ; + + cpu =cpumask_first (cpu_online_mask); + } + its_dev->event_map.col_map[event] = cpu;irq_data_update_effective_affinity (d,cpumask_of (cpu));
Signature · 1 line
2.17.1
PATCH 5/6 irqchip/gic-v3-its: Only emit SYNC if targetting a valid collection
In reply to Marc ZyngierIt is possible, under obscure circumstances, to convince the ITS driver to emit a SYNC operation that targets a collection that is not bound to any redistributor (and the target_address field is zero) because the corresponding CPU has not been seen yet (the system has been booted with max_cpus="something small").
If the ITS is using the linear CPU number as the target, this is not a big deal, as we just end-up issuing a SYNC to CPU0. But if the ITS requires the physical address of the redistributor (with GITS_TYPER.PTA==1), we end-up asking the ITS to write to the physical address zero, which is not exactly a good idea (there has been report of the ITS locking up). This should of course never happen, but hey, this is SW...
In order to avoid the above disaster, let's track which collections have been actually initialized, and let's not generate a SYNC if the collection hasn't been properly bound to a redistributor. We take this opportunity to spit our a warning, in the hope that someone may report the issue if it arrises again.
--- drivers/irqchip/irq-gic-v3-its.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +19 -6
@@ -182,6 +182,14 @@ static struct its_collection *dev_event_to_col(struct its_device *its_dev,return its->collections + its_dev->event_map.col_map[event]; } +static struct its_collection *valid_col (struct its_collection *col) +{ +if (WARN_ON_ONCE (col->target_address &GENMASK_ULL (0 ,15 ))) +return NULL ; + +return col; +} +/* * ITS command descriptors - parameters to be encoded in a command * block.
@@ -439,7 +447,7 @@ static struct its_collection *its_build_mapti_cmd(struct its_node *its,its_fixup_cmd (cmd); -return col; +return valid_col (col); } static struct its_collection *its_build_movi_cmd(struct its_node *its,
@@ -458,7 +466,7 @@ static struct its_collection *its_build_movi_cmd(struct its_node *its,its_fixup_cmd (cmd); -return col; +return valid_col (col); } static struct its_collection *its_build_discard_cmd(struct its_node *its,
@@ -476,7 +484,7 @@ static struct its_collection *its_build_discard_cmd(struct its_node *its,its_fixup_cmd (cmd); -return col; +return valid_col (col); } static struct its_collection *its_build_inv_cmd(struct its_node *its,
@@ -494,7 +502,7 @@ static struct its_collection *its_build_inv_cmd(struct its_node *its,its_fixup_cmd (cmd); -return col; +return valid_col (col); } static struct its_collection *its_build_int_cmd(struct its_node *its,
@@ -512,7 +520,7 @@ static struct its_collection *its_build_int_cmd(struct its_node *its,its_fixup_cmd (cmd); -return col; +return valid_col (col); } static struct its_collection *its_build_clear_cmd(struct its_node *its,
@@ -530,7 +538,7 @@ static struct its_collection *its_build_clear_cmd(struct its_node *its,its_fixup_cmd (cmd); -return col; +return valid_col (col); } static struct its_collection *its_build_invall_cmd(struct its_node *its,
@@ -1824,11 +1832,16 @@ static int its_alloc_tables(struct its_node *its)static int its_alloc_collections (struct its_node *its) { +int i; + its->collections =kcalloc (nr_cpu_ids,sizeof (*its->collections),GFP_KERNEL );if (!its->collections)return -ENOMEM ; +for (i =0 ; i < nr_cpu_ids; i++) + its->collections[i].target_address = ~0ULL ; +return 0 ; }
Signature · 1 line
2.17.1
PATCH 6/6 irqchip/gic-v3-its: Only emit VSYNC if targetting a valid collection
In reply to Marc ZyngierSimilarily to the SYNC operation, we need to verify that the VPE targetted by a VLPI is backed by a valid collection in the GIC driver data structures.
--- drivers/irqchip/irq-gic-v3-its.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +13 -5
@@ -190,6 +190,14 @@ static struct its_collection *valid_col(struct its_collection *col)return col; } +static struct its_vpe *valid_vpe (struct its_node *its,struct its_vpe *vpe) +{ +if (valid_col (its->collections + vpe->col_idx)) +return vpe; + +return NULL ; +} +/* * ITS command descriptors - parameters to be encoded in a command * block.
@@ -562,7 +570,7 @@ static struct its_vpe *its_build_vinvall_cmd(struct its_node *its,its_fixup_cmd (cmd); -return desc->its_vinvall_cmd.vpe; +return valid_vpe (its, desc->its_vinvall_cmd.vpe); } static struct its_vpe *its_build_vmapp_cmd(struct its_node *its,
@@ -584,7 +592,7 @@ static struct its_vpe *its_build_vmapp_cmd(struct its_node *its,its_fixup_cmd (cmd); -return desc->its_vmapp_cmd.vpe; +return valid_vpe (its, desc->its_vmapp_cmd.vpe); } static struct its_vpe *its_build_vmapti_cmd(struct its_node *its,
@@ -607,7 +615,7 @@ static struct its_vpe *its_build_vmapti_cmd(struct its_node *its,its_fixup_cmd (cmd); -return desc->its_vmapti_cmd.vpe; +return valid_vpe (its, desc->its_vmapti_cmd.vpe); } static struct its_vpe *its_build_vmovi_cmd(struct its_node *its,
@@ -630,7 +638,7 @@ static struct its_vpe *its_build_vmovi_cmd(struct its_node *its,its_fixup_cmd (cmd); -return desc->its_vmovi_cmd.vpe; +return valid_vpe (its, desc->its_vmovi_cmd.vpe); } static struct its_vpe *its_build_vmovp_cmd(struct its_node *its,
@@ -648,7 +656,7 @@ static struct its_vpe *its_build_vmovp_cmd(struct its_node *its,its_fixup_cmd (cmd); -return desc->its_vmovp_cmd.vpe; +return valid_vpe (its, desc->its_vmovp_cmd.vpe); } static u64 its_cmd_ptr_to_offset(struct its_node *its,
Signature · 1 line
2.17.1