Message ID | 1377287112-12018-3-git-send-email-ccross@android.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBDb2xpbiBDcm9zcyBbbWFpbHRv OmNjcm9zc0BhbmRyb2lkLmNvbV0NCj4gU2VudDogMjAxM8TqONTCMjTI1SAzOjQ1DQo+IFRvOiBs aW51eC1wbUB2Z2VyLmtlcm5lbC5vcmcNCj4gQ2M6IGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5v cmc7IE5laWwgWmhhbmc7IEpvc2VwaCBMbzsNCj4gbGludXgtdGVncmFAdmdlci5rZXJuZWwub3Jn OyBDb2xpbiBDcm9zczsgc3RhYmxlQHZnZXIua2VybmVsLm9yZzsgUmFmYWVsIEouDQo+IFd5c29j a2k7IERhbmllbCBMZXpjYW5vDQo+IFN1YmplY3Q6IFtQQVRDSCAzLzNdIGNwdWlkbGU6IGNvdXBs ZWQ6IGZpeCByYWNlIGNvbmRpdGlvbiBiZXR3ZWVuIHBva2VzIGFuZCBzYWZlDQo+IHN0YXRlDQo+ IA0KPiBUaGUgY291cGxlZCBjcHVpZGxlIHdhaXRpbmcgbG9vcCBjbGVhcnMgcGVuZGluZyBwb2tl cyBiZWZvcmUgZW50ZXJpbmcgdGhlIHNhZmUNCj4gc3RhdGUuICBJZiBhIHBva2UgYXJyaXZlcyBq dXN0IGJlZm9yZSB0aGUgcG9rZXMgYXJlIGNsZWFyZWQsIGJ1dCBhZnRlciB0aGUgd2hpbGUNCj4g bG9vcCBjb25kaXRpb24gY2hlY2tzLCB0aGUgcG9rZSB3aWxsIGJlIGxvc3QgYW5kIHRoZSBjcHUg d2lsbCBzdGF5IGluIHRoZSBzYWZlIHN0YXRlDQo+IHVudGlsIGFub3RoZXIgaW50ZXJydXB0IGFy cml2ZXMuICBUaGlzIG1heSBjYXVzZSB0aGUgY3B1IHRoYXQgc2VudCB0aGUgcG9rZSB0bw0K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hY3B1bWFza190ZXN0X2NwdShkZXYtPmNwdSwgJmNwdWlkbGVf Y291cGxlZF9wb2tlZCkpIHsNCj4gLQkJaWYgKGNwdWlkbGVfY291cGxlZF9jbGVhcl9wb2tlcyhk ZXYtPmNwdSkpIHsNCj4gKwkJaWYgKGNwdWlkbGVfY291cGxlZF9jbGVhcl9wb2tlcyhkZXYtPmNw dSkpDQo+ICsJCQljb250aW51ZTsNCj4gKw0KPiArCQlpZiAobmVlZF9yZXNjaGVkKCkpIHsNCj4g IAkJCWNwdWlkbGVfY291cGxlZF9zZXRfbm90X3dhaXRpbmcoZGV2LT5jcHUsIGNvdXBsZWQpOw0K PiAgCQkJZ290byBvdXQ7DQo+ICAJCX0NCj4gQEAgLTUxOCw3ICs1MjUsOCBAQCByZXRyeToNCj4g IAkJbG9jYWxfaXJxX2Rpc2FibGUoKTsNCj4gIAl9DQo+IA0KPiAtCWlmIChjcHVpZGxlX2NvdXBs ZWRfY2xlYXJfcG9rZXMoZGV2LT5jcHUpKSB7DQo+ICsJY3B1aWRsZV9jb3VwbGVkX2NsZWFyX3Bv a2VzKGRldi0+Y3B1KTsNCj4gKwlpZiAobmVlZF9yZXNjaGVkKCkpIHsNCj4gIAkJY3B1aWRsZV9j b3VwbGVkX3NldF9ub3Rfd2FpdGluZyhkZXYtPmNwdSwgY291cGxlZCk7DQo+ICAJCWdvdG8gb3V0 Ow0KPiAgCX0NCj4gLS0NCj4gMS44LjMNCg0KSSB0aGluayB0aGlzIHBhdGNoIHNob3VsZCBhbHNv IGJlIHdvcmthYmxlLg0KVGhhbmtzLg0KDQpSZXZpZXdlZC1ieTogTmVpbCBaaGFuZyA8emhhbmd3 bUBtYXJ2ZWxsLmNvbT4NCg0KQmVzdCBSZWdhcmRzLA0KTmVpbCBaaGFuZw0K -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/cpuidle/coupled.c b/drivers/cpuidle/coupled.c index bbc4ba5..c91230b 100644 --- a/drivers/cpuidle/coupled.c +++ b/drivers/cpuidle/coupled.c @@ -408,19 +408,22 @@ static void cpuidle_coupled_set_done(int cpu, struct cpuidle_coupled *coupled) * been processed and the poke bit has been cleared. * * Other interrupts may also be processed while interrupts are enabled, so - * need_resched() must be tested after turning interrupts off again to make sure + * need_resched() must be tested after this function returns to make sure * the interrupt didn't schedule work that should take the cpu out of idle. * - * Returns 0 if need_resched was false, -EINTR if need_resched was true. + * Returns 0 if no poke was pending, 1 if a poke was cleared. */ static int cpuidle_coupled_clear_pokes(int cpu) { + if (!cpumask_test_cpu(cpu, &cpuidle_coupled_poke_pending)) + return 0; + local_irq_enable(); while (cpumask_test_cpu(cpu, &cpuidle_coupled_poke_pending)) cpu_relax(); local_irq_disable(); - return need_resched() ? -EINTR : 0; + return 1; } static bool cpuidle_coupled_any_pokes_pending(struct cpuidle_coupled *coupled) @@ -464,7 +467,8 @@ int cpuidle_enter_state_coupled(struct cpuidle_device *dev, return -EINVAL; while (coupled->prevent) { - if (cpuidle_coupled_clear_pokes(dev->cpu)) { + cpuidle_coupled_clear_pokes(dev->cpu); + if (need_resched()) { local_irq_enable(); return entered_state; } @@ -503,7 +507,10 @@ retry: */ while (!cpuidle_coupled_cpus_waiting(coupled) || !cpumask_test_cpu(dev->cpu, &cpuidle_coupled_poked)) { - if (cpuidle_coupled_clear_pokes(dev->cpu)) { + if (cpuidle_coupled_clear_pokes(dev->cpu)) + continue; + + if (need_resched()) { cpuidle_coupled_set_not_waiting(dev->cpu, coupled); goto out; } @@ -518,7 +525,8 @@ retry: local_irq_disable(); } - if (cpuidle_coupled_clear_pokes(dev->cpu)) { + cpuidle_coupled_clear_pokes(dev->cpu); + if (need_resched()) { cpuidle_coupled_set_not_waiting(dev->cpu, coupled); goto out; }
The coupled cpuidle waiting loop clears pending pokes before entering the safe state. If a poke arrives just before the pokes are cleared, but after the while loop condition checks, the poke will be lost and the cpu will stay in the safe state until another interrupt arrives. This may cause the cpu that sent the poke to spin in the ready loop with interrupts off until another cpu receives an interrupt, and if no other cpus have interrupts routed to them it can spin forever. Change the return value of cpuidle_coupled_clear_pokes to return if a poke was cleared, and move the need_resched() checks into the callers. In the waiting loop, if a poke was cleared restart the loop to repeat the while condition checks. Reported-by: Neil Zhang <zhangwm@marvell.com> CC: stable@vger.kernel.org Signed-off-by: Colin Cross <ccross@android.com> --- drivers/cpuidle/coupled.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)