Skip to content

Commit 88fa025

Browse files
committed
Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull irq fixes from Thomas Gleixner: "A rather large update after the kaisered maintainer finally found time to handle regression reports. - The larger part addresses a regression caused by the x86 vector management rework. The reservation based model does not work reliably for MSI interrupts, if they cannot be masked (yes, yet another hw engineering trainwreck). The reason is that the reservation mode assigns a dummy vector when the interrupt is allocated and switches to a real vector when the interrupt is requested. If the MSI entry cannot be masked then the initialization might raise an interrupt before the interrupt is requested, which ends up as spurious interrupt and causes device malfunction and worse. The fix is to exclude MSI interrupts which do not support masking from reservation mode and assign a real vector right away. - Extend the extra lockdep class setup for nested interrupts with a class for the recently added irq_desc::request_mutex so lockdep can differeniate and does not emit false positive warnings. - A ratelimit guard for the bad irq printout so in case a bad irq comes back immediately the system does not drown in dmesg spam" * 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: genirq/msi, x86/vector: Prevent reservation mode for non maskable MSI genirq/irqdomain: Rename early argument of irq_domain_activate_irq() x86/vector: Use IRQD_CAN_RESERVE flag genirq: Introduce IRQD_CAN_RESERVE flag genirq/msi: Handle reactivation only on success gpio: brcmstb: Make really use of the new lockdep class genirq: Guard handle_bad_irq log messages kernel/irq: Extend lockdep class for request mutex
2 parents 31336ed + bc97623 commit 88fa025

28 files changed

+196
-72
lines changed

arch/powerpc/sysdev/fsl_msi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ static int fsl_of_msi_remove(struct platform_device *ofdev)
354354
}
355355

356356
static struct lock_class_key fsl_msi_irq_class;
357+
static struct lock_class_key fsl_msi_irq_request_class;
357358

358359
static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev,
359360
int offset, int irq_index)
@@ -373,7 +374,8 @@ static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev,
373374
dev_err(&dev->dev, "No memory for MSI cascade data\n");
374375
return -ENOMEM;
375376
}
376-
irq_set_lockdep_class(virt_msir, &fsl_msi_irq_class);
377+
irq_set_lockdep_class(virt_msir, &fsl_msi_irq_class,
378+
&fsl_msi_irq_request_class);
377379
cascade_data->index = offset;
378380
cascade_data->msi_data = msi;
379381
cascade_data->virq = virt_msir;

arch/x86/include/asm/irqdomain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extern int mp_irqdomain_alloc(struct irq_domain *domain, unsigned int virq,
4444
extern void mp_irqdomain_free(struct irq_domain *domain, unsigned int virq,
4545
unsigned int nr_irqs);
4646
extern int mp_irqdomain_activate(struct irq_domain *domain,
47-
struct irq_data *irq_data, bool early);
47+
struct irq_data *irq_data, bool reserve);
4848
extern void mp_irqdomain_deactivate(struct irq_domain *domain,
4949
struct irq_data *irq_data);
5050
extern int mp_irqdomain_ioapic_idx(struct irq_domain *domain);

arch/x86/include/asm/trace/irq_vectors.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,34 +283,34 @@ TRACE_EVENT(vector_alloc_managed,
283283
DECLARE_EVENT_CLASS(vector_activate,
284284

285285
TP_PROTO(unsigned int irq, bool is_managed, bool can_reserve,
286-
bool early),
286+
bool reserve),
287287

288-
TP_ARGS(irq, is_managed, can_reserve, early),
288+
TP_ARGS(irq, is_managed, can_reserve, reserve),
289289

290290
TP_STRUCT__entry(
291291
__field( unsigned int, irq )
292292
__field( bool, is_managed )
293293
__field( bool, can_reserve )
294-
__field( bool, early )
294+
__field( bool, reserve )
295295
),
296296

297297
TP_fast_assign(
298298
__entry->irq = irq;
299299
__entry->is_managed = is_managed;
300300
__entry->can_reserve = can_reserve;
301-
__entry->early = early;
301+
__entry->reserve = reserve;
302302
),
303303

304-
TP_printk("irq=%u is_managed=%d can_reserve=%d early=%d",
304+
TP_printk("irq=%u is_managed=%d can_reserve=%d reserve=%d",
305305
__entry->irq, __entry->is_managed, __entry->can_reserve,
306-
__entry->early)
306+
__entry->reserve)
307307
);
308308

309309
#define DEFINE_IRQ_VECTOR_ACTIVATE_EVENT(name) \
310310
DEFINE_EVENT_FN(vector_activate, name, \
311311
TP_PROTO(unsigned int irq, bool is_managed, \
312-
bool can_reserve, bool early), \
313-
TP_ARGS(irq, is_managed, can_reserve, early), NULL, NULL); \
312+
bool can_reserve, bool reserve), \
313+
TP_ARGS(irq, is_managed, can_reserve, reserve), NULL, NULL); \
314314

315315
DEFINE_IRQ_VECTOR_ACTIVATE_EVENT(vector_activate);
316316
DEFINE_IRQ_VECTOR_ACTIVATE_EVENT(vector_deactivate);

arch/x86/kernel/apic/io_apic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2988,7 +2988,7 @@ void mp_irqdomain_free(struct irq_domain *domain, unsigned int virq,
29882988
}
29892989

29902990
int mp_irqdomain_activate(struct irq_domain *domain,
2991-
struct irq_data *irq_data, bool early)
2991+
struct irq_data *irq_data, bool reserve)
29922992
{
29932993
unsigned long flags;
29942994

arch/x86/kernel/apic/vector.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static void reserve_irq_vector_locked(struct irq_data *irqd)
184184
irq_matrix_reserve(vector_matrix);
185185
apicd->can_reserve = true;
186186
apicd->has_reserved = true;
187+
irqd_set_can_reserve(irqd);
187188
trace_vector_reserve(irqd->irq, 0);
188189
vector_assign_managed_shutdown(irqd);
189190
}
@@ -368,8 +369,18 @@ static int activate_reserved(struct irq_data *irqd)
368369
int ret;
369370

370371
ret = assign_irq_vector_any_locked(irqd);
371-
if (!ret)
372+
if (!ret) {
372373
apicd->has_reserved = false;
374+
/*
375+
* Core might have disabled reservation mode after
376+
* allocating the irq descriptor. Ideally this should
377+
* happen before allocation time, but that would require
378+
* completely convoluted ways of transporting that
379+
* information.
380+
*/
381+
if (!irqd_can_reserve(irqd))
382+
apicd->can_reserve = false;
383+
}
373384
return ret;
374385
}
375386

@@ -398,21 +409,21 @@ static int activate_managed(struct irq_data *irqd)
398409
}
399410

400411
static int x86_vector_activate(struct irq_domain *dom, struct irq_data *irqd,
401-
bool early)
412+
bool reserve)
402413
{
403414
struct apic_chip_data *apicd = apic_chip_data(irqd);
404415
unsigned long flags;
405416
int ret = 0;
406417

407418
trace_vector_activate(irqd->irq, apicd->is_managed,
408-
apicd->can_reserve, early);
419+
apicd->can_reserve, reserve);
409420

410421
/* Nothing to do for fixed assigned vectors */
411422
if (!apicd->can_reserve && !apicd->is_managed)
412423
return 0;
413424

414425
raw_spin_lock_irqsave(&vector_lock, flags);
415-
if (early || irqd_is_managed_and_shutdown(irqd))
426+
if (reserve || irqd_is_managed_and_shutdown(irqd))
416427
vector_assign_managed_shutdown(irqd);
417428
else if (apicd->is_managed)
418429
ret = activate_managed(irqd);
@@ -478,6 +489,7 @@ static bool vector_configure_legacy(unsigned int virq, struct irq_data *irqd,
478489
} else {
479490
/* Release the vector */
480491
apicd->can_reserve = true;
492+
irqd_set_can_reserve(irqd);
481493
clear_irq_vector(irqd);
482494
realloc = true;
483495
}

arch/x86/platform/uv/uv_irq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static void uv_domain_free(struct irq_domain *domain, unsigned int virq,
128128
* on the specified blade to allow the sending of MSIs to the specified CPU.
129129
*/
130130
static int uv_domain_activate(struct irq_domain *domain,
131-
struct irq_data *irq_data, bool early)
131+
struct irq_data *irq_data, bool reserve)
132132
{
133133
uv_program_mmr(irqd_cfg(irq_data), irq_data->chip_data);
134134
return 0;

drivers/gpio/gpio-bcm-kona.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ static struct of_device_id const bcm_kona_gpio_of_match[] = {
522522
* category than their parents, so it won't report false recursion.
523523
*/
524524
static struct lock_class_key gpio_lock_class;
525+
static struct lock_class_key gpio_request_class;
525526

526527
static int bcm_kona_gpio_irq_map(struct irq_domain *d, unsigned int irq,
527528
irq_hw_number_t hwirq)
@@ -531,7 +532,7 @@ static int bcm_kona_gpio_irq_map(struct irq_domain *d, unsigned int irq,
531532
ret = irq_set_chip_data(irq, d->host_data);
532533
if (ret < 0)
533534
return ret;
534-
irq_set_lockdep_class(irq, &gpio_lock_class);
535+
irq_set_lockdep_class(irq, &gpio_lock_class, &gpio_request_class);
535536
irq_set_chip_and_handler(irq, &bcm_gpio_irq_chip, handle_simple_irq);
536537
irq_set_noprobe(irq);
537538

drivers/gpio/gpio-brcmstb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ static struct brcmstb_gpio_bank *brcmstb_gpio_hwirq_to_bank(
327327
* category than their parents, so it won't report false recursion.
328328
*/
329329
static struct lock_class_key brcmstb_gpio_irq_lock_class;
330+
static struct lock_class_key brcmstb_gpio_irq_request_class;
330331

331332

332333
static int brcmstb_gpio_irq_map(struct irq_domain *d, unsigned int irq,
@@ -346,7 +347,8 @@ static int brcmstb_gpio_irq_map(struct irq_domain *d, unsigned int irq,
346347
ret = irq_set_chip_data(irq, &bank->gc);
347348
if (ret < 0)
348349
return ret;
349-
irq_set_lockdep_class(irq, &brcmstb_gpio_irq_lock_class);
350+
irq_set_lockdep_class(irq, &brcmstb_gpio_irq_lock_class,
351+
&brcmstb_gpio_irq_request_class);
350352
irq_set_chip_and_handler(irq, &priv->irq_chip, handle_level_irq);
351353
irq_set_noprobe(irq);
352354
return 0;

drivers/gpio/gpio-tegra.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ static const struct dev_pm_ops tegra_gpio_pm_ops = {
565565
* than their parents, so it won't report false recursion.
566566
*/
567567
static struct lock_class_key gpio_lock_class;
568+
static struct lock_class_key gpio_request_class;
568569

569570
static int tegra_gpio_probe(struct platform_device *pdev)
570571
{
@@ -670,7 +671,8 @@ static int tegra_gpio_probe(struct platform_device *pdev)
670671

671672
bank = &tgi->bank_info[GPIO_BANK(gpio)];
672673

673-
irq_set_lockdep_class(irq, &gpio_lock_class);
674+
irq_set_lockdep_class(irq, &gpio_lock_class,
675+
&gpio_request_class);
674676
irq_set_chip_data(irq, bank);
675677
irq_set_chip_and_handler(irq, &tgi->ic, handle_simple_irq);
676678
}

drivers/gpio/gpio-xgene-sb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static int xgene_gpio_sb_to_irq(struct gpio_chip *gc, u32 gpio)
139139

140140
static int xgene_gpio_sb_domain_activate(struct irq_domain *d,
141141
struct irq_data *irq_data,
142-
bool early)
142+
bool reserve)
143143
{
144144
struct xgene_gpio_sb *priv = d->host_data;
145145
u32 gpio = HWIRQ_TO_GPIO(priv, irq_data->hwirq);

drivers/gpio/gpiolib.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ LIST_HEAD(gpio_devices);
7373

7474
static void gpiochip_free_hogs(struct gpio_chip *chip);
7575
static int gpiochip_add_irqchip(struct gpio_chip *gpiochip,
76-
struct lock_class_key *key);
76+
struct lock_class_key *lock_key,
77+
struct lock_class_key *request_key);
7778
static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip);
7879
static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip);
7980
static void gpiochip_irqchip_free_valid_mask(struct gpio_chip *gpiochip);
@@ -1100,7 +1101,8 @@ static void gpiochip_setup_devs(void)
11001101
}
11011102

11021103
int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
1103-
struct lock_class_key *key)
1104+
struct lock_class_key *lock_key,
1105+
struct lock_class_key *request_key)
11041106
{
11051107
unsigned long flags;
11061108
int status = 0;
@@ -1246,7 +1248,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
12461248
if (status)
12471249
goto err_remove_from_list;
12481250

1249-
status = gpiochip_add_irqchip(chip, key);
1251+
status = gpiochip_add_irqchip(chip, lock_key, request_key);
12501252
if (status)
12511253
goto err_remove_chip;
12521254

@@ -1632,7 +1634,7 @@ int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
16321634
* This lock class tells lockdep that GPIO irqs are in a different
16331635
* category than their parents, so it won't report false recursion.
16341636
*/
1635-
irq_set_lockdep_class(irq, chip->irq.lock_key);
1637+
irq_set_lockdep_class(irq, chip->irq.lock_key, chip->irq.request_key);
16361638
irq_set_chip_and_handler(irq, chip->irq.chip, chip->irq.handler);
16371639
/* Chips that use nested thread handlers have them marked */
16381640
if (chip->irq.threaded)
@@ -1712,10 +1714,12 @@ static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset)
17121714
/**
17131715
* gpiochip_add_irqchip() - adds an IRQ chip to a GPIO chip
17141716
* @gpiochip: the GPIO chip to add the IRQ chip to
1715-
* @lock_key: lockdep class
1717+
* @lock_key: lockdep class for IRQ lock
1718+
* @request_key: lockdep class for IRQ request
17161719
*/
17171720
static int gpiochip_add_irqchip(struct gpio_chip *gpiochip,
1718-
struct lock_class_key *lock_key)
1721+
struct lock_class_key *lock_key,
1722+
struct lock_class_key *request_key)
17191723
{
17201724
struct irq_chip *irqchip = gpiochip->irq.chip;
17211725
const struct irq_domain_ops *ops;
@@ -1753,6 +1757,7 @@ static int gpiochip_add_irqchip(struct gpio_chip *gpiochip,
17531757
gpiochip->to_irq = gpiochip_to_irq;
17541758
gpiochip->irq.default_type = type;
17551759
gpiochip->irq.lock_key = lock_key;
1760+
gpiochip->irq.request_key = request_key;
17561761

17571762
if (gpiochip->irq.domain_ops)
17581763
ops = gpiochip->irq.domain_ops;
@@ -1850,7 +1855,8 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
18501855
* @type: the default type for IRQs on this irqchip, pass IRQ_TYPE_NONE
18511856
* to have the core avoid setting up any default type in the hardware.
18521857
* @threaded: whether this irqchip uses a nested thread handler
1853-
* @lock_key: lockdep class
1858+
* @lock_key: lockdep class for IRQ lock
1859+
* @request_key: lockdep class for IRQ request
18541860
*
18551861
* This function closely associates a certain irqchip with a certain
18561862
* gpiochip, providing an irq domain to translate the local IRQs to
@@ -1872,7 +1878,8 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip,
18721878
irq_flow_handler_t handler,
18731879
unsigned int type,
18741880
bool threaded,
1875-
struct lock_class_key *lock_key)
1881+
struct lock_class_key *lock_key,
1882+
struct lock_class_key *request_key)
18761883
{
18771884
struct device_node *of_node;
18781885

@@ -1913,6 +1920,7 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip,
19131920
gpiochip->irq.default_type = type;
19141921
gpiochip->to_irq = gpiochip_to_irq;
19151922
gpiochip->irq.lock_key = lock_key;
1923+
gpiochip->irq.request_key = request_key;
19161924
gpiochip->irq.domain = irq_domain_add_simple(of_node,
19171925
gpiochip->ngpio, first_irq,
19181926
&gpiochip_domain_ops, gpiochip);
@@ -1940,7 +1948,8 @@ EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_key);
19401948
#else /* CONFIG_GPIOLIB_IRQCHIP */
19411949

19421950
static inline int gpiochip_add_irqchip(struct gpio_chip *gpiochip,
1943-
struct lock_class_key *key)
1951+
struct lock_class_key *lock_key,
1952+
struct lock_class_key *request_key)
19441953
{
19451954
return 0;
19461955
}

drivers/iommu/amd_iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4184,7 +4184,7 @@ static void amd_ir_update_irte(struct irq_data *irqd, struct amd_iommu *iommu,
41844184
struct irq_cfg *cfg);
41854185

41864186
static int irq_remapping_activate(struct irq_domain *domain,
4187-
struct irq_data *irq_data, bool early)
4187+
struct irq_data *irq_data, bool reserve)
41884188
{
41894189
struct amd_ir_data *data = irq_data->chip_data;
41904190
struct irq_2_irte *irte_info = &data->irq_2_irte;

drivers/iommu/intel_irq_remapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ static void intel_irq_remapping_free(struct irq_domain *domain,
13971397
}
13981398

13991399
static int intel_irq_remapping_activate(struct irq_domain *domain,
1400-
struct irq_data *irq_data, bool early)
1400+
struct irq_data *irq_data, bool reserve)
14011401
{
14021402
intel_ir_reconfigure_irte(irq_data, true);
14031403
return 0;

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
23032303
}
23042304

23052305
static int its_irq_domain_activate(struct irq_domain *domain,
2306-
struct irq_data *d, bool early)
2306+
struct irq_data *d, bool reserve)
23072307
{
23082308
struct its_device *its_dev = irq_data_get_irq_chip_data(d);
23092309
u32 event = its_get_event_id(d);
@@ -2818,7 +2818,7 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
28182818
}
28192819

28202820
static int its_vpe_irq_domain_activate(struct irq_domain *domain,
2821-
struct irq_data *d, bool early)
2821+
struct irq_data *d, bool reserve)
28222822
{
28232823
struct its_vpe *vpe = irq_data_get_irq_chip_data(d);
28242824
struct its_node *its;

drivers/irqchip/irq-renesas-intc-irqpin.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ static irqreturn_t intc_irqpin_shared_irq_handler(int irq, void *dev_id)
342342
*/
343343
static struct lock_class_key intc_irqpin_irq_lock_class;
344344

345+
/* And this is for the request mutex */
346+
static struct lock_class_key intc_irqpin_irq_request_class;
347+
345348
static int intc_irqpin_irq_domain_map(struct irq_domain *h, unsigned int virq,
346349
irq_hw_number_t hw)
347350
{
@@ -352,7 +355,8 @@ static int intc_irqpin_irq_domain_map(struct irq_domain *h, unsigned int virq,
352355

353356
intc_irqpin_dbg(&p->irq[hw], "map");
354357
irq_set_chip_data(virq, h->host_data);
355-
irq_set_lockdep_class(virq, &intc_irqpin_irq_lock_class);
358+
irq_set_lockdep_class(virq, &intc_irqpin_irq_lock_class,
359+
&intc_irqpin_irq_request_class);
356360
irq_set_chip_and_handler(virq, &p->irq_chip, handle_level_irq);
357361
return 0;
358362
}

drivers/mfd/arizona-irq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,16 @@ static struct irq_chip arizona_irq_chip = {
184184
};
185185

186186
static struct lock_class_key arizona_irq_lock_class;
187+
static struct lock_class_key arizona_irq_request_class;
187188

188189
static int arizona_irq_map(struct irq_domain *h, unsigned int virq,
189190
irq_hw_number_t hw)
190191
{
191192
struct arizona *data = h->host_data;
192193

193194
irq_set_chip_data(virq, data);
194-
irq_set_lockdep_class(virq, &arizona_irq_lock_class);
195+
irq_set_lockdep_class(virq, &arizona_irq_lock_class,
196+
&arizona_irq_request_class);
195197
irq_set_chip_and_handler(virq, &arizona_irq_chip, handle_simple_irq);
196198
irq_set_nested_thread(virq, 1);
197199
irq_set_noprobe(virq);

0 commit comments

Comments
 (0)