Skip to content

Commit 39c3fd5

Browse files
lunnKAGA-KOKO
authored andcommitted
kernel/irq: Extend lockdep class for request mutex
The IRQ code already has support for lockdep class for the lock mutex in an interrupt descriptor. Extend this to add a second class for the request mutex in the descriptor. Not having a class is resulting in false positive splats in some code paths. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: linus.walleij@linaro.org Cc: grygorii.strashko@ti.com Cc: f.fainelli@gmail.com Link: https://lkml.kernel.org/r/1512234664-21555-1-git-send-email-andrew@lunn.ch
1 parent beacbc6 commit 39c3fd5

File tree

11 files changed

+75
-35
lines changed

11 files changed

+75
-35
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;

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_lock_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/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/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);

drivers/pinctrl/pinctrl-single.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ static enum pin_config_param pcs_bias[] = {
222222
*/
223223
static struct lock_class_key pcs_lock_class;
224224

225+
/* Class for the IRQ request mutex */
226+
static struct lock_class_key pcs_request_class;
227+
225228
/*
226229
* REVISIT: Reads and writes could eventually use regmap or something
227230
* generic. But at least on omaps, some mux registers are performance
@@ -1486,7 +1489,7 @@ static int pcs_irqdomain_map(struct irq_domain *d, unsigned int irq,
14861489
irq_set_chip_data(irq, pcs_soc);
14871490
irq_set_chip_and_handler(irq, &pcs->chip,
14881491
handle_level_irq);
1489-
irq_set_lockdep_class(irq, &pcs_lock_class);
1492+
irq_set_lockdep_class(irq, &pcs_lock_class, &pcs_request_class);
14901493
irq_set_noprobe(irq);
14911494

14921495
return 0;

include/linux/gpio/driver.h

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ struct gpio_irq_chip {
6666
/**
6767
* @lock_key:
6868
*
69-
* Per GPIO IRQ chip lockdep class.
69+
* Per GPIO IRQ chip lockdep classes.
7070
*/
7171
struct lock_class_key *lock_key;
72+
struct lock_class_key *request_key;
7273

7374
/**
7475
* @parent_handler:
@@ -323,7 +324,8 @@ extern const char *gpiochip_is_requested(struct gpio_chip *chip,
323324

324325
/* add/remove chips */
325326
extern int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
326-
struct lock_class_key *lock_key);
327+
struct lock_class_key *lock_key,
328+
struct lock_class_key *request_key);
327329

328330
/**
329331
* gpiochip_add_data() - register a gpio_chip
@@ -350,11 +352,13 @@ extern int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
350352
*/
351353
#ifdef CONFIG_LOCKDEP
352354
#define gpiochip_add_data(chip, data) ({ \
353-
static struct lock_class_key key; \
354-
gpiochip_add_data_with_key(chip, data, &key); \
355+
static struct lock_class_key lock_key; \
356+
static struct lock_class_key request_key; \
357+
gpiochip_add_data_with_key(chip, data, &lock_key, \
358+
&request_key); \
355359
})
356360
#else
357-
#define gpiochip_add_data(chip, data) gpiochip_add_data_with_key(chip, data, NULL)
361+
#define gpiochip_add_data(chip, data) gpiochip_add_data_with_key(chip, data, NULL, NULL)
358362
#endif
359363

360364
static inline int gpiochip_add(struct gpio_chip *chip)
@@ -429,7 +433,8 @@ int gpiochip_irqchip_add_key(struct gpio_chip *gpiochip,
429433
irq_flow_handler_t handler,
430434
unsigned int type,
431435
bool threaded,
432-
struct lock_class_key *lock_key);
436+
struct lock_class_key *lock_key,
437+
struct lock_class_key *request_key);
433438

434439
#ifdef CONFIG_LOCKDEP
435440

@@ -445,10 +450,12 @@ static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
445450
irq_flow_handler_t handler,
446451
unsigned int type)
447452
{
448-
static struct lock_class_key key;
453+
static struct lock_class_key lock_key;
454+
static struct lock_class_key request_key;
449455

450456
return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
451-
handler, type, false, &key);
457+
handler, type, false,
458+
&lock_key, &request_key);
452459
}
453460

454461
static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip,
@@ -458,10 +465,12 @@ static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip,
458465
unsigned int type)
459466
{
460467

461-
static struct lock_class_key key;
468+
static struct lock_class_key lock_key;
469+
static struct lock_class_key request_key;
462470

463471
return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
464-
handler, type, true, &key);
472+
handler, type, true,
473+
&lock_key, &request_key);
465474
}
466475
#else
467476
static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
@@ -471,7 +480,7 @@ static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip,
471480
unsigned int type)
472481
{
473482
return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
474-
handler, type, false, NULL);
483+
handler, type, false, NULL, NULL);
475484
}
476485

477486
static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip,
@@ -481,7 +490,7 @@ static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip,
481490
unsigned int type)
482491
{
483492
return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq,
484-
handler, type, true, NULL);
493+
handler, type, true, NULL, NULL);
485494
}
486495
#endif /* CONFIG_LOCKDEP */
487496

include/linux/irqdesc.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,15 @@ static inline bool irq_is_percpu_devid(unsigned int irq)
255255
}
256256

257257
static inline void
258-
irq_set_lockdep_class(unsigned int irq, struct lock_class_key *class)
258+
irq_set_lockdep_class(unsigned int irq, struct lock_class_key *lock_class,
259+
struct lock_class_key *request_class)
259260
{
260261
struct irq_desc *desc = irq_to_desc(irq);
261262

262-
if (desc)
263-
lockdep_set_class(&desc->lock, class);
263+
if (desc) {
264+
lockdep_set_class(&desc->lock, lock_class);
265+
lockdep_set_class(&desc->request_mutex, request_class);
266+
}
264267
}
265268

266269
#ifdef CONFIG_IRQ_PREFLOW_FASTEOI

kernel/irq/generic-chip.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,11 @@ irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq)
364364
EXPORT_SYMBOL_GPL(irq_get_domain_generic_chip);
365365

366366
/*
367-
* Separate lockdep class for interrupt chip which can nest irq_desc
368-
* lock.
367+
* Separate lockdep classes for interrupt chip which can nest irq_desc
368+
* lock and request mutex.
369369
*/
370370
static struct lock_class_key irq_nested_lock_class;
371+
static struct lock_class_key irq_nested_request_class;
371372

372373
/*
373374
* irq_map_generic_chip - Map a generic chip for an irq domain
@@ -409,7 +410,8 @@ int irq_map_generic_chip(struct irq_domain *d, unsigned int virq,
409410
set_bit(idx, &gc->installed);
410411

411412
if (dgc->gc_flags & IRQ_GC_INIT_NESTED_LOCK)
412-
irq_set_lockdep_class(virq, &irq_nested_lock_class);
413+
irq_set_lockdep_class(virq, &irq_nested_lock_class,
414+
&irq_nested_request_class);
413415

414416
if (chip->irq_calc_mask)
415417
chip->irq_calc_mask(data);
@@ -479,7 +481,8 @@ void irq_setup_generic_chip(struct irq_chip_generic *gc, u32 msk,
479481
continue;
480482

481483
if (flags & IRQ_GC_INIT_NESTED_LOCK)
482-
irq_set_lockdep_class(i, &irq_nested_lock_class);
484+
irq_set_lockdep_class(i, &irq_nested_lock_class,
485+
&irq_nested_request_class);
483486

484487
if (!(flags & IRQ_GC_NO_MASK)) {
485488
struct irq_data *d = irq_get_irq_data(i);

0 commit comments

Comments
 (0)