Re: [PATCH v4 2/8] irqchip: Add Realtek RTD1295 mux driver

From: Marc Zyngier
Date: Wed Nov 20 2019 - 05:20:23 EST


On 2019-11-19 23:33, Andreas FÃrber wrote:
Am 19.11.19 um 23:29 schrieb Marc Zyngier:
On Tue, 19 Nov 2019 21:56:48 +0100
Andreas FÃrber <afaerber@xxxxxxx> wrote:
Am 19.11.19 um 13:01 schrieb Marc Zyngier:
On 2019-11-19 02:19, Andreas FÃrber wrote:
+static void rtd1195_mux_enable_irq(struct irq_data *data)
+{
+ÂÂÂ struct rtd1195_irq_mux_data *mux_data =
irq_data_get_irq_chip_data(data);
+ÂÂÂ unsigned long flags;
+ÂÂÂ u32 mask;
+
+ÂÂÂ mask = mux_data->info->isr_to_int_en_mask[data->hwirq];
+ÂÂÂ if (!mask)
+ÂÂÂÂÂÂÂ return;

How can this happen? You've mapped the interrupt, so it exists.
I can't see how you can decide to fail such enable.

The [UMSK_]ISR bits and the SCPU_INT_EN bits are not (all) the same.

My ..._isr_to_scpu_int_en[] arrays have 32 entries for O(1) lookup, but
are sparsely populated. So there are circumstances such as WDOG_NMI as
well as reserved bits that we cannot enable.

But the you should have failed the map. The moment you allow the
mapping to occur, you have accepted the contract that this interrupt is
usable.

This check should be
identical to v3; the equivalent mask check inside the interrupt handler
was extended with "mask &&" to do the same in this v4.

Spurious interrupts are a different matter. What I'm objecting to here
is a simple question of logic, whether or not you are allowed to fail
enabling an interrupt that you've otherwise allowed to be populated.

Then what are you suggesting instead? I don't see how my array map
lookup could fail other than returning a zero value, given its static
initialization. Check for a zero mask in rtd1195_mux_irq_domain_map()?
Then we wouldn't be able to use the mentioned WDOG_NMI. Add another
per-mux info field for which interrupts are valid to map?

I'm suggesting that you fail the map if you're unable to allow the
interrupt to be enabled.

M.
--
Jazz is not dead. It just smells funny...