Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Andrew Lunn and committed by
Thomas Gleixner
39c3fd58 beacbc68

+75 -35
+3 -1
arch/powerpc/sysdev/fsl_msi.c
··· 354 354 } 355 355 356 356 static struct lock_class_key fsl_msi_irq_class; 357 + static struct lock_class_key fsl_msi_irq_request_class; 357 358 358 359 static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev, 359 360 int offset, int irq_index) ··· 374 373 dev_err(&dev->dev, "No memory for MSI cascade data\n"); 375 374 return -ENOMEM; 376 375 } 377 - irq_set_lockdep_class(virt_msir, &fsl_msi_irq_class); 376 + irq_set_lockdep_class(virt_msir, &fsl_msi_irq_class, 377 + &fsl_msi_irq_request_class); 378 378 cascade_data->index = offset; 379 379 cascade_data->msi_data = msi; 380 380 cascade_data->virq = virt_msir;
+2 -1
drivers/gpio/gpio-bcm-kona.c
··· 522 522 * category than their parents, so it won't report false recursion. 523 523 */ 524 524 static struct lock_class_key gpio_lock_class; 525 + static struct lock_class_key gpio_request_class; 525 526 526 527 static int bcm_kona_gpio_irq_map(struct irq_domain *d, unsigned int irq, 527 528 irq_hw_number_t hwirq) ··· 532 531 ret = irq_set_chip_data(irq, d->host_data); 533 532 if (ret < 0) 534 533 return ret; 535 - irq_set_lockdep_class(irq, &gpio_lock_class); 534 + irq_set_lockdep_class(irq, &gpio_lock_class, &gpio_request_class); 536 535 irq_set_chip_and_handler(irq, &bcm_gpio_irq_chip, handle_simple_irq); 537 536 irq_set_noprobe(irq); 538 537
+3 -1
drivers/gpio/gpio-brcmstb.c
··· 327 327 * category than their parents, so it won't report false recursion. 328 328 */ 329 329 static struct lock_class_key brcmstb_gpio_irq_lock_class; 330 + static struct lock_class_key brcmstb_gpio_irq_request_class; 330 331 331 332 332 333 static int brcmstb_gpio_irq_map(struct irq_domain *d, unsigned int irq, ··· 347 346 ret = irq_set_chip_data(irq, &bank->gc); 348 347 if (ret < 0) 349 348 return ret; 350 - irq_set_lockdep_class(irq, &brcmstb_gpio_irq_lock_class); 349 + irq_set_lockdep_class(irq, &brcmstb_gpio_irq_lock_class, 350 + &brcmstb_gpio_irq_lock_class); 351 351 irq_set_chip_and_handler(irq, &priv->irq_chip, handle_level_irq); 352 352 irq_set_noprobe(irq); 353 353 return 0;
+3 -1
drivers/gpio/gpio-tegra.c
··· 565 565 * than their parents, so it won't report false recursion. 566 566 */ 567 567 static struct lock_class_key gpio_lock_class; 568 + static struct lock_class_key gpio_request_class; 568 569 569 570 static int tegra_gpio_probe(struct platform_device *pdev) 570 571 { ··· 671 670 672 671 bank = &tgi->bank_info[GPIO_BANK(gpio)]; 673 672 674 - irq_set_lockdep_class(irq, &gpio_lock_class); 673 + irq_set_lockdep_class(irq, &gpio_lock_class, 674 + &gpio_request_class); 675 675 irq_set_chip_data(irq, bank); 676 676 irq_set_chip_and_handler(irq, &tgi->ic, handle_simple_irq); 677 677 }
+18 -9
drivers/gpio/gpiolib.c
··· 73 73 74 74 static void gpiochip_free_hogs(struct gpio_chip *chip); 75 75 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); 77 78 static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip); 78 79 static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip); 79 80 static void gpiochip_irqchip_free_valid_mask(struct gpio_chip *gpiochip); ··· 1101 1100 } 1102 1101 1103 1102 int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, 1104 - struct lock_class_key *key) 1103 + struct lock_class_key *lock_key, 1104 + struct lock_class_key *request_key) 1105 1105 { 1106 1106 unsigned long flags; 1107 1107 int status = 0; ··· 1248 1246 if (status) 1249 1247 goto err_remove_from_list; 1250 1248 1251 - status = gpiochip_add_irqchip(chip, key); 1249 + status = gpiochip_add_irqchip(chip, lock_key, request_key); 1252 1250 if (status) 1253 1251 goto err_remove_chip; 1254 1252 ··· 1634 1632 * This lock class tells lockdep that GPIO irqs are in a different 1635 1633 * category than their parents, so it won't report false recursion. 1636 1634 */ 1637 - irq_set_lockdep_class(irq, chip->irq.lock_key); 1635 + irq_set_lockdep_class(irq, chip->irq.lock_key, chip->irq.request_key); 1638 1636 irq_set_chip_and_handler(irq, chip->irq.chip, chip->irq.handler); 1639 1637 /* Chips that use nested thread handlers have them marked */ 1640 1638 if (chip->irq.threaded) ··· 1714 1712 /** 1715 1713 * gpiochip_add_irqchip() - adds an IRQ chip to a GPIO chip 1716 1714 * @gpiochip: the GPIO chip to add the IRQ chip to 1717 - * @lock_key: lockdep class 1715 + * @lock_key: lockdep class for IRQ lock 1716 + * @request_key: lockdep class for IRQ request 1718 1717 */ 1719 1718 static int gpiochip_add_irqchip(struct gpio_chip *gpiochip, 1720 - struct lock_class_key *lock_key) 1719 + struct lock_class_key *lock_key, 1720 + struct lock_class_key *request_key) 1721 1721 { 1722 1722 struct irq_chip *irqchip = gpiochip->irq.chip; 1723 1723 const struct irq_domain_ops *ops; ··· 1757 1753 gpiochip->to_irq = gpiochip_to_irq; 1758 1754 gpiochip->irq.default_type = type; 1759 1755 gpiochip->irq.lock_key = lock_key; 1756 + gpiochip->irq.request_key = request_key; 1760 1757 1761 1758 if (gpiochip->irq.domain_ops) 1762 1759 ops = gpiochip->irq.domain_ops; ··· 1855 1850 * @type: the default type for IRQs on this irqchip, pass IRQ_TYPE_NONE 1856 1851 * to have the core avoid setting up any default type in the hardware. 1857 1852 * @threaded: whether this irqchip uses a nested thread handler 1858 - * @lock_key: lockdep class 1853 + * @lock_key: lockdep class for IRQ lock 1854 + * @request_key: lockdep class for IRQ request 1859 1855 * 1860 1856 * This function closely associates a certain irqchip with a certain 1861 1857 * gpiochip, providing an irq domain to translate the local IRQs to ··· 1878 1872 irq_flow_handler_t handler, 1879 1873 unsigned int type, 1880 1874 bool threaded, 1881 - struct lock_class_key *lock_key) 1875 + struct lock_class_key *lock_key, 1876 + struct lock_class_key *request_key) 1882 1877 { 1883 1878 struct device_node *of_node; 1884 1879 ··· 1920 1913 gpiochip->irq.default_type = type; 1921 1914 gpiochip->to_irq = gpiochip_to_irq; 1922 1915 gpiochip->irq.lock_key = lock_key; 1916 + gpiochip->irq.request_key = request_key; 1923 1917 gpiochip->irq.domain = irq_domain_add_simple(of_node, 1924 1918 gpiochip->ngpio, first_irq, 1925 1919 &gpiochip_domain_ops, gpiochip); ··· 1948 1940 #else /* CONFIG_GPIOLIB_IRQCHIP */ 1949 1941 1950 1942 static inline int gpiochip_add_irqchip(struct gpio_chip *gpiochip, 1951 - struct lock_class_key *key) 1943 + struct lock_class_key *lock_key, 1944 + struct lock_class_key *request_key) 1952 1945 { 1953 1946 return 0; 1954 1947 }
+5 -1
drivers/irqchip/irq-renesas-intc-irqpin.c
··· 342 342 */ 343 343 static struct lock_class_key intc_irqpin_irq_lock_class; 344 344 345 + /* And this is for the request mutex */ 346 + static struct lock_class_key intc_irqpin_irq_request_class; 347 + 345 348 static int intc_irqpin_irq_domain_map(struct irq_domain *h, unsigned int virq, 346 349 irq_hw_number_t hw) 347 350 { ··· 355 352 356 353 intc_irqpin_dbg(&p->irq[hw], "map"); 357 354 irq_set_chip_data(virq, h->host_data); 358 - irq_set_lockdep_class(virq, &intc_irqpin_irq_lock_class); 355 + irq_set_lockdep_class(virq, &intc_irqpin_irq_lock_class, 356 + &intc_irqpin_irq_request_class); 359 357 irq_set_chip_and_handler(virq, &p->irq_chip, handle_level_irq); 360 358 return 0; 361 359 }
+3 -1
drivers/mfd/arizona-irq.c
··· 184 184 }; 185 185 186 186 static struct lock_class_key arizona_irq_lock_class; 187 + static struct lock_class_key arizona_irq_request_class; 187 188 188 189 static int arizona_irq_map(struct irq_domain *h, unsigned int virq, 189 190 irq_hw_number_t hw) ··· 192 191 struct arizona *data = h->host_data; 193 192 194 193 irq_set_chip_data(virq, data); 195 - irq_set_lockdep_class(virq, &arizona_irq_lock_class); 194 + irq_set_lockdep_class(virq, &arizona_irq_lock_class, 195 + &arizona_irq_request_class); 196 196 irq_set_chip_and_handler(virq, &arizona_irq_chip, handle_simple_irq); 197 197 irq_set_nested_thread(virq, 1); 198 198 irq_set_noprobe(virq);
+4 -1
drivers/pinctrl/pinctrl-single.c
··· 222 222 */ 223 223 static struct lock_class_key pcs_lock_class; 224 224 225 + /* Class for the IRQ request mutex */ 226 + static struct lock_class_key pcs_request_class; 227 + 225 228 /* 226 229 * REVISIT: Reads and writes could eventually use regmap or something 227 230 * generic. But at least on omaps, some mux registers are performance ··· 1489 1486 irq_set_chip_data(irq, pcs_soc); 1490 1487 irq_set_chip_and_handler(irq, &pcs->chip, 1491 1488 handle_level_irq); 1492 - irq_set_lockdep_class(irq, &pcs_lock_class); 1489 + irq_set_lockdep_class(irq, &pcs_lock_class, &pcs_request_class); 1493 1490 irq_set_noprobe(irq); 1494 1491 1495 1492 return 0;
+21 -12
include/linux/gpio/driver.h
··· 66 66 /** 67 67 * @lock_key: 68 68 * 69 - * Per GPIO IRQ chip lockdep class. 69 + * Per GPIO IRQ chip lockdep classes. 70 70 */ 71 71 struct lock_class_key *lock_key; 72 + struct lock_class_key *request_key; 72 73 73 74 /** 74 75 * @parent_handler: ··· 324 323 325 324 /* add/remove chips */ 326 325 extern int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, 327 - struct lock_class_key *lock_key); 326 + struct lock_class_key *lock_key, 327 + struct lock_class_key *request_key); 328 328 329 329 /** 330 330 * gpiochip_add_data() - register a gpio_chip ··· 352 350 */ 353 351 #ifdef CONFIG_LOCKDEP 354 352 #define gpiochip_add_data(chip, data) ({ \ 355 - static struct lock_class_key key; \ 356 - gpiochip_add_data_with_key(chip, data, &key); \ 353 + static struct lock_class_key lock_key; \ 354 + static struct lock_class_key request_key; \ 355 + gpiochip_add_data_with_key(chip, data, &lock_key, \ 356 + &request_key); \ 357 357 }) 358 358 #else 359 - #define gpiochip_add_data(chip, data) gpiochip_add_data_with_key(chip, data, NULL) 359 + #define gpiochip_add_data(chip, data) gpiochip_add_data_with_key(chip, data, NULL, NULL) 360 360 #endif 361 361 362 362 static inline int gpiochip_add(struct gpio_chip *chip) ··· 433 429 irq_flow_handler_t handler, 434 430 unsigned int type, 435 431 bool threaded, 436 - struct lock_class_key *lock_key); 432 + struct lock_class_key *lock_key, 433 + struct lock_class_key *request_key); 437 434 438 435 #ifdef CONFIG_LOCKDEP 439 436 ··· 450 445 irq_flow_handler_t handler, 451 446 unsigned int type) 452 447 { 453 - static struct lock_class_key key; 448 + static struct lock_class_key lock_key; 449 + static struct lock_class_key request_key; 454 450 455 451 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, 456 - handler, type, false, &key); 452 + handler, type, false, 453 + &lock_key, &request_key); 457 454 } 458 455 459 456 static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, ··· 465 458 unsigned int type) 466 459 { 467 460 468 - static struct lock_class_key key; 461 + static struct lock_class_key lock_key; 462 + static struct lock_class_key request_key; 469 463 470 464 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, 471 - handler, type, true, &key); 465 + handler, type, true, 466 + &lock_key, &request_key); 472 467 } 473 468 #else 474 469 static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip, ··· 480 471 unsigned int type) 481 472 { 482 473 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, 483 - handler, type, false, NULL); 474 + handler, type, false, NULL, NULL); 484 475 } 485 476 486 477 static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, ··· 490 481 unsigned int type) 491 482 { 492 483 return gpiochip_irqchip_add_key(gpiochip, irqchip, first_irq, 493 - handler, type, true, NULL); 484 + handler, type, true, NULL, NULL); 494 485 } 495 486 #endif /* CONFIG_LOCKDEP */ 496 487
+6 -3
include/linux/irqdesc.h
··· 255 255 } 256 256 257 257 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) 259 260 { 260 261 struct irq_desc *desc = irq_to_desc(irq); 261 262 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 + } 264 267 } 265 268 266 269 #ifdef CONFIG_IRQ_PREFLOW_FASTEOI
+7 -4
kernel/irq/generic-chip.c
··· 364 364 EXPORT_SYMBOL_GPL(irq_get_domain_generic_chip); 365 365 366 366 /* 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. 369 369 */ 370 370 static struct lock_class_key irq_nested_lock_class; 371 + static struct lock_class_key irq_nested_request_class; 371 372 372 373 /* 373 374 * irq_map_generic_chip - Map a generic chip for an irq domain ··· 410 409 set_bit(idx, &gc->installed); 411 410 412 411 if (dgc->gc_flags & IRQ_GC_INIT_NESTED_LOCK) 413 - irq_set_lockdep_class(virq, &irq_nested_lock_class); 412 + irq_set_lockdep_class(virq, &irq_nested_lock_class, 413 + &irq_nested_request_class); 414 414 415 415 if (chip->irq_calc_mask) 416 416 chip->irq_calc_mask(data); ··· 481 479 continue; 482 480 483 481 if (flags & IRQ_GC_INIT_NESTED_LOCK) 484 - irq_set_lockdep_class(i, &irq_nested_lock_class); 482 + irq_set_lockdep_class(i, &irq_nested_lock_class, 483 + &irq_nested_request_class); 485 484 486 485 if (!(flags & IRQ_GC_NO_MASK)) { 487 486 struct irq_data *d = irq_get_irq_data(i);