manage.c (091738a266fc74329ae186f22ff2b3f01319112d) | manage.c (02725e7471b8dd58fa96f6604bdb5dde45405a2e) |
---|---|
1/* 2 * linux/kernel/irq/manage.c 3 * 4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar 5 * Copyright (C) 2005-2006 Thomas Gleixner 6 * 7 * This file contains driver APIs to the irq subsystem. 8 */ --- 158 unchanged lines hidden (view full) --- 167 irq_compat_set_affinity(desc); 168 irqd_set(&desc->irq_data, IRQD_AFFINITY_SET); 169 raw_spin_unlock_irqrestore(&desc->lock, flags); 170 return ret; 171} 172 173int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m) 174{ | 1/* 2 * linux/kernel/irq/manage.c 3 * 4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar 5 * Copyright (C) 2005-2006 Thomas Gleixner 6 * 7 * This file contains driver APIs to the irq subsystem. 8 */ --- 158 unchanged lines hidden (view full) --- 167 irq_compat_set_affinity(desc); 168 irqd_set(&desc->irq_data, IRQD_AFFINITY_SET); 169 raw_spin_unlock_irqrestore(&desc->lock, flags); 170 return ret; 171} 172 173int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m) 174{ |
175 struct irq_desc *desc = irq_to_desc(irq); | |
176 unsigned long flags; | 175 unsigned long flags; |
176 struct irq_desc *desc = irq_get_desc_lock(irq, &flags); |
|
177 178 if (!desc) 179 return -EINVAL; | 177 178 if (!desc) 179 return -EINVAL; |
180 181 raw_spin_lock_irqsave(&desc->lock, flags); | |
182 desc->affinity_hint = m; | 180 desc->affinity_hint = m; |
183 raw_spin_unlock_irqrestore(&desc->lock, flags); 184 | 181 irq_put_desc_unlock(desc, flags); |
185 return 0; 186} 187EXPORT_SYMBOL_GPL(irq_set_affinity_hint); 188 189static void irq_affinity_notify(struct work_struct *work) 190{ 191 struct irq_affinity_notify *notify = 192 container_of(work, struct irq_affinity_notify, work); --- 138 unchanged lines hidden (view full) --- 331 return; 332 desc->istate |= IRQS_SUSPENDED; 333 } 334 335 if (!desc->depth++) 336 irq_disable(desc); 337} 338 | 182 return 0; 183} 184EXPORT_SYMBOL_GPL(irq_set_affinity_hint); 185 186static void irq_affinity_notify(struct work_struct *work) 187{ 188 struct irq_affinity_notify *notify = 189 container_of(work, struct irq_affinity_notify, work); --- 138 unchanged lines hidden (view full) --- 328 return; 329 desc->istate |= IRQS_SUSPENDED; 330 } 331 332 if (!desc->depth++) 333 irq_disable(desc); 334} 335 |
336static int __disable_irq_nosync(unsigned int irq) 337{ 338 unsigned long flags; 339 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags); 340 341 if (!desc) 342 return -EINVAL; 343 __disable_irq(desc, irq, false); 344 irq_put_desc_busunlock(desc, flags); 345 return 0; 346} 347 |
|
339/** 340 * disable_irq_nosync - disable an irq without waiting 341 * @irq: Interrupt to disable 342 * 343 * Disable the selected interrupt line. Disables and Enables are 344 * nested. 345 * Unlike disable_irq(), this function does not ensure existing 346 * instances of the IRQ handler have completed before returning. 347 * 348 * This function may be called from IRQ context. 349 */ 350void disable_irq_nosync(unsigned int irq) 351{ | 348/** 349 * disable_irq_nosync - disable an irq without waiting 350 * @irq: Interrupt to disable 351 * 352 * Disable the selected interrupt line. Disables and Enables are 353 * nested. 354 * Unlike disable_irq(), this function does not ensure existing 355 * instances of the IRQ handler have completed before returning. 356 * 357 * This function may be called from IRQ context. 358 */ 359void disable_irq_nosync(unsigned int irq) 360{ |
352 struct irq_desc *desc = irq_to_desc(irq); 353 unsigned long flags; 354 355 if (!desc) 356 return; 357 358 chip_bus_lock(desc); 359 raw_spin_lock_irqsave(&desc->lock, flags); 360 __disable_irq(desc, irq, false); 361 raw_spin_unlock_irqrestore(&desc->lock, flags); 362 chip_bus_sync_unlock(desc); | 361 __disable_irq_nosync(irq); |
363} 364EXPORT_SYMBOL(disable_irq_nosync); 365 366/** 367 * disable_irq - disable an irq and wait for completion 368 * @irq: Interrupt to disable 369 * 370 * Disable the selected interrupt line. Enables and Disables are 371 * nested. 372 * This function waits for any pending IRQ handlers for this interrupt 373 * to complete before returning. If you use this function while 374 * holding a resource the IRQ handler may need you will deadlock. 375 * 376 * This function may be called - with care - from IRQ context. 377 */ 378void disable_irq(unsigned int irq) 379{ | 362} 363EXPORT_SYMBOL(disable_irq_nosync); 364 365/** 366 * disable_irq - disable an irq and wait for completion 367 * @irq: Interrupt to disable 368 * 369 * Disable the selected interrupt line. Enables and Disables are 370 * nested. 371 * This function waits for any pending IRQ handlers for this interrupt 372 * to complete before returning. If you use this function while 373 * holding a resource the IRQ handler may need you will deadlock. 374 * 375 * This function may be called - with care - from IRQ context. 376 */ 377void disable_irq(unsigned int irq) 378{ |
380 struct irq_desc *desc = irq_to_desc(irq); 381 382 if (!desc) 383 return; 384 385 disable_irq_nosync(irq); 386 if (desc->action) | 379 if (!__disable_irq_nosync(irq)) |
387 synchronize_irq(irq); 388} 389EXPORT_SYMBOL(disable_irq); 390 391void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume) 392{ 393 if (resume) { 394 if (!(desc->istate & IRQS_SUSPENDED)) { --- 34 unchanged lines hidden (view full) --- 429 * matches the last disable, processing of interrupts on this 430 * IRQ line is re-enabled. 431 * 432 * This function may be called from IRQ context only when 433 * desc->irq_data.chip->bus_lock and desc->chip->bus_sync_unlock are NULL ! 434 */ 435void enable_irq(unsigned int irq) 436{ | 380 synchronize_irq(irq); 381} 382EXPORT_SYMBOL(disable_irq); 383 384void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume) 385{ 386 if (resume) { 387 if (!(desc->istate & IRQS_SUSPENDED)) { --- 34 unchanged lines hidden (view full) --- 422 * matches the last disable, processing of interrupts on this 423 * IRQ line is re-enabled. 424 * 425 * This function may be called from IRQ context only when 426 * desc->irq_data.chip->bus_lock and desc->chip->bus_sync_unlock are NULL ! 427 */ 428void enable_irq(unsigned int irq) 429{ |
437 struct irq_desc *desc = irq_to_desc(irq); | |
438 unsigned long flags; | 430 unsigned long flags; |
431 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags); |
|
439 440 if (!desc) 441 return; | 432 433 if (!desc) 434 return; |
442 | |
443 if (WARN(!desc->irq_data.chip, 444 KERN_ERR "enable_irq before setup/request_irq: irq %u\n", irq)) | 435 if (WARN(!desc->irq_data.chip, 436 KERN_ERR "enable_irq before setup/request_irq: irq %u\n", irq)) |
445 return; | 437 goto out; |
446 | 438 |
447 chip_bus_lock(desc); 448 raw_spin_lock_irqsave(&desc->lock, flags); | |
449 __enable_irq(desc, irq, false); | 439 __enable_irq(desc, irq, false); |
450 raw_spin_unlock_irqrestore(&desc->lock, flags); 451 chip_bus_sync_unlock(desc); | 440out: 441 irq_put_desc_busunlock(desc, flags); |
452} 453EXPORT_SYMBOL(enable_irq); 454 455static int set_irq_wake_real(unsigned int irq, unsigned int on) 456{ 457 struct irq_desc *desc = irq_to_desc(irq); 458 int ret = -ENXIO; 459 --- 12 unchanged lines hidden (view full) --- 472 * disabled by default. Enables and disables must match, 473 * just as they match for non-wakeup mode support. 474 * 475 * Wakeup mode lets this IRQ wake the system from sleep 476 * states like "suspend to RAM". 477 */ 478int irq_set_irq_wake(unsigned int irq, unsigned int on) 479{ | 442} 443EXPORT_SYMBOL(enable_irq); 444 445static int set_irq_wake_real(unsigned int irq, unsigned int on) 446{ 447 struct irq_desc *desc = irq_to_desc(irq); 448 int ret = -ENXIO; 449 --- 12 unchanged lines hidden (view full) --- 462 * disabled by default. Enables and disables must match, 463 * just as they match for non-wakeup mode support. 464 * 465 * Wakeup mode lets this IRQ wake the system from sleep 466 * states like "suspend to RAM". 467 */ 468int irq_set_irq_wake(unsigned int irq, unsigned int on) 469{ |
480 struct irq_desc *desc = irq_to_desc(irq); | |
481 unsigned long flags; | 470 unsigned long flags; |
471 struct irq_desc *desc = irq_get_desc_buslock(irq, &flags); |
|
482 int ret = 0; 483 484 /* wakeup-capable irqs can be shared between drivers that 485 * don't need to have the same sleep mode behaviors. 486 */ | 472 int ret = 0; 473 474 /* wakeup-capable irqs can be shared between drivers that 475 * don't need to have the same sleep mode behaviors. 476 */ |
487 chip_bus_lock(desc); 488 raw_spin_lock_irqsave(&desc->lock, flags); | |
489 if (on) { 490 if (desc->wake_depth++ == 0) { 491 ret = set_irq_wake_real(irq, on); 492 if (ret) 493 desc->wake_depth = 0; 494 else 495 irqd_set(&desc->irq_data, IRQD_WAKEUP_STATE); 496 } 497 } else { 498 if (desc->wake_depth == 0) { 499 WARN(1, "Unbalanced IRQ %d wake disable\n", irq); 500 } else if (--desc->wake_depth == 0) { 501 ret = set_irq_wake_real(irq, on); 502 if (ret) 503 desc->wake_depth = 1; 504 else 505 irqd_clear(&desc->irq_data, IRQD_WAKEUP_STATE); 506 } 507 } | 477 if (on) { 478 if (desc->wake_depth++ == 0) { 479 ret = set_irq_wake_real(irq, on); 480 if (ret) 481 desc->wake_depth = 0; 482 else 483 irqd_set(&desc->irq_data, IRQD_WAKEUP_STATE); 484 } 485 } else { 486 if (desc->wake_depth == 0) { 487 WARN(1, "Unbalanced IRQ %d wake disable\n", irq); 488 } else if (--desc->wake_depth == 0) { 489 ret = set_irq_wake_real(irq, on); 490 if (ret) 491 desc->wake_depth = 1; 492 else 493 irqd_clear(&desc->irq_data, IRQD_WAKEUP_STATE); 494 } 495 } |
508 509 raw_spin_unlock_irqrestore(&desc->lock, flags); 510 chip_bus_sync_unlock(desc); | 496 irq_put_desc_busunlock(desc, flags); |
511 return ret; 512} 513EXPORT_SYMBOL(irq_set_irq_wake); 514 515/* 516 * Internal function that tells the architecture code whether a 517 * particular irq has been exclusively allocated or is available 518 * for driver use. 519 */ 520int can_request_irq(unsigned int irq, unsigned long irqflags) 521{ | 497 return ret; 498} 499EXPORT_SYMBOL(irq_set_irq_wake); 500 501/* 502 * Internal function that tells the architecture code whether a 503 * particular irq has been exclusively allocated or is available 504 * for driver use. 505 */ 506int can_request_irq(unsigned int irq, unsigned long irqflags) 507{ |
522 struct irq_desc *desc = irq_to_desc(irq); 523 struct irqaction *action; | |
524 unsigned long flags; | 508 unsigned long flags; |
509 struct irq_desc *desc = irq_get_desc_lock(irq, &flags); 510 int canrequest = 0; |
|
525 526 if (!desc) 527 return 0; 528 | 511 512 if (!desc) 513 return 0; 514 |
529 if (!irq_settings_can_request(desc)) 530 return 0; 531 532 raw_spin_lock_irqsave(&desc->lock, flags); 533 action = desc->action; 534 if (action) 535 if (irqflags & action->flags & IRQF_SHARED) 536 action = NULL; 537 538 raw_spin_unlock_irqrestore(&desc->lock, flags); 539 540 return !action; | 515 if (irq_settings_can_request(desc)) { 516 if (desc->action) 517 if (irqflags & desc->action->flags & IRQF_SHARED) 518 canrequest =1; 519 } 520 irq_put_desc_unlock(desc, flags); 521 return canrequest; |
541} 542 543int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, 544 unsigned long flags) 545{ 546 struct irq_chip *chip = desc->irq_data.chip; 547 int ret, unmask = 0; 548 --- 754 unchanged lines hidden --- | 522} 523 524int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, 525 unsigned long flags) 526{ 527 struct irq_chip *chip = desc->irq_data.chip; 528 int ret, unmask = 0; 529 --- 754 unchanged lines hidden --- |