genirq: Consider domain hierarchy when checking for IRQCHIP_ONESHOT_SAFE
PATCH 1/1 genirq: Consider domain hierarchy when checking for IRQCHIP_ONESHOT_SAFE
In case of a domain hierarchy we may miss the IRQCHIP_ONESHOT_SAFE flag because we look at top of the stack only. See also discussion
here: https://marc.info/?l=linux-kernel&m=153301773524685&w=2
---
Uups, PATCH tag was missing.
--- kernel/irq/manage.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
kernel/irq/manage.c +11 -1
@@ -1156,6 +1156,16 @@ setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary)return 0 ; } +static bool irq_data_oneshot_safe (struct irq_data *data) +{ +#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY +/* check topmost irq_chip only */ +while (data->parent_data) + data = data->parent_data; +#endif +return !!(data->chip->flags &IRQCHIP_ONESHOT_SAFE ); +} +/* * Internal function to register an irqaction - typically used to * allocate special interrupts that are part of the architecture.
@@ -1243,7 +1253,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)* chip flags, so we can avoid the unmask dance at the end of * the threaded handler for those. */ -if (desc->irq_data.chip->flags &IRQCHIP_ONESHOT_SAFE ) +if (irq_data_oneshot_safe (&desc->irq_data)) new->flags &= ~IRQF_ONESHOT ;/*
Signature · 1 line
2.18.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 18 lines · Thomas Gleixner
Quoted 3 lines · Heiner Kallweit
In case of a domain hierarchy we may miss the
IRQCHIP_ONESHOT_SAFEflag because we look at top of the stack only. See also discussion
here: https://marc.info/?l=linux-kernel&m=153301773524685&w=2I think you misunderstood:
Quoted 3 lines
I think the top most chip is the key, the rest of the hierarchy is irrelevant because the top most chip is the one which is responsible for not creating an interrupt storm after the interrupt got acknowledged.
The top most chip in the hierarchy, e.g. the PCI MSI one, is the key. If that one is badly implemented and starts to resend after ack/eoi then the interrupt storm happens. The lower layers in the hierarchy down to the vector domain are just transporting what the top level chip does. So it is actively wrong to flag the lower layers.
Quoted 5 lines
if (
desc->irq_data.chip->flags&IRQCHIP_ONESHOT_SAFE)is the correct check as it looks at the topmost irq chip which is the one which initiates the interrupt.
So you're saying it's correct as it is now in __setup_irq(). Then I don't really understand Marc's following comment from earlier in the discussion. What else needs to be done if it is correct already?
"We could also consider extending this to support interrupt hierarchies, as __setup_irq() seems only concerned with the top of the stack (an IRQ provided by a generic MSI stack and backed by an irqchip providing IRQCHIP_ONESHOT_SAFE would go unnoticed)."
Quoted 4 lines
Thanks,
tglx
Quoted 25 lines · Heiner Kallweit
Quoted 18 lines · Thomas Gleixner
Quoted 3 lines · Heiner Kallweit
In case of a domain hierarchy we may miss the
IRQCHIP_ONESHOT_SAFEflag because we look at top of the stack only. See also discussion
here: https://marc.info/?l=linux-kernel&m=153301773524685&w=2I think you misunderstood:
Quoted 3 lines
I think the top most chip is the key, the rest of the hierarchy is irrelevant because the top most chip is the one which is responsible for not creating an interrupt storm after the interrupt got acknowledged.
The top most chip in the hierarchy, e.g. the PCI MSI one, is the key. If that one is badly implemented and starts to resend after ack/eoi then the interrupt storm happens. The lower layers in the hierarchy down to the vector domain are just transporting what the top level chip does. So it is actively wrong to flag the lower layers.
Quoted 5 lines
if (
desc->irq_data.chip->flags&IRQCHIP_ONESHOT_SAFE)is the correct check as it looks at the topmost irq chip which is the one which initiates the interrupt.
Quoted 8 lines
So you're saying it's correct as it is now in
__setup_irq(). Then I don't really understand Marc's following comment from earlier in the discussion. What else needs to be done if it is correct already?"We could also consider extending this to support interrupt hierarchies, as
__setup_irq()seems only concerned with the top of the stack (an IRQ provided by a generic MSI stack and backed by an irqchip providingIRQCHIP_ONESHOT_SAFEwould go unnoticed)."
I think Marc is wrong there, but I'm not sure what he had in mind.
Thanks,
tglx