ARM: 6742/1: pmu: avoid setting IRQ affinity on UP systems

Now that we can execute a CONFIG_SMP kernel on a uniprocessor system,
extra care has to be taken in the PMU IRQ affinity setting code to
ensure that we don't always fail to initialise.

This patch changes the CPU PMU initialisation code so that when we
only have a single IRQ, whose affinity can not be changed at the
controller, we report success (0) rather than -EINVAL.

Reported-by: Avik Sil <avik.sil@linaro.org>
Acked-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Will Deacon and committed by Russell King 71efb063 885028e4

+14 -8
+14 -8
arch/arm/kernel/pmu.c
··· 97 irq, cpu); 98 return err; 99 #else 100 - return 0; 101 #endif 102 } 103 104 static int 105 init_cpu_pmu(void) 106 { 107 - int i, err = 0; 108 struct platform_device *pdev = pmu_devices[ARM_PMU_DEVICE_CPU]; 109 110 - if (!pdev) { 111 - err = -ENODEV; 112 - goto out; 113 - } 114 115 - for (i = 0; i < pdev->num_resources; ++i) { 116 err = set_irq_affinity(platform_get_irq(pdev, i), i); 117 if (err) 118 break; 119 } 120 121 - out: 122 return err; 123 } 124
··· 97 irq, cpu); 98 return err; 99 #else 100 + return -EINVAL; 101 #endif 102 } 103 104 static int 105 init_cpu_pmu(void) 106 { 107 + int i, irqs, err = 0; 108 struct platform_device *pdev = pmu_devices[ARM_PMU_DEVICE_CPU]; 109 110 + if (!pdev) 111 + return -ENODEV; 112 113 + irqs = pdev->num_resources; 114 + 115 + /* 116 + * If we have a single PMU interrupt that we can't shift, assume that 117 + * we're running on a uniprocessor machine and continue. 118 + */ 119 + if (irqs == 1 && !irq_can_set_affinity(platform_get_irq(pdev, 0))) 120 + return 0; 121 + 122 + for (i = 0; i < irqs; ++i) { 123 err = set_irq_affinity(platform_get_irq(pdev, i), i); 124 if (err) 125 break; 126 } 127 128 return err; 129 } 130