ARM: OMAP: PM: remove the latency related functions from the API
Subsystems (8)
cover ARM: OMAP: PM: remove the latency related functions from the API
From: Jean Pihet <[email protected]>
Remove the following functions from the OMAP PM API and the callers (currently only I2C driver):
omap_pm_set_max_mpu_wakeup_lat omap_pm_set_max_dev_wakeup_lat
omap_pm_set_max_sdma_lat
and updated the kernel Documentation accordingly.
The generic per-device PM QoS functions shall be used instead of the OMAP PM API, cf. include/linux/pm_qos.h and Documentation/power/pm_qos_interface.txt.
Based on the pm-qos branch of the linux-omap git tree (3.4.0-rc2) [1] with the changes for the functional power states [2] and the per-device PM QoS support for OMAP [3].
Tested cpuidle and suspend on OMAP3 Beagleboard (ES2.x) with constraints on MPU, CORE, PER in RETention and OFF modes.
[1] git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
[2] http://marc.info/?l=linux-omap&m=133475291911194&w=2
[3] http://marc.info/?l=linux-omap&m=133475685213067&w=2
Jean Pihet (2):
ARM: OMAP: convert I2C driver to PM QoS for latency constraints
ARM: OMAP: PM: remove the latency related functions from the API
Documentation/arm/OMAP/omap_pm | 68 ++++++-------------- arch/arm/plat-omap/i2c.c | 21 ------ arch/arm/plat-omap/include/plat/omap-pm.h | 99 ----------------------------- arch/arm/plat-omap/omap-pm-noop.c | 88 ------------------------- drivers/i2c/busses/i2c-omap.c | 28 +++++--- include/linux/i2c-omap.h | 1 - 6 files changed, 38 insertions(+), 267 deletions(-)
Signature · 1 line
1.7.7.6
PATCH 1/2 ARM: OMAP: convert I2C driver to PM QoS for latency constraints
From: Jean Pihet <[email protected]>
Convert the driver from the outdated omap_pm_set_max_mpu_wakeup_lat API to the new PM QoS API.
Since the constraint is on the MPU subsystem, use the PM_QOS_CPU_DMA_LATENCY class of PM QoS. The resulting MPU constraints are used by cpuidle to decide the next power state of the MPU subsystem.
The I2C device latency timing is derived from the FIFO size and the clock speed and so is applicable to all OMAP SoCs.
--- arch/arm/plat-omap/i2c.c | 21 --------------------- drivers/i2c/busses/i2c-omap.c | 28 +++++++++++++++++----------- include/linux/i2c-omap.h | 1 - 3 files changed, 17 insertions(+), 33 deletions(-)
arch/arm/plat-omap/i2c.c +0 -21
@@ -26,7 +26,6 @@#include <linux/kernel.h> #include <linux/platform_device.h> #include <linux/i2c.h> -#include <linux/i2c-omap.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/clk.h>
@@ -34,7 +33,6 @@#include <mach/irqs.h> #include <plat/mux.h> #include <plat/i2c.h> -#include <plat/omap-pm.h> #include <plat/omap_device.h> #define OMAP_I2C_SIZE 0x3f
@@ -129,16 +127,6 @@ static inline int omap1_i2c_add_bus(int bus_id)#ifdef CONFIG_ARCH_OMAP2PLUS -/* -* XXX This function is a temporary compatibility wrapper - only -* needed until the I2C driver can be converted to call -* omap_pm_set_max_dev_wakeup_lat() and handle a return code. -*/ -static void omap_pm_set_max_mpu_wakeup_lat_compat (struct device *dev,long t) -{ -omap_pm_set_max_mpu_wakeup_lat (dev, t); -} -static inline int omap2_i2c_add_bus (int bus_id) {int l;
@@ -170,15 +158,6 @@ static inline int omap2_i2c_add_bus(int bus_id) dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr; pdata->flags = dev_attr->flags; -/* -* When waiting for completion of a i2c transfer, we need to -* set a wake up latency constraint for the MPU. This is to -* ensure quick enough wakeup from idle, when transfer -* completes. -* Only omap3 has support for constraints -*/ -if (cpu_is_omap34xx ()) - pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat; pdev =omap_device_build (name, bus_id, oh, pdata,sizeof (struct omap_i2c_bus_platform_data ),NULL ,0 ,0 );
drivers/i2c/busses/i2c-omap.c +17 -11
@@ -43,6 +43,7 @@#include <linux/slab.h> #include <linux/i2c-omap.h> #include <linux/pm_runtime.h> +#include <linux/pm_qos.h> /* I2C controller revisions */ #define OMAP_I2C_OMAP1_REV_2 0x20
@@ -183,8 +184,7 @@ struct omap_i2c_dev {struct completion cmd_complete;struct resource *ioarea;u32 latency;/* maximum mpu wkup latency */ -void (*set_mpu_wkup_lat)(struct device *dev, -long latency); +struct pm_qos_request pm_qos_request;u32 speed;/* Speed of bus in kHz */ u32 dtrev;/* extra revision from DT */ u32 flags;
@@ -634,8 +634,16 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)if (r <0 ) goto out; -if (dev->set_mpu_wkup_lat !=NULL ) - dev->set_mpu_wkup_lat (dev->dev, dev->latency); +/* +* When waiting for completion of a i2c transfer, we need to +* set a wake up latency constraint for the MPU. This is to +* ensure quick enough wakeup from idle, when transfer +* completes. +*/ +if (dev->latency) +pm_qos_add_request (&dev->pm_qos_request, +PM_QOS_CPU_DMA_LATENCY , + dev->latency);for (i =0 ; i < num; i++) { r =omap_i2c_xfer_msg (adap, &msgs[i], (i == (num -1 )));
@@ -643,8 +651,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)break ; } -if (dev->set_mpu_wkup_lat !=NULL ) - dev->set_mpu_wkup_lat (dev->dev,-1 ); +if (dev->latency) +pm_qos_remove_request (&dev->pm_qos_request);if (r ==0 ) r = num;
@@ -1032,7 +1040,6 @@ omap_i2c_probe(struct platform_device *pdev) }else if (pdata !=NULL ) { dev->speed = pdata->clkrate; dev->flags = pdata->flags; - dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; dev->dtrev = pdata->rev; }
@@ -1081,10 +1088,9 @@ omap_i2c_probe(struct platform_device *pdev)else dev->b_hw =1 ;/* Enable hardware fixes */ -/* calculate wakeup latency constraint for MPU */ -if (dev->set_mpu_wkup_lat !=NULL ) - dev->latency = (1000000 * dev->fifo_size) / - (1000 * dev->speed /8 ); +/* calculate wakeup latency constraint */ + dev->latency = (1000000 * dev->fifo_size) / + (1000 * dev->speed /8 ); }/* reset ASAP, clearing any IRQs */
include/linux/i2c-omap.h +0 -1
@@ -34,7 +34,6 @@ struct omap_i2c_bus_platform_data {u32 clkrate;u32 rev; u32 flags; - void (*set_mpu_wkup_lat)(struct device *dev, long set); };#endif
Signature · 1 line
1.7.7.6
PATCH 2/2 ARM: OMAP: PM: remove the latency related functions from the API
In reply to jean.pihet at newoldbits.comFrom: Jean Pihet <[email protected]>
Remove the following functions from the OMAP PM API:
omap_pm_set_max_mpu_wakeup_lat omap_pm_set_max_dev_wakeup_lat omap_pm_set_max_sdma_lat
and updated the kernel Documentation accordingly.
The generic per-device PM QoS functions shall be used instead of the OMAP PM API, cf. include/linux/pm_qos.h and Documentation/power/pm_qos_interface.txt.
--- Documentation/arm/OMAP/omap_pm | 68 ++++++-------------- arch/arm/plat-omap/include/plat/omap-pm.h | 99 ----------------------------- arch/arm/plat-omap/omap-pm-noop.c | 88 ------------------------- 3 files changed, 21 insertions(+), 234 deletions(-)
Documentation/arm/OMAP/omap_pm +21 -47
@@ -5,8 +5,19 @@ The OMAP PM interface This document describes the temporary OMAP PM interface. Driver authors use these functions to communicate minimum latency or throughput constraints to the kernel power management code. + Over time, the intention is to merge features from the OMAP PM interface into the Linux PM QoS code. +The following PM QoS features already migrated to the PM QoS framework: +- PM QoS CPU and DMA latency: used to specify the maximum allowed wake-up + latency for the CPU, +- per device PM QoS latency: used to specifiy the maximum allowed wake-up + latency for a given device. + +Please refer to the corresponding header file and kernel documentation +for the PM QoS framework, respectively at include/linux/pm_qos.h and +Documentation/power/pm_qos_interface.txt. + Drivers need to express PM parameters which:
@@ -29,21 +40,12 @@ Drivers need to express PM parameters which: This document proposes the OMAP PM interface, including the following -five power management functions for driver code: - -1. Set the maximum MPU wakeup latency: - (*pdata->set_max_mpu_wakeup_lat)(struct device *dev, unsigned long t) +power management functions for driver code: -2. Set the maximum device wakeup latency: - (*pdata->set_max_dev_wakeup_lat)(struct device *dev, unsigned long t) - -3. Set the maximum system DMA transfer start latency (CORE pwrdm): - (*pdata->set_max_sdma_lat)(struct device *dev, long t) - -4. Set the minimum bus throughput needed by a device: +1. Set the minimum bus throughput needed by a device: (*pdata->set_min_bus_tput)(struct device *dev, u8 agent_id, unsigned long r) -5. Return the number of times the device has lost context +2. Return the number of times the device has lost context (*pdata->get_dev_context_loss_count)(struct device *dev)
@@ -55,10 +57,12 @@ The OMAP PM layer is intended to be temporary --------------------------------------------- The intention is that eventually the Linux PM QoS layer should support -the range of power management features present in OMAP3. As this -happens, existing drivers using the OMAP PM interface can be modified +the range of power management features present in OMAP3. As this +happens, existing drivers using the OMAP PM interface shall be modified to use the Linux PM QoS code; and the OMAP PM interface can disappear. +The set_min_bus_tput function shall be converted to a throughput PM QoS +framework. Driver usage of the OMAP PM functions -------------------------------------
@@ -66,39 +70,9 @@ Driver usage of the OMAP PM functions As the 'pdata' in the above examples indicates, these functions are exposed to drivers through function pointers in driver .platform_data structures. The function pointers are initialized by the board-*.c -files to point to the corresponding OMAP PM functions: -.set_max_dev_wakeup_lat will point to -omap_pm_set_max_dev_wakeup_lat(), etc. Other architectures which do -not support these functions should leave these function pointers set -to NULL. Drivers should use the following idiom: - - if (pdata->set_max_dev_wakeup_lat) - (*pdata->set_max_dev_wakeup_lat)(dev, t); - -The most common usage of these functions will probably be to specify -the maximum time from when an interrupt occurs, to when the device -becomes accessible. To accomplish this, driver writers should use the -set_max_mpu_wakeup_lat() function to to constrain the MPU wakeup -latency, and the set_max_dev_wakeup_lat() function to constrain the -device wakeup latency (from clk_enable() to accessibility). For -example, - - /* Limit MPU wakeup latency */ - if (pdata->set_max_mpu_wakeup_lat) - (*pdata->set_max_mpu_wakeup_lat)(dev, tc); - - /* Limit device powerdomain wakeup latency */ - if (pdata->set_max_dev_wakeup_lat) - (*pdata->set_max_dev_wakeup_lat)(dev, td); - - /* total wakeup latency in this example: (tc + td) */ - -The PM parameters can be overwritten by calling the function again -with the new value. The settings can be removed by calling the -function with a t argument of -1 (except in the case of -set_max_bus_tput(), which should be called with an r argument of 0). - -The fifth function above, omap_pm_get_dev_context_loss_count(), +files to point to the corresponding OMAP PM functions. + +The omap_pm_get_dev_context_loss_count() function is intended as an optimization to allow drivers to determine whether the device has lost its internal context. If context has been lost, the driver must restore its internal context before proceeding.
arch/arm/plat-omap/include/plat/omap-pm.h +0 -99
111 lines not on this page · raw message
arch/arm/plat-omap/omap-pm-noop.c +0 -88
100 lines not on this page · raw message
Signature · 1 line
1.7.7.6
PATCH 2/2 ARM: OMAP: PM: remove the latency related functions from the API
Quoted 8 lines · jean.pihet at newoldbits.com
From: Jean Pihet <[email protected]>
Remove the following functions from the OMAP PM API:
omap_pm_set_max_mpu_wakeup_latomap_pm_set_max_dev_wakeup_latomap_pm_set_max_sdma_lat
and updated the kernel Documentation accordingly.
Quoted 5 lines
The generic per-device PM QoS functions shall be used instead of the OMAP PM API, cf.
include/linux/pm_qos.handDocumentation/power/pm_qos_interface.txt.Signed-off-by Jean Pihet <[email protected]>