From patchwork Wed Mar 23 18:49:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: omar ramirez X-Patchwork-Id: 656731 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2NJ1MgL014737 for ; Wed, 23 Mar 2011 19:01:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932698Ab1CWTBV (ORCPT ); Wed, 23 Mar 2011 15:01:21 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:44791 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932659Ab1CWTBR (ORCPT ); Wed, 23 Mar 2011 15:01:17 -0400 Received: from dlep33.itg.ti.com ([157.170.170.112]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id p2NJ1F5l017643 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 23 Mar 2011 14:01:15 -0500 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id p2NJ1F06028859; Wed, 23 Mar 2011 14:01:15 -0500 (CDT) Received: from localhost (bacab.am.dhcp.ti.com [128.247.77.143]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id p2NJ1Ff09273; Wed, 23 Mar 2011 14:01:15 -0500 (CDT) From: Omar Ramirez Luna To: l-o Cc: Omar Ramirez Luna , Fernando Guzman Lugo , Armando Uribe , Felipe Contreras Subject: [PATCH 8/8] staging: tidspbridge: protect critical sections on PM routines Date: Wed, 23 Mar 2011 12:49:53 -0600 Message-Id: <1300906193-1732-9-git-send-email-omar.ramirez@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1300906193-1732-1-git-send-email-omar.ramirez@ti.com> References: <1300906193-1732-1-git-send-email-omar.ramirez@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 (demeter1.kernel.org [140.211.167.41]); Wed, 23 Mar 2011 19:01:23 +0000 (UTC) diff --git a/drivers/staging/tidspbridge/core/tiomap3430_pwr.c b/drivers/staging/tidspbridge/core/tiomap3430_pwr.c index 95089ef..fdbf4eb 100644 --- a/drivers/staging/tidspbridge/core/tiomap3430_pwr.c +++ b/drivers/staging/tidspbridge/core/tiomap3430_pwr.c @@ -49,6 +49,8 @@ #define PWRSTST_TIMEOUT 200 +DEFINE_SPINLOCK(pwr_lock); + /* * ======== handle_constraints_set ======== * Sets new DSP constraint @@ -91,6 +93,8 @@ int handle_hibernation_from_dsp(struct bridge_dev_context *dev_context) struct omap_dsp_platform_data *pdata = omap_dspbridge_dev->dev.platform_data; + spin_lock_bh(&pwr_lock); + /* Wait for DSP to move into OFF state */ v = msecs_to_jiffies(PWRSTST_TIMEOUT) + jiffies; do { @@ -103,6 +107,7 @@ int handle_hibernation_from_dsp(struct bridge_dev_context *dev_context) if (!t) { pr_err("%s: Timed out waiting for DSP off mode\n", __func__); + spin_unlock_bh(&pwr_lock); return -ETIMEDOUT; } @@ -111,14 +116,19 @@ int handle_hibernation_from_dsp(struct bridge_dev_context *dev_context) /* Turn off DSP Peripheral clocks and DSP Load monitor timer */ status = dsp_clock_disable_all(dev_context->dsp_per_clks); - if (status) + if (status) { + spin_unlock_bh(&pwr_lock); return status; + } /* Disable wdt on hibernation. */ dsp_wdt_enable(false); /* Update the Bridger Driver state */ dev_context->brd_state = BRD_DSP_HIBERNATION; + + spin_unlock_bh(&pwr_lock); + #ifdef CONFIG_TIDSPBRIDGE_DVFS status = dev_get_io_mgr(dev_context->dev_obj, &hio_mgr); if (!hio_mgr) @@ -189,11 +199,15 @@ int sleep_dsp(struct bridge_dev_context *dev_context, u32 dw_cmd, return -EPERM; } + spin_lock_bh(&pwr_lock); + omap_mbox_save_ctx(dev_context->mbox); status = omap_mbox_msg_send(dev_context->mbox, mbx_msg); - if (status) + if (status) { + spin_unlock_bh(&pwr_lock); return status; + } /* Wait for DSP to move into target power state */ v = msecs_to_jiffies(PWRSTST_TIMEOUT) + jiffies; @@ -212,6 +226,7 @@ int sleep_dsp(struct bridge_dev_context *dev_context, u32 dw_cmd, dev_get_deh_mgr(dev_context->dev_obj, &hdeh_mgr); bridge_deh_notify(hdeh_mgr, DSP_PWRERROR, 0); #endif /* CONFIG_TIDSPBRIDGE_NTFY_PWRERR */ + spin_unlock_bh(&pwr_lock); return -ETIMEDOUT; } @@ -226,8 +241,13 @@ int sleep_dsp(struct bridge_dev_context *dev_context, u32 dw_cmd, /* Turn off DSP Peripheral clocks */ status = dsp_clock_disable_all(dev_context->dsp_per_clks); - if (status) + if (status) { + spin_unlock_bh(&pwr_lock); return status; + } + + spin_unlock_bh(&pwr_lock); + #ifdef CONFIG_TIDSPBRIDGE_DVFS if (target_pwr_state == PWRDM_POWER_OFF) { /* @@ -259,8 +279,11 @@ int wake_dsp(struct bridge_dev_context *dev_context, void *pargs) if (!dev_context->mbox || !resources) return -EPERM; + spin_lock_bh(&pwr_lock); + switch (dev_context->brd_state) { case BRD_STOPPED: + spin_unlock_bh(&pwr_lock); return 0; case BRD_RUNNING: break; @@ -318,12 +341,15 @@ int wake_dsp(struct bridge_dev_context *dev_context, void *pargs) default: pr_err("%s: unexpected state %x\n", __func__, dev_context->brd_state); + spin_unlock_bh(&pwr_lock); return -EINVAL; } /* Send a wakeup message to DSP */ status = omap_mbox_msg_send(dev_context->mbox, MBX_PM_DSPWAKEUP); + spin_unlock_bh(&pwr_lock); + #endif /* CONFIG_PM */ return status; }