irqchip: v4.18-rc1 fixes
Subsystems (3)
v2 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.
* From v1:
- Much better fix for the ls-scfg driver (thanks to Thomas)
- New patch fixing a CPU hotplug regression on GICv3
Marc Zyngier (6):
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 irqchip/gic-v3-its: Fix reprogramming of redistributors on CPU hotplug
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 | 62 +++++++++++++++++++++++++------ drivers/irqchip/irq-ls-scfg-msi.c | 10 +++-- include/linux/irq.h | 1 + kernel/irq/debugfs.c | 1 + 5 files changed, 60 insertions(+), 16 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/7 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
tip-bot for Marc Zyngier
merge bot[tip:irq/urgent] genirq/debugfs: Add missing IRQCHIP_SUPPORTS_LEVEL_MSI debug
genirq/debugfs: Add missing IRQCHIP_SUPPORTS_LEVEL_MSI debug
Commit-ID: 72a8edc2d9134c2895eac2fec5eecf8230a05c96 Gitweb: https://git.kernel.org/tip/72a8edc2d9134c2895eac2fec5eecf8230a05c96 Author: Marc Zyngier <[email protected]> AuthorDate: Fri, 22 Jun 2018 10:52:48 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 22 Jun 2018 14:22:00 +0200
genirq/debugfs: Add missing IRQCHIP_SUPPORTS_LEVEL_MSI debug
Debug is 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
PATCH v2 2/7 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. Also prevent the driver from messing with the internals of the affinity setting infrastructure.
--- drivers/irqchip/irq-ls-scfg-msi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/irqchip/irq-ls-scfg-msi.c +7 -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,7 @@ static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,return -EINVAL ; } -cpumask_copy (irq_data->common->affinity, mask); +irq_data_update_effective_affinity (irq_data,cpumask_of (cpu));return IRQ_SET_MASK_OK ; }
Signature · 1 line
2.17.1
Re: [PATCH v2 2/7] irqchip/ls-scfg-msi: Fix MSI affinity handling
Quoted 7 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. Also prevent the driver from messing with the internals of the affinity setting infrastructure.
Reported-by Alexandre Belloni <[email protected]>Signed-off-by Marc Zyngier <[email protected]>
Quoted 35 lines
--- drivers/irqchip/irq-ls-scfg-msi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/irqchip/irq-ls-scfg-msi.c +7
-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,7 @@ static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,return -EINVAL ; } -cpumask_copy (irq_data->common->affinity, mask); +irq_data_update_effective_affinity (irq_data,cpumask_of (cpu));return IRQ_SET_MASK_OK ; }Signature · 1 line
2.17.1
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
tip-bot for Marc Zyngier
merge bot[tip:irq/urgent] irqchip/ls-scfg-msi: Fix MSI affinity handling
In reply to Marc Zyngierirqchip/ls-scfg-msi: Fix MSI affinity handling
Commit-ID: 893fbfff976cd069f2e60c3b186dbe3f85504db2 Gitweb: https://git.kernel.org/tip/893fbfff976cd069f2e60c3b186dbe3f85504db2 Author: Marc Zyngier <[email protected]> AuthorDate: Fri, 22 Jun 2018 10:52:49 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 22 Jun 2018 14:22:00 +0200
irqchip/ls-scfg-msi: Fix MSI affinity handling
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. Also prevent the driver from messing with the internals of the affinity setting infrastructure.
--- drivers/irqchip/irq-ls-scfg-msi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/irqchip/irq-ls-scfg-msi.c +7 -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,7 @@ static int ls_scfg_msi_set_affinity(struct irq_data *irq_data,return -EINVAL ; } -cpumask_copy (irq_data->common->affinity, mask); +irq_data_update_effective_affinity (irq_data,cpumask_of (cpu));return IRQ_SET_MASK_OK ; }
PATCH v2 3/7 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
tip-bot for Marc Zyngier
merge bot[tip:irq/urgent] irqchip/gic-v2m: Fix SPI release on error path
irqchip/gic-v2m: Fix SPI release on error path
Commit-ID: cbaf45a6be497c272e80500e4fd9bccdf20d5050 Gitweb: https://git.kernel.org/tip/cbaf45a6be497c272e80500e4fd9bccdf20d5050 Author: Marc Zyngier <[email protected]> AuthorDate: Fri, 22 Jun 2018 10:52:50 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 22 Jun 2018 14:22:00 +0200
irqchip/gic-v2m: Fix SPI release on error path
On failing to allocate the required SPIs, the actual number of interrupts should be freed 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; }
PATCH v2 4/7 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
tip-bot for Yang Yingliang
merge bot[tip:irq/urgent] irqchip/gic-v3-its: Don't bind LPI to unavailable NUMA node
irqchip/gic-v3-its: Don't bind LPI to unavailable NUMA node
Commit-ID: c1797b11a09c8323c92b074fd48b89a936c991d0 Gitweb: https://git.kernel.org/tip/c1797b11a09c8323c92b074fd48b89a936c991d0 Author: Yang Yingliang <[email protected]> AuthorDate: Fri, 22 Jun 2018 10:52:51 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 22 Jun 2018 14:22:01 +0200
irqchip/gic-v3-its: Don't bind LPI to unavailable NUMA node
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, 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, 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));
PATCH v2 5/7 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
tip-bot for Marc Zyngier
merge bot[tip:irq/urgent] irqchip/gic-v3-its: Only emit SYNC if targetting a valid collection
irqchip/gic-v3-its: Only emit SYNC if targetting a valid collection
Commit-ID: 83559b47cdc4d396fc1187a13b527d01b55e0fe6 Gitweb: https://git.kernel.org/tip/83559b47cdc4d396fc1187a13b527d01b55e0fe6 Author: Marc Zyngier <[email protected]> AuthorDate: Fri, 22 Jun 2018 10:52:52 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 22 Jun 2018 14:22:01 +0200
irqchip/gic-v3-its: Only emit SYNC if targetting a valid collection
It 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. 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 ; }
PATCH v2 6/7 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
tip-bot for Marc Zyngier
merge bot[tip:irq/urgent] irqchip/gic-v3-its: Only emit VSYNC if targetting a valid collection
irqchip/gic-v3-its: Only emit VSYNC if targetting a valid collection
Commit-ID: 205e065d91d72e6afad112ea84f0ca60b30bf5ab Gitweb: https://git.kernel.org/tip/205e065d91d72e6afad112ea84f0ca60b30bf5ab Author: Marc Zyngier <[email protected]> AuthorDate: Fri, 22 Jun 2018 10:52:53 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 22 Jun 2018 14:22:01 +0200
irqchip/gic-v3-its: Only emit VSYNC if targetting a valid collection
Similarily to the SYNC operation, it must be verified 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,
PATCH v2 7/7 irqchip/gic-v3-its: Fix reprogramming of redistributors on CPU hotplug
In reply to Marc ZyngierWe recently made enabling LPIs a lot stricter, by checking that they are disabled before we enable them. By doing so, we missed the CPU hotplug case altogether, where we leave LPIs enabled on hotplug off (we expect the CPU to eventually come back), and won't write a different value anyway on hotplug on.
So let's skip that check if we detect that particular case.
--- drivers/irqchip/irq-gic-v3-its.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/irqchip/irq-gic-v3-its.c +10 -0
@@ -3427,6 +3427,16 @@ static int redist_disable_lpis(void)u64 timeout =USEC_PER_SEC ;u64 val; +/* +* If coming via a CPU hotplug event, we don't need to disable +* LPIs before trying to re-enable them. They are already +* configured and all is well in the world. Detect this case +* by checking the allocation of the pending table for the +* current CPU. +*/ +if (gic_data_rdist ()->pend_page) +return 0 ; +if (!gic_rdists_supports_plpis ()) {pr_info ("CPU%d: LPIs not supported\n" ,smp_processor_id ());return -ENXIO ;
Signature · 1 line
2.17.1
tip-bot for Marc Zyngier
merge bot[tip:irq/urgent] irqchip/gic-v3-its: Fix reprogramming of redistributors on CPU hotplug
irqchip/gic-v3-its: Fix reprogramming of redistributors on CPU hotplug
Commit-ID: 82f499c8811149069ec958b72a86643a7a289b25 Gitweb: https://git.kernel.org/tip/82f499c8811149069ec958b72a86643a7a289b25 Author: Marc Zyngier <[email protected]> AuthorDate: Fri, 22 Jun 2018 10:52:54 +0100 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 22 Jun 2018 14:22:02 +0200
irqchip/gic-v3-its: Fix reprogramming of redistributors on CPU hotplug
Enabling LPIs was made a lot stricter recently, by checking that they are disabled before enabling them. By doing so, the CPU hotplug case was missed altogether, which leaves LPIs enabled on hotplug off (expecting the CPU to eventually come back), and won't write a different value anyway on hotplug on.
So skip that check if that particular case is detected
--- drivers/irqchip/irq-gic-v3-its.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/irqchip/irq-gic-v3-its.c +10 -0
@@ -3427,6 +3427,16 @@ static int redist_disable_lpis(void)u64 timeout =USEC_PER_SEC ;u64 val; +/* +* If coming via a CPU hotplug event, we don't need to disable +* LPIs before trying to re-enable them. They are already +* configured and all is well in the world. Detect this case +* by checking the allocation of the pending table for the +* current CPU. +*/ +if (gic_data_rdist ()->pend_page) +return 0 ; +if (!gic_rdists_supports_plpis ()) {pr_info ("CPU%d: LPIs not supported\n" ,smp_processor_id ());return -ENXIO ;