All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.de>
To: Len Brown <lenb@kernel.org>
Cc: linux-pm@lists.linux-foundation.org, x86@kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	sfr@canb.auug.org.au
Subject: Re: [linux-pm] [PATCH 8/8] intel_idle: create a native cpuidle driver for select intel processors
Date: Sat, 29 May 2010 06:17:19 +0200	[thread overview]
Message-ID: <201005290617.20771.trenn@suse.de> (raw)
In-Reply-To: <alpine.LFD.2.00.1005272131400.24823@localhost.localdomain>

On Friday 28 May 2010 03:44:16 am Len Brown wrote:
> On Thu, 27 May 2010, Thomas Renninger wrote:
> > On Thursday 27 May 2010 04:42:31 Len Brown wrote:
...
> > If this is known broken, should this already be spread through
> > linux-next?
>
> If you know somebody with a system that supports CPU hot-add
> on one of the processors supported by intel_idle, and they
> are willing to test linux-next, please have them contact me.
This was my attempt to fix it.
There still is an issue, eventually someone sees it,
but it may give a picture what is missing.

        Thomas

diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index b5658cd..62cd8a3 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -445,7 +445,28 @@ static int acpi_processor_get_info(struct acpi_device *device)
 		    (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
 			return -ENODEV;
 		}
+		/*
+		 * CPU not initialized yet, the rest of .add must not touch
+		 * (struct cpuinfo_x86) cpu_data(cpu)!
+		 * If it does, move it from .add to init_components to
+		 * get it done, once the cpu got online and set up the
+		 * first time. Also look into the CPU_ONLINE notify code.
+		 */
+		pr->flags.hotplugged_uninitialized = 1;
+	} else {
+		struct cpuinfo_x86 *c;
+		c = &cpu_data(pr->id);
+		/*
+		 * Same as above, but the driver could have been unloaded
+		 * before the cpu got onlined the first time.
+		 */
+		if (c->x86 == 0 && c->x86_model == 0 && c->x86_mask == 0) {
+			printk(KERN_INFO "CPU %d not initialized yet!\n",
+			       pr->id);
+			pr->flags.hotplugged_uninitialized = 1;
+		}
 	}
+
 	/*
 	 * On some boxes several processors use the same processor bus id.
 	 * But they are located in different scope. For example:
@@ -535,16 +556,94 @@ static void acpi_processor_notify(struct acpi_device *device, u32 event)
 	return;
 }
 
+/*
+ * Add everything that must be run on the CPU that gets initialized
+ * or that depends on cpu_data(cpu) here.
+ * Otherwise things will break in cpu hotadd case as this info is not
+ * yet available in acpi_processor_add or acpi_processor_get_info()
+ */
+
+static int __cpuinit acpi_processor_init_components(struct acpi_processor *pr)
+{
+	int result = 0;
+	struct acpi_device *device;
+
+	acpi_bus_get_device(pr->handle, &device);
+
+	printk(KERN_INFO "%s - cpu: %d\n", __func__, pr->id);
+
+#ifdef CONFIG_CPU_FREQ
+	acpi_processor_ppc_has_changed(pr, 0);
+#endif
+	acpi_processor_get_throttling_info(pr);
+	acpi_processor_get_limit_info(pr);
+
+
+	acpi_processor_power_init(pr, device);
+
+	pr->cdev = thermal_cooling_device_register("Processor", device,
+						&processor_cooling_ops);
+	if (IS_ERR(pr->cdev)) {
+		result = PTR_ERR(pr->cdev);
+		goto err_power_exit;
+	}
+
+	dev_dbg(&device->dev, "registered as cooling_device%d\n",
+		 pr->cdev->id);
+
+	result = sysfs_create_link(&device->dev.kobj,
+				   &pr->cdev->device.kobj,
+				   "thermal_cooling");
+	if (result) {
+		printk(KERN_ERR PREFIX "Create sysfs link\n");
+		goto err_thermal_unregister;
+	}
+	result = sysfs_create_link(&pr->cdev->device.kobj,
+				   &device->dev.kobj,
+				   "device");
+	if (result) {
+		printk(KERN_ERR PREFIX "Create sysfs link\n");
+		goto err_remove_sysfs;
+	}
+
+	return 0;
+
+err_remove_sysfs:
+	sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
+err_thermal_unregister:
+	thermal_cooling_device_unregister(pr->cdev);
+err_power_exit:
+	acpi_processor_power_exit(pr, device);
+
+	return result;
+}
+
+
 static int acpi_cpu_soft_notify(struct notifier_block *nfb,
 		unsigned long action, void *hcpu)
 {
 	unsigned int cpu = (unsigned long)hcpu;
 	struct acpi_processor *pr = per_cpu(processors, cpu);
+	int ret;
 
 	if (action == CPU_ONLINE && pr) {
-		acpi_processor_ppc_has_changed(pr, 0);
-		acpi_processor_cst_has_changed(pr);
-		acpi_processor_tstate_has_changed(pr);
+		if (pr->flags.hotplugged_uninitialized) {
+			/* We only run into this if a CPU got hotplugged
+			 * and not fully initialized yet in .add
+			 * We have to do it here and only once,
+			 * because in .add cpu_data(cpu) is not set up yet
+			 */
+			acpi_processor_set_pdc(pr);
+			ret = acpi_processor_init_components(pr);
+			printk(KERN_INFO "Do initialize: %d - CPU: %d\n",
+			       ret, pr->id);
+			pr->flags.hotplugged_uninitialized = 0;
+		} else {
+			printk(KERN_INFO "already initialized: %d\n", pr->id);
+			acpi_processor_ppc_has_changed(pr, 0);
+			acpi_processor_cst_has_changed(pr);
+			acpi_processor_tstate_has_changed(pr);
+		}
 	}
 	return NOTIFY_OK;
 }
@@ -608,48 +707,14 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
 		goto err_remove_fs;
 	}
 
-#ifdef CONFIG_CPU_FREQ
-	acpi_processor_ppc_has_changed(pr, 0);
-#endif
-	acpi_processor_get_throttling_info(pr);
-	acpi_processor_get_limit_info(pr);
-
-
-	acpi_processor_power_init(pr, device);
-
-	pr->cdev = thermal_cooling_device_register("Processor", device,
-						&processor_cooling_ops);
-	if (IS_ERR(pr->cdev)) {
-		result = PTR_ERR(pr->cdev);
-		goto err_power_exit;
-	}
-
-	dev_dbg(&device->dev, "registered as cooling_device%d\n",
-		 pr->cdev->id);
-
-	result = sysfs_create_link(&device->dev.kobj,
-				   &pr->cdev->device.kobj,
-				   "thermal_cooling");
-	if (result) {
-		printk(KERN_ERR PREFIX "Create sysfs link\n");
-		goto err_thermal_unregister;
-	}
-	result = sysfs_create_link(&pr->cdev->device.kobj,
-				   &device->dev.kobj,
-				   "device");
-	if (result) {
-		printk(KERN_ERR PREFIX "Create sysfs link\n");
-		goto err_remove_sysfs;
+	if (!pr->flags.hotplugged_uninitialized) {
+		result = acpi_processor_init_components(pr);
+		if (result)
+			goto err_remove_fs;
 	}
 
 	return 0;
 
-err_remove_sysfs:
-	sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
-err_thermal_unregister:
-	thermal_cooling_device_unregister(pr->cdev);
-err_power_exit:
-	acpi_processor_power_exit(pr, device);
 err_remove_fs:
 	acpi_processor_remove_fs(device);
 err_free_cpumask:
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 86825dd..e7716ec 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -207,6 +207,7 @@ struct acpi_processor_flags {
 	u8 has_cst:1;
 	u8 power_setup_done:1;
 	u8 bm_rld_set:1;
+	u8 hotplugged_uninitialized:1;
 };
 
 struct acpi_processor {


  parent reply	other threads:[~2010-05-29  4:17 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27  2:42 idle-test patches queued for upstream Len Brown
2010-05-27  2:42 ` [PATCH 1/8] cpuidle: fail to register if !CONFIG_CPU_IDLE Len Brown
2010-05-27  2:42   ` [PATCH 2/8] cpuidle: add cpuidle_unregister_driver() error check Len Brown
2010-05-27  2:42   ` Len Brown
2010-05-27  3:14     ` Andrew Morton
2010-05-27  3:14     ` Andrew Morton
2010-05-27  5:11       ` [PATCH-v2 " Len Brown
2010-05-27  5:11       ` Len Brown
2010-05-27  5:13         ` Andrew Morton
2010-05-27  5:13         ` Andrew Morton
2010-05-27  2:42   ` [PATCH 3/8] cpuidle: make cpuidle_curr_driver static Len Brown
2010-05-27  2:42   ` Len Brown
2010-05-27  5:27     ` [PATCH-v2 " Len Brown
2010-05-27  5:27     ` Len Brown
2010-05-27 18:40       ` Luck, Tony
2010-05-27 18:40       ` Luck, Tony
2010-05-27 23:30         ` Len Brown
2010-05-27 23:30         ` Len Brown
2010-05-27  2:42   ` [PATCH 4/8] ACPI: allow a native cpuidle driver to displace ACPI Len Brown
2010-05-27  2:42   ` Len Brown
2010-05-27  2:42   ` [PATCH 5/8] sched: clarify commment for TS_POLLING Len Brown
2010-05-27  5:25     ` (No subject header) Milton Miller
2010-05-27  5:25       ` Milton Miller
2010-05-27  5:47       ` Len Brown
2010-05-27  5:53     ` [PATCH-v2 5/8] sched: clarify commment for TS_POLLING Len Brown
2010-05-27  5:53     ` Len Brown
2010-05-27  2:42   ` [PATCH " Len Brown
2010-05-27  2:42   ` [PATCH 6/8] acpi_pad: uses MONITOR/MWAIT, so it doesn't need to clear TS_POLLING Len Brown
2010-05-27  2:42   ` Len Brown
2010-05-27  2:42   ` [PATCH 7/8] ACPI: acpi_idle: touch TS_POLLING only in the non-MWAIT case Len Brown
2010-05-27  2:42   ` Len Brown
2010-05-27  2:42   ` [PATCH 8/8] intel_idle: create a native cpuidle driver for select intel processors Len Brown
2010-05-27  2:42   ` Len Brown
2010-05-27  3:44     ` Andrew Morton
2010-05-28  3:57       ` Len Brown
2010-05-28  3:57       ` Len Brown
2010-05-30  9:20         ` Andi Kleen
2010-05-30  9:20         ` Andi Kleen
2010-05-27  3:44     ` Andrew Morton
2010-05-27  8:53     ` Thomas Renninger
2010-05-27  8:53     ` [linux-pm] " Thomas Renninger
2010-05-28  1:44       ` Len Brown
2010-05-28  1:44       ` [linux-pm] " Len Brown
2010-05-28  7:46         ` Thomas Renninger
2010-05-28 17:38           ` Len Brown
2010-05-28 17:38             ` [linux-pm] " Len Brown
2010-05-28  7:46         ` Thomas Renninger
2010-05-29  4:17         ` Thomas Renninger
2010-05-29  4:17         ` Thomas Renninger [this message]
2010-05-27 14:14     ` Kevin Hilman
2010-05-27 14:14     ` Kevin Hilman
2010-05-27 14:22       ` Arjan van de Ven
2010-05-27 14:22       ` Arjan van de Ven
2010-05-27 14:36         ` Kevin Hilman
2010-05-28  0:22           ` Len Brown
2010-05-28 17:28             ` Kevin Hilman
2010-05-28 17:28             ` Kevin Hilman
2010-05-28  0:22           ` Len Brown
2010-05-27 14:36         ` Kevin Hilman
2010-05-27 14:51         ` [linux-pm] " Igor Stoppa
2010-05-28  3:14           ` Arjan van de Ven
2010-05-28  3:14           ` [linux-pm] " Arjan van de Ven
2010-05-28 17:27             ` Kevin Hilman
2010-05-29  0:38               ` Arjan van de Ven
2010-05-29  0:38               ` Arjan van de Ven
2010-05-28 17:27             ` Kevin Hilman
2010-05-27 14:51         ` Igor Stoppa
2010-05-28  2:32     ` Chase Douglas
2010-05-28  2:32     ` Chase Douglas
2010-05-28  4:16       ` Len Brown
2010-05-28 15:09         ` Chase Douglas
2010-05-28 15:09         ` Chase Douglas
2010-05-28 17:43           ` Len Brown
2010-05-28 17:43           ` Len Brown
2010-05-28 19:51             ` Chase Douglas
2010-05-28 20:14               ` Chase Douglas
2010-05-28 20:14               ` Chase Douglas
2010-05-28 19:51             ` Chase Douglas
2010-05-28  4:16       ` Len Brown
2010-05-27  2:42 ` [PATCH 1/8] cpuidle: fail to register if !CONFIG_CPU_IDLE Len Brown
2010-05-27  8:45 ` idle-test patches queued for upstream Thomas Renninger
2010-05-27  8:45 ` [linux-pm] " Thomas Renninger
2010-05-28  0:59   ` Len Brown
2010-05-28  0:59   ` [linux-pm] " Len Brown
2010-05-28  8:07     ` Thomas Renninger
2010-05-28 17:42       ` Len Brown
2010-05-28 17:42       ` [linux-pm] " Len Brown
2010-05-28  8:07     ` Thomas Renninger
2010-06-16  7:53     ` [linux-pm] " Pavel Machek
2010-06-16  7:53     ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201005290617.20771.trenn@suse.de \
    --to=trenn@suse.de \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=sfr@canb.auug.org.au \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.