ACPI & PM patch queue for Linux 3.2
Subsystems (15)
Len Brown
maintainerThese patches are queued for Linux 3.2.
Let me know if you see troubles with any of them.
Also, due to kernel.org taking my e-mail and patchwork out of action, i've missed quite a bit of e-mail, so feel free to ping/re-send patches I've missed.
thanks,
-Len Brown
Intel Open Source Technology Center
Len Brown
maintainerPATCH 1/14 tools/power turbostat: less verbose debugging
From: Len Brown <[email protected]>
dump only the counters which are active
--- tools/power/x86/turbostat/turbostat.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-)
tools/power/x86/turbostat/turbostat.c +15 -13
@@ -162,19 +162,21 @@ void print_header(void)void dump_cnt (struct counters *cnt) { -fprintf (stderr,"package: %d " , cnt->pkg); -fprintf (stderr,"core:: %d " , cnt->core); -fprintf (stderr,"CPU: %d " , cnt->cpu); -fprintf (stderr,"TSC: %016llX\n" , cnt->tsc); -fprintf (stderr,"c3: %016llX\n" , cnt->c3); -fprintf (stderr,"c6: %016llX\n" , cnt->c6); -fprintf (stderr,"c7: %016llX\n" , cnt->c7); -fprintf (stderr,"aperf: %016llX\n" , cnt->aperf); -fprintf (stderr,"pc2: %016llX\n" , cnt->pc2); -fprintf (stderr,"pc3: %016llX\n" , cnt->pc3); -fprintf (stderr,"pc6: %016llX\n" , cnt->pc6); -fprintf (stderr,"pc7: %016llX\n" , cnt->pc7); -fprintf (stderr,"msr0x%x: %016llX\n" , extra_msr_offset, cnt->extra_msr); +if (!cnt) +return ; +if (cnt->pkg)fprintf (stderr,"package: %d " , cnt->pkg); +if (cnt->core)fprintf (stderr,"core:: %d " , cnt->core); +if (cnt->cpu)fprintf (stderr,"CPU: %d " , cnt->cpu); +if (cnt->tsc)fprintf (stderr,"TSC: %016llX\n" , cnt->tsc); +if (cnt->c3)fprintf (stderr,"c3: %016llX\n" , cnt->c3); +if (cnt->c6)fprintf (stderr,"c6: %016llX\n" , cnt->c6); +if (cnt->c7)fprintf (stderr,"c7: %016llX\n" , cnt->c7); +if (cnt->aperf)fprintf (stderr,"aperf: %016llX\n" , cnt->aperf); +if (cnt->pc2)fprintf (stderr,"pc2: %016llX\n" , cnt->pc2); +if (cnt->pc3)fprintf (stderr,"pc3: %016llX\n" , cnt->pc3); +if (cnt->pc6)fprintf (stderr,"pc6: %016llX\n" , cnt->pc6); +if (cnt->pc7)fprintf (stderr,"pc7: %016llX\n" , cnt->pc7); +if (cnt->extra_msr)fprintf (stderr,"msr0x%x: %016llX\n" , extra_msr_offset, cnt->extra_msr); }void dump_list (struct counters *cnt)
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 2/14 mrst pmu: update comment
In reply to Len BrownFrom: Len Brown <[email protected]>
referenced MeeGo, in particular, but really means Linux, in general.
--- arch/x86/platform/mrst/pmu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/platform/mrst/pmu.c +1 -1
@@ -70,7 +70,7 @@ static struct mrst_device mrst_devs[] = { /* 24 */ { 0x4110, 0 }, /* Lincroft */ }; -/* n.b. We ignore PCI-id 0x815 in LSS9 b/c MeeGo has no driver for it */ +/* n.b. We ignore PCI-id 0x815 in LSS9 b/c Linux has no driver for it */ static u16 mrst_lss9_pci_ids[] = {0x080a ,0x0814 ,0 };static u16 mrst_lss10_pci_ids[] = {0x0800 ,0x0801 ,0x0802 ,0x0803 ,0x0804 ,0x0805 ,0x080f ,0 };
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 3/14 ACPI: use kstrdup()
In reply to Len BrownFrom: Thomas Meyer <[email protected]>
Use kstrdup rather than duplicating its implementation
The semantic patch that makes this output is available in scripts/coccinelle/api/kstrdup.cocci.
More information about semantic patching is available at
http://coccinelle.lip6.fr/
--- drivers/acpi/scan.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/acpi/scan.c +1 -2
@@ -1062,13 +1062,12 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id)if (!id)return ; - id->id =kmalloc (strlen (dev_id) +1 ,GFP_KERNEL ); + id->id =kstrdup (dev_id,GFP_KERNEL );if (!id->id) {kfree (id);return ; } -strcpy (id->id, dev_id);list_add_tail (&id->list, &device->pnp.ids); }
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 4/14 ACPI: Fix possible recursive locking in hwregs.c
In reply to Len BrownFrom: Rakib Mullick <[email protected]>
Calling pm-suspend might trigger a recursive lock in it's code path. In function acpi_hw_clear_acpi_status, acpi_os_acquire_lock holds the lock acpi_gbl_hardware_lock before calling acpi_hw_register_write(), then without releasing acpi_gbl_hardware_lock, this function calls acpi_ev_walk_gpe_list, which tries to hold acpi_gbl_gpe_lock. Both acpi_gbl_hardware_lock and acpi_gbl_gpe_lock are at same lock-class and which might cause lock recursion deadlock.
Following patch fixes this scenario by just releasing acpi_gbl_hardware_lock before calling acpi_ev_walk_gpe_list.
Changes since v0(https://lkml.org/lkml/2011/9/21/355):
- Fix changelog, thanks to Lin Ming.
Changes since v1 (https://lkml.org/lkml/2011/11/3/89):
- Update changelog and rename goto label, courtesy Srivatsa S. Bhat.
--- drivers/acpi/acpica/hwregs.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/acpi/acpica/hwregs.c +6 -5
@@ -269,16 +269,17 @@ acpi_status acpi_hw_clear_acpi_status(void) status =acpi_hw_register_write (ACPI_REGISTER_PM1_STATUS ,ACPI_BITMASK_ALL_FIXED_STATUS ); -if (ACPI_FAILURE (status)) { - goto unlock_and_exit; - } + +acpi_os_release_lock (acpi_gbl_hardware_lock, lock_flags); + +if (ACPI_FAILURE (status)) + goto exit;/* Clear the GPE Bits in all GPE registers in all GPE blocks */ status =acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block,NULL ); - unlock_and_exit: -acpi_os_release_lock (acpi_gbl_hardware_lock, lock_flags); +exit:return_ACPI_STATUS (status); }
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 5/14 PNPACPI: Simplify disabled resource registration
In reply to Len BrownFrom: Witold Szczeponik <[email protected]>
The attached patch simplifies 29df8d8f8702f0f53c1375015f09f04bc8d023c1. As the "pnp_xxx" structs are not designed to cope with IORESOURCE_DISABLED, and hence no code can test for this value, setting this value is actually a "no op" and can be skipped altogether. It is sufficient to remove the checks for "empty" resources and continue processing.
The patch is applied against 3.1.
--- drivers/pnp/pnpacpi/rsparser.c | 62 +++++++++------------------------------ 1 files changed, 15 insertions(+), 47 deletions(-)
drivers/pnp/pnpacpi/rsparser.c +15 -47
@@ -509,15 +509,12 @@ static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, struct acpi_resource_dma *p) {int i; -unsigned char map =0 , flags =0 ; - -if (p->channel_count ==0 ) - flags |=IORESOURCE_DISABLED ; +unsigned char map =0 , flags;for (i =0 ; i < p->channel_count; i++) map |=1 << p->channels[i]; - flags |=dma_flags (dev, p->type, p->bus_master, p->transfer); + flags =dma_flags (dev, p->type, p->bus_master, p->transfer);pnp_register_dma_resource (dev, option_flags, map, flags); }
@@ -527,17 +524,14 @@ static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, {int i;pnp_irq_mask_t map; -unsigned char flags =0 ; - -if (p->interrupt_count ==0 ) - flags |=IORESOURCE_DISABLED ; +unsigned char flags;bitmap_zero (map.bits,PNP_IRQ_NR );for (i =0 ; i < p->interrupt_count; i++)if (p->interrupts[i])__set_bit (p->interrupts[i], map.bits); - flags |=irq_flags (p->triggering, p->polarity, p->sharable); + flags =irq_flags (p->triggering, p->polarity, p->sharable);pnp_register_irq_resource (dev, option_flags, &map, flags); }
@@ -547,10 +541,7 @@ static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, {int i;pnp_irq_mask_t map; -unsigned char flags =0 ; - -if (p->interrupt_count ==0 ) - flags |=IORESOURCE_DISABLED ; +unsigned char flags;bitmap_zero (map.bits,PNP_IRQ_NR );for (i =0 ; i < p->interrupt_count; i++) {
@@ -564,7 +555,7 @@ static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, } } - flags |=irq_flags (p->triggering, p->polarity, p->sharable); + flags =irq_flags (p->triggering, p->polarity, p->sharable);pnp_register_irq_resource (dev, option_flags, &map, flags); }
@@ -574,11 +565,8 @@ static __init void pnpacpi_parse_port_option(struct pnp_dev *dev, {unsigned char flags =0 ; -if (io->address_length ==0 ) - flags |=IORESOURCE_DISABLED ; -if (io->io_decode ==ACPI_DECODE_16 ) - flags |=IORESOURCE_IO_16BIT_ADDR ; + flags =IORESOURCE_IO_16BIT_ADDR ;pnp_register_port_resource (dev, option_flags, io->minimum, io->maximum, io->alignment, io->address_length, flags); }
@@ -587,13 +575,8 @@ static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev,unsigned int option_flags, struct acpi_resource_fixed_io *io) { - unsigned char flags = 0; - -if (io->address_length ==0 ) - flags |=IORESOURCE_DISABLED ; - pnp_register_port_resource(dev, option_flags, io->address, io->address, -0 , io->address_length, flags |IORESOURCE_IO_FIXED ); + 0, io->address_length, IORESOURCE_IO_FIXED); } static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev,
@@ -602,11 +585,8 @@ static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, {unsigned char flags =0 ; -if (p->address_length ==0 ) - flags |=IORESOURCE_DISABLED ; -if (p->write_protect ==ACPI_READ_WRITE_MEMORY ) - flags |=IORESOURCE_MEM_WRITEABLE ; + flags =IORESOURCE_MEM_WRITEABLE ;pnp_register_mem_resource (dev, option_flags, p->minimum, p->maximum, p->alignment, p->address_length, flags); }
@@ -617,11 +597,8 @@ static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev, {unsigned char flags =0 ; -if (p->address_length ==0 ) - flags |=IORESOURCE_DISABLED ; -if (p->write_protect ==ACPI_READ_WRITE_MEMORY ) - flags |=IORESOURCE_MEM_WRITEABLE ; + flags =IORESOURCE_MEM_WRITEABLE ;pnp_register_mem_resource (dev, option_flags, p->minimum, p->maximum, p->alignment, p->address_length, flags); }
@@ -632,11 +609,8 @@ static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, {unsigned char flags =0 ; -if (p->address_length ==0 ) - flags |=IORESOURCE_DISABLED ; -if (p->write_protect ==ACPI_READ_WRITE_MEMORY ) - flags |=IORESOURCE_MEM_WRITEABLE ; + flags =IORESOURCE_MEM_WRITEABLE ;pnp_register_mem_resource (dev, option_flags, p->address, p->address,0 , p->address_length, flags); }
@@ -656,19 +630,16 @@ static __init void pnpacpi_parse_address_option(struct pnp_dev *dev,return ; } -if (p->address_length ==0 ) - flags |=IORESOURCE_DISABLED ; -if (p->resource_type ==ACPI_MEMORY_RANGE ) {if (p->info.mem.write_protect ==ACPI_READ_WRITE_MEMORY ) - flags |=IORESOURCE_MEM_WRITEABLE ; + flags =IORESOURCE_MEM_WRITEABLE ;pnp_register_mem_resource (dev, option_flags, p->minimum, p->minimum,0 , p->address_length, flags); }else if (p->resource_type ==ACPI_IO_RANGE )pnp_register_port_resource (dev, option_flags, p->minimum, p->minimum,0 , p->address_length, - flags |IORESOURCE_IO_FIXED ); +IORESOURCE_IO_FIXED ); } static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev,
@@ -678,19 +649,16 @@ static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev,struct acpi_resource_extended_address64 *p = &r->data.ext_address64;unsigned char flags =0 ; -if (p->address_length ==0 ) - flags |=IORESOURCE_DISABLED ; -if (p->resource_type ==ACPI_MEMORY_RANGE ) {if (p->info.mem.write_protect ==ACPI_READ_WRITE_MEMORY ) - flags |=IORESOURCE_MEM_WRITEABLE ; + flags =IORESOURCE_MEM_WRITEABLE ;pnp_register_mem_resource (dev, option_flags, p->minimum, p->minimum,0 , p->address_length, flags); }else if (p->resource_type ==ACPI_IO_RANGE )pnp_register_port_resource (dev, option_flags, p->minimum, p->minimum,0 , p->address_length, - flags |IORESOURCE_IO_FIXED ); +IORESOURCE_IO_FIXED ); }struct acpipnp_parse_option_s {
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 6/14 ACPI atomicio: Convert width in bits to bytes in __acpi_ioremap_fast()
In reply to Len BrownFrom: "Luck, Tony" <[email protected]>
Callers to __acpi_ioremap_fast() pass the bit_width that they found in the acpi_generic_address structure. Convert from bits to bytes when passing to __acpi_find_iomap() - as it wants to see bytes, not bits.
--- drivers/acpi/atomicio.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/atomicio.c +1 -1
@@ -76,7 +76,7 @@ static void __iomem *__acpi_ioremap_fast(phys_addr_t paddr, {struct acpi_iomap *map; - map =__acpi_find_iomap (paddr, size); + map =__acpi_find_iomap (paddr, size/8 );if (map)return map->vaddr + (paddr - map->paddr);else
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 7/14 ACPI: Drop ACPI_NO_HARDWARE_INIT
In reply to Len BrownFrom: "Rafael J. Wysocki" <[email protected]>
ACPI_NO_HARDWARE_INIT is only used by acpi_early_init() and acpi_bus_init() when calling acpi_enable_subsystem(), but acpi_enable_subsystem() doesn't check that flag, so it can be dropped.
--- drivers/acpi/bus.c | 8 ++------ include/acpi/actypes.h | 1 - 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/acpi/bus.c +2 -6
@@ -911,10 +911,7 @@ void __init acpi_early_init(void) }#endif - status = -acpi_enable_subsystem (~ - (ACPI_NO_HARDWARE_INIT | -ACPI_NO_ACPI_ENABLE )); + status =acpi_enable_subsystem (~ACPI_NO_ACPI_ENABLE );if (ACPI_FAILURE (status)) { printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); goto error0;
@@ -935,8 +932,7 @@ static int __init acpi_bus_init(void)acpi_os_initialize1 (); - status = -acpi_enable_subsystem (ACPI_NO_HARDWARE_INIT |ACPI_NO_ACPI_ENABLE ); + status =acpi_enable_subsystem (ACPI_NO_ACPI_ENABLE );if (ACPI_FAILURE (status)) { printk(KERN_ERR PREFIX "Unable to start the ACPI Interpreter\n");
include/acpi/actypes.h +0 -1
@@ -470,7 +470,6 @@ typedef u64 acpi_integer;*/ #define ACPI_FULL_INITIALIZATION 0x00#define ACPI_NO_ADDRESS_SPACE_INIT 0x01 -#define ACPI_NO_HARDWARE_INIT 0x02#define ACPI_NO_EVENT_INIT 0x04#define ACPI_NO_HANDLER_INIT 0x08#define ACPI_NO_ACPI_ENABLE 0x10
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 8/14 thermal: Prevent polling from happening during system suspend
In reply to Len BrownFrom: "Rafael J. Wysocki" <[email protected]>
The thermal driver should use a freezable workqueue to schedule polling to prevent thermal_zone_device_update() from being run during system suspend, when the devices it relies on may be inactive. Make it use the system freezable workqueue for this purpose.
--- drivers/thermal/thermal_sys.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/thermal_sys.c +2 -2
@@ -678,10 +678,10 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,return ;if (delay >1000 ) -schedule_delayed_work (&(tz->poll_queue), +queue_delayed_work (system_freezable_wq, &(tz->poll_queue),round_jiffies (msecs_to_jiffies (delay)));else -schedule_delayed_work (&(tz->poll_queue), +queue_delayed_work (system_freezable_wq, &(tz->poll_queue),msecs_to_jiffies (delay)); }
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 9/14 ACPI: Export FADT pm_profile integer value to userspace
In reply to Len BrownFrom: Thomas Renninger <[email protected]>
There are a lot userspace approaches to detect the usage of the platform (laptop, workstation, server, ...) and adjust kernel tunables accordingly (io/process scheduler, power management, ...).
These approaches need constant maintaining and are ugly to implement (detect PCMCIA controller -> laptop,
does not work on recent systems anymore, ...)
On ACPI systems there is an easy and reliable way (if implemented in BIOS and most recent platforms have this value set). -> export it to userspace.
--- Documentation/ABI/stable/sysfs-acpi-pmprofile | 22 ++++++++++++++++++++++ drivers/acpi/sysfs.c | 14 +++++++++++++- 2 files changed, 35 insertions(+), 1 deletions(-) create mode 100644 Documentation/ABI/stable/sysfs-acpi-pmprofile
Documentation/ABI/stable/sysfs-acpi-pmprofile new file +22 -0
@@ -0,0 +1,22 @@ +What: /sys/firmware/acpi/pm_profile +Date: 03-Nov-2011 +KernelVersion: v3.2 +Contact: [email protected] +Description: The ACPI pm_profile sysfs interface exports the platform + power management (and performance) requirement expectations + as provided by BIOS. The integer value is directly passed as + retrieved from the FADT ACPI table. +Values: For possible values see ACPI specification: + 5.2.9 Fixed ACPI Description Table (FADT) + Field: Preferred_PM_Profile + + Currently these values are defined by spec: + 0 Unspecified + 1 Desktop + 2 Mobile + 3 Workstation + 4 Enterprise Server + 5 SOHO Server + 6 Appliance PC + 7 Performance Server + >7 Reserved
drivers/acpi/sysfs.c +13 -1
@@ -706,11 +706,23 @@ static void __exit interrupt_stats_exit(void)return ; } +static ssize_t +acpi_show_profile (struct device *dev,struct device_attribute *attr, +char *buf) +{ +return sprintf (buf,"%d\n" , acpi_gbl_FADT.preferred_profile); +} + +static const struct device_attribute pm_profile_attr = +__ATTR (pm_profile,S_IRUGO , acpi_show_profile,NULL ); +int __init acpi_sysfs_init (void ) {int result; result =acpi_tables_sysfs_init (); - +if (result) +return result; + result =sysfs_create_file (acpi_kobj, &pm_profile_attr.attr);return result; }
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 10/14 ACPI: Fix CONFIG_ACPI_DOCK=n compiler warning
In reply to Len BrownFrom: Bart Van Assche <[email protected]>
Recently the ACPI ops structs were constified but the inline version of register_hotplug_dock_device() was overlooked (see also commit 9c8b04b, June 25 2011). Update the inline function register_hotplug_dock_device() that is enabled with CONFIG_ACPI_DOCK=n too. This patch fixes at least the following compiler warnings:
drivers/ata/libata-acpi.c: In function .ata_acpi_associate.:drivers/ata/libata-acpi.c:266:11: warning: passing argument 2 of .register_hotplug_dock_device. discards qualifiers from pointer target type include/acpi/acpi_drivers.h:146:19: note: expected .struct acpi_dock_ops *. but argument is of type .const struct acpi_dock_ops *. drivers/ata/libata-acpi.c:275:11: warning: passing argument 2 of .register_hotplug_dock_device. discards qualifiers from pointer target type include/acpi/acpi_drivers.h:146:19: note: expected .struct acpi_dock_ops *. but argument is of type .const struct acpi_dock_ops *.
--- include/acpi/acpi_drivers.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/acpi/acpi_drivers.h +1 -1
@@ -144,7 +144,7 @@ static inline void unregister_dock_notifier(struct notifier_block *nb) { }static inline int register_hotplug_dock_device (acpi_handle handle, -struct acpi_dock_ops *ops, +const struct acpi_dock_ops *ops,void *context) {return -ENODEV ;
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 11/14 cpuidle: Move dev->last_residency update to driver enter routine; remove dev->last_state
In reply to Len BrownFrom: Deepthi Dharwar <[email protected]>
Cpuidle governor only suggests the state to enter using the governor->select() interface, but allows the low level driver to override the recommended state. The actual entered state may be different because of software or hardware demotion. Software demotion is done by the back-end cpuidle driver and can be accounted correctly. Current cpuidle code uses last_state field to capture the actual state entered and based on that updates the statistics for the state entered.
Ideally the driver enter routine should update the counters, and it should return the state actually entered rather than the time spent there. The generic cpuidle code should simply handle where the counters live in the sysfs namespace, not updating the counters.
Reference:
https://lkml.org/lkml/2011/3/25/52
--- arch/arm/mach-at91/cpuidle.c | 10 +++-- arch/arm/mach-davinci/cpuidle.c | 9 +++- arch/arm/mach-exynos4/cpuidle.c | 7 ++- arch/arm/mach-kirkwood/cpuidle.c | 12 ++++-- arch/arm/mach-omap2/cpuidle34xx.c | 67 +++++++++++++++++------------ arch/sh/kernel/cpu/shmobile/cpuidle.c | 12 +++-- drivers/acpi/processor_idle.c | 75 +++++++++++++++++++++----------- drivers/cpuidle/cpuidle.c | 32 +++++++------- drivers/cpuidle/governors/ladder.c | 13 ++++++ drivers/cpuidle/governors/menu.c | 7 ++- drivers/idle/intel_idle.c | 12 ++++-- include/linux/cpuidle.h | 7 +-- 12 files changed, 164 insertions(+), 99 deletions(-)
arch/arm/mach-at91/cpuidle.c +6 -4
@@ -33,7 +33,7 @@ static struct cpuidle_driver at91_idle_driver = {/* Actual code that puts the SoC in different idle states */ static int at91_enter_idle (struct cpuidle_device *dev, -struct cpuidle_state *state) +int index) {struct timeval before, after;int idle_time;
@@ -41,10 +41,10 @@ static int at91_enter_idle(struct cpuidle_device *dev,local_irq_disable ();do_gettimeofday (&before); -if (state == &dev->states[0 ]) +if (index ==0 )/* Wait for interrupt state */ cpu_do_idle (); -else if (state == &dev->states[1 ]) { +else if (index ==1 ) { asm("b 1f; .align 5; 1:" ); asm("mcr p15, 0, r0, c7, c10, 4" );/* drain write buffer */ saved_lpr =sdram_selfrefresh_enable ();
@@ -55,7 +55,9 @@ static int at91_enter_idle(struct cpuidle_device *dev,local_irq_enable (); idle_time = (after.tv_sec - before.tv_sec) *USEC_PER_SEC + (after.tv_usec - before.tv_usec); -return idle_time; + + dev->last_residency = idle_time; +return index; }/* Initialize CPU idle by registering the idle states */
arch/arm/mach-davinci/cpuidle.c +6 -3
@@ -78,9 +78,9 @@ static struct davinci_ops davinci_states[DAVINCI_CPUIDLE_MAX_STATES] = {/* Actual code that puts the SoC in different idle states */ static int davinci_enter_idle (struct cpuidle_device *dev, -struct cpuidle_state *state) +int index) { -struct davinci_ops *ops =cpuidle_get_statedata (state); +struct davinci_ops *ops =cpuidle_get_statedata (&dev->states[index]);struct timeval before, after;int idle_time;
@@ -98,7 +98,10 @@ static int davinci_enter_idle(struct cpuidle_device *dev,local_irq_enable (); idle_time = (after.tv_sec - before.tv_sec) *USEC_PER_SEC + (after.tv_usec - before.tv_usec); -return idle_time; + + dev->last_residency = idle_time; + +return index; }static int __init davinci_cpuidle_probe (struct platform_device *pdev)
arch/arm/mach-exynos4/cpuidle.c +4 -3
@@ -16,7 +16,7 @@#include <asm/proc-fns.h> static int exynos4_enter_idle (struct cpuidle_device *dev, -struct cpuidle_state *state); +int index);static struct cpuidle_state exynos4_cpuidle_set[] = { [0 ] = {
@@ -37,7 +37,7 @@ static struct cpuidle_driver exynos4_idle_driver = { };static int exynos4_enter_idle (struct cpuidle_device *dev, -struct cpuidle_state *state) +int index) {struct timeval before, after;int idle_time;
@@ -52,7 +52,8 @@ static int exynos4_enter_idle(struct cpuidle_device *dev, idle_time = (after.tv_sec - before.tv_sec) *USEC_PER_SEC + (after.tv_usec - before.tv_usec); -return idle_time; + dev->last_residency = idle_time; +return index; }static int __init exynos4_init_cpuidle (void )
arch/arm/mach-kirkwood/cpuidle.c +8 -4
@@ -32,17 +32,17 @@ static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device);/* Actual code that puts the SoC in different idle states */ static int kirkwood_enter_idle (struct cpuidle_device *dev, -struct cpuidle_state *state) +int index) {struct timeval before, after;int idle_time;local_irq_disable ();do_gettimeofday (&before); -if (state == &dev->states[0 ]) +if (index ==0 )/* Wait for interrupt state */ cpu_do_idle (); -else if (state == &dev->states[1 ]) { +else if (index ==1 ) {/* * Following write will put DDR in self refresh. * Note that we have 256 cycles before DDR puts it
@@ -57,7 +57,11 @@ static int kirkwood_enter_idle(struct cpuidle_device *dev,local_irq_enable (); idle_time = (after.tv_sec - before.tv_sec) *USEC_PER_SEC + (after.tv_usec - before.tv_usec); -return idle_time; + +/* Update last residency */ + dev->last_residency = idle_time; + +return index; }/* Initialize CPU idle by registering the idle states */
arch/arm/mach-omap2/cpuidle34xx.c +39 -28
184 lines not on this page · raw message
arch/sh/kernel/cpu/shmobile/cpuidle.c +7 -5
@@ -25,11 +25,11 @@ static unsigned long cpuidle_mode[] = { };static int cpuidle_sleep_enter (struct cpuidle_device *dev, -struct cpuidle_state *state) +int index) {unsigned long allowed_mode =arch_hwblk_sleep_mode ();ktime_t before, after; -int requested_state = state - &dev->states[0 ]; +int requested_state = index;int allowed_state;int k;
@@ -46,11 +46,13 @@ static int cpuidle_sleep_enter(struct cpuidle_device *dev,*/ k =min_t (int, allowed_state, requested_state); - dev->last_state = &dev->states[k]; before =ktime_get ();sh_mobile_call_standby (cpuidle_mode[k]); after =ktime_get (); -return ktime_to_ns (ktime_sub (after, before)) >>10 ; + + dev->last_residency = (int )ktime_to_ns (ktime_sub (after, before)) >>10 ; + +return k; }static struct cpuidle_device cpuidle_dev;
@@ -84,7 +86,7 @@ void sh_mobile_setup_cpuidle(void) state->flags |=CPUIDLE_FLAG_TIME_VALID ; state->enter = cpuidle_sleep_enter; - dev->safe_state = state; + dev->safe_state_index = i-1 ;if (sh_mobile_sleep_supported &SUSP_SH_SF ) { state = &dev->states[i++];
drivers/acpi/processor_idle.c +49 -26
210 lines not on this page · raw message
drivers/cpuidle/cpuidle.c +16 -16
@@ -62,7 +62,7 @@ int cpuidle_idle_call(void) {struct cpuidle_device *dev =__this_cpu_read (cpuidle_devices);struct cpuidle_state *target_state; -int next_state; +int next_state, entered_state;if (off)return -ENODEV ;
@@ -102,26 +102,27 @@ int cpuidle_idle_call(void) target_state = &dev->states[next_state]; -/* enter the state and update stats */ - dev->last_state = target_state; -trace_power_start (POWER_CSTATE , next_state, dev->cpu);trace_cpu_idle (next_state, dev->cpu); - dev->last_residency = target_state->enter (dev, target_state); + entered_state = target_state->enter (dev, next_state);trace_power_end (dev->cpu);trace_cpu_idle (PWR_EVENT_EXIT , dev->cpu); -if (dev->last_state) - target_state = dev->last_state; - - target_state->time += (unsigned long long )dev->last_residency; - target_state->usage++; +if (entered_state >=0 ) { +/* Update cpuidle counters */ +/* This can be moved to within driver enter routine +* but that results in multiple copies of same code. +*/ + dev->states[entered_state].time += + (unsigned long long )dev->last_residency; + dev->states[entered_state].usage++; + }/* give the governor an opportunity to reflect on the outcome */ if (cpuidle_curr_governor->reflect) - cpuidle_curr_governor->reflect (dev); + cpuidle_curr_governor->reflect (dev, entered_state);return 0 ; }
@@ -172,11 +173,10 @@ void cpuidle_resume_and_unlock(void)EXPORT_SYMBOL_GPL (cpuidle_resume_and_unlock);#ifdef CONFIG_ARCH_HAS_CPU_RELAX -static int poll_idle (struct cpuidle_device *dev,struct cpuidle_state *st) +static int poll_idle (struct cpuidle_device *dev,int index) {ktime_t t1, t2;s64 diff; -int ret; t1 =ktime_get ();local_irq_enable ();
@@ -188,8 +188,9 @@ static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st)if (diff >INT_MAX ) diff =INT_MAX ; - ret = (int ) diff; -return ret; + dev->last_residency = (int ) diff; + +return index; }static void poll_idle_init (struct cpuidle_device *dev)
@@ -248,7 +249,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev) dev->states[i].time =0 ; } dev->last_residency =0 ; - dev->last_state =NULL ;smp_wmb ();
drivers/cpuidle/governors/ladder.c +13 -0
@@ -153,11 +153,24 @@ static int ladder_enable_device(struct cpuidle_device *dev)return 0 ; } +/** +* ladder_reflect - update the correct last_state_idx +* @dev: the CPU +* @index: the index of actual state entered +*/ +static void ladder_reflect (struct cpuidle_device *dev,int index) +{ +struct ladder_device *ldev = &__get_cpu_var (ladder_devices); +if (index >0 ) + ldev->last_state_idx = index; +} +static struct cpuidle_governor ladder_governor = { .name ="ladder" , .rating =10 , .enable = ladder_enable_device, .select = ladder_select_state, + .reflect = ladder_reflect, .owner =THIS_MODULE , };
drivers/cpuidle/governors/menu.c +5 -2
@@ -310,14 +310,17 @@ static int menu_select(struct cpuidle_device *dev)/** * menu_reflect - records that data structures need update * @dev: the CPU +* @index: the index of actual entered state * * NOTE: it's important to be fast here because this operation will add to * the overall exit latency. */ -static void menu_reflect (struct cpuidle_device *dev) +static void menu_reflect (struct cpuidle_device *dev,int index) {struct menu_device *data = &__get_cpu_var (menu_devices); - data->needs_update =1 ; + data->last_state_idx = index; +if (index >=0 ) + data->needs_update =1 ; }/**
drivers/idle/intel_idle.c +8 -4
@@ -81,7 +81,7 @@ static unsigned int mwait_substates;static unsigned int lapic_timer_reliable_states = (1 <<1 );/* Default to only C1 */ static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; -static int intel_idle (struct cpuidle_device *dev,struct cpuidle_state *state); +static int intel_idle (struct cpuidle_device *dev,int index);static struct cpuidle_state *cpuidle_state_table;
@@ -209,12 +209,13 @@ static struct cpuidle_state atom_cstates[MWAIT_MAX_NUM_CSTATES] = {/** * intel_idle * @dev: cpuidle_device -* @state: cpuidle state +* @index: index of cpuidle state * */ -static int intel_idle (struct cpuidle_device *dev,struct cpuidle_state *state) +static int intel_idle (struct cpuidle_device *dev,int index) {unsigned long ecx =1 ;/* break on interrupt flag */ +struct cpuidle_state *state = &dev->states[index];unsigned long eax = (unsigned long )cpuidle_get_statedata (state);unsigned int cstate;ktime_t kt_before, kt_after;
@@ -256,7 +257,10 @@ static int intel_idle(struct cpuidle_device *dev, struct cpuidle_state *state)if (!(lapic_timer_reliable_states & (1 << (cstate))))clockevents_notify (CLOCK_EVT_NOTIFY_BROADCAST_EXIT , &cpu); -return usec_delta; +/* Update cpuidle counters */ + dev->last_residency = (int )usec_delta; + +return index; }static void __setup_broadcast_timer (void *arg)
include/linux/cpuidle.h +3 -4
@@ -42,7 +42,7 @@ struct cpuidle_state {unsigned long long time;/* in US */ int (*enter) (struct cpuidle_device *dev, -struct cpuidle_state *state); +int index); };/* Idle State Flags */
@@ -87,13 +87,12 @@ struct cpuidle_device {int state_count;struct cpuidle_state states[CPUIDLE_STATE_MAX ];struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX ]; -struct cpuidle_state *last_state;struct list_head device_list;struct kobject kobj;struct completion kobj_unregister;void *governor_data; -struct cpuidle_state *safe_state; +int safe_state_index;int (*prepare) (struct cpuidle_device *dev); };
@@ -169,7 +168,7 @@ struct cpuidle_governor {void (*disable) (struct cpuidle_device *dev);int (*select) (struct cpuidle_device *dev); -void (*reflect) (struct cpuidle_device *dev); +void (*reflect) (struct cpuidle_device *dev,int index);struct module *owner; };
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 12/14 cpuidle: Remove CPUIDLE_FLAG_IGNORE and dev->prepare()
In reply to Len BrownFrom: Deepthi Dharwar <[email protected]>
The cpuidle_device->prepare() mechanism causes updates to the cpuidle_state[].flags, setting and clearing CPUIDLE_FLAG_IGNORE to tell the governor not to chose a state on a per-cpu basis at run-time. State demotion is now handled by the driver and it returns the actual state entered. Hence, this mechanism is not required. Also this removes per-cpu flags from cpuidle_state enabling it to be made global.
Reference:
https://lkml.org/lkml/2011/3/25/52
--- drivers/cpuidle/cpuidle.c | 10 ---------- drivers/cpuidle/governors/menu.c | 2 -- include/linux/cpuidle.h | 3 --- 3 files changed, 0 insertions(+), 15 deletions(-)
drivers/cpuidle/cpuidle.c +0 -10
@@ -83,16 +83,6 @@ int cpuidle_idle_call(void)hrtimer_peek_ahead_timers ();#endif -/* -* Call the device's prepare function before calling the -* governor's select function. ->prepare gives the device's -* cpuidle driver a chance to update any dynamic information -* of its cpuidle states for the current idle period, e.g. -* state availability, latencies, residencies, etc. -*/ -if (dev->prepare) - dev->prepare (dev); -/* ask the governor for the next state */ next_state = cpuidle_curr_governor->select (dev);if (need_resched ()) {
drivers/cpuidle/governors/menu.c +0 -2
@@ -288,8 +288,6 @@ static int menu_select(struct cpuidle_device *dev)for (i =CPUIDLE_DRIVER_STATE_START ; i < dev->state_count; i++) {struct cpuidle_state *s = &dev->states[i]; -if (s->flags &CPUIDLE_FLAG_IGNORE ) -continue ;if (s->target_residency > data->predicted_us)continue ;if (s->exit_latency > latency_req)
include/linux/cpuidle.h +0 -3
@@ -47,7 +47,6 @@ struct cpuidle_state {/* Idle State Flags */ #define CPUIDLE_FLAG_TIME_VALID (0x01)/* is residency time measurable? */ -#define CPUIDLE_FLAG_IGNORE (0x100)/* ignore during this idle period */ #define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000)
@@ -93,8 +92,6 @@ struct cpuidle_device {struct completion kobj_unregister;void *governor_data;int safe_state_index; - -int (*prepare) (struct cpuidle_device *dev); }; DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 13/14 cpuidle: Split cpuidle_state structure and move per-cpu statistics fields
In reply to Len BrownFrom: Deepthi Dharwar <[email protected]>
This is the first step towards global registration of cpuidle states. The statistics used primarily by the governor are per-cpu and have to be split from rest of the fields inside cpuidle_state, which would be made global i.e. single copy. The driver_data field is also per-cpu and moved.
--- arch/arm/mach-davinci/cpuidle.c | 5 ++- arch/arm/mach-omap2/cpuidle34xx.c | 13 +++++----- drivers/acpi/processor_idle.c | 25 +++++++++---------- drivers/cpuidle/cpuidle.c | 11 +++++---- drivers/cpuidle/sysfs.c | 19 ++++++++++----- drivers/idle/intel_idle.c | 46 +++++++++++++++++++++++++++--------- include/linux/cpuidle.h | 25 ++++++++++++-------- 7 files changed, 90 insertions(+), 54 deletions(-)
arch/arm/mach-davinci/cpuidle.c +3 -2
@@ -80,7 +80,8 @@ static struct davinci_ops davinci_states[DAVINCI_CPUIDLE_MAX_STATES] = {static int davinci_enter_idle (struct cpuidle_device *dev,int index) { -struct davinci_ops *ops =cpuidle_get_statedata (&dev->states[index]); +struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; +struct davinci_ops *ops =cpuidle_get_statedata (state_usage);struct timeval before, after;int idle_time;
@@ -142,7 +143,7 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev)strcpy (device->states[1 ].desc,"WFI and DDR Self Refresh" );if (pdata->ddr2_pdown) davinci_states[1 ].flags |=DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN ; -cpuidle_set_statedata (&device->states[1 ], &davinci_states[1 ]); +cpuidle_set_statedata (&device->states_usage[1 ], &davinci_states[1 ]); device->state_count =DAVINCI_CPUIDLE_MAX_STATES ;
arch/arm/mach-omap2/cpuidle34xx.c +7 -6
@@ -97,7 +97,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev, int index) {struct omap3_idle_statedata *cx = -cpuidle_get_statedata (&dev->states[index]); +cpuidle_get_statedata (&dev->states_usage[index]);struct timespec ts_preidle, ts_postidle, ts_idle;u32 mpu_state = cx->mpu_state, core_state = cx->core_state;int idle_time;
@@ -160,8 +160,9 @@ return_sleep_time:static int next_valid_state (struct cpuidle_device *dev,int index) { +struct cpuidle_state_usage *curr_usage = &dev->states_usage[index];struct cpuidle_state *curr = &dev->states[index]; -struct omap3_idle_statedata *cx =cpuidle_get_statedata (curr); +struct omap3_idle_statedata *cx =cpuidle_get_statedata (curr_usage);u32 mpu_deepest_state =PWRDM_POWER_RET ;u32 core_deepest_state =PWRDM_POWER_RET ;int next_index =-1 ;
@@ -202,7 +203,7 @@ static int next_valid_state(struct cpuidle_device *dev,*/ idx--;for (; idx >=0 ; idx--) { - cx =cpuidle_get_statedata (&dev->states[idx]); + cx =cpuidle_get_statedata (&dev->states_usage[idx]);if ((cx->valid) && (cx->mpu_state >= mpu_deepest_state) && (cx->core_state >= core_deepest_state)) {
@@ -231,7 +232,6 @@ static int next_valid_state(struct cpuidle_device *dev,static int omap3_enter_idle_bm (struct cpuidle_device *dev,int index) { -struct cpuidle_state *state = &dev->states[index];int new_state_idx;u32 core_next_state, per_next_state =0 , per_saved_state =0 , cam_state;struct omap3_idle_statedata *cx;
@@ -264,7 +264,7 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,* Prevent PER off if CORE is not in retention or off as this * would disable PER wakeups completely. */ - cx =cpuidle_get_statedata (state); + cx =cpuidle_get_statedata (&dev->states_usage[index]); core_next_state = cx->core_state; per_next_state = per_saved_state =pwrdm_read_next_pwrst (per_pd); if ((per_next_state == PWRDM_POWER_OFF) &&
@@ -318,6 +318,7 @@ static inline struct omap3_idle_statedata *_fill_cstate( {struct omap3_idle_statedata *cx = &omap3_idle_data[idx];struct cpuidle_state *state = &dev->states[idx]; +struct cpuidle_state_usage *state_usage = &dev->states_usage[idx]; state->exit_latency = cpuidle_params_table[idx].exit_latency; state->target_residency = cpuidle_params_table[idx].target_residency;
@@ -326,7 +327,7 @@ static inline struct omap3_idle_statedata *_fill_cstate( cx->valid = cpuidle_params_table[idx].valid;sprintf (state->name,"C%d" , idx +1 );strncpy (state->desc, descr,CPUIDLE_DESC_LEN ); -cpuidle_set_statedata (state, cx); +cpuidle_set_statedata (state_usage, cx);return cx; }
drivers/acpi/processor_idle.c +12 -13
@@ -745,14 +745,13 @@ static inline void acpi_idle_do_entry(struct acpi_processor_cx *cx)* * This is equivalent to the HALT instruction. */ -static int acpi_idle_enter_c1 (struct cpuidle_device *dev, -int index) +static int acpi_idle_enter_c1 (struct cpuidle_device *dev,int index) {ktime_t kt1, kt2;s64 idle_time;struct acpi_processor *pr; -struct cpuidle_state *state = &dev->states[index]; -struct acpi_processor_cx *cx =cpuidle_get_statedata (state); +struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; +struct acpi_processor_cx *cx =cpuidle_get_statedata (state_usage); pr =__this_cpu_read (processors); dev->last_residency =0 ;
@@ -790,12 +789,11 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,* @dev: the target CPU * @index: the index of suggested state */ -static int acpi_idle_enter_simple (struct cpuidle_device *dev, -int index) +static int acpi_idle_enter_simple (struct cpuidle_device *dev,int index) {struct acpi_processor *pr; -struct cpuidle_state *state = &dev->states[index]; -struct acpi_processor_cx *cx =cpuidle_get_statedata (state); +struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; +struct acpi_processor_cx *cx =cpuidle_get_statedata (state_usage);ktime_t kt1, kt2;s64 idle_time_ns;s64 idle_time;
@@ -875,12 +873,11 @@ static DEFINE_SPINLOCK(c3_lock);* * If BM is detected, the deepest non-C3 idle state is entered instead. */ -static int acpi_idle_enter_bm (struct cpuidle_device *dev, -int index) +static int acpi_idle_enter_bm (struct cpuidle_device *dev,int index) {struct acpi_processor *pr; -struct cpuidle_state *state = &dev->states[index]; -struct acpi_processor_cx *cx =cpuidle_get_statedata (state); +struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; +struct acpi_processor_cx *cx =cpuidle_get_statedata (state_usage);ktime_t kt1, kt2;s64 idle_time_ns;s64 idle_time;
@@ -1004,6 +1001,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)int i, count =CPUIDLE_DRIVER_STATE_START ;struct acpi_processor_cx *cx;struct cpuidle_state *state; +struct cpuidle_state_usage *state_usage;struct cpuidle_device *dev = &pr->power.dev;if (!pr->flags.power_setup_done)
@@ -1026,6 +1024,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)for (i =1 ; i <ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { cx = &pr->power.states[i]; state = &dev->states[count]; + state_usage = &dev->states_usage[count];if (!cx->valid)continue ;
@@ -1036,7 +1035,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) continue;#endif -cpuidle_set_statedata (state, cx); +cpuidle_set_statedata (state_usage, cx);snprintf (state->name,CPUIDLE_NAME_LEN ,"C%d" , i);strncpy (state->desc, cx->desc,CPUIDLE_DESC_LEN );
drivers/cpuidle/cpuidle.c +6 -5
@@ -105,9 +105,9 @@ int cpuidle_idle_call(void)/* This can be moved to within driver enter routine * but that results in multiple copies of same code. */ - dev->states[entered_state].time += + dev->states_usage[entered_state].time += (unsigned long long )dev->last_residency; - dev->states[entered_state].usage++; + dev->states_usage[entered_state].usage++; }/* give the governor an opportunity to reflect on the outcome */
@@ -186,8 +186,9 @@ static int poll_idle(struct cpuidle_device *dev, int index)static void poll_idle_init (struct cpuidle_device *dev) {struct cpuidle_state *state = &dev->states[0 ]; +struct cpuidle_state_usage *state_usage = &dev->states_usage[0 ]; -cpuidle_set_statedata (state,NULL ); +cpuidle_set_statedata (state_usage,NULL );snprintf (state->name,CPUIDLE_NAME_LEN ,"POLL" );snprintf (state->desc,CPUIDLE_DESC_LEN ,"CPUIDLE CORE POLL IDLE" );
@@ -235,8 +236,8 @@ int cpuidle_enable_device(struct cpuidle_device *dev) goto fail_sysfs;for (i =0 ; i < dev->state_count; i++) { - dev->states[i].usage =0 ; - dev->states[i].time =0 ; + dev->states_usage[i].usage =0 ; + dev->states_usage[i].time =0 ; } dev->last_residency =0 ;
drivers/cpuidle/sysfs.c +13 -6
@@ -216,7 +216,8 @@ static struct kobj_type ktype_cpuidle = {struct cpuidle_state_attr {struct attribute attr; -ssize_t (*show)(struct cpuidle_state *,char *); +ssize_t (*show)(struct cpuidle_state *, \ +struct cpuidle_state_usage *,char *);ssize_t (*store)(struct cpuidle_state *,const char *,size_t ); };
@@ -224,19 +225,22 @@ struct cpuidle_state_attr { static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL)#define define_show_state_function (_name) \ -static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ +static ssize_t show_state_##_name(struct cpuidle_state *state, \ + struct cpuidle_state_usage *state_usage, char *buf) \ { \ return sprintf(buf, "%u\n", state->_name);\ }#define define_show_state_ull_function (_name) \ -static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ +static ssize_t show_state_##_name(struct cpuidle_state *state, \ + struct cpuidle_state_usage *state_usage, char *buf) \ { \ - return sprintf(buf, "%llu\n", state->_name);\ + return sprintf(buf, "%llu\n", state_usage->_name);\ }#define define_show_state_str_function (_name) \ -static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ +static ssize_t show_state_##_name(struct cpuidle_state *state, \ + struct cpuidle_state_usage *state_usage, char *buf) \ { \ if (state->_name[0] == '\0')\ return sprintf(buf, "<null>\n");\
@@ -269,16 +273,18 @@ static struct attribute *cpuidle_state_default_attrs[] = {#define kobj_to_state_obj (k) container_of(k, struct cpuidle_state_kobj, kobj)#define kobj_to_state (k) (kobj_to_state_obj(k)->state) +#define kobj_to_state_usage (k) (kobj_to_state_obj(k)->state_usage)#define attr_to_stateattr (a) container_of(a, struct cpuidle_state_attr, attr)static ssize_t cpuidle_state_show (struct kobject * kobj,struct attribute * attr ,char * buf) {int ret = -EIO ;struct cpuidle_state *state =kobj_to_state (kobj); +struct cpuidle_state_usage *state_usage =kobj_to_state_usage (kobj);struct cpuidle_state_attr * cattr =attr_to_stateattr (attr);if (cattr->show) - ret = cattr->show (state, buf); + ret = cattr->show (state, state_usage, buf);return ret; }
@@ -323,6 +329,7 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device)if (!kobj) goto error_state; kobj->state = &device->states[i]; + kobj->state_usage = &device->states_usage[i];init_completion (&kobj->kobj_unregister); ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj,
drivers/idle/intel_idle.c +34 -12
130 lines not on this page · raw message
include/linux/cpuidle.h +15 -10
@@ -28,19 +28,22 @@ struct cpuidle_device;* CPUIDLE DEVICE INTERFACE * ****************************/ +struct cpuidle_state_usage { +void *driver_data; + +unsigned long long usage; +unsigned long long time;/* in US */ +}; +struct cpuidle_state {char name[CPUIDLE_NAME_LEN ];char desc[CPUIDLE_DESC_LEN ]; -void *driver_data;unsigned int flags;unsigned int exit_latency;/* in US */ unsigned int power_usage;/* in mW */ unsigned int target_residency;/* in US */ -unsigned long long usage; -unsigned long long time;/* in US */ -int (*enter) (struct cpuidle_device *dev,int index); };
@@ -52,26 +55,27 @@ struct cpuidle_state {/** * cpuidle_get_statedata - retrieves private driver state data -* @state: the state +* @st_usage: the state usage statistics */ -static inline void *cpuidle_get_statedata (struct cpuidle_state *state) +static inline void *cpuidle_get_statedata (struct cpuidle_state_usage *st_usage) { -return state->driver_data; +return st_usage->driver_data; }/** * cpuidle_set_statedata - stores private driver state data -* @state: the state +* @st_usage: the state usage statistics * @data: the private data */ static inline void -cpuidle_set_statedata (struct cpuidle_state *state,void *data) +cpuidle_set_statedata (struct cpuidle_state_usage *st_usage,void *data) { - state->driver_data = data; + st_usage->driver_data = data; }struct cpuidle_state_kobj {struct cpuidle_state *state; +struct cpuidle_state_usage *state_usage;struct completion kobj_unregister;struct kobject kobj; };
@@ -85,6 +89,7 @@ struct cpuidle_device {int last_residency;int state_count;struct cpuidle_state states[CPUIDLE_STATE_MAX ]; +struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX ];struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX ];struct list_head device_list;
Signature · 1 line
1.7.7.rc0.72.g4b5ea
Len Brown
maintainerPATCH 14/14 cpuidle: Single/Global registration of idle states
In reply to Len BrownFrom: Deepthi Dharwar <[email protected]>
This patch makes the cpuidle_states structure global (single copy) instead of per-cpu. The statistics needed on per-cpu basis by the governor are kept per-cpu. This simplifies the cpuidle subsystem as state registration is done by single cpu only. Having single copy of cpuidle_states saves memory. Rare case of asymmetric C-states can be handled within the cpuidle driver and architectures such as POWER do not have asymmetric C-states.
Having single/global registration of all the idle states, dynamic C-state transitions on x86 are handled by
the boot cpu. Here, the boot cpu would disable all the devices, re-populate the states and later enable all the devices, irrespective of the cpu that would receive the notification first.
Reference:
https://lkml.org/lkml/2011/4/25/83
--- arch/arm/mach-at91/cpuidle.c | 31 +++--- arch/arm/mach-davinci/cpuidle.c | 39 ++++--- arch/arm/mach-exynos4/cpuidle.c | 23 +++-- arch/arm/mach-kirkwood/cpuidle.c | 30 +++--- arch/arm/mach-omap2/cpuidle34xx.c | 73 +++++++++---- arch/sh/kernel/cpu/shmobile/cpuidle.c | 18 ++-- drivers/acpi/processor_driver.c | 20 +--- drivers/acpi/processor_idle.c | 191 ++++++++++++++++++++++++++++----- drivers/cpuidle/cpuidle.c | 45 ++------ drivers/cpuidle/driver.c | 25 +++++ drivers/cpuidle/governors/ladder.c | 28 +++-- drivers/cpuidle/governors/menu.c | 20 ++-- drivers/cpuidle/sysfs.c | 3 +- drivers/idle/intel_idle.c | 80 +++++++++++---- include/acpi/processor.h | 1 + include/linux/cpuidle.h | 19 +++- 16 files changed, 439 insertions(+), 207 deletions(-)
arch/arm/mach-at91/cpuidle.c +17 -14
@@ -33,6 +33,7 @@ static struct cpuidle_driver at91_idle_driver = {/* Actual code that puts the SoC in different idle states */ static int at91_enter_idle (struct cpuidle_device *dev, +struct cpuidle_driver *drv,int index) {struct timeval before, after;
@@ -64,27 +65,29 @@ static int at91_enter_idle(struct cpuidle_device *dev,static int at91_init_cpuidle (void ) {struct cpuidle_device *device; - -cpuidle_register_driver (&at91_idle_driver); +struct cpuidle_driver *driver = &at91_idle_driver; device = &per_cpu (at91_cpuidle_device,smp_processor_id ()); device->state_count =AT91_MAX_STATES ; + driver->state_count =AT91_MAX_STATES ;/* Wait for interrupt state */ - device->states[0 ].enter = at91_enter_idle; - device->states[0 ].exit_latency =1 ; - device->states[0 ].target_residency =10000 ; - device->states[0 ].flags =CPUIDLE_FLAG_TIME_VALID ; -strcpy (device->states[0 ].name,"WFI" ); -strcpy (device->states[0 ].desc,"Wait for interrupt" ); + driver->states[0 ].enter = at91_enter_idle; + driver->states[0 ].exit_latency =1 ; + driver->states[0 ].target_residency =10000 ; + driver->states[0 ].flags =CPUIDLE_FLAG_TIME_VALID ; +strcpy (driver->states[0 ].name,"WFI" ); +strcpy (driver->states[0 ].desc,"Wait for interrupt" );/* Wait for interrupt and RAM self refresh state */ - device->states[1 ].enter = at91_enter_idle; - device->states[1 ].exit_latency =10 ; - device->states[1 ].target_residency =10000 ; - device->states[1 ].flags =CPUIDLE_FLAG_TIME_VALID ; -strcpy (device->states[1 ].name,"RAM_SR" ); -strcpy (device->states[1 ].desc,"WFI and RAM Self Refresh" ); + driver->states[1 ].enter = at91_enter_idle; + driver->states[1 ].exit_latency =10 ; + driver->states[1 ].target_residency =10000 ; + driver->states[1 ].flags =CPUIDLE_FLAG_TIME_VALID ; +strcpy (driver->states[1 ].name,"RAM_SR" ); +strcpy (driver->states[1 ].desc,"WFI and RAM Self Refresh" ); + +cpuidle_register_driver (&at91_idle_driver);if (cpuidle_register_device (device)) {printk (KERN_ERR "at91_init_cpuidle: Failed registering\n" );
arch/arm/mach-davinci/cpuidle.c +21 -18
@@ -78,6 +78,7 @@ static struct davinci_ops davinci_states[DAVINCI_CPUIDLE_MAX_STATES] = {/* Actual code that puts the SoC in different idle states */ static int davinci_enter_idle (struct cpuidle_device *dev, +struct cpuidle_driver *drv,int index) {struct cpuidle_state_usage *state_usage = &dev->states_usage[index];
@@ -109,6 +110,7 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev) {int ret;struct cpuidle_device *device; +struct cpuidle_driver *driver = &davinci_idle_driver;struct davinci_cpuidle_config *pdata = pdev->dev.platform_data; device = &per_cpu (davinci_cpuidle_device,smp_processor_id ());
@@ -120,32 +122,33 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev) ddr2_reg_base = pdata->ddr2_ctlr_base; - ret =cpuidle_register_driver (&davinci_idle_driver); -if (ret) { -dev_err (&pdev->dev,"failed to register driver\n" ); -return ret; - } -/* Wait for interrupt state */ - device->states[0 ].enter = davinci_enter_idle; - device->states[0 ].exit_latency =1 ; - device->states[0 ].target_residency =10000 ; - device->states[0 ].flags =CPUIDLE_FLAG_TIME_VALID ; -strcpy (device->states[0 ].name,"WFI" ); -strcpy (device->states[0 ].desc,"Wait for interrupt" ); + driver->states[0 ].enter = davinci_enter_idle; + driver->states[0 ].exit_latency =1 ; + driver->states[0 ].target_residency =10000 ; + driver->states[0 ].flags =CPUIDLE_FLAG_TIME_VALID ; +strcpy (driver->states[0 ].name,"WFI" ); +strcpy (driver->states[0 ].desc,"Wait for interrupt" );/* Wait for interrupt and DDR self refresh state */ - device->states[1 ].enter = davinci_enter_idle; - device->states[1 ].exit_latency =10 ; - device->states[1 ].target_residency =10000 ; - device->states[1 ].flags =CPUIDLE_FLAG_TIME_VALID ; -strcpy (device->states[1 ].name,"DDR SR" ); -strcpy (device->states[1 ].desc,"WFI and DDR Self Refresh" ); + driver->states[1 ].enter = davinci_enter_idle; + driver->states[1 ].exit_latency =10 ; + driver->states[1 ].target_residency =10000 ; + driver->states[1 ].flags =CPUIDLE_FLAG_TIME_VALID ; +strcpy (driver->states[1 ].name,"DDR SR" ); +strcpy (driver->states[1 ].desc,"WFI and DDR Self Refresh" );if (pdata->ddr2_pdown) davinci_states[1 ].flags |=DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN ;cpuidle_set_statedata (&device->states_usage[1 ], &davinci_states[1 ]); device->state_count =DAVINCI_CPUIDLE_MAX_STATES ; + driver->state_count =DAVINCI_CPUIDLE_MAX_STATES ; + + ret =cpuidle_register_driver (&davinci_idle_driver); +if (ret) { +dev_err (&pdev->dev,"failed to register driver\n" ); +return ret; + } ret =cpuidle_register_device (device);if (ret) {
arch/arm/mach-exynos4/cpuidle.c +13 -10
@@ -16,6 +16,7 @@#include <asm/proc-fns.h> static int exynos4_enter_idle (struct cpuidle_device *dev, +struct cpuidle_driver *drv,int index);static struct cpuidle_state exynos4_cpuidle_set[] = {
@@ -37,6 +38,7 @@ static struct cpuidle_driver exynos4_idle_driver = { };static int exynos4_enter_idle (struct cpuidle_device *dev, +struct cpuidle_driver *drv,int index) {struct timeval before, after;
@@ -60,22 +62,23 @@ static int __init exynos4_init_cpuidle(void) {int i, max_cpuidle_state, cpu_id;struct cpuidle_device *device; - +struct cpuidle_driver *drv = &exynos4_idle_driver; + +/* Setup cpuidle driver */ + drv->state_count = (sizeof (exynos4_cpuidle_set) / +sizeof (struct cpuidle_state )); + max_cpuidle_state = drv->state_count; +for (i =0 ; i < max_cpuidle_state; i++) { +memcpy (&drv->states[i], &exynos4_cpuidle_set[i], +sizeof (struct cpuidle_state )); + }cpuidle_register_driver (&exynos4_idle_driver);for_each_cpu (cpu_id, cpu_online_mask) { device = &per_cpu (exynos4_cpuidle_device, cpu_id); device->cpu = cpu_id; - device->state_count = (sizeof (exynos4_cpuidle_set) / -sizeof (struct cpuidle_state )); - - max_cpuidle_state = device->state_count; - -for (i =0 ; i < max_cpuidle_state; i++) { -memcpy (&device->states[i], &exynos4_cpuidle_set[i], -sizeof (struct cpuidle_state )); - } + device->state_count = drv->state_count;if (cpuidle_register_device (device)) {printk (KERN_ERR "CPUidle register device failed\n," );
arch/arm/mach-kirkwood/cpuidle.c +16 -14
@@ -32,6 +32,7 @@ static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device);/* Actual code that puts the SoC in different idle states */ static int kirkwood_enter_idle (struct cpuidle_device *dev, +struct cpuidle_driver *drv,int index) {struct timeval before, after;
@@ -68,28 +69,29 @@ static int kirkwood_enter_idle(struct cpuidle_device *dev,static int kirkwood_init_cpuidle (void ) {struct cpuidle_device *device; - -cpuidle_register_driver (&kirkwood_idle_driver); +struct cpuidle_driver *driver = &kirkwood_idle_driver; device = &per_cpu (kirkwood_cpuidle_device,smp_processor_id ()); device->state_count =KIRKWOOD_MAX_STATES ; + driver->state_count =KIRKWOOD_MAX_STATES ;/* Wait for interrupt state */ - device->states[0 ].enter = kirkwood_enter_idle; - device->states[0 ].exit_latency =1 ; - device->states[0 ].target_residency =10000 ; - device->states[0 ].flags =CPUIDLE_FLAG_TIME_VALID ; -strcpy (device->states[0 ].name,"WFI" ); -strcpy (device->states[0 ].desc,"Wait for interrupt" ); + driver->states[0 ].enter = kirkwood_enter_idle; + driver->states[0 ].exit_latency =1 ; + driver->states[0 ].target_residency =10000 ; + driver->states[0 ].flags =CPUIDLE_FLAG_TIME_VALID ; +strcpy (driver->states[0 ].name,"WFI" ); +strcpy (driver->states[0 ].desc,"Wait for interrupt" );/* Wait for interrupt and DDR self refresh state */ - device->states[1 ].enter = kirkwood_enter_idle; - device->states[1 ].exit_latency =10 ; - device->states[1 ].target_residency =10000 ; - device->states[1 ].flags =CPUIDLE_FLAG_TIME_VALID ; -strcpy (device->states[1 ].name,"DDR SR" ); -strcpy (device->states[1 ].desc,"WFI and DDR Self Refresh" ); + driver->states[1 ].enter = kirkwood_enter_idle; + driver->states[1 ].exit_latency =10 ; + driver->states[1 ].target_residency =10000 ; + driver->states[1 ].flags =CPUIDLE_FLAG_TIME_VALID ; +strcpy (driver->states[1 ].name,"DDR SR" ); +strcpy (driver->states[1 ].desc,"WFI and DDR Self Refresh" ); +cpuidle_register_driver (&kirkwood_idle_driver);if (cpuidle_register_device (device)) {printk (KERN_ERR "kirkwood_init_cpuidle: Failed registering\n" );return -EIO ;
arch/arm/mach-omap2/cpuidle34xx.c +49 -24
199 lines not on this page · raw message
arch/sh/kernel/cpu/shmobile/cpuidle.c +11 -7
@@ -25,6 +25,7 @@ static unsigned long cpuidle_mode[] = { };static int cpuidle_sleep_enter (struct cpuidle_device *dev, +struct cpuidle_driver *drv,int index) {unsigned long allowed_mode =arch_hwblk_sleep_mode ();
@@ -64,19 +65,19 @@ static struct cpuidle_driver cpuidle_driver = {void sh_mobile_setup_cpuidle (void ) {struct cpuidle_device *dev = &cpuidle_dev; +struct cpuidle_driver *drv = &cpuidle_driver;struct cpuidle_state *state;int i; -cpuidle_register_driver (&cpuidle_driver);for (i =0 ; i <CPUIDLE_STATE_MAX ; i++) { - dev->states[i].name[0 ] ='\0' ; - dev->states[i].desc[0 ] ='\0' ; + drv->states[i].name[0 ] ='\0' ; + drv->states[i].desc[0 ] ='\0' ; } i =CPUIDLE_DRIVER_STATE_START ; - state = &dev->states[i++]; + state = &drv->states[i++];snprintf (state->name,CPUIDLE_NAME_LEN ,"C1" );strncpy (state->desc,"SuperH Sleep Mode" ,CPUIDLE_DESC_LEN ); state->exit_latency =1 ;
@@ -86,10 +87,10 @@ void sh_mobile_setup_cpuidle(void) state->flags |=CPUIDLE_FLAG_TIME_VALID ; state->enter = cpuidle_sleep_enter; - dev->safe_state_index = i-1 ; + drv->safe_state_index = i-1 ;if (sh_mobile_sleep_supported &SUSP_SH_SF ) { - state = &dev->states[i++]; + state = &drv->states[i++];snprintf (state->name,CPUIDLE_NAME_LEN ,"C2" );strncpy (state->desc,"SuperH Sleep Mode [SF]" ,CPUIDLE_DESC_LEN );
@@ -102,7 +103,7 @@ void sh_mobile_setup_cpuidle(void) }if (sh_mobile_sleep_supported &SUSP_SH_STANDBY ) { - state = &dev->states[i++]; + state = &drv->states[i++];snprintf (state->name,CPUIDLE_NAME_LEN ,"C3" );strncpy (state->desc,"SuperH Mobile Standby Mode [SF]" ,CPUIDLE_DESC_LEN );
@@ -114,7 +115,10 @@ void sh_mobile_setup_cpuidle(void) state->enter = cpuidle_sleep_enter; } + drv->state_count = i; dev->state_count = i; +cpuidle_register_driver (&cpuidle_driver); +cpuidle_register_device (dev); }
drivers/acpi/processor_driver.c +3 -17
@@ -426,7 +426,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,if (action ==CPU_ONLINE && pr) {acpi_processor_ppc_has_changed (pr,0 ); -acpi_processor_cst_has_changed (pr); +acpi_processor_hotplug (pr);acpi_processor_reevaluate_tstate (pr, action);acpi_processor_tstate_has_changed (pr); }
@@ -503,8 +503,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)acpi_processor_get_throttling_info (pr);acpi_processor_get_limit_info (pr); - -if (cpuidle_get_driver () == &acpi_idle_driver) +if (!cpuidle_get_driver () ||cpuidle_get_driver () == &acpi_idle_driver)acpi_processor_power_init (pr, device); pr->cdev = thermal_cooling_device_register("Processor", device,
@@ -800,17 +799,9 @@ static int __init acpi_processor_init(void)memset (&errata,0 ,sizeof (errata)); -if (!cpuidle_register_driver (&acpi_idle_driver)) { -printk (KERN_DEBUG "ACPI: %s registered with cpuidle\n" , - acpi_idle_driver.name); - }else { -printk (KERN_DEBUG "ACPI: acpi_idle yielding to %s\n" , -cpuidle_get_driver ()->name); - } - result =acpi_bus_register_driver (&acpi_processor_driver);if (result <0 ) - goto out_cpuidle; +return result;acpi_processor_install_hotplug_notify ();
@@ -821,11 +812,6 @@ static int __init acpi_processor_init(void)acpi_processor_throttling_init ();return 0 ; - -out_cpuidle: -cpuidle_unregister_driver (&acpi_idle_driver); - -return result; } static void __exit acpi_processor_exit(void)
drivers/acpi/processor_idle.c +166 -25
307 lines not on this page · raw message
drivers/cpuidle/cpuidle.c +12 -33
108 lines not on this page · raw message
drivers/cpuidle/driver.c +25 -0
@@ -17,6 +17,30 @@static struct cpuidle_driver *cpuidle_curr_driver;DEFINE_SPINLOCK (cpuidle_driver_lock); +static void __cpuidle_register_driver (struct cpuidle_driver *drv) +{ +int i; +/* +* cpuidle driver should set the drv->power_specified bit +* before registering if the driver provides +* power_usage numbers. +* +* If power_specified is not set, +* we fill in power_usage with decreasing values as the +* cpuidle code has an implicit assumption that state Cn +* uses less power than C(n-1). +* +* With CONFIG_ARCH_HAS_CPU_RELAX, C0 is already assigned +* an power value of -1. So we use -2, -3, etc, for other +* c-states. +*/ +if (!drv->power_specified) { +for (i =CPUIDLE_DRIVER_STATE_START ; i < drv->state_count; i++) + drv->states[i].power_usage =-1 - i; + } +} + +/** * cpuidle_register_driver - registers a driver * @drv: the driver
@@ -34,6 +58,7 @@ int cpuidle_register_driver(struct cpuidle_driver *drv)spin_unlock (&cpuidle_driver_lock);return -EBUSY ; } +__cpuidle_register_driver (drv); cpuidle_curr_driver = drv;spin_unlock (&cpuidle_driver_lock);
drivers/cpuidle/governors/ladder.c +17 -11
@@ -60,9 +60,11 @@ static inline void ladder_do_selection(struct ladder_device *ldev,/** * ladder_select_state - selects the next state to enter +* @drv: cpuidle driver * @dev: the CPU */ -static int ladder_select_state (struct cpuidle_device *dev) +static int ladder_select_state (struct cpuidle_driver *drv, +struct cpuidle_device *dev) {struct ladder_device *ldev = &__get_cpu_var (ladder_devices);struct ladder_device_state *last_state;
@@ -77,15 +79,17 @@ static int ladder_select_state(struct cpuidle_device *dev) last_state = &ldev->states[last_idx]; -if (dev->states[last_idx].flags &CPUIDLE_FLAG_TIME_VALID ) - last_residency =cpuidle_get_last_residency (dev) - dev->states[last_idx].exit_latency; +if (drv->states[last_idx].flags &CPUIDLE_FLAG_TIME_VALID ) { + last_residency =cpuidle_get_last_residency (dev) - \ + drv->states[last_idx].exit_latency; + }else last_residency = last_state->threshold.promotion_time +1 ;/* consider promotion */ -if (last_idx < dev->state_count -1 && +if (last_idx < drv->state_count -1 && last_residency > last_state->threshold.promotion_time && - dev->states[last_idx +1 ].exit_latency <= latency_req) { + drv->states[last_idx +1 ].exit_latency <= latency_req) { last_state->stats.promotion_count++; last_state->stats.demotion_count =0 ;if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) {
@@ -96,11 +100,11 @@ static int ladder_select_state(struct cpuidle_device *dev)/* consider demotion */ if (last_idx >CPUIDLE_DRIVER_STATE_START && - dev->states[last_idx].exit_latency > latency_req) { + drv->states[last_idx].exit_latency > latency_req) {int i;for (i = last_idx -1 ; i >CPUIDLE_DRIVER_STATE_START ; i--) { -if (dev->states[i].exit_latency <= latency_req) +if (drv->states[i].exit_latency <= latency_req)break ; }ladder_do_selection (ldev, last_idx, i);
@@ -123,9 +127,11 @@ static int ladder_select_state(struct cpuidle_device *dev)/** * ladder_enable_device - setup for the governor +* @drv: cpuidle driver * @dev: the CPU */ -static int ladder_enable_device (struct cpuidle_device *dev) +static int ladder_enable_device (struct cpuidle_driver *drv, +struct cpuidle_device *dev) {int i;struct ladder_device *ldev = &per_cpu (ladder_devices, dev->cpu);
@@ -134,8 +140,8 @@ static int ladder_enable_device(struct cpuidle_device *dev) ldev->last_state_idx =CPUIDLE_DRIVER_STATE_START ; -for (i =0 ; i < dev->state_count; i++) { - state = &dev->states[i]; +for (i =0 ; i < drv->state_count; i++) { + state = &drv->states[i]; lstate = &ldev->states[i]; lstate->stats.promotion_count =0 ;
@@ -144,7 +150,7 @@ static int ladder_enable_device(struct cpuidle_device *dev) lstate->threshold.promotion_count =PROMOTION_COUNT ; lstate->threshold.demotion_count =DEMOTION_COUNT ; -if (i < dev->state_count -1 ) +if (i < drv->state_count -1 ) lstate->threshold.promotion_time = state->exit_latency;if (i >0 ) lstate->threshold.demotion_time = state->exit_latency;
drivers/cpuidle/governors/menu.c +12 -8
@@ -182,7 +182,7 @@ static inline int performance_multiplier(void) static DEFINE_PER_CPU(struct menu_device, menu_devices); -static void menu_update (struct cpuidle_device *dev); +static void menu_update (struct cpuidle_driver *drv,struct cpuidle_device *dev);/* This implements DIV_ROUND_CLOSEST but avoids 64 bit division */ static u64 div_round64 (u64 dividend,u32 divisor)
@@ -228,9 +228,10 @@ static void detect_repeating_patterns(struct menu_device *data)/** * menu_select - selects the next idle state to enter +* @drv: cpuidle driver containing state data * @dev: the CPU */ -static int menu_select (struct cpuidle_device *dev) +static int menu_select (struct cpuidle_driver *drv,struct cpuidle_device *dev) {struct menu_device *data = &__get_cpu_var (menu_devices);int latency_req =pm_qos_request (PM_QOS_CPU_DMA_LATENCY );
@@ -240,7 +241,7 @@ static int menu_select(struct cpuidle_device *dev)struct timespec t;if (data->needs_update) { -menu_update (dev); +menu_update (drv, dev); data->needs_update =0 ; }
@@ -285,8 +286,8 @@ static int menu_select(struct cpuidle_device *dev)* Find the idle state with the lowest power while satisfying * our constraints. */ -for (i =CPUIDLE_DRIVER_STATE_START ; i < dev->state_count; i++) { -struct cpuidle_state *s = &dev->states[i]; +for (i =CPUIDLE_DRIVER_STATE_START ; i < drv->state_count; i++) { +struct cpuidle_state *s = &drv->states[i];if (s->target_residency > data->predicted_us)continue ;
@@ -323,14 +324,15 @@ static void menu_reflect(struct cpuidle_device *dev, int index)/** * menu_update - attempts to guess what happened after entry +* @drv: cpuidle driver containing state data * @dev: the CPU */ -static void menu_update (struct cpuidle_device *dev) +static void menu_update (struct cpuidle_driver *drv,struct cpuidle_device *dev) {struct menu_device *data = &__get_cpu_var (menu_devices);int last_idx = data->last_state_idx;unsigned int last_idle_us =cpuidle_get_last_residency (dev); -struct cpuidle_state *target = &dev->states[last_idx]; +struct cpuidle_state *target = &drv->states[last_idx];unsigned int measured_us;u64 new_factor;
@@ -384,9 +386,11 @@ static void menu_update(struct cpuidle_device *dev)/** * menu_enable_device - scans a CPU's states and does setup +* @drv: cpuidle driver * @dev: the CPU */ -static int menu_enable_device (struct cpuidle_device *dev) +static int menu_enable_device (struct cpuidle_driver *drv, +struct cpuidle_device *dev) {struct menu_device *data = &per_cpu (menu_devices, dev->cpu);
drivers/cpuidle/sysfs.c +2 -1
@@ -322,13 +322,14 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device) {int i, ret = -ENOMEM ;struct cpuidle_state_kobj *kobj; +struct cpuidle_driver *drv =cpuidle_get_driver ();/* state statistics */ for (i =0 ; i < device->state_count; i++) { kobj =kzalloc (sizeof (struct cpuidle_state_kobj ),GFP_KERNEL );if (!kobj) goto error_state; - kobj->state = &device->states[i]; + kobj->state = &drv->states[i]; kobj->state_usage = &device->states_usage[i];init_completion (&kobj->kobj_unregister);
drivers/idle/intel_idle.c +61 -19
124 lines not on this page · raw message
include/acpi/processor.h +1 -0
@@ -329,6 +329,7 @@ extern void acpi_processor_throttling_init(void);int acpi_processor_power_init (struct acpi_processor *pr,struct acpi_device *device);int acpi_processor_cst_has_changed (struct acpi_processor *pr); +int acpi_processor_hotplug (struct acpi_processor *pr);int acpi_processor_power_exit (struct acpi_processor *pr,struct acpi_device *device);int acpi_processor_suspend (struct acpi_device * device,pm_message_t state);
include/linux/cpuidle.h +13 -6
@@ -22,6 +22,7 @@#define CPUIDLE_DESC_LEN 32struct cpuidle_device ; +struct cpuidle_driver ;/****************************
@@ -45,6 +46,7 @@ struct cpuidle_state {unsigned int target_residency;/* in US */ int (*enter) (struct cpuidle_device *dev, +struct cpuidle_driver *drv,int index); };
@@ -83,12 +85,10 @@ struct cpuidle_state_kobj {struct cpuidle_device {unsigned int registered:1 ;unsigned int enabled:1 ; -unsigned int power_specified:1 ;unsigned int cpu;int last_residency;int state_count; -struct cpuidle_state states[CPUIDLE_STATE_MAX ];struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX ];struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX ];
@@ -96,7 +96,6 @@ struct cpuidle_device {struct kobject kobj;struct completion kobj_unregister;void *governor_data; -int safe_state_index; }; DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
@@ -120,6 +119,11 @@ static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)struct cpuidle_driver {char name[CPUIDLE_NAME_LEN ];struct module *owner; + +unsigned int power_specified:1 ; +struct cpuidle_state states[CPUIDLE_STATE_MAX ]; +int state_count; +int safe_state_index; };#ifdef CONFIG_CPU_IDLE
@@ -166,10 +170,13 @@ struct cpuidle_governor {struct list_head governor_list;unsigned int rating; -int (*enable) (struct cpuidle_device *dev); -void (*disable) (struct cpuidle_device *dev); +int (*enable) (struct cpuidle_driver *drv, +struct cpuidle_device *dev); +void (*disable) (struct cpuidle_driver *drv, +struct cpuidle_device *dev); -int (*select) (struct cpuidle_device *dev); +int (*select) (struct cpuidle_driver *drv, +struct cpuidle_device *dev);void (*reflect) (struct cpuidle_device *dev,int index);struct module *owner;
Signature · 1 line
1.7.7.rc0.72.g4b5ea
On Monday 07 November 2011 05:11:50 Len Brown wrote:
..
Quoted 3 lines
Also, due to kernel.org taking my e-mail and patchwork out of action, i've missed quite a bit of e-mail, so feel free to ping/re-send patches I've missed.
Any chance the two I posted:
Subjet: Override arbitrary ACPI tables via initrd
Date: Fri, 04-11-11
can make it?
One patch is in ACPICA, but it's nicely separated. Robert and Lin agreed with it, but seem to lack time to convert it to ACPICA sources:
If it's not in ACPICA could it still get into Linus' and reverted and synced with acpica in 3.3 or similar?
Thanks,
Thomas
On Monday 07 November 2011 05:11:50 Len Brown wrote:
..
Quoted 3 lines
Also, due to kernel.org taking my e-mail and patchwork out of action, i've missed quite a bit of e-mail, so feel free to ping/re-send patches I've missed.
Any chance the two I posted:
Subjet: Override arbitrary ACPI tables via initrd
Date: Fri, 04-11-11
can make it?
One patch is in ACPICA, but it's nicely separated. Robert and Lin agreed with it, but seem to lack time to convert it to ACPICA sources:
If it's not in ACPICA could it still get into Linus' and reverted and synced with acpica in 3.3 or similar?
Thanks,
Thomas