From patchwork Thu Jan 31 09:03:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 2071511 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C8FE9DF2E5 for ; Thu, 31 Jan 2013 09:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751248Ab3AaJDZ (ORCPT ); Thu, 31 Jan 2013 04:03:25 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:44567 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753173Ab3AaJDY (ORCPT ); Thu, 31 Jan 2013 04:03:24 -0500 Received: by mail-pa0-f49.google.com with SMTP id bi1so1634774pad.36 for ; Thu, 31 Jan 2013 01:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:sender:message-id:to:cc:in-reply-to:references:from :subject:mime-version:content-type; bh=2xLtM3BIrbpEDxF6EsQdqqvsX8fJcwJCzVhcsjnc97Q=; b=n4+gHj0ElAcXEwwikyaBVbOJUHLrkBLl1UD33U4TIp02KCVuKx2X1HoWey/tRpfGHN AiYbOwcEjhTgDxkPqQAOA/JZqihwITGLdmRSUsY1wWyeQMBTHgXmpv9U77MSf/GilQbp yd0+GM7+PMulyNbUNAToXpgxrgZBqlComnr8pY1flGSftrmT0PPgfdocyz14g/dfMiVa n2Y3LPvNqLWZNR2YB3uzIHITxvhS2Zlw46dOQCKV7WncVxiqza8wPaF6ov2cigfYRc0x 31r8tUq64wflxphIyLOdPf7p5ENLxgoJa8qK3wFB6189ZU/hZyew5h4bmx2PVyKn/N85 NItw== X-Received: by 10.66.73.105 with SMTP id k9mr18768349pav.37.1359623003309; Thu, 31 Jan 2013 01:03:23 -0800 (PST) Received: from morimoto-Dell-XPS420.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPS id gv9sm4428150pbc.21.2013.01.31.01.03.21 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 31 Jan 2013 01:03:22 -0800 (PST) Date: Thu, 31 Jan 2013 01:03:22 -0800 (PST) Message-ID: <87txpxpvvs.wl%kuninori.morimoto.gx@renesas.com> To: Zhang Rui Cc: Simon , Magnus , linux-pm@vger.kernel.org, Kuninori Morimoto In-Reply-To: <87y5f9pvxv.wl%kuninori.morimoto.gx@renesas.com> References: <87y5f9pvxv.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 3/7] thermal: rcar: use mutex lock instead of spin lock MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Current R-Car thermal driver is using spin lock for each registers read/write, but it is pointless lock. This lock is required while reading temperature, but it needs long wait (= 300ms). So, this patch used mutex lock while reading temperature, instead of spin lock for each registers. Signed-off-by: Kuninori Morimoto --- drivers/thermal/rcar_thermal.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 068b2a1..e19b267 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -42,7 +42,7 @@ struct rcar_thermal_priv { void __iomem *base; struct device *dev; - spinlock_t lock; + struct mutex lock; }; #define MCELSIUS(temp) ((temp) * 1000) @@ -54,46 +54,26 @@ struct rcar_thermal_priv { */ static u32 rcar_thermal_read(struct rcar_thermal_priv *priv, u32 reg) { - unsigned long flags; - u32 ret; - - spin_lock_irqsave(&priv->lock, flags); - - ret = ioread32(priv->base + reg); - - spin_unlock_irqrestore(&priv->lock, flags); - - return ret; + return ioread32(priv->base + reg); } #if 0 /* no user at this point */ static void rcar_thermal_write(struct rcar_thermal_priv *priv, u32 reg, u32 data) { - unsigned long flags; - - spin_lock_irqsave(&priv->lock, flags); - iowrite32(data, priv->base + reg); - - spin_unlock_irqrestore(&priv->lock, flags); } #endif static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg, u32 mask, u32 data) { - unsigned long flags; u32 val; - spin_lock_irqsave(&priv->lock, flags); - val = ioread32(priv->base + reg); val &= ~mask; val |= (data & mask); iowrite32(val, priv->base + reg); - - spin_unlock_irqrestore(&priv->lock, flags); } /* @@ -107,6 +87,8 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int i; int ctemp, old, new; + mutex_lock(&priv->lock); + /* * TSC decides a value of CPTAP automatically, * and this is the conditions which validate interrupt. @@ -138,6 +120,8 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, *temp = MCELSIUS((ctemp * 5) - 65); + mutex_unlock(&priv->lock); + return 0; } @@ -225,7 +209,7 @@ static int rcar_thermal_probe(struct platform_device *pdev) } priv->dev = &pdev->dev; - spin_lock_init(&priv->lock); + mutex_init(&priv->lock); priv->base = devm_ioremap_nocache(&pdev->dev, res->start, resource_size(res)); if (!priv->base) {