public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 03/04] OMAP3 SRF: omap3 srf driver
@ 2008-10-16 14:12 Rajendra Nayak
  2008-10-17 11:04 ` Dasgupta, Romit
  0 siblings, 1 reply; 3+ messages in thread
From: Rajendra Nayak @ 2008-10-16 14:12 UTC (permalink / raw)
  To: linux-omap

Adds init/change_level/validate_level calls for latency 
resources on OMAP3

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/resource34xx.c |  126 +++++++++++++++++++++++++++++++++++++
 1 files changed, 126 insertions(+)

Index: linux-omap-2.6/arch/arm/mach-omap2/resource34xx.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-omap-2.6/arch/arm/mach-omap2/resource34xx.c	2008-10-16 18:07:14.000000000 +0530
@@ -0,0 +1,126 @@
+/*
+ * linux/arch/arm/mach-omap2/resource34xx.c
+ * OMAP3 resource init/change_level/validate_level functions
+ *
+ * Copyright (C) 2007-2008 Texas Instruments, Inc.
+ * Rajendra Nayak <rnayak@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * History:
+ *
+ */
+
+#include <linux/pm_qos_params.h>
+#include <mach/powerdomain.h>
+#include <mach/clockdomain.h>
+#include "resource34xx.h"
+
+int set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
+
+/**
+ * init_latency - Initializes the mpu/core latency resource.
+ * @resp: Latency resource to be initalized
+ *
+ * No return value.
+ */
+void init_latency(struct shared_resource *resp)
+{
+	resp->no_of_users = 0;
+	resp->curr_level = RES_DEFAULTLEVEL;
+	*((u8 *)resp->resource_data) = 0;
+	return;
+}
+
+/**
+ * set_latency - Adds/Updates and removes the CPU_DMA_LATENCY in *pm_qos_params.
+ * @resp: resource pointer
+ * @latency: target latency to be set
+ *
+ * Returns 0 on success, or error values as returned by
+ * pm_qos_update_requirement/pm_qos_add_requirement.
+ */
+int set_latency(struct shared_resource *resp, u32 latency)
+{
+	u8 *pm_qos_req_added;
+
+	if (resp->curr_level == latency)
+		return 0;
+	else
+		/* Update the resources current level */
+		resp->curr_level = latency;
+
+	pm_qos_req_added = resp->resource_data;
+	if (latency == RES_DEFAULTLEVEL)
+		/* No more users left, remove the pm_qos_req if present */
+		if (*pm_qos_req_added) {
+			pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
+							resp->name);
+			*pm_qos_req_added = 0;
+			return 0;
+		}
+
+	if (*pm_qos_req_added) {
+		return pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY,
+						resp->name, latency);
+	} else {
+		*pm_qos_req_added = 1;
+		return pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY,
+						resp->name, latency);
+	}
+}
+
+/**
+ * init_pd_latency - Initializes the power domain latency resource.
+ * @resp: Power Domain Latency resource to be initialized.
+ *
+ * No return value.
+ */
+void init_pd_latency(struct shared_resource *resp)
+{
+	struct pd_latency_db *pd_lat_db;
+
+	resp->no_of_users = 0;
+	resp->curr_level = PD_LATENCY_OFF;
+	pd_lat_db = resp->resource_data;
+	/* Populate the power domain associated with the latency resource */
+	pd_lat_db->pd = pwrdm_lookup(pd_lat_db->pwrdm_name);
+	return;
+}
+
+/**
+ * set_pd_latency - Updates the curr_level of the power domain resource.
+ * @resp: Power domain latency resource.
+ * @latency: New latency value acceptable.
+ *
+ * This function maps the latency in microsecs to the acceptable
+ * Power domain state using the latency DB.
+ * It then programs the power domain to enter the target state.
+ * Always returns 0.
+ */
+int set_pd_latency(struct shared_resource *resp, u32 latency)
+{
+	u32 pd_lat_level, ind;
+	struct pd_latency_db *pd_lat_db;
+	struct powerdomain *pwrdm;
+
+	pd_lat_db = resp->resource_data;
+	pwrdm = pd_lat_db->pd;
+	pd_lat_level = PD_LATENCY_OFF;
+	/* using the latency db map to the appropriate PD state */
+	for (ind = 0; ind < PD_LATENCY_MAXLEVEL; ind++) {
+		if (pd_lat_db->latency[ind] < latency) {
+			pd_lat_level = ind;
+			break;
+		}
+	}
+
+	resp->curr_level = pd_lat_level;
+	set_pwrdm_state(pwrdm, pd_lat_level);
+	return 0;
+}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH 03/04] OMAP3 SRF: omap3 srf driver
  2008-10-16 14:12 [PATCH 03/04] OMAP3 SRF: omap3 srf driver Rajendra Nayak
@ 2008-10-17 11:04 ` Dasgupta, Romit
  2008-10-17 11:41   ` Dasgupta, Romit
  0 siblings, 1 reply; 3+ messages in thread
From: Dasgupta, Romit @ 2008-10-17 11:04 UTC (permalink / raw)
  To: Nayak, Rajendra, linux-omap@vger.kernel.org

>+ */
>+int set_latency(struct shared_resource *resp, u32 latency)
>+{
>+	u8 *pm_qos_req_added;
>+
>+	if (resp->curr_level == latency)
>+		return 0;
>+	else
>+		/* Update the resources current level */
>+		resp->curr_level = latency;
>+
[Romit] I think this should be done outside this function, in update_resource_level function. 
>+	pm_qos_req_added = resp->resource_data;
>+	if (latency == RES_DEFAULTLEVEL)
>+		/* No more users left, remove the pm_qos_req if present */
>+		if (*pm_qos_req_added) {
>+
>	pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY,
>+							resp->name);
>+			*pm_qos_req_added = 0;
>+			return 0;
>+		}
>+
>+	if (*pm_qos_req_added) {
>+		return
>pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY,
>+						resp->name, latency);
>+	} else {
[Romit] Shouldn't the following line execute only if pm_qos_add_requirement returns successfully?
>+		*pm_qos_req_added = 1;
>+		return pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY,
>+						resp->name, latency);
>+	}
>+}
>+
>+int set_pd_latency(struct shared_resource *resp, u32 latency)
>+{
>+	u32 pd_lat_level, ind;
>+	struct pd_latency_db *pd_lat_db;
>+	struct powerdomain *pwrdm;
>+
>+	pd_lat_db = resp->resource_data;
>+	pwrdm = pd_lat_db->pd;
>+	pd_lat_level = PD_LATENCY_OFF;
>+	/* using the latency db map to the appropriate PD state */
>+	for (ind = 0; ind < PD_LATENCY_MAXLEVEL; ind++) {
>+		if (pd_lat_db->latency[ind] < latency) {
>+			pd_lat_level = ind;
>+			break;
>+		}
>+	}
>+
[Romit] Again is this the right place for this?  It should be done only if set_pwrdm_state returns successfully. So I think that should be checked as well.
>+	resp->curr_level = pd_lat_level;
>+	set_pwrdm_state(pwrdm, pd_lat_level);
>+	return 0;
>+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH 03/04] OMAP3 SRF: omap3 srf driver
  2008-10-17 11:04 ` Dasgupta, Romit
@ 2008-10-17 11:41   ` Dasgupta, Romit
  0 siblings, 0 replies; 3+ messages in thread
From: Dasgupta, Romit @ 2008-10-17 11:41 UTC (permalink / raw)
  To: Dasgupta, Romit, Nayak, Rajendra, linux-omap@vger.kernel.org

One final point
>>+int set_pd_latency(struct shared_resource *resp, u32 latency)
>>+{
>>+	u32 pd_lat_level, ind;
>>+	struct pd_latency_db *pd_lat_db;
>>+	struct powerdomain *pwrdm;
>>+
>>+	pd_lat_db = resp->resource_data;
>>+	pwrdm = pd_lat_db->pd;
>>+	pd_lat_level = PD_LATENCY_OFF;
>>+	/* using the latency db map to the appropriate PD state */
>>+	for (ind = 0; ind < PD_LATENCY_MAXLEVEL; ind++) {
>>+		if (pd_lat_db->latency[ind] < latency) {
>>+			pd_lat_level = ind;
>>+			break;
>>+		}
>>+	}
>>+
>[Romit] Again is this the right place for this?  It should be done only if
>set_pwrdm_state returns successfully. So I think that should be checked as well.
>>+	resp->curr_level = pd_lat_level;
>>+	set_pwrdm_state(pwrdm, pd_lat_level);
>>+	return 0;
>>+}

[Romit]  In retrospect, I think the code is not right. Someone sets a latency for say 30ms and what gets updated is the index in the curr_level. Next [s]he sets a latency value and we will be comparing index with time. Cant we have a function that would convert the latency (in time) to the right index? 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-17 11:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-16 14:12 [PATCH 03/04] OMAP3 SRF: omap3 srf driver Rajendra Nayak
2008-10-17 11:04 ` Dasgupta, Romit
2008-10-17 11:41   ` Dasgupta, Romit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox