Skip to contentSkip to conversation

PM / shmobile: Specify PM domain and device latency information directly

RFC PATCH New Rafael J. Wysocki 1 participant 11 messages Jul 21, 2012 – Aug 7, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover PM / shmobile: Specify PM domain and device latency information directly

Hi all,

The following patchset is on top of the previous one at:

https://lkml.org/lkml/2012/7/16/399

Generally speaking, it adds code for the direct specification of various PM domain and device latencies used by PM QoS to the SH7372 SoC and Mackerel board and suggests a mechanism for reading that information from device trees.

Thanks,
Rafael

#2 lore raw

RFC PATCH 2/5 PM / shmobile: Allow device latencies to be specified directly

Make it possible to specify device start/stop and save/restore state latencies directy when adding devices to PM domains. For this purpose, introduce rmobile_add_device_to_domain_td() whose third argument is a pointer to a struct gpd_timing_data object containing device latency data.

---
 arch/arm/mach-shmobile/include/mach/pm-rmobile.h |   14 ++++++++++++--
 arch/arm/mach-shmobile/pm-rmobile.c              |    7 ++++---
 2 files changed, 16 insertions(+), 5 deletions(-)
arch/arm/mach-shmobile/pm-rmobile.c +4 -3
Index: linux/arch/arm/mach-shmobile/pm-rmobile.c
===================================================================
@@ -152,14 +152,15 @@ static void rmobile_init_pm_domain(struc
 	__rmobile_pd_power_up(rmobile_pd, false);
 }
 
-void rmobile_add_device_to_domain(const char *domain_name,
-				 struct platform_device *pdev)
+void rmobile_add_device_to_domain_td(const char *domain_name,
+				     struct platform_device *pdev,
+				     struct gpd_timing_data *td)
 {
 	struct device *dev = &pdev->dev;
 	int ret;
 
 	do
-		ret = pm_genpd_name_add_device(domain_name, dev);
+		ret = __pm_genpd_name_add_device(domain_name, dev, td);
 	while (ret == -EAGAIN);
 	if (pm_clk_no_clocks(dev))
 		pm_clk_add(dev, NULL);
arch/arm/mach-shmobile/include/mach/pm-rmobile.h +12 -2
Index: linux/arch/arm/mach-shmobile/include/mach/pm-rmobile.h
===================================================================
@@ -31,10 +31,20 @@ struct rmobile_pm_domain *to_rmobile_pd(
 
 #ifdef CONFIG_PM
 extern void rmobile_init_domains(struct rmobile_pm_domain domains[], int num);
-extern void rmobile_add_device_to_domain(const char *domain_name,
-					struct platform_device *pdev);
+extern void rmobile_add_device_to_domain_td(const char *domain_name,
+					    struct platform_device *pdev,
+					    struct gpd_timing_data *td);
+
+static inline void rmobile_add_device_to_domain(const char *domain_name,
+						struct platform_device *pdev)
+{
+	rmobile_add_device_to_domain_td(domain_name, pdev, NULL);
+}
+
 #else
+
 #define rmobile_init_domains(domains, num) do { } while (0)
+#define rmobile_add_device_to_domain_td(name, pdev, td) do { } while (0)
 #define rmobile_add_device_to_domain(name, pdev) do { } while (0)
 #endif /* CONFIG_PM */
 
#5 lore raw

RFC PATCH 5/5 PM / shmobile: Allow device latencies to be read from a DT

In reply to Rafael J. Wysocki

Modify rmobile_read_domain_from_dt() so that it can read device latency information from the device tree along with the PM domain name and make it use rmobile_add_device_to_domain_td() for adding the device to the PM domain along with the device latency data.

---
 arch/arm/mach-shmobile/pm-rmobile.c |   24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
arch/arm/mach-shmobile/pm-rmobile.c +22 -2
Index: linux/arch/arm/mach-shmobile/pm-rmobile.c
===================================================================
@@ -170,14 +170,34 @@ void rmobile_add_device_to_domain_td(con
 
 static void rmobile_read_domain_from_dt(struct device *dev)
 {
+	struct gpd_timing_data latencies = { 0 };
 	const char *domain_name;
+	u64 val;
 	int ret;
 
 	ret = of_property_read_string(dev->of_node, "renesas,pmdomain",
 				      &domain_name);
+	if (ret)
+		return;
+
+	ret = of_property_read_u64(dev->of_node, "pm-stop-latency", &val);
+	if (!ret)
+		latencies.stop_latency_ns = val;
+
+	ret = of_property_read_u64(dev->of_node, "pm-start-latency", &val);
+	if (!ret)
+		latencies.start_latency_ns = val;
+
+	ret = of_property_read_u64(dev->of_node, "pm-save-latency", &val);
+	if (!ret)
+		latencies.save_state_latency_ns = val;
+
+	ret = of_property_read_u64(dev->of_node, "pm-restore-latency", &val);
 	if (!ret)
-		rmobile_add_device_to_domain(domain_name,
-					     to_platform_device(dev));
+		latencies.restore_state_latency_ns = val;
+
+	rmobile_add_device_to_domain_td(domain_name, to_platform_device(dev),
+					&latencies);
 }
 
 static void rmobile_remove_from_domain(struct device *dev)
#3 lore raw

RFC PATCH 3/5 PM / shmobile: Specify device latencies for SH7372 devices directly

In reply to Rafael J. Wysocki

The results of adaptive latency computations in GENPD_DEV_TIMED_CALLBACK() show that the start/stop and save/restore state latencies of all devices on SH7372 I have tried are a little below 250 us. Therefore, if the 250 us is used as the common initial value of the latency fields in struct gpd_timing_data for all devices on SH7372, the latency values will never have to change at run time and there won't be any overhead related to re-computation of the corresponding PM QoS data.

---
 arch/arm/mach-shmobile/setup-sh7372.c |   57 +++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 24 deletions(-)
arch/arm/mach-shmobile/setup-sh7372.c +33 -24
Index: linux/arch/arm/mach-shmobile/setup-sh7372.c
===================================================================
@@ -999,8 +999,17 @@ static struct platform_device *sh7372_la
 	&spu1_device,
 };
 
+#define DEV_LATENCY_NS	250000
+
 void __init sh7372_add_standard_devices(void)
 {
+	struct gpd_timing_data latencies = {
+		.stop_latency_ns = DEV_LATENCY_NS,
+		.start_latency_ns = DEV_LATENCY_NS,
+		.save_state_latency_ns = DEV_LATENCY_NS,
+		.restore_state_latency_ns = DEV_LATENCY_NS,
+	};
+
 	sh7372_init_pm_domains();
 
 	platform_add_devices(sh7372_early_devices,
@@ -1009,30 +1018,30 @@ void __init sh7372_add_standard_devices(
 	platform_add_devices(sh7372_late_devices,
 			    ARRAY_SIZE(sh7372_late_devices));
 
-	rmobile_add_device_to_domain("A3RV", &vpu_device);
-	rmobile_add_device_to_domain("A4MP", &spu0_device);
-	rmobile_add_device_to_domain("A4MP", &spu1_device);
-	rmobile_add_device_to_domain("A3SP", &scif0_device);
-	rmobile_add_device_to_domain("A3SP", &scif1_device);
-	rmobile_add_device_to_domain("A3SP", &scif2_device);
-	rmobile_add_device_to_domain("A3SP", &scif3_device);
-	rmobile_add_device_to_domain("A3SP", &scif4_device);
-	rmobile_add_device_to_domain("A3SP", &scif5_device);
-	rmobile_add_device_to_domain("A3SP", &scif6_device);
-	rmobile_add_device_to_domain("A3SP", &iic1_device);
-	rmobile_add_device_to_domain("A3SP", &dma0_device);
-	rmobile_add_device_to_domain("A3SP", &dma1_device);
-	rmobile_add_device_to_domain("A3SP", &dma2_device);
-	rmobile_add_device_to_domain("A3SP", &usb_dma0_device);
-	rmobile_add_device_to_domain("A3SP", &usb_dma1_device);
-	rmobile_add_device_to_domain("A4R", &iic0_device);
-	rmobile_add_device_to_domain("A4R", &veu0_device);
-	rmobile_add_device_to_domain("A4R", &veu1_device);
-	rmobile_add_device_to_domain("A4R", &veu2_device);
-	rmobile_add_device_to_domain("A4R", &veu3_device);
-	rmobile_add_device_to_domain("A4R", &jpu_device);
-	rmobile_add_device_to_domain("A4R", &tmu00_device);
-	rmobile_add_device_to_domain("A4R", &tmu01_device);
+	rmobile_add_device_to_domain_td("A3RV", &vpu_device, &latencies);
+	rmobile_add_device_to_domain_td("A4MP", &spu0_device, &latencies);
+	rmobile_add_device_to_domain_td("A4MP", &spu1_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &scif0_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &scif1_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &scif2_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &scif3_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &scif4_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &scif5_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &scif6_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &iic1_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &dma0_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &dma1_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &dma2_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &usb_dma0_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &usb_dma1_device, &latencies);
+	rmobile_add_device_to_domain_td("A4R", &iic0_device, &latencies);
+	rmobile_add_device_to_domain_td("A4R", &veu0_device, &latencies);
+	rmobile_add_device_to_domain_td("A4R", &veu1_device, &latencies);
+	rmobile_add_device_to_domain_td("A4R", &veu2_device, &latencies);
+	rmobile_add_device_to_domain_td("A4R", &veu3_device, &latencies);
+	rmobile_add_device_to_domain_td("A4R", &jpu_device, &latencies);
+	rmobile_add_device_to_domain_td("A4R", &tmu00_device, &latencies);
+	rmobile_add_device_to_domain_td("A4R", &tmu01_device, &latencies);
 }
 
 static void __init sh7372_earlytimer_init(void)
#1 lore raw

RFC PATCH 1/5 PM / shmobile: Set SH7372 PM domain on/off latencies directly

In reply to Rafael J. Wysocki

The results of adaptive latency computations in __pm_genpd_poweron() and pm_genpd_poweroff() show that the power on/power off latencies of all power domains in SH7372 are a little below 250 us. Therefore, if 250 us is used as the common initial value of the latency fields in struct generic_pm_domain for all domains, the latency values will never have to change at run time and there won't be any overhead related to re-computation of the corresponding PM QoS data.

---
 arch/arm/mach-shmobile/pm-sh7372.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm/mach-shmobile/pm-sh7372.c +20 -0
Index: linux/arch/arm/mach-shmobile/pm-sh7372.c
===================================================================
@@ -71,6 +71,8 @@
 
 #ifdef CONFIG_PM
 
+#define PM_DOMAIN_ON_OFF_LATENCY_NS	250000
+
 static int sh7372_a4r_pd_suspend(void)
 {
 	sh7372_intcs_suspend();
@@ -99,32 +101,46 @@ static int sh7372_a3sp_pd_suspend(void)
 static struct rmobile_pm_domain sh7372_pm_domains[] = {
 	{
 		.genpd.name = "A4LC",
+		.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+		.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
 		.bit_shift = 1,
 	},
 	{
 		.genpd.name = "A4MP",
+		.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+		.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
 		.bit_shift = 2,
 	},
 	{
 		.genpd.name = "D4",
+		.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+		.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
 		.bit_shift = 3,
 	},
 	{
 		.genpd.name = "A4R",
+		.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+		.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
 		.bit_shift = 5,
 		.suspend = sh7372_a4r_pd_suspend,
 		.resume = sh7372_intcs_resume,
 	},
 	{
 		.genpd.name = "A3RV",
+		.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+		.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
 		.bit_shift = 6,
 	},
 	{
 		.genpd.name = "A3RI",
+		.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+		.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
 		.bit_shift = 8,
 	},
 	{
 		.genpd.name = "A4S",
+		.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+		.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
 		.bit_shift = 10,
 		.gov = &pm_domain_always_on_gov,
 		.no_debug = true,
@@ -132,6 +148,8 @@ static struct rmobile_pm_domain sh7372_p
 	},
 	{
 		.genpd.name = "A3SP",
+		.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+		.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
 		.bit_shift = 11,
 		.gov = &pm_domain_always_on_gov,
 		.no_debug = true,
@@ -139,6 +157,8 @@ static struct rmobile_pm_domain sh7372_p
 	},
 	{
 		.genpd.name = "A3SG",
+		.genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+		.genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
 		.bit_shift = 13,
 	},
 };
#4 lore raw

RFC PATCH 4/5 PM / shmobile: Specify device latencies for Mackerel devices directly

In reply to Rafael J. Wysocki

The results of adaptive latency computations in GENPD_DEV_TIMED_CALLBACK() show that the start/stop and save/restore state latencies of all devices on the Mackerel board I have tried are a little below 250 us. Therefore, if the 250 us is used as the common initial value of the latency fields in struct gpd_timing_data for all devices on Mackerel, the latency values will never have to change at run time and there won't be any overhead related to re-computation of the corresponding PM QoS data.

---
 arch/arm/mach-shmobile/board-mackerel.c |   31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)
arch/arm/mach-shmobile/board-mackerel.c +19 -12
Index: linux/arch/arm/mach-shmobile/board-mackerel.c
===================================================================
@@ -1407,8 +1407,15 @@ static struct i2c_board_info i2c1_device
 #define GPIO_PORT168CR	0xE60520A8
 #define SRCR4		0xe61580bc
 #define USCCR1		0xE6058144
+#define DEV_LATENCY_NS	250000
 static void __init mackerel_init(void)
 {
+	struct gpd_timing_data latencies = {
+		.stop_latency_ns = DEV_LATENCY_NS,
+		.start_latency_ns = DEV_LATENCY_NS,
+		.save_state_latency_ns = DEV_LATENCY_NS,
+		.restore_state_latency_ns = DEV_LATENCY_NS,
+	};
 	u32 srcr4;
 	struct clk *clk;
 
@@ -1623,20 +1630,20 @@ static void __init mackerel_init(void)
 
 	platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
 
-	rmobile_add_device_to_domain("A4LC", &lcdc_device);
-	rmobile_add_device_to_domain("A4LC", &hdmi_lcdc_device);
-	rmobile_add_device_to_domain("A4LC", &meram_device);
-	rmobile_add_device_to_domain("A4MP", &fsi_device);
-	rmobile_add_device_to_domain("A3SP", &usbhs0_device);
-	rmobile_add_device_to_domain("A3SP", &usbhs1_device);
-	rmobile_add_device_to_domain("A3SP", &nand_flash_device);
-	rmobile_add_device_to_domain("A3SP", &sh_mmcif_device);
-	rmobile_add_device_to_domain("A3SP", &sdhi0_device);
+	rmobile_add_device_to_domain_td("A4LC", &lcdc_device, &latencies);
+	rmobile_add_device_to_domain_td("A4LC", &hdmi_lcdc_device, &latencies);
+	rmobile_add_device_to_domain_td("A4LC", &meram_device, &latencies);
+	rmobile_add_device_to_domain_td("A4MP", &fsi_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &usbhs0_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &usbhs1_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &nand_flash_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &sh_mmcif_device, &latencies);
+	rmobile_add_device_to_domain_td("A3SP", &sdhi0_device, &latencies);
 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
-	rmobile_add_device_to_domain("A3SP", &sdhi1_device);
+	rmobile_add_device_to_domain_td("A3SP", &sdhi1_device, &latencies);
 #endif
-	rmobile_add_device_to_domain("A3SP", &sdhi2_device);
-	rmobile_add_device_to_domain("A4R", &ceu_device);
+	rmobile_add_device_to_domain_td("A3SP", &sdhi2_device, &latencies);
+	rmobile_add_device_to_domain_td("A4R", &ceu_device, &latencies);
 
 	hdmi_init_pm_clock();
 	sh7372_pm_init();
#6 lore raw

cover PM / shmobile: Specify PM domain and device latency information directly

In reply to Rafael J. Wysocki

Hi all,

Quoted 10 lines · Rafael J. Wysocki

Hi all,

The following patchset is on top of the previous one at:

https://lkml.org/lkml/2012/7/16/399

Generally speaking, it adds code for the direct specification of various PM domain and device latencies used by PM QoS to the SH7372 SoC and Mackerel board and suggests a mechanism for reading that information from device trees.

Since I haven't received any comments, I suppose everyone is OK with these patches, except for the DT one that depended on another DT patch that was rejected. Thus, a regular (non-RFC) submission follows.

The patches are on top of this patch series posted yesterday:

http://marc.info/?l=linux-pm&m4429494917435&w=4

Thanks,
Rafael

#7 lore raw

PATCH 1/4 PM / shmobile: Set PM domain on/off latencies directly

The results of adaptive latency computations in __pm_genpd_poweron() and pm_genpd_poweroff() show that the power on/power off latencies of all power domains in SH7372 are a little below 250 us. Therefore, if 250 us is used as the common initial value of the latency fields in struct generic_pm_domain for all domains, the latency values will never have to change at run time and there won't be any overhead related to re-computation of the corresponding PM QoS data.

---
 arch/arm/mach-shmobile/pm-sh7372.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Index: linux/arch/arm/mach-shmobile/pm-sh7372.c =================================--- linux.orig/arch/arm/mach-shmobile/pm-sh7372.c +++ linux/arch/arm/mach-shmobile/pm-sh7372.c
@@ -71,6 +71,8 @@

#ifdef CONFIG_PM

+#define PM_DOMAIN_ON_OFF_LATENCY_NS 250000
+
static int sh7372_a4r_pd_suspend(void)
{
sh7372_intcs_suspend();
@@ -110,32 +112,46 @@ static int sh7372_a3sp_pd_suspend(void)
static struct rmobile_pm_domain sh7372_pm_domains[] = {
{
.genpd.name = "A4LC",
+ .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+ .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.bit_shift = 1,
},
{
.genpd.name = "A4MP",
+ .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+ .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.bit_shift = 2,
},
{
.genpd.name = "D4",
+ .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+ .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.bit_shift = 3,
},
{
.genpd.name = "A4R",
+ .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+ .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.bit_shift = 5,
.suspend = sh7372_a4r_pd_suspend, .resume = sh7372_intcs_resume,
},
{
.genpd.name = "A3RV",
+ .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+ .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.bit_shift = 6,
},
{
.genpd.name = "A3RI",
+ .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+ .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.bit_shift = 8,
},
{
.genpd.name = "A4S",
+ .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+ .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.bit_shift = 10,
.gov = &pm_domain_always_on_gov, .no_debug = true,
@@ -144,6 +160,8 @@ static struct rmobile_pm_domain sh7372_p
},
{
.genpd.name = "A3SP",
+ .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+ .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.bit_shift = 11,
.gov = &pm_domain_always_on_gov, .no_debug = true,
@@ -151,6 +169,8 @@ static struct rmobile_pm_domain sh7372_p
},
{
.genpd.name = "A3SG",
+ .genpd.power_on_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
+ .genpd.power_off_latency_ns = PM_DOMAIN_ON_OFF_LATENCY_NS,
.bit_shift = 13,
},
};

#8 lore raw

PATCH 2/4 PM / shmobile: Allow device latencies to be specified directly

In reply to Rafael J. Wysocki

Make it possible to specify device start/stop and save/restore state latencies directy when adding devices to PM domains. For this purpose, introduce rmobile_add_device_to_domain_td() whose third argument is a pointer to a struct gpd_timing_data object containing device latency data.

---
 arch/arm/mach-shmobile/include/mach/pm-rmobile.h |   14 ++++++++++++--
 arch/arm/mach-shmobile/pm-rmobile.c              |    7 ++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

Index: linux/arch/arm/mach-shmobile/pm-rmobile.c =================================--- linux.orig/arch/arm/mach-shmobile/pm-rmobile.c +++ linux/arch/arm/mach-shmobile/pm-rmobile.c
@@ -157,12 +157,13 @@ void rmobile_init_domains(struct rmobile
rmobile_init_pm_domain(&domains[j]);
}

-void rmobile_add_device_to_domain(const char *domain_name,
- struct platform_device *pdev)
+void rmobile_add_device_to_domain_td(const char *domain_name,
+ struct platform_device *pdev,
+ struct gpd_timing_data *td)
{
struct device *dev = &pdev->dev;

- pm_genpd_name_add_device(domain_name, dev);
+ __pm_genpd_name_add_device(domain_name, dev, td);
if (pm_clk_no_clocks(dev))
pm_clk_add(dev, NULL);
}
Index: linux/arch/arm/mach-shmobile/include/mach/pm-rmobile.h =================================--- linux.orig/arch/arm/mach-shmobile/include/mach/pm-rmobile.h +++ linux/arch/arm/mach-shmobile/include/mach/pm-rmobile.h
@@ -31,10 +31,20 @@ struct rmobile_pm_domain *to_rmobile_pd(

#ifdef CONFIG_PM
extern void rmobile_init_domains(struct rmobile_pm_domain domains[], int num);
-extern void rmobile_add_device_to_domain(const char *domain_name,
- struct platform_device *pdev);
+extern void rmobile_add_device_to_domain_td(const char *domain_name,
+ struct platform_device *pdev,
+ struct gpd_timing_data *td);
+
+static inline void rmobile_add_device_to_domain(const char *domain_name,
+ struct platform_device *pdev)
+{
+ rmobile_add_device_to_domain_td(domain_name, pdev, NULL);
+}
+
#else
+
#define rmobile_init_domains(domains, num) do { } while (0)
+#define rmobile_add_device_to_domain_td(name, pdev, td) do { } while (0)
#define rmobile_add_device_to_domain(name, pdev) do { } while (0) #endif /* CONFIG_PM */

#9 lore raw

PATCH 3/4 PM / shmobile: Specify device latencies for SH7372 devices directly

In reply to Rafael J. Wysocki

The results of adaptive latency computations in GENPD_DEV_TIMED_CALLBACK() show that the start/stop and save/restore state latencies of all devices on SH7372 I have tried are a little below 250 us. Therefore, if the 250 us is used as the common initial value of the latency fields in struct gpd_timing_data for all devices on SH7372, the latency values will never have to change at run time and there won't be any overhead related to re-computation of the corresponding PM QoS data.

---
 arch/arm/mach-shmobile/setup-sh7372.c |   57 +++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 24 deletions(-)

Index: linux/arch/arm/mach-shmobile/setup-sh7372.c =================================--- linux.orig/arch/arm/mach-shmobile/setup-sh7372.c +++ linux/arch/arm/mach-shmobile/setup-sh7372.c
@@ -999,8 +999,17 @@ static struct platform_device *sh7372_la
&spu1_device,
};

+#define DEV_LATENCY_NS 250000
+
void __init sh7372_add_standard_devices(void)
{
+ struct gpd_timing_data latencies = {
+ .stop_latency_ns = DEV_LATENCY_NS,
+ .start_latency_ns = DEV_LATENCY_NS,
+ .save_state_latency_ns = DEV_LATENCY_NS,
+ .restore_state_latency_ns = DEV_LATENCY_NS,
+ };
+
sh7372_init_pm_domains();

platform_add_devices(sh7372_early_devices,
@@ -1009,30 +1018,30 @@ void __init sh7372_add_standard_devices(
platform_add_devices(sh7372_late_devices,
ARRAY_SIZE(sh7372_late_devices));

- rmobile_add_device_to_domain("A3RV", &vpu_device);
- rmobile_add_device_to_domain("A4MP", &spu0_device);
- rmobile_add_device_to_domain("A4MP", &spu1_device);
- rmobile_add_device_to_domain("A3SP", &scif0_device);
- rmobile_add_device_to_domain("A3SP", &scif1_device);
- rmobile_add_device_to_domain("A3SP", &scif2_device);
- rmobile_add_device_to_domain("A3SP", &scif3_device);
- rmobile_add_device_to_domain("A3SP", &scif4_device);
- rmobile_add_device_to_domain("A3SP", &scif5_device);
- rmobile_add_device_to_domain("A3SP", &scif6_device);
- rmobile_add_device_to_domain("A3SP", &iic1_device);
- rmobile_add_device_to_domain("A3SP", &dma0_device);
- rmobile_add_device_to_domain("A3SP", &dma1_device);
- rmobile_add_device_to_domain("A3SP", &dma2_device);
- rmobile_add_device_to_domain("A3SP", &usb_dma0_device);
- rmobile_add_device_to_domain("A3SP", &usb_dma1_device);
- rmobile_add_device_to_domain("A4R", &iic0_device);
- rmobile_add_device_to_domain("A4R", &veu0_device);
- rmobile_add_device_to_domain("A4R", &veu1_device);
- rmobile_add_device_to_domain("A4R", &veu2_device);
- rmobile_add_device_to_domain("A4R", &veu3_device);
- rmobile_add_device_to_domain("A4R", &jpu_device);
- rmobile_add_device_to_domain("A4R", &tmu00_device);
- rmobile_add_device_to_domain("A4R", &tmu01_device);
+ rmobile_add_device_to_domain_td("A3RV", &vpu_device, &latencies);
+ rmobile_add_device_to_domain_td("A4MP", &spu0_device, &latencies);
+ rmobile_add_device_to_domain_td("A4MP", &spu1_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &scif0_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &scif1_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &scif2_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &scif3_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &scif4_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &scif5_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &scif6_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &iic1_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &dma0_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &dma1_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &dma2_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &usb_dma0_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &usb_dma1_device, &latencies);
+ rmobile_add_device_to_domain_td("A4R", &iic0_device, &latencies);
+ rmobile_add_device_to_domain_td("A4R", &veu0_device, &latencies);
+ rmobile_add_device_to_domain_td("A4R", &veu1_device, &latencies);
+ rmobile_add_device_to_domain_td("A4R", &veu2_device, &latencies);
+ rmobile_add_device_to_domain_td("A4R", &veu3_device, &latencies);
+ rmobile_add_device_to_domain_td("A4R", &jpu_device, &latencies);
+ rmobile_add_device_to_domain_td("A4R", &tmu00_device, &latencies);
+ rmobile_add_device_to_domain_td("A4R", &tmu01_device, &latencies);
}

static void __init sh7372_earlytimer_init(void)

#10 lore raw

PATCH 4/4 PM / shmobile: Specify device latencies for Mackerel devices directly

In reply to Rafael J. Wysocki

The results of adaptive latency computations in GENPD_DEV_TIMED_CALLBACK() show that the start/stop and save/restore state latencies of all devices on the Mackerel board I have tried are a little below 250 us. Therefore, if the 250 us is used as the common initial value of the latency fields in struct gpd_timing_data for all devices on Mackerel, the latency values will never have to change at run time and there won't be any overhead related to re-computation of the corresponding PM QoS data.

---
 arch/arm/mach-shmobile/board-mackerel.c |   31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

Index: linux/arch/arm/mach-shmobile/board-mackerel.c =================================--- linux.orig/arch/arm/mach-shmobile/board-mackerel.c +++ linux/arch/arm/mach-shmobile/board-mackerel.c
@@ -1407,8 +1407,15 @@ static struct i2c_board_info i2c1_device
#define GPIO_PORT168CR 0xE60520A8
#define SRCR4 0xe61580bc
#define USCCR1 0xE6058144
+#define DEV_LATENCY_NS 250000
static void __init mackerel_init(void)
{
+ struct gpd_timing_data latencies = {
+ .stop_latency_ns = DEV_LATENCY_NS,
+ .start_latency_ns = DEV_LATENCY_NS,
+ .save_state_latency_ns = DEV_LATENCY_NS,
+ .restore_state_latency_ns = DEV_LATENCY_NS,
+ };
u32 srcr4;
struct clk *clk;

@@ -1623,20 +1630,20 @@ static void __init mackerel_init(void)

platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));

- rmobile_add_device_to_domain("A4LC", &lcdc_device);
- rmobile_add_device_to_domain("A4LC", &hdmi_lcdc_device);
- rmobile_add_device_to_domain("A4LC", &meram_device);
- rmobile_add_device_to_domain("A4MP", &fsi_device);
- rmobile_add_device_to_domain("A3SP", &usbhs0_device);
- rmobile_add_device_to_domain("A3SP", &usbhs1_device);
- rmobile_add_device_to_domain("A3SP", &nand_flash_device);
- rmobile_add_device_to_domain("A3SP", &sh_mmcif_device);
- rmobile_add_device_to_domain("A3SP", &sdhi0_device);
+ rmobile_add_device_to_domain_td("A4LC", &lcdc_device, &latencies);
+ rmobile_add_device_to_domain_td("A4LC", &hdmi_lcdc_device, &latencies);
+ rmobile_add_device_to_domain_td("A4LC", &meram_device, &latencies);
+ rmobile_add_device_to_domain_td("A4MP", &fsi_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &usbhs0_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &usbhs1_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &nand_flash_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &sh_mmcif_device, &latencies);
+ rmobile_add_device_to_domain_td("A3SP", &sdhi0_device, &latencies);
#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
- rmobile_add_device_to_domain("A3SP", &sdhi1_device);
+ rmobile_add_device_to_domain_td("A3SP", &sdhi1_device, &latencies);
#endif
- rmobile_add_device_to_domain("A3SP", &sdhi2_device);
- rmobile_add_device_to_domain("A4R", &ceu_device);
+ rmobile_add_device_to_domain_td("A3SP", &sdhi2_device, &latencies);
+ rmobile_add_device_to_domain_td("A4R", &ceu_device, &latencies);

hdmi_init_pm_clock();
sh7372_pm_init();