From patchwork Fri Jun 3 10:00:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 846002 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p53An0ia017589 for ; Fri, 3 Jun 2011 10:49:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753815Ab1FCKBT (ORCPT ); Fri, 3 Jun 2011 06:01:19 -0400 Received: from na3sys009aog115.obsmtp.com ([74.125.149.238]:44316 "EHLO na3sys009aog115.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753744Ab1FCKBR (ORCPT ); Fri, 3 Jun 2011 06:01:17 -0400 Received: from mail-fx0-f44.google.com ([209.85.161.44]) (using TLSv1) by na3sys009aob115.postini.com ([74.125.148.12]) with SMTP ID DSNKTeiw7PdpltkWHIWq0JtVIMXs+/AP7Bhx@postini.com; Fri, 03 Jun 2011 03:01:16 PDT Received: by mail-fx0-f44.google.com with SMTP id 15so1197989fxm.3 for ; Fri, 03 Jun 2011 03:01:16 -0700 (PDT) Received: by 10.223.1.209 with SMTP id 17mr1886766fag.89.1307095275987; Fri, 03 Jun 2011 03:01:15 -0700 (PDT) Received: from localhost.localdomain (a62-248-131-233.elisa-laajakaista.fi [62.248.131.233]) by mx.google.com with ESMTPS id b22sm445843fak.1.2011.06.03.03.01.13 (version=SSLv3 cipher=OTHER); Fri, 03 Jun 2011 03:01:15 -0700 (PDT) From: Tomi Valkeinen To: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org Cc: b-cousson@ti.com, paul@pwsan.com, khilman@ti.com, Tomi Valkeinen Subject: [PATCH 08/27] OMAP: DSS2: rewrite use of context_loss_count Date: Fri, 3 Jun 2011 13:00:18 +0300 Message-Id: <1307095237-14805-9-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1307095237-14805-1-git-send-email-tomi.valkeinen@ti.com> References: <1307095237-14805-1-git-send-email-tomi.valkeinen@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 03 Jun 2011 10:49:02 +0000 (UTC) The function to get device's context loss count has changed from omap_pm_get_last_off_on_transaction_id() to omap_pm_get_dev_context_loss_count() Change name of the function pointer in omapdss.h accordingly, and use the term "context loss count" instead of "context id" in the code. Restructure the context loss count functions to handle errors properly, and ensure that context is always considered lost if an error happens. Signed-off-by: Tomi Valkeinen --- arch/arm/mach-omap2/display.c | 2 +- drivers/video/omap2/dss/dss.c | 71 +++++++++++++++++++++++++++-------------- drivers/video/omap2/dss/dss.h | 1 - include/video/omapdss.h | 2 +- 4 files changed, 49 insertions(+), 27 deletions(-) diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c index 543fcb8..084a51b 100644 --- a/arch/arm/mach-omap2/display.c +++ b/arch/arm/mach-omap2/display.c @@ -117,7 +117,7 @@ int __init omap_display_init(struct omap_dss_board_info *board_data) } pdata.board_data = board_data; - pdata.board_data->get_last_off_on_transaction_id = NULL; + pdata.board_data->get_context_loss_count = NULL; pdata.opt_clock_available = opt_clock_available; for (i = 0; i < oh_count; i++) { diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c index f5f9fcb..b63e290 100644 --- a/drivers/video/omap2/dss/dss.c +++ b/drivers/video/omap2/dss/dss.c @@ -60,7 +60,7 @@ struct dss_reg { static struct { struct platform_device *pdev; void __iomem *base; - int ctx_id; + int ctx_loss_cnt; struct clk *dpll4_m4_ck; struct clk *dss_ick; @@ -665,34 +665,58 @@ void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select hdmi) } /* CONTEXT */ -static int dss_get_ctx_id(void) +static void dss_init_ctx_loss_count(void) { - struct omap_display_platform_data *pdata = dss.pdev->dev.platform_data; - int r; + struct device *dev = &dss.pdev->dev; + struct omap_display_platform_data *pdata = dev->platform_data; + struct omap_dss_board_info *board_data = pdata->board_data; + int cnt = 0; - if (!pdata->board_data->get_last_off_on_transaction_id) - return 0; - r = pdata->board_data->get_last_off_on_transaction_id(&dss.pdev->dev); - if (r < 0) { - dev_err(&dss.pdev->dev, "getting transaction ID failed, " - "will force context restore\n"); - r = -1; - } - return r; + /* + * get_context_loss_count returns negative on error. We'll ignore the + * error and store the error to ctx_loss_cnt, which will cause + * dss_need_ctx_restore() call to return true. + */ + + if (board_data->get_context_loss_count) + cnt = board_data->get_context_loss_count(dev); + + WARN_ON(cnt < 0); + + dss.ctx_loss_cnt = cnt; + + DSSDBG("initial ctx_loss_cnt %u\n", cnt); } -int dss_need_ctx_restore(void) +static bool dss_need_ctx_restore(void) { - int id = dss_get_ctx_id(); + struct device *dev = &dss.pdev->dev; + struct omap_display_platform_data *pdata = dev->platform_data; + struct omap_dss_board_info *board_data = pdata->board_data; + int cnt; - if (id < 0 || id != dss.ctx_id) { - DSSDBG("ctx id %d -> id %d\n", - dss.ctx_id, id); - dss.ctx_id = id; - return 1; - } else { - return 0; + /* + * If get_context_loss_count is not available, assume that we need + * context restore always. + */ + if (!board_data->get_context_loss_count) + return true; + + cnt = board_data->get_context_loss_count(dev); + if (cnt < 0) { + dev_err(dev, "getting context loss count failed, will force " + "context restore\n"); + dss.ctx_loss_cnt = cnt; + return true; } + + if (cnt == dss.ctx_loss_cnt) + return false; + + DSSDBG("ctx_loss_cnt %d -> %d\n", dss.ctx_loss_cnt, cnt); + dss.ctx_loss_cnt = cnt; + + return true; } static void save_all_ctx(void) @@ -1046,8 +1070,7 @@ static int omap_dsshw_probe(struct platform_device *pdev) dss_clk_enable_all_no_ctx(); - dss.ctx_id = dss_get_ctx_id(); - DSSDBG("initial ctx id %u\n", dss.ctx_id); + dss_init_ctx_loss_count(); /* disable LCD and DIGIT output. This seems to fix the synclost * problem that we get, if the bootloader starts the DSS and diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h index 8ab6d43..aeb611d 100644 --- a/drivers/video/omap2/dss/dss.h +++ b/drivers/video/omap2/dss/dss.h @@ -226,7 +226,6 @@ void dss_restore_context(void); void dss_clk_enable(enum dss_clock clks); void dss_clk_disable(enum dss_clock clks); unsigned long dss_clk_get_rate(enum dss_clock clk); -int dss_need_ctx_restore(void); const char *dss_get_generic_clk_source_name(enum omap_dss_clk_source clk_src); void dss_dump_clocks(struct seq_file *s); diff --git a/include/video/omapdss.h b/include/video/omapdss.h index bb39738..4f914a5 100644 --- a/include/video/omapdss.h +++ b/include/video/omapdss.h @@ -244,7 +244,7 @@ int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel); /* Board specific data */ struct omap_dss_board_info { - int (*get_last_off_on_transaction_id)(struct device *dev); + int (*get_context_loss_count)(struct device *dev); int num_devices; struct omap_dss_device **devices; struct omap_dss_device *default_device;