[PATCH 09/10] xen/acpi: Change Cx notify and add PPC handle

From: Liu Jinsong
Date: Wed Dec 14 2011 - 02:59:02 EST


This patch update Xen Cx notify.
Current Cx notify has 2 potential trigger points w/ some logically redundan=
t.
We remove the Cx notify point which is outside __xen_acpi_processor_add,
merging its logic to the Cx notify point inside __xen_acpi_processor_add.
This would more clean, as what native Cx did.

This patch also add Xen PPC handle when cpu hotadd.

Signed-off-by: Liu, Jinsong <jinsong.liu@xxxxxxxxx>
---
drivers/acpi/processor_xen.c | 103 +++++++++++++++++++++++---------------=
----
1 files changed, 57 insertions(+), 46 deletions(-)

diff --git a/drivers/acpi/processor_xen.c b/drivers/acpi/processor_xen.c
index 3af1f73..083e2b1 100644
--- a/drivers/acpi/processor_xen.c
+++ b/drivers/acpi/processor_xen.c
@@ -283,6 +283,59 @@ static int xen_acpi_processor_get_info(struct acpi_dev=
ice *device)
return 0;
}
=20
+static int xen_acpi_processor_get_platform_limit(struct acpi_processor *pr=
)
+{
+ acpi_status status =3D 0;
+ unsigned long long ppc =3D 0;
+
+ if (!pr)
+ return -EINVAL;
+
+ /*
+ * _PPC indicates the maximum state currently supported by the pla=
tform
+ * (e.g. 0 =3D states 0..n; 1 =3D states 1..n; etc.
+ */
+ status =3D acpi_evaluate_integer(pr->handle, "_PPC", NULL, &ppc);
+
+ if (ACPI_FAILURE(status) && status !=3D AE_NOT_FOUND) {
+ ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC"));
+ return -ENODEV;
+ }
+
+ pr->performance_platform_limit =3D (int)ppc;
+
+ return 0;
+}
+
+static int xen_acpi_processor_ppc_has_changed(struct acpi_processor *pr)
+{
+ int ret;
+
+ ret =3D xen_acpi_processor_get_platform_limit(pr);
+
+ if (ret < 0)
+ return ret;
+ else
+ return processor_cntl_xen_notify(pr,
+ PROCESSOR_PM_CHANGE, PM_TYPE_PERF);
+}
+
+static void __cpuinit xen_acpi_processor_power_init(struct acpi_processor =
*pr,
+ struct acpi_device *device)
+{
+ if (likely(!pr->flags.power_setup_done)) {
+ /* reset idle boot option which we don't care */
+ boot_option_idle_override =3D IDLE_NO_OVERRIDE;
+ acpi_processor_power_init(pr, device);
+ /* set to IDLE_HALT for trapping into Xen */
+ boot_option_idle_override =3D IDLE_HALT;
+
+ if (pr->flags.power)
+ processor_cntl_xen_notify(pr,
+ PROCESSOR_PM_INIT, PM_TYPE_IDLE);
+ }
+}
+
static int __cpuinit __xen_acpi_processor_add(struct acpi_device *device)
{
struct acpi_processor *pr =3D NULL;
@@ -339,14 +392,12 @@ static int __cpuinit __xen_acpi_processor_add(struct =
acpi_device *device)
}
=20
#ifdef CONFIG_CPU_FREQ
- acpi_processor_ppc_has_changed(pr, 0);
+ xen_acpi_processor_ppc_has_changed(pr);
#endif
acpi_processor_get_throttling_info(pr);
acpi_processor_get_limit_info(pr);
=20
-
- if (cpuidle_get_driver() =3D=3D &acpi_idle_driver)
- acpi_processor_power_init(pr, device);
+ xen_acpi_processor_power_init(pr, device);
=20
pr->cdev =3D thermal_cooling_device_register("Processor", device,
&processor_cooling_ops);
@@ -400,48 +451,8 @@ static int __cpuinit xen_acpi_processor_add(struct acp=
i_device *device)
if (!pr)
return -EINVAL;
=20
- if (pr->id =3D=3D -1) {
- int device_declaration;
- int apic_id =3D -1;
-
- if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID))
- device_declaration =3D 0;
- else
- device_declaration =3D 1;
-
- apic_id =3D acpi_get_cpuid(pr->handle,
- device_declaration, pr->acpi_id);
- if (apic_id =3D=3D -1) {
- /* Processor is not present in MADT table */
- return 0;
- }
-
- /*
- * It's possible to have pr->id as '-1' even when it's actually
- * present in MADT table, e.g. due to limiting dom0 max vcpus
- * less than physical present number. In such case we still want
- * to parse ACPI processor object information, so mimic the
- * pr->id to CPU-0. This should be safe because we only care
- * about raw ACPI information, which only relies on pr->acpi_id.
- * For other information relying on pr->id and gathered through
- * SMP function call, it's safe to let them run on CPU-0 since
- * underlying Xen will collect them. Only a valid pr->id can
- * make later invocations forward progress.
- */
- pr->id =3D 0;
- }
-
- if (likely(!pr->flags.power_setup_done)) {
- /* reset idle boot option which we don't care */
- boot_option_idle_override =3D IDLE_NO_OVERRIDE;
- acpi_processor_power_init(pr, device);
- /* set to IDLE_HALT for trapping into Xen */
- boot_option_idle_override =3D IDLE_HALT;
-
- if (pr->flags.power)
- processor_cntl_xen_notify(pr,
- PROCESSOR_PM_INIT, PM_TYPE_IDLE);
- }
+ if (pr->id =3D=3D -1)
+ return 0;
=20
#ifdef CONFIG_CPU_FREQ
if (likely(!pr->performance))
--=20
1.6.5.6

--_002_DE8DF0795D48FD4CA783C40EC82923359737SHSMSX101ccrcorpint_
Content-Type: application/octet-stream;
name="0009-xen-acpi-Change-Cx-notify-and-add-PPC-handle.patch"
Content-Description: 0009-xen-acpi-Change-Cx-notify-and-add-PPC-handle.patch
Content-Disposition: attachment;
filename="0009-xen-acpi-Change-Cx-notify-and-add-PPC-handle.patch";
size=4832; creation-date="Wed, 14 Dec 2011 15:20:15 GMT";
modification-date="Wed, 14 Dec 2011 15:03:34 GMT"
Content-Transfer-Encoding: base64

RnJvbSBjYTQwMzU2NmU5MjJkZGU1MWU4ODA5ZDc0ODkzMzdiZTRhNTVhZGZjIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBMaXUgSmluc29uZyA8amluc29uZy5saXVAaW50ZWwuY29tPgpE
YXRlOiBXZWQsIDE0IERlYyAyMDExIDE1OjU5OjAyICswODAwClN1YmplY3Q6IFtQQVRDSCAwOS8x
MF0geGVuL2FjcGk6IENoYW5nZSBDeCBub3RpZnkgYW5kIGFkZCBQUEMgaGFuZGxlCgpUaGlzIHBh
dGNoIHVwZGF0ZSBYZW4gQ3ggbm90aWZ5LgpDdXJyZW50IEN4IG5vdGlmeSBoYXMgMiBwb3RlbnRp
YWwgdHJpZ2dlciBwb2ludHMgdy8gc29tZSBsb2dpY2FsbHkgcmVkdW5kYW50LgpXZSByZW1vdmUg
dGhlIE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HJvZ3Jlc3MuCi0JCSAqLwotCQlwci0+
aWQgPSAwOwotCX0KLQotCWlmIChsaWtlbHkoIXByLT5mbGFncy5wb3dlcl9zZXR1cF9kb25lKSkg
ewotCQkvKiByZXNldCBpZGxlIGJvb3Qgb3B0aW9uIHdoaWNoIHdlIGRvbid0IGNhcmUgKi8KLQkJ
Ym9vdF9vcHRpb25faWRsZV9vdmVycmlkZSA9IElETEVfTk9fT1ZFUlJJREU7Ci0JCWFjcGlfcHJv
Y2Vzc29yX3Bvd2VyX2luaXQocHIsIGRldmljZSk7Ci0JCS8qIHNldCB0byBJRExFX0hBTFQgZm9y
IHRyYXBwaW5nIGludG8gWGVuICovCi0JCWJvb3Rfb3B0aW9uX2lkbGVfb3ZlcnJpZGUgPSBJRExF
X0hBTFQ7Ci0KLQkJaWYgKHByLT5mbGFncy5wb3dlcikKLQkJCXByb2Nlc3Nvcl9jbnRsX3hlbl9u
b3RpZnkocHIsCi0JCQkJCVBST0NFU1NPUl9QTV9JTklULCBQTV9UWVBFX0lETEUpOwotCX0KKwlp
ZiAocHItPmlkID09IC0xKQorCQlyZXR1cm4gMDsKIAogI2lmZGVmIENPTkZJR19DUFVfRlJFUQog
CWlmIChsaWtlbHkoIXByLT5wZXJmb3JtYW5jZSkpCi0tIAoxLjYuNS42Cgo=

--_002_DE8DF0795D48FD4CA783C40EC82923359737SHSMSX101ccrcorpint_--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/