diff options
author | Yinghai Lu <yinghai@kernel.org> | 2009-04-27 20:59:21 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-28 06:21:16 -0400 |
commit | d5dedd4507d307eb3f35f21b6e16f336fdc0d82a (patch) | |
tree | 2c31b00395bde49ec4c5a415b081daaec44d3dab /arch/x86/kernel/apic/io_apic.c | |
parent | fcef5911c7ea89b80d5bfc727f402f37c9eefd57 (diff) |
irq: change ->set_affinity() to return status
according to Ingo, change set_affinity() in irq_chip should return int,
because that way we can handle failure cases in a much cleaner way, in
the genirq layer.
v2: fix two typos
[ Impact: extend API ]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-arch@vger.kernel.org
LKML-Reference: <49F654E9.4070809@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/apic/io_apic.c')
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 9fbf0f7ec7eb..5c7630b40a54 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -574,13 +574,14 @@ set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) | |||
574 | return apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain); | 574 | return apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain); |
575 | } | 575 | } |
576 | 576 | ||
577 | static void | 577 | static int |
578 | set_ioapic_affinity_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | 578 | set_ioapic_affinity_irq_desc(struct irq_desc *desc, const struct cpumask *mask) |
579 | { | 579 | { |
580 | struct irq_cfg *cfg; | 580 | struct irq_cfg *cfg; |
581 | unsigned long flags; | 581 | unsigned long flags; |
582 | unsigned int dest; | 582 | unsigned int dest; |
583 | unsigned int irq; | 583 | unsigned int irq; |
584 | int ret = -1; | ||
584 | 585 | ||
585 | irq = desc->irq; | 586 | irq = desc->irq; |
586 | cfg = desc->chip_data; | 587 | cfg = desc->chip_data; |
@@ -591,18 +592,21 @@ set_ioapic_affinity_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | |||
591 | /* Only the high 8 bits are valid. */ | 592 | /* Only the high 8 bits are valid. */ |
592 | dest = SET_APIC_LOGICAL_ID(dest); | 593 | dest = SET_APIC_LOGICAL_ID(dest); |
593 | __target_IO_APIC_irq(irq, dest, cfg); | 594 | __target_IO_APIC_irq(irq, dest, cfg); |
595 | ret = 0; | ||
594 | } | 596 | } |
595 | spin_unlock_irqrestore(&ioapic_lock, flags); | 597 | spin_unlock_irqrestore(&ioapic_lock, flags); |
598 | |||
599 | return ret; | ||
596 | } | 600 | } |
597 | 601 | ||
598 | static void | 602 | static int |
599 | set_ioapic_affinity_irq(unsigned int irq, const struct cpumask *mask) | 603 | set_ioapic_affinity_irq(unsigned int irq, const struct cpumask *mask) |
600 | { | 604 | { |
601 | struct irq_desc *desc; | 605 | struct irq_desc *desc; |
602 | 606 | ||
603 | desc = irq_to_desc(irq); | 607 | desc = irq_to_desc(irq); |
604 | 608 | ||
605 | set_ioapic_affinity_irq_desc(desc, mask); | 609 | return set_ioapic_affinity_irq_desc(desc, mask); |
606 | } | 610 | } |
607 | #endif /* CONFIG_SMP */ | 611 | #endif /* CONFIG_SMP */ |
608 | 612 | ||
@@ -2348,24 +2352,25 @@ static int ioapic_retrigger_irq(unsigned int irq) | |||
2348 | * Real vector that is used for interrupting cpu will be coming from | 2352 | * Real vector that is used for interrupting cpu will be coming from |
2349 | * the interrupt-remapping table entry. | 2353 | * the interrupt-remapping table entry. |
2350 | */ | 2354 | */ |
2351 | static void | 2355 | static int |
2352 | migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | 2356 | migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) |
2353 | { | 2357 | { |
2354 | struct irq_cfg *cfg; | 2358 | struct irq_cfg *cfg; |
2355 | struct irte irte; | 2359 | struct irte irte; |
2356 | unsigned int dest; | 2360 | unsigned int dest; |
2357 | unsigned int irq; | 2361 | unsigned int irq; |
2362 | int ret = -1; | ||
2358 | 2363 | ||
2359 | if (!cpumask_intersects(mask, cpu_online_mask)) | 2364 | if (!cpumask_intersects(mask, cpu_online_mask)) |
2360 | return; | 2365 | return ret; |
2361 | 2366 | ||
2362 | irq = desc->irq; | 2367 | irq = desc->irq; |
2363 | if (get_irte(irq, &irte)) | 2368 | if (get_irte(irq, &irte)) |
2364 | return; | 2369 | return ret; |
2365 | 2370 | ||
2366 | cfg = desc->chip_data; | 2371 | cfg = desc->chip_data; |
2367 | if (assign_irq_vector(irq, cfg, mask)) | 2372 | if (assign_irq_vector(irq, cfg, mask)) |
2368 | return; | 2373 | return ret; |
2369 | 2374 | ||
2370 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask); | 2375 | dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask); |
2371 | 2376 | ||
@@ -2381,27 +2386,30 @@ migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | |||
2381 | send_cleanup_vector(cfg); | 2386 | send_cleanup_vector(cfg); |
2382 | 2387 | ||
2383 | cpumask_copy(desc->affinity, mask); | 2388 | cpumask_copy(desc->affinity, mask); |
2389 | |||
2390 | return 0; | ||
2384 | } | 2391 | } |
2385 | 2392 | ||
2386 | /* | 2393 | /* |
2387 | * Migrates the IRQ destination in the process context. | 2394 | * Migrates the IRQ destination in the process context. |
2388 | */ | 2395 | */ |
2389 | static void set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc, | 2396 | static int set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc, |
2390 | const struct cpumask *mask) | 2397 | const struct cpumask *mask) |
2391 | { | 2398 | { |
2392 | migrate_ioapic_irq_desc(desc, mask); | 2399 | return migrate_ioapic_irq_desc(desc, mask); |
2393 | } | 2400 | } |
2394 | static void set_ir_ioapic_affinity_irq(unsigned int irq, | 2401 | static int set_ir_ioapic_affinity_irq(unsigned int irq, |
2395 | const struct cpumask *mask) | 2402 | const struct cpumask *mask) |
2396 | { | 2403 | { |
2397 | struct irq_desc *desc = irq_to_desc(irq); | 2404 | struct irq_desc *desc = irq_to_desc(irq); |
2398 | 2405 | ||
2399 | set_ir_ioapic_affinity_irq_desc(desc, mask); | 2406 | return set_ir_ioapic_affinity_irq_desc(desc, mask); |
2400 | } | 2407 | } |
2401 | #else | 2408 | #else |
2402 | static inline void set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc, | 2409 | static inline int set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc, |
2403 | const struct cpumask *mask) | 2410 | const struct cpumask *mask) |
2404 | { | 2411 | { |
2412 | return 0; | ||
2405 | } | 2413 | } |
2406 | #endif | 2414 | #endif |
2407 | 2415 | ||
@@ -3318,7 +3326,7 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms | |||
3318 | } | 3326 | } |
3319 | 3327 | ||
3320 | #ifdef CONFIG_SMP | 3328 | #ifdef CONFIG_SMP |
3321 | static void set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) | 3329 | static int set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) |
3322 | { | 3330 | { |
3323 | struct irq_desc *desc = irq_to_desc(irq); | 3331 | struct irq_desc *desc = irq_to_desc(irq); |
3324 | struct irq_cfg *cfg; | 3332 | struct irq_cfg *cfg; |
@@ -3327,7 +3335,7 @@ static void set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) | |||
3327 | 3335 | ||
3328 | dest = set_desc_affinity(desc, mask); | 3336 | dest = set_desc_affinity(desc, mask); |
3329 | if (dest == BAD_APICID) | 3337 | if (dest == BAD_APICID) |
3330 | return; | 3338 | return -1; |
3331 | 3339 | ||
3332 | cfg = desc->chip_data; | 3340 | cfg = desc->chip_data; |
3333 | 3341 | ||
@@ -3339,13 +3347,15 @@ static void set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) | |||
3339 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); | 3347 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); |
3340 | 3348 | ||
3341 | write_msi_msg_desc(desc, &msg); | 3349 | write_msi_msg_desc(desc, &msg); |
3350 | |||
3351 | return 0; | ||
3342 | } | 3352 | } |
3343 | #ifdef CONFIG_INTR_REMAP | 3353 | #ifdef CONFIG_INTR_REMAP |
3344 | /* | 3354 | /* |
3345 | * Migrate the MSI irq to another cpumask. This migration is | 3355 | * Migrate the MSI irq to another cpumask. This migration is |
3346 | * done in the process context using interrupt-remapping hardware. | 3356 | * done in the process context using interrupt-remapping hardware. |
3347 | */ | 3357 | */ |
3348 | static void | 3358 | static int |
3349 | ir_set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) | 3359 | ir_set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) |
3350 | { | 3360 | { |
3351 | struct irq_desc *desc = irq_to_desc(irq); | 3361 | struct irq_desc *desc = irq_to_desc(irq); |
@@ -3354,11 +3364,11 @@ ir_set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) | |||
3354 | struct irte irte; | 3364 | struct irte irte; |
3355 | 3365 | ||
3356 | if (get_irte(irq, &irte)) | 3366 | if (get_irte(irq, &irte)) |
3357 | return; | 3367 | return -1; |
3358 | 3368 | ||
3359 | dest = set_desc_affinity(desc, mask); | 3369 | dest = set_desc_affinity(desc, mask); |
3360 | if (dest == BAD_APICID) | 3370 | if (dest == BAD_APICID) |
3361 | return; | 3371 | return -1; |
3362 | 3372 | ||
3363 | irte.vector = cfg->vector; | 3373 | irte.vector = cfg->vector; |
3364 | irte.dest_id = IRTE_DEST(dest); | 3374 | irte.dest_id = IRTE_DEST(dest); |
@@ -3375,6 +3385,8 @@ ir_set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) | |||
3375 | */ | 3385 | */ |
3376 | if (cfg->move_in_progress) | 3386 | if (cfg->move_in_progress) |
3377 | send_cleanup_vector(cfg); | 3387 | send_cleanup_vector(cfg); |
3388 | |||
3389 | return 0; | ||
3378 | } | 3390 | } |
3379 | 3391 | ||
3380 | #endif | 3392 | #endif |
@@ -3528,7 +3540,7 @@ void arch_teardown_msi_irq(unsigned int irq) | |||
3528 | 3540 | ||
3529 | #if defined (CONFIG_DMAR) || defined (CONFIG_INTR_REMAP) | 3541 | #if defined (CONFIG_DMAR) || defined (CONFIG_INTR_REMAP) |
3530 | #ifdef CONFIG_SMP | 3542 | #ifdef CONFIG_SMP |
3531 | static void dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask) | 3543 | static int dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask) |
3532 | { | 3544 | { |
3533 | struct irq_desc *desc = irq_to_desc(irq); | 3545 | struct irq_desc *desc = irq_to_desc(irq); |
3534 | struct irq_cfg *cfg; | 3546 | struct irq_cfg *cfg; |
@@ -3537,7 +3549,7 @@ static void dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask) | |||
3537 | 3549 | ||
3538 | dest = set_desc_affinity(desc, mask); | 3550 | dest = set_desc_affinity(desc, mask); |
3539 | if (dest == BAD_APICID) | 3551 | if (dest == BAD_APICID) |
3540 | return; | 3552 | return -1; |
3541 | 3553 | ||
3542 | cfg = desc->chip_data; | 3554 | cfg = desc->chip_data; |
3543 | 3555 | ||
@@ -3549,6 +3561,8 @@ static void dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask) | |||
3549 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); | 3561 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); |
3550 | 3562 | ||
3551 | dmar_msi_write(irq, &msg); | 3563 | dmar_msi_write(irq, &msg); |
3564 | |||
3565 | return 0; | ||
3552 | } | 3566 | } |
3553 | 3567 | ||
3554 | #endif /* CONFIG_SMP */ | 3568 | #endif /* CONFIG_SMP */ |
@@ -3582,7 +3596,7 @@ int arch_setup_dmar_msi(unsigned int irq) | |||
3582 | #ifdef CONFIG_HPET_TIMER | 3596 | #ifdef CONFIG_HPET_TIMER |
3583 | 3597 | ||
3584 | #ifdef CONFIG_SMP | 3598 | #ifdef CONFIG_SMP |
3585 | static void hpet_msi_set_affinity(unsigned int irq, const struct cpumask *mask) | 3599 | static int hpet_msi_set_affinity(unsigned int irq, const struct cpumask *mask) |
3586 | { | 3600 | { |
3587 | struct irq_desc *desc = irq_to_desc(irq); | 3601 | struct irq_desc *desc = irq_to_desc(irq); |
3588 | struct irq_cfg *cfg; | 3602 | struct irq_cfg *cfg; |
@@ -3591,7 +3605,7 @@ static void hpet_msi_set_affinity(unsigned int irq, const struct cpumask *mask) | |||
3591 | 3605 | ||
3592 | dest = set_desc_affinity(desc, mask); | 3606 | dest = set_desc_affinity(desc, mask); |
3593 | if (dest == BAD_APICID) | 3607 | if (dest == BAD_APICID) |
3594 | return; | 3608 | return -1; |
3595 | 3609 | ||
3596 | cfg = desc->chip_data; | 3610 | cfg = desc->chip_data; |
3597 | 3611 | ||
@@ -3603,6 +3617,8 @@ static void hpet_msi_set_affinity(unsigned int irq, const struct cpumask *mask) | |||
3603 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); | 3617 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); |
3604 | 3618 | ||
3605 | hpet_msi_write(irq, &msg); | 3619 | hpet_msi_write(irq, &msg); |
3620 | |||
3621 | return 0; | ||
3606 | } | 3622 | } |
3607 | 3623 | ||
3608 | #endif /* CONFIG_SMP */ | 3624 | #endif /* CONFIG_SMP */ |
@@ -3659,7 +3675,7 @@ static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector) | |||
3659 | write_ht_irq_msg(irq, &msg); | 3675 | write_ht_irq_msg(irq, &msg); |
3660 | } | 3676 | } |
3661 | 3677 | ||
3662 | static void set_ht_irq_affinity(unsigned int irq, const struct cpumask *mask) | 3678 | static int set_ht_irq_affinity(unsigned int irq, const struct cpumask *mask) |
3663 | { | 3679 | { |
3664 | struct irq_desc *desc = irq_to_desc(irq); | 3680 | struct irq_desc *desc = irq_to_desc(irq); |
3665 | struct irq_cfg *cfg; | 3681 | struct irq_cfg *cfg; |
@@ -3667,11 +3683,13 @@ static void set_ht_irq_affinity(unsigned int irq, const struct cpumask *mask) | |||
3667 | 3683 | ||
3668 | dest = set_desc_affinity(desc, mask); | 3684 | dest = set_desc_affinity(desc, mask); |
3669 | if (dest == BAD_APICID) | 3685 | if (dest == BAD_APICID) |
3670 | return; | 3686 | return -1; |
3671 | 3687 | ||
3672 | cfg = desc->chip_data; | 3688 | cfg = desc->chip_data; |
3673 | 3689 | ||
3674 | target_ht_irq(irq, dest, cfg->vector); | 3690 | target_ht_irq(irq, dest, cfg->vector); |
3691 | |||
3692 | return 0; | ||
3675 | } | 3693 | } |
3676 | 3694 | ||
3677 | #endif | 3695 | #endif |