From patchwork Thu Oct 19 17:05:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116416 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp721666qgn; Thu, 19 Oct 2017 10:08:41 -0700 (PDT) X-Received: by 10.99.67.71 with SMTP id q68mr1914344pga.163.1508432921632; Thu, 19 Oct 2017 10:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508432921; cv=none; d=google.com; s=arc-20160816; b=LPvI1UkFZzoGNWnGu8DXYIV0WB4vxL5zwEeKNI7/443mRKSorxtxpjc13oFfxx8beF hyD1+F9+ev8SNOFpyokUgr7sUF1PDwJUMI7hkdV4Q9JpCYOKDq7dI9HPC0gr52IOUHkV W4nSNEmsjFQ813FwO6/fCsT+sB1ArHG/48lffIp2rVFXVzYXuabvb0StUXabw+HUVxEW Xy3G/p618nyt/oS/jyFelebxsanqgW7xmH1AIe8WnXISLKYV1PxlHEgboBrq2fPbRQ5i AV0ZX6OIzOjj3iHL8uhln8qqGIAtXHSsbXyNIhRGVBdGlsE3+0njkfhWFsAMK8bPap9h JcHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3+tH7NwZkH40QyBS8/8cN9a6ZBOua5bckmsjgKvaaaY=; b=YBpT7e9UJBkCkrTmi/rEX+fGHFSU34te/Q7rZ0PjKWaue0HcgkX0/HuzgQv7LYtMhK ZlBDon6rrHIT/PBoYcQWVT0JSqNi46BPAJqgflKBECE5Foz7xf0xGkD0zazk/JnyflTz B0K+RWso9tG+2tW24DTFYC8CVzLHzZLFE66CqHZqJl2OBajPhxOkbBU3CPyaipTxvMac Cd3h2Xq34C8WIUfFuDNXc5Vcq4LQjJ0qQTx4XgKKyI6Dqz0C1GTqxqIyXurKiUeAvHjU 0uyltjG/jJCkw8wig0lSkfs17nQcmMVkFWZh0Q9utBAcGAHZ9Z77TMJGuWAIo4JvoTGA EGwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XNynWd5f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a24si8812310pfg.299.2017.10.19.10.08.41; Thu, 19 Oct 2017 10:08:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XNynWd5f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755057AbdJSRIj (ORCPT + 27 others); Thu, 19 Oct 2017 13:08:39 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:54522 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753422AbdJSRIc (ORCPT ); Thu, 19 Oct 2017 13:08:32 -0400 Received: by mail-wm0-f68.google.com with SMTP id i124so17714408wmf.3 for ; Thu, 19 Oct 2017 10:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3+tH7NwZkH40QyBS8/8cN9a6ZBOua5bckmsjgKvaaaY=; b=XNynWd5flG1lW5/Yvjd2Gwv875wI3xLNSjhsQhGzTJB+vFwaSxTj1uhKvgTdwThifq OF5MaXnhTILxDCZoa8H/7MCTxpCpfgFTaY7oVFBPJQzeIf0ZrUZJqkF7K5/XD5dtUENw ziTC7eXach4Rn4qjWL+dqd3mj+XslXUZgVrYA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3+tH7NwZkH40QyBS8/8cN9a6ZBOua5bckmsjgKvaaaY=; b=WQFeZpD5b1ABzRRSwHXRGMzc/+77v2CV4uJfSyTfpTH8tL6VW2tzUHAbpOjM4rWj6m e8nZultjtsbBYntdTG8Dyv5AvoCj0iUhVcvdGx4ObNrTxngQau2DigmERU65ppb0Nk0u whheSs4kUpYLjml15l7WYgy+FTvlMqfeYJPz+Ht5Y8bBXMujyTUSd6TH2x5lYaUF3xa7 b2Vy+RvJlolxWqyZ0EBm+N2HF+n8/2IQ8uJwlkv2DMSR2HWEpxPNaRrFQciNycl6Pg6Q Gmhs+VoN7hONGmeOlu1tWd1kOMeXhEMIuCZOs2sXgtE0hm5WqX0vv1+pDyq2U2jBMlG7 swkw== X-Gm-Message-State: AMCzsaUk4RigPC88O5AJLJ7SomEJrqrQ+n1QPdYYix9AoMiJCYU5tfcd tGKGVjYOL4QszcvCLAG5vsH1LA== X-Google-Smtp-Source: ABhQp+ScwMlU+D+0GugQuPYsWthI8u4lyJU1XOe2Ax38ulwxX/rV/dpZFatu4yijnGUuWohsIKQwqg== X-Received: by 10.28.15.198 with SMTP id 189mr2245415wmp.140.1508432911384; Thu, 19 Oct 2017 10:08:31 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:30 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, "Wangtao (Kevin, Kirin)" Subject: [PATCH 02/18] thermal/drivers/hisi: Remove the multiple sensors support Date: Thu, 19 Oct 2017 19:05:44 +0200 Message-Id: <1508432760-17847-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By essence, the tsensor does not really support multiple sensor at the same time. It allows to set a sensor and use it to get the temperature, another sensor could be switched but with a delay of 3-5ms. It is difficult to read simultaneously several sensors without a big delay. Today, just one sensor is used, it is not necessary to deal with multiple sensors in the code. Remove them and if it is needed in the future add them on top of a code which will be clean up in the meantime. Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan Acked-by: Wangtao (Kevin, Kirin) --- drivers/thermal/hisi_thermal.c | 75 +++++++++++------------------------------- 1 file changed, 19 insertions(+), 56 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index f3b50b0..687efd4 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -39,6 +39,7 @@ #define HISI_TEMP_RESET (100000) #define HISI_MAX_SENSORS 4 +#define HISI_DEFAULT_SENSOR 2 struct hisi_thermal_sensor { struct hisi_thermal_data *thermal; @@ -53,9 +54,8 @@ struct hisi_thermal_data { struct mutex thermal_lock; /* protects register data */ struct platform_device *pdev; struct clk *clk; - struct hisi_thermal_sensor sensors[HISI_MAX_SENSORS]; - - int irq, irq_bind_sensor; + struct hisi_thermal_sensor sensors; + int irq; bool irq_enabled; void __iomem *regs; @@ -113,7 +113,7 @@ static void hisi_thermal_enable_bind_irq_sensor mutex_lock(&data->thermal_lock); - sensor = &data->sensors[data->irq_bind_sensor]; + sensor = &data->sensors; /* setting the hdak time */ writel(0x0, data->regs + TEMP0_CFG); @@ -160,31 +160,8 @@ static int hisi_thermal_get_temp(void *_sensor, int *temp) struct hisi_thermal_sensor *sensor = _sensor; struct hisi_thermal_data *data = sensor->thermal; - int sensor_id = -1, i; - long max_temp = 0; - *temp = hisi_thermal_get_sensor_temp(data, sensor); - sensor->sensor_temp = *temp; - - for (i = 0; i < HISI_MAX_SENSORS; i++) { - if (!data->sensors[i].tzd) - continue; - - if (data->sensors[i].sensor_temp >= max_temp) { - max_temp = data->sensors[i].sensor_temp; - sensor_id = i; - } - } - - /* If no sensor has been enabled, then skip to enable irq */ - if (sensor_id == -1) - return 0; - - mutex_lock(&data->thermal_lock); - data->irq_bind_sensor = sensor_id; - mutex_unlock(&data->thermal_lock); - dev_dbg(&data->pdev->dev, "id=%d, irq=%d, temp=%d, thres=%d\n", sensor->id, data->irq_enabled, *temp, sensor->thres_temp); /* @@ -197,7 +174,7 @@ static int hisi_thermal_get_temp(void *_sensor, int *temp) return 0; } - if (max_temp < sensor->thres_temp) { + if (*temp < sensor->thres_temp) { data->irq_enabled = true; hisi_thermal_enable_bind_irq_sensor(data); enable_irq(data->irq); @@ -224,22 +201,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) { struct hisi_thermal_data *data = dev; struct hisi_thermal_sensor *sensor; - int i; mutex_lock(&data->thermal_lock); - sensor = &data->sensors[data->irq_bind_sensor]; + sensor = &data->sensors; dev_crit(&data->pdev->dev, "THERMAL ALARM: T > %d\n", sensor->thres_temp / 1000); mutex_unlock(&data->thermal_lock); - for (i = 0; i < HISI_MAX_SENSORS; i++) { - if (!data->sensors[i].tzd) - continue; - - thermal_zone_device_update(data->sensors[i].tzd, - THERMAL_EVENT_UNSPECIFIED); - } + thermal_zone_device_update(data->sensors.tzd, + THERMAL_EVENT_UNSPECIFIED); return IRQ_HANDLED; } @@ -296,7 +267,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) { struct hisi_thermal_data *data; struct resource *res; - int i; int ret; data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); @@ -347,16 +317,17 @@ static int hisi_thermal_probe(struct platform_device *pdev) hisi_thermal_enable_bind_irq_sensor(data); data->irq_enabled = true; - for (i = 0; i < HISI_MAX_SENSORS; ++i) { - ret = hisi_thermal_register_sensor(pdev, data, - &data->sensors[i], i); - if (ret) - dev_err(&pdev->dev, - "failed to register thermal sensor: %d\n", ret); - else - hisi_thermal_toggle_sensor(&data->sensors[i], true); + ret = hisi_thermal_register_sensor(pdev, data, + &data->sensors, + HISI_DEFAULT_SENSOR); + if (ret) { + dev_err(&pdev->dev, "failed to register thermal sensor: %d\n", + ret); + return ret; } + hisi_thermal_toggle_sensor(&data->sensors, true); + enable_irq(data->irq); return 0; @@ -365,17 +336,9 @@ static int hisi_thermal_probe(struct platform_device *pdev) static int hisi_thermal_remove(struct platform_device *pdev) { struct hisi_thermal_data *data = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < HISI_MAX_SENSORS; i++) { - struct hisi_thermal_sensor *sensor = &data->sensors[i]; - - if (!sensor->tzd) - continue; - - hisi_thermal_toggle_sensor(sensor, false); - } + struct hisi_thermal_sensor *sensor = &data->sensors; + hisi_thermal_toggle_sensor(sensor, false); hisi_thermal_disable_sensor(data); clk_disable_unprepare(data->clk); From patchwork Thu Oct 19 17:05:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116415 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp721657qgn; Thu, 19 Oct 2017 10:08:41 -0700 (PDT) X-Received: by 10.99.189.18 with SMTP id a18mr1908174pgf.168.1508432920924; Thu, 19 Oct 2017 10:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508432920; cv=none; d=google.com; s=arc-20160816; b=GNd+NZOakdP5QUk4FJyA8a06aorTT9FOwmxRmphf87A/Xp4nli6ZDpaifuuM2qlvrn OaYDNPltnEpysH7FfmLOKcpC/fQqGF3nlr/VM4RyarmjlNX7HqOscW9Wz10f9QVOK3/h ucuhan0TDFMKZaKxucelJtCWkEgacO/4Aluc2eZSRrcfJUBE1GN+pWR+waeGOJ7N4UqT Sq0fRXSTnFwbu4qPUm9mxZ3GNoBXCQ+p3k+159UsbqkFCZshmJTwfHRRdF6kR/9GdJlO gTJXP1bwnmJMqg962bnmhrQKLOkW/BMNrlbBR7QQ0vOLft9zPealsC3eSgj5UhF5/Zz9 FfbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=b1XO1Q6oDJ+0Zqsb1mpoVsrFtWrFMVdCtEDLzYWAduw=; b=HQGEWllq8/GRNlExgO2gM8Aubq5zuzmw2f55iGmx2e1BdrAehR1UP8hxpVUawf2+WR LysET8MF1kOZtrFsTjp6jBpdmQGGfr4UUSsrS9N2gUkpaivpFz+9c8Bs8fb7/Ifznk+W AckzzdZYkqwupaVGih0gl/GcJMZD7LB2BT/FB8XevsgxPccY9J51Eqr2CxJ5crQvkOfM 04oZ+sQPL+SQ0kv1hnn+vcdgjYCRUxRwon+AK9NGPne5L0rI4WxPeCGGBAp38GccXiP8 n4UvAJBTftESyypQV1MA7CpT8BLStW6DGV1RQMkFEkXsMx4S+HtLLJhW8u+E3ZfiIcLV /bgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NfTva1ov; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a24si8812310pfg.299.2017.10.19.10.08.40; Thu, 19 Oct 2017 10:08:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NfTva1ov; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755035AbdJSRIi (ORCPT + 27 others); Thu, 19 Oct 2017 13:08:38 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:54526 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755012AbdJSRIe (ORCPT ); Thu, 19 Oct 2017 13:08:34 -0400 Received: by mail-wm0-f65.google.com with SMTP id i124so17714537wmf.3 for ; Thu, 19 Oct 2017 10:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b1XO1Q6oDJ+0Zqsb1mpoVsrFtWrFMVdCtEDLzYWAduw=; b=NfTva1ov5vV73p4Gco+pnyW2XhwHN5uWqlrEAjBOtaVjtGHgps0KSvP9LfyKaNCZWX IQUmw8LwpzIFfR7vdWYRbEe9R6OeSXo/6fbrp+GqEM9jVke+OeCwwDw+t2p9UbWsKx9q LKe7tV9U1coEloDb2o1E0Yrgw4JbYFzph/vgA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b1XO1Q6oDJ+0Zqsb1mpoVsrFtWrFMVdCtEDLzYWAduw=; b=TZX7/CbJUqpBX27nc8u6U0pUhVcJp9UxRx8wdk4gHEFwLbV6+rojN/TYmWjkMbDayU DhgFGsQytQmszn3LrtlkGaSpn/uKJVmJRLlzIgqKFW/qvckDEDCBRYpaBnEHTqzJGswR upueKL+8SaDGjHDUBa1LaXfRx4vwKiLt4+AI8Fm8QuID0VsaB6baab6tCMnBzC5/cpke XZN7OYEM03pOOCBXj9ZuBcU0XSQLxxpeMmVeyHzoj5QiF5SwpfZ2N/FJTNcy2n7XY0M8 iYp6kXa31BzdGUCXnbFdJRfkK9iTFsNGKrGabZ3lkiYYLyrXWwIWp2aaQtbouT/XXsgF 2YrQ== X-Gm-Message-State: AMCzsaV+0H8YUzgzLlJtxGfd/9vZ3QB4cyi8SXk2UHHnk8K9+/rEE0u0 NULfXCCrDRf4e+q+x3r/U3Gkbw== X-Google-Smtp-Source: ABhQp+QRcTQ+99md1v4YlbzHK/FE+akPfqqbmjlYZIPjULUqOtpKolT9dgij20jRFlBOUqkkdajL8w== X-Received: by 10.28.184.141 with SMTP id i135mr2414871wmf.143.1508432912971; Thu, 19 Oct 2017 10:08:32 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:32 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/18] thermal/drivers/hisi: Fix kernel panic on alarm interrupt Date: Thu, 19 Oct 2017 19:05:45 +0200 Message-Id: <1508432760-17847-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The threaded interrupt for the alarm interrupt is requested before the temperature controller is setup. This one can fire an interrupt immediately leading to a kernel panic as the sensor data is not initialized. In order to prevent that, move the threaded irq after the Tsensor is setup. Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan Tested-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 687efd4..feae552 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -287,15 +287,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) if (data->irq < 0) return data->irq; - ret = devm_request_threaded_irq(&pdev->dev, data->irq, - hisi_thermal_alarm_irq, - hisi_thermal_alarm_irq_thread, - 0, "hisi_thermal", data); - if (ret < 0) { - dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret); - return ret; - } - platform_set_drvdata(pdev, data); data->clk = devm_clk_get(&pdev->dev, "thermal_clk"); @@ -328,6 +319,15 @@ static int hisi_thermal_probe(struct platform_device *pdev) hisi_thermal_toggle_sensor(&data->sensors, true); + ret = devm_request_threaded_irq(&pdev->dev, data->irq, + hisi_thermal_alarm_irq, + hisi_thermal_alarm_irq_thread, + 0, "hisi_thermal", data); + if (ret < 0) { + dev_err(&pdev->dev, "failed to request alarm irq: %d\n", ret); + return ret; + } + enable_irq(data->irq); return 0; From patchwork Thu Oct 19 17:05:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116432 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp726872qgn; Thu, 19 Oct 2017 10:13:55 -0700 (PDT) X-Received: by 10.84.241.207 with SMTP id t15mr2017610plm.158.1508433235003; Thu, 19 Oct 2017 10:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508433234; cv=none; d=google.com; s=arc-20160816; b=KxBO8+MWincI0No5MsEU5I8yxJtTL949c4lFJNgThRB7/Tg6ClkrsJVKZX9/dvfG+3 9AhMJkhaHqWlg9/Xow8SPgATMY0tzLckhS4CepWJPA8w8eMOX9GQsyP9QkW1MhopM4hz v3v7e9Y/LZoGspfIqmlZYbUqZHU/7wQoqxL4iCtbtb9Sj5GSR3lpChp6KXpfSJFpgCkV A1brF15EYXWYbqBjx/ZdQM9tHKV/1WjZb7HuaMcYlCdgTcPDZO4unxyzP/sG5GeFo5+p 92VeboqUgOG33oKLzDHFjRwUW9LcKuDIYKCDwxRfZtRyBEZvD77Bpyxu7fZ68aSxkfgv wKTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=EYuadkShQdCiMrX8H0Tm3wmurc4mV8xR4jVW+FYgK4Q=; b=d2C8D8wdyZNQ+pUZxtLZYTPiq7qnCrViCQ9JHyJrA2yo9/dpI4n2f9GtmL0dRtgE1C Ny6HlWBf4bMG2gmrpzRE8R3cHSh0NH6wo4jECB9SXtaCMrQSYHW/S42l6hbYlboEWdYk iIA3Wu+FBgdNqfCUzM0xl2MCpasilHTQCUYNMe7LJd3h1y0lfWD2oZDtvr5Cd0ZUfanI MuCXSkvwuECA2usJ0u+qfQ4STwm6M5V7E9szV9uAnLgNt+XyjT+VHyaJQmV+C5V2y8Bg nBB/3OJJkA5C7YwMdYzVlxTQv5VI0BHxcsrtopX3YJ55y1aSJ62YScnenPNDeEUL0zxk 5aUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HabCQJOq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 39si5018553plc.68.2017.10.19.10.13.54; Thu, 19 Oct 2017 10:13:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HabCQJOq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752328AbdJSRNw (ORCPT + 27 others); Thu, 19 Oct 2017 13:13:52 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:56779 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755013AbdJSRIg (ORCPT ); Thu, 19 Oct 2017 13:08:36 -0400 Received: by mail-wm0-f65.google.com with SMTP id l68so17713425wmd.5 for ; Thu, 19 Oct 2017 10:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EYuadkShQdCiMrX8H0Tm3wmurc4mV8xR4jVW+FYgK4Q=; b=HabCQJOqTh8plwrw25WWu4VRdMr5P8zZL/UPKSl3F+fvAL+dXZ7P4+zPcWEhFTKh+j nb7qVhn0NcMycoU+vWcB8YgzxkphonhvkaV+H1knFiBdMsxoAYSGdhCzfGZCw2zSu7Fr SkbVxomhCUDf9rWeh4l9il618nuGAETIyFfdY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EYuadkShQdCiMrX8H0Tm3wmurc4mV8xR4jVW+FYgK4Q=; b=IOF3Y8l3UBSn5p6qY5XwsJtyR0z8g0N8oIzUp5mjmTOgteSBQBffYs0Lb8HGbRWx3i s4L0H1pDDRmPdiHDU20tUYizuCuU3ILYa9XQQNRrVhX9SaVkQlyaEgHrahjqczgExIXM yBcglCf/IKp3VX+MfTJTXEBqJsvqbbkvx55kFK1ftHbbj+3jFhTco9+rsmSl82vbycCI A/NLXp87gN6G4cqMW8dY8mS19qt/3dFP4ujSJOlNIO9BJ9Vi1KVjElAWiCCAj4ZSV/ng Y5L8b21iy6Hv1LYhTUlcEiLE7b3/FaFxoJ6/XNFZrVfF1/Sl3THTf0pXxmTObSgE9QGi yg0w== X-Gm-Message-State: AMCzsaVSrGVmuwMEVAcjIHuv4JpvWVK9UJXc367e3Q31pMbZBXWXRHY2 KHskW0URyNJBIgWR28xp+WGqS6geMn4= X-Google-Smtp-Source: ABhQp+QuuHVXSegM5wdaiLONsNqy6oWU+O5V5o2l5+Kjwdj4b2E3c8Lv4cnhYvyHmNg0R9CJzdI79g== X-Received: by 10.28.55.2 with SMTP id e2mr2430377wma.60.1508432914824; Thu, 19 Oct 2017 10:08:34 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:33 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/18] thermal/drivers/hisi: Simplify the temperature/step computation Date: Thu, 19 Oct 2017 19:05:46 +0200 Message-Id: <1508432760-17847-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The step and the base temperature are fixed values, we can simplify the computation by converting the base temperature to milli celsius and use a pre-computed step value. That saves us a lot of mult + div for nothing at runtime. Take also the opportunity to change the function names to be consistent with the rest of the code. Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan Tested-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index feae552..04eb5e2 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -35,8 +35,9 @@ #define TEMP0_RST_MSK (0x1C) #define TEMP0_VALUE (0x28) -#define HISI_TEMP_BASE (-60) +#define HISI_TEMP_BASE (-60000) #define HISI_TEMP_RESET (100000) +#define HISI_TEMP_STEP (784) #define HISI_MAX_SENSORS 4 #define HISI_DEFAULT_SENSOR 2 @@ -61,19 +62,32 @@ struct hisi_thermal_data { void __iomem *regs; }; -/* in millicelsius */ -static inline int _step_to_temp(int step) +/* + * The temperature computation on the tsensor is as follow: + * Unit: millidegree Celsius + * Step: 255/200 (0.7843) + * Temperature base: -60°C + * + * The register is programmed in temperature steps, every step is 784 + * millidegree and begins at -60 000 m°C + * + * The temperature from the steps: + * + * Temp = TempBase + (steps x 784) + * + * and the steps from the temperature: + * + * steps = (Temp - TempBase) / 784 + * + */ +static inline int hisi_thermal_step_to_temp(int step) { - /* - * Every step equals (1 * 200) / 255 celsius, and finally - * need convert to millicelsius. - */ - return (HISI_TEMP_BASE * 1000 + (step * 200000 / 255)); + return HISI_TEMP_BASE + (step * HISI_TEMP_STEP); } -static inline long _temp_to_step(long temp) +static inline long hisi_thermal_temp_to_step(long temp) { - return ((temp - HISI_TEMP_BASE * 1000) * 255) / 200000; + return (temp - HISI_TEMP_BASE) / HISI_TEMP_STEP; } static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data, @@ -99,7 +113,7 @@ static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data, usleep_range(3000, 5000); val = readl(data->regs + TEMP0_VALUE); - val = _step_to_temp(val); + val = hisi_thermal_step_to_temp(val); mutex_unlock(&data->thermal_lock); @@ -126,10 +140,11 @@ static void hisi_thermal_enable_bind_irq_sensor writel((sensor->id << 12), data->regs + TEMP0_CFG); /* enable for interrupt */ - writel(_temp_to_step(sensor->thres_temp) | 0x0FFFFFF00, + writel(hisi_thermal_temp_to_step(sensor->thres_temp) | 0x0FFFFFF00, data->regs + TEMP0_TH); - writel(_temp_to_step(HISI_TEMP_RESET), data->regs + TEMP0_RST_TH); + writel(hisi_thermal_temp_to_step(HISI_TEMP_RESET), + data->regs + TEMP0_RST_TH); /* enable module */ writel(0x1, data->regs + TEMP0_RST_MSK); From patchwork Thu Oct 19 17:05:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116431 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp726460qgn; Thu, 19 Oct 2017 10:13:28 -0700 (PDT) X-Received: by 10.84.215.9 with SMTP id k9mr1977202pli.284.1508433208006; Thu, 19 Oct 2017 10:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508433207; cv=none; d=google.com; s=arc-20160816; b=K9hVfHwFg9Ic0NNgICSdJxA6+LVIcl1IMl9sw66+lcDRiHbPQ/fSE4DBqSM+Ezwqe1 nLSMSAWYYOJuk1zkJHtvQwlkpSn00BfKAGM+b07uwc+SqlbsdEm9Qe/lY3i5PYldWlKy YZmY2QQ2yDqLqS29cifyJIUC0Lw8Kq1dvS241CiDISXW5Yic3CDCoYTMovMqhIDrkJvI y53AONqAgEOSY08qk4cklyYiQesF+pH5DUJ4yhiy1hwjjZeDRLruAFP5fnud3G/mtfXj XsSuCit1EQ/S3Z7RXN6bWM8SLft1Wyf82D/+7b4PwmE7RIiO4YKRbKXRf5Fp6vo7gFRd ZuVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=LcCqOg6R5HLIWn70fOZmoXFqfJp/EJeqARoLFLmxNCE=; b=Vp4PTMx+ebx7Vrj4LaLKq9EHkAAhULHx07D+Lf510c+MDgM9JVQqF7aP7Uigl/eiua TWb38l8fN4fMnFwjXwn+KcUmCXlThp8O0bn5At2IzxD8byMSQLlwmroGxiK0G7xzpxLn JfaAYkYrTkWbNxy0vmlCeB50djtYxvNMukTTQI0SxACE+IXOp3sebXR46/2gZvOv9e9H xiUg2NjU2JAA8K24tLoN6TiKyeD05nxvxXr7L41vtnVwcmOLlkTj5EmQSe1KyQcLKAst k/xbTdBJcjSAFhDe+s9VzhWApBiyhRtGVrrHXWwcIMAIrm+ooePHT0e363zqDMmlWn1/ n/cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fLlkdUnk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si8101669pfb.458.2017.10.19.10.13.27; Thu, 19 Oct 2017 10:13:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fLlkdUnk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753701AbdJSRNZ (ORCPT + 27 others); Thu, 19 Oct 2017 13:13:25 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:52625 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755018AbdJSRIh (ORCPT ); Thu, 19 Oct 2017 13:08:37 -0400 Received: by mail-wr0-f195.google.com with SMTP id k62so9037255wrc.9 for ; Thu, 19 Oct 2017 10:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LcCqOg6R5HLIWn70fOZmoXFqfJp/EJeqARoLFLmxNCE=; b=fLlkdUnk+uUXYW1zNvxmm/6SH6zHJMLAB8OFN7hzFCXtSEz4mKuPMCFCn94lt4V1aE BnilSnUqPZbEXmxMhz8lOC8Mvdkhq4G8LnHkkui7lENNkrPAS9ldjfeOhdG6WZu/giHt GGDuCs0R60S3aLKZI8NnwacplMe3H9Dy9KD78= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LcCqOg6R5HLIWn70fOZmoXFqfJp/EJeqARoLFLmxNCE=; b=OpEbbUVCFhZLvd9UMNbKGB31EPizzs6+bLbD6XaCS2uaM7u9JOciEvdJ6364zT10v3 iaZpt4Vc/iyqrQJzzKnVK92H6pX3Km0VR2vUgfn1hKH+i6EQdrZXWf7QntbOtMYQRdbw vnpclwJYcglpfO7++njrKQjkaBz5vW0GAl54vMqXJjRD28uCGf7vjlFf9mHx2feN4nl3 2CAuXOWWLwiLYgi0tgSpq7wHYK77lFN1jNTZ6ahNCVf9mnG9NUs82BL7FdGKD2G1NjP6 FFvFi6fdeRkv5xSCK4LuyCBksMV1D8wP+S9MVobZ/VDOJRv14Hzx8zX4dmDVhh5nWSNg jihw== X-Gm-Message-State: AMCzsaWHbYHoHo+tfKfMY0nu7DYJvzqlpMP6mm0dwUeUu6UMTAaLEws0 8nEwUdL0ecfp6lXKCgWX5jZuu3sErJM= X-Google-Smtp-Source: ABhQp+R0mJ02LkZB9RBnxEDig9J0EUS1574EwBe1JlHRFoC1s+wiQipKJmY9ULJEwOl81wacbeZMLw== X-Received: by 10.223.150.76 with SMTP id c12mr2335345wra.10.1508432916400; Thu, 19 Oct 2017 10:08:36 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:35 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/18] thermal/drivers/hisi: Fix multiple alarm interrupts firing Date: Thu, 19 Oct 2017 19:05:47 +0200 Message-Id: <1508432760-17847-5-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DT specifies a threshold of 65000, we setup the register with a value in the temperature resolution for the controller, 64656. When we reach 64656, the interrupt fires, the interrupt is disabled. Then the irq thread runs and calls thermal_zone_device_update() which will call in turn hisi_thermal_get_temp(). The function will look if the temperature decreased, assuming it was more than 65000, but that is not the case because the current temperature is 64656 (because of the rounding when setting the threshold). This condition being true, we re-enable the interrupt which fires immediately after exiting the irq thread. That happens again and again until the temperature goes to more than 65000. Potentially, there is here an interrupt storm if the temperature stabilizes at this temperature. A very unlikely case but possible. In any case, it does not make sense to handle dozens of alarm interrupt for nothing. Fix this by rounding the threshold value to the controller resolution so the check against the threshold is consistent with the one set in the controller. Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan Tested-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 04eb5e2..1b44bfe 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -90,6 +90,12 @@ static inline long hisi_thermal_temp_to_step(long temp) return (temp - HISI_TEMP_BASE) / HISI_TEMP_STEP; } +static inline long hisi_thermal_round_temp(int temp) +{ + return hisi_thermal_step_to_temp( + hisi_thermal_temp_to_step(temp)); +} + static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data, struct hisi_thermal_sensor *sensor) { @@ -221,7 +227,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) sensor = &data->sensors; dev_crit(&data->pdev->dev, "THERMAL ALARM: T > %d\n", - sensor->thres_temp / 1000); + sensor->thres_temp); mutex_unlock(&data->thermal_lock); thermal_zone_device_update(data->sensors.tzd, @@ -255,7 +261,7 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, for (i = 0; i < of_thermal_get_ntrips(sensor->tzd); i++) { if (trip[i].type == THERMAL_TRIP_PASSIVE) { - sensor->thres_temp = trip[i].temperature; + sensor->thres_temp = hisi_thermal_round_temp(trip[i].temperature); break; } } From patchwork Thu Oct 19 17:05:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116430 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp725337qgn; Thu, 19 Oct 2017 10:12:20 -0700 (PDT) X-Received: by 10.98.147.73 with SMTP id b70mr2153505pfe.347.1508433140322; Thu, 19 Oct 2017 10:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508433140; cv=none; d=google.com; s=arc-20160816; b=s6vat9zG1ZNuN/vScgCH+HlFQ8ww7NlS02xaU4eMkGa2reOLcsoAswWhxhQuqi7HAt Rv5OQ+B6nnvi+SH9M+3Y7PeewiL1NEgXqoVrg4qkQU9+qilhI9jfxDOLlfBWnfqUE2+Z AqDqv91GQ7Wi+Z4OfumE3Y4nSOvESX/UsOoKZUzJXws8L1mhrmtR6asGLhqi9ab5F4xo d3md8U4+YsPnpcE0n7aE3LvEe3EErOrjhmGo21i/nbqFnzRZxy9Gxs3Z5B06eNnNi6aL tWw2bNLDfX5xGo3nNy16eHAvKj3yxskqy0qypQTNw8zMfVfIvnr91lKwDQeHA3WSWnPe /73A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=RXq2HM2wsx+XsSvP5yIIgV1sF/W7OK4M6nuLfQ5ydXg=; b=zco10Xfa1EIBnSzfIkT6cCiJ/14eRElBC85rhCANoqCoT+v+t+u7ptw4Pyqzny/Xfz fFXCYcOLciQdRCb4t27ZRbIRGmweU1o49lWP30uLCt+RtKeQkkgzkgjibA1KwPAAjD9v 4UsAhpZd61gxSg+fSgmmEQCSb90BKjLrRuIxoYGoAXc87LzMpXgvWHYUx0cKrSinDk0I IvwOmf3Oa8h+QPnYmNqYZfdAS07B7WVwBqAJVR6dMQ5IOdmluu98G4qvU7gNmcWTFFm9 Ixj+h95A57bllFkP5D7pviDDdIFjjQ79ywY2iVcB8ubxDrJtWv1FcIYd7BvxiUhm8hUP +xtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X0IG+/1X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10si7220536pfi.256.2017.10.19.10.12.20; Thu, 19 Oct 2017 10:12:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X0IG+/1X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753641AbdJSRMS (ORCPT + 27 others); Thu, 19 Oct 2017 13:12:18 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:44591 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753500AbdJSRIi (ORCPT ); Thu, 19 Oct 2017 13:08:38 -0400 Received: by mail-wr0-f194.google.com with SMTP id z55so2981740wrz.1 for ; Thu, 19 Oct 2017 10:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RXq2HM2wsx+XsSvP5yIIgV1sF/W7OK4M6nuLfQ5ydXg=; b=X0IG+/1XJw8fWVRi6aOTaU/TLGZ6yqydkxuLEr4sCZfMYyp9F9NDsdRmvi2MGkB2iv /0qcTQg7ytoOSMOSZO9U5ELIGEvYunT1JPV+gPpbIKlTslGUFHebCN8BlQzsH9YIf3Y4 h2Hvc1Q780LeuI42PFQYlyHuEZRiG+TyQzxXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RXq2HM2wsx+XsSvP5yIIgV1sF/W7OK4M6nuLfQ5ydXg=; b=IPtHG4py1EOI8LWDaKoOdVsCt10LD8chz2W3tNMVBLzDLfG4EHMUiqQNy2zsisVKXj bIIhVGzqkHN6tCj4Q9EbhBVaWRkLZyL8Ej4RTbZxTx4yXO/uislFna7+dCJdaIvl9LQ4 mNkJPg4oPKHtbkyIZDOvUSP/v6G3XmsrrLAma3o7sPs31VVb8OqBx+K5Dx1w7Bll9aVk d3HGDKHtSB0TOSIiu5BudUJKWED5VDuL0+O4zSKLXf+Xcctot5RDQGxJsW+nGI/ud8cy heXTrDUw9LTDSbaKf1n1ZcvtiaK20LxeyFsTIvy+ZnaUNyHp9dALiVtD6PIGXAQceLuB aBtg== X-Gm-Message-State: AMCzsaX4bg3BWF7h/wwKXp/60B51NInj1DFKMw1QkYbx37KjR/cP+aq2 To0tLrpYJ5y5dYG+xsNAocnZTQ== X-Google-Smtp-Source: ABhQp+RtFwTjl9wzK8zHbgfHY2/NWkWgr1D/2IQFud8Tbs8OqIs6ISyH8hUSXRtVcLuISc34o+9Olw== X-Received: by 10.223.162.152 with SMTP id s24mr2389956wra.173.1508432917681; Thu, 19 Oct 2017 10:08:37 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:37 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/18] thermal/drivers/hisi: Remove pointless lock Date: Thu, 19 Oct 2017 19:05:48 +0200 Message-Id: <1508432760-17847-6-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The threaded interrupt inspect the sensors structure to look in the temp threshold field, but this field is read-only in all the code, except in the probe function before the threaded interrupt is set. In other words there is not race window in the threaded interrupt when reading the field value. Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 1b44bfe..b657ae4 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -221,14 +221,10 @@ static irqreturn_t hisi_thermal_alarm_irq(int irq, void *dev) static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) { struct hisi_thermal_data *data = dev; - struct hisi_thermal_sensor *sensor; - - mutex_lock(&data->thermal_lock); - sensor = &data->sensors; + struct hisi_thermal_sensor *sensor = &data->sensors; dev_crit(&data->pdev->dev, "THERMAL ALARM: T > %d\n", sensor->thres_temp); - mutex_unlock(&data->thermal_lock); thermal_zone_device_update(data->sensors.tzd, THERMAL_EVENT_UNSPECIFIED); From patchwork Thu Oct 19 17:05:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116426 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp724190qgn; Thu, 19 Oct 2017 10:11:10 -0700 (PDT) X-Received: by 10.84.240.140 with SMTP id z12mr2049756plk.328.1508433070092; Thu, 19 Oct 2017 10:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508433070; cv=none; d=google.com; s=arc-20160816; b=pJrSPCW2RnICcN5//8q3z9bovlfEDMxYARIVE4Kc27YHdCBGaSL6V1fxa4rDYhAgmy EimIZv57/JjZE4DWMSS3+lw2J1Oq/3TLfKdWDKA0pukeuHtRMnqV1sexBCFPtnrJ7M8U 7UhqfhS+2oc4ikx9vlhQ9t0HB95xivfemSQ4rZrAAWz77BdvIbMJfLYKbsxFQpH96NjM LX4HoiaP7B4BxdDUZ2WO4AlECa4MHr1PETg6WCoscQVHcg5fuGOtpalyRl5KPGLlppLM +mHrxF4I42U2jvYKYsMS6lRI1cGGi2YTjGePgoy3G3obfkJYtytbD0Gc3OjkXB6G0Ysl MA2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=AGT7sYZX77Q44Vpe57+dMHFMiTlzmOmmxVDwzbt3maM=; b=FVy96NdpwFrX3mwehOVEDtw2jFJJeCZv6340JSqS4uhbUzxgA5VQI3taSrO28ESh3h BZjBxhPEMV6HQl0F5g/L80rDMxqhIPAa30ZCJas4ISu62Y9GRJCkPXC6Lhh2EgPhq5lD eB+1XXtU+NRE7ZOWNtOVBcfjduRladrSVXCvqAtC52FdrDvV7W51AkAvtSitZc+eaQIh SevBlpFDCBV3jYqBXnwrhK8GRstZnrtc76UgOpi1q6DzhofKtFIpD085kg3AX4p2FLiz bfKT0oHdutGcnNX7Wr1BnrP722DlAorgR977NtMLGX3UGI7+9LdyLH0ZZDT3FlXQVcOK szow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mm6guW5D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si9696670pfl.470.2017.10.19.10.11.09; Thu, 19 Oct 2017 10:11:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mm6guW5D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754540AbdJSRLI (ORCPT + 27 others); Thu, 19 Oct 2017 13:11:08 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:46378 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755077AbdJSRIq (ORCPT ); Thu, 19 Oct 2017 13:08:46 -0400 Received: by mail-wm0-f65.google.com with SMTP id m72so17367331wmc.1 for ; Thu, 19 Oct 2017 10:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AGT7sYZX77Q44Vpe57+dMHFMiTlzmOmmxVDwzbt3maM=; b=Mm6guW5DxW1dbyGQdipfV/tB2gXaJLZzUIBmUuyRlf7F25x4EtbNeyRisl0CMCiTr9 +cUjse4jzl9P0HI0+Fym6mE8klBBbBp/sOBAQXICI0FtLYT/7YTol/vsy6ei+F9vwaLu jgxJJlpahC451wbn8hIKl9LDTI9vXR1ELjIBE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AGT7sYZX77Q44Vpe57+dMHFMiTlzmOmmxVDwzbt3maM=; b=gpUrKdoO3o/WxvpU6lyZfg6p1wGNFZyf2wIpNr/OEesp7xW+stoaXnGc/ne8Wc4UG3 IrxcypmnAntQTmatvBhMOFASoBWNsn1Oufiz3FhXfQrIJp4i7tsTUpuMeXjwlB/qez7c l3GTMl9gOlJAWc4AYa/Kgc+p0wNNWE04g8sxfIB+qdcq540/kWXC/BFRvDNRvGE5GgJU 3iiLCIUDyehY8PbvUXnDnQa49sI2cXdf5v3M4SyQMyRs0xOgAzs1Gh88VoQez95j3iIw If3L/dB2K/U2LFh5QqNHh0AANG+TM+kwqz++0h4Xpzb3kNtHN4e1wraSR1wdejy2I2P3 l+kQ== X-Gm-Message-State: AMCzsaX0lDBm3tQ/6goRYwXQ1FdvgEF3fZegIpu1LV4ZeD4SKgDlfH7p q2ImFXQbWKRB76PIKlKhrwkt4A== X-Google-Smtp-Source: ABhQp+Rm1z/Y+/WlyHrDVw5wvc0dOl1wNqEDbWtitOFciQJbQkRm+Xxg7GTdOqfLBYtDieXR4ZnC1g== X-Received: by 10.28.134.66 with SMTP id i63mr2193452wmd.107.1508432925166; Thu, 19 Oct 2017 10:08:45 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:44 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/18] thermal/drivers/hisi: Convert long to int Date: Thu, 19 Oct 2017 19:05:53 +0200 Message-Id: <1508432760-17847-11-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no point to specify the temperature as long variable, the int is enough. Replace all long variables to int, so making the code consistent. Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index baa3853..5382073 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -85,12 +85,12 @@ static inline int hisi_thermal_step_to_temp(int step) return HISI_TEMP_BASE + (step * HISI_TEMP_STEP); } -static inline long hisi_thermal_temp_to_step(long temp) +static inline int hisi_thermal_temp_to_step(int temp) { return (temp - HISI_TEMP_BASE) / HISI_TEMP_STEP; } -static inline long hisi_thermal_round_temp(int temp) +static inline int hisi_thermal_round_temp(int temp) { return hisi_thermal_step_to_temp( hisi_thermal_temp_to_step(temp)); From patchwork Thu Oct 19 17:05:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116419 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp721911qgn; Thu, 19 Oct 2017 10:08:54 -0700 (PDT) X-Received: by 10.159.246.23 with SMTP id b23mr2009904pls.60.1508432934477; Thu, 19 Oct 2017 10:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508432934; cv=none; d=google.com; s=arc-20160816; b=Cw6FiZ7fVTS06CCN8dSEmaKlCqtmu5kj4PeDNUcg0br1vsiZxc07WTGDZOmBtCRDa8 cU8VA+PPpAfmwEYclpbKZxn3tuhMow7evPYeZ1c0je96v1m7JMQi5oBlpwJsB8gvAjK9 qGataTPQ5QwCRv9VfeKCCjf3Fqy8VC3QtLyION5eA7eG67n0As5OCVqEm0CWlf3O3OrK yYOKzwGuZJOKZgNINCNSEpm0u/F+iyk5T86LHXnGXdAPs26xxQKpac8bzkX03/2TlAi6 7l+HDslOfjXRnrvTF1BXSv55cXG8vc/79ITQfSKNMUrswWRiuqxxPJZdYEveUDXoOVER p7Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ml7oe/0YASyeXw6/R0x/YhaVd3BkPfM0Dt8qWCr5GTg=; b=xXJW9oBRnp4hq7s60muWdLNYSoUlrvGyLm+xeuno5ujgT4nUOaqoYD9BIArAL/wB97 YIWqMqV8Cj85CFclAEvDkg+jo5/stUNT9GdaW7oPUBUwnK16ycKcyKqts5Tb5POt5yLg jFjOIXShGlWji2uS20fCNtva06YMNIlq1nGN3eMYwHzYbNOnIzCfKoqf210wZQfwK3qF PbnU5aRxOF1tLws+gkYOFwzGIzIPVcuKu20Zk/5NnKwSfV8+4U+8mngvwr0C87jCuq6w mwBI1rLzJZeI8DbDmf3W8s3qVM2sV+WwEWmnRuNiSiqSaYDl3Z2NyBMmMb8Woqs0RJcJ zQeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MMD8Ts2m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si4409160pgq.28.2017.10.19.10.08.54; Thu, 19 Oct 2017 10:08:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MMD8Ts2m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755131AbdJSRIw (ORCPT + 27 others); Thu, 19 Oct 2017 13:08:52 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:47725 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755101AbdJSRIt (ORCPT ); Thu, 19 Oct 2017 13:08:49 -0400 Received: by mail-wm0-f68.google.com with SMTP id t69so17363591wmt.2 for ; Thu, 19 Oct 2017 10:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ml7oe/0YASyeXw6/R0x/YhaVd3BkPfM0Dt8qWCr5GTg=; b=MMD8Ts2m85jDApV5Au8lq3JOBzvpbORTmHIeayr7bbFnAdyiJYkU3tXkND+t56AAx7 eC5QzKoFxYe+0c3iKkT+oikjyaXJImowl1Az0tvc3SmJKNKKPjW9GaJyHgnaMZWLcJzO VWeMieJDjJboLleu/LgscXp+yhkkHfRwgmYAc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ml7oe/0YASyeXw6/R0x/YhaVd3BkPfM0Dt8qWCr5GTg=; b=qmymbQgq8gT/aqw+k+h/qsI45jML3t++YuoVokPFe2de/jcDulLIctZAESFWrDhzMc /ru0qAQ7Ccm+S/YKP1xqcigEHP5ooWp4KYv/KyCoiqKyj2D/T2efdhMonEV2VCrQeeX+ 8QyAU81ZZjurvWnh/SBNRE5iLXLZX3VnTm1rClsDpWsEyzwkI1cv9ChnFUj2iin5K+nz mjtZTU+Q/Wj5/wbI5c/AT8R7dc6ZzfnV30+LUeLt12P/7V7Qo132RobO+6c6WErMxgy6 J036DQzovzIbAjDJQf3tFc0rDS0Ij2d+hFmh3MOduQJKySv7pIzef4T0n2mrAj17yMD1 vCxg== X-Gm-Message-State: AMCzsaU83BCzP6oyZqe9gZzHSCi++WuStq01/Yqfc3t1++/g2NlZgY+1 A/9ooZQUxAHKPkZTujBBFadnKQ== X-Google-Smtp-Source: ABhQp+QmVpluCm0pph+AaO7Mh9cvtXr80LMv0XyAn7vfJZ2/BWmjha/PiJamcBdHGnqAdsHhVI5YQg== X-Received: by 10.28.45.9 with SMTP id t9mr2331808wmt.94.1508432927846; Thu, 19 Oct 2017 10:08:47 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:47 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/18] thermal/drivers/hisi: Remove mutex_lock in the code Date: Thu, 19 Oct 2017 19:05:55 +0200 Message-Id: <1508432760-17847-13-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mutex is used to protect against writes in the configuration register. That happens at probe time, with no possible race yet. Then when the module is unloaded and at suspend/resume. When the module is unloaded, it is an userspace operation, thus via a process. Suspending the system goes through the freezer to suspend all the tasks synchronously before continuing. So it is not possible to hit the suspend ops in this driver while we are unloading it. The resume is the same situation than the probe. In other words, even if there are several places where we write the configuration register, there is no situation where we can write it at the same time, so far as I can judge Signed-off-by: Daniel Lezcano Reviewed-by: Leo Yan Tested-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index b77ca19..8d1a8be 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -53,7 +53,6 @@ struct hisi_thermal_sensor { }; struct hisi_thermal_data { - struct mutex thermal_lock; /* protects register data */ struct platform_device *pdev; struct clk *clk; struct hisi_thermal_sensor sensor; @@ -200,14 +199,10 @@ static inline void hisi_thermal_hdak_set(void __iomem *addr, int value) static void hisi_thermal_disable_sensor(struct hisi_thermal_data *data) { - mutex_lock(&data->thermal_lock); - /* disable sensor module */ hisi_thermal_enable(data->regs, 0); hisi_thermal_alarm_enable(data->regs, 0); hisi_thermal_reset_enable(data->regs, 0); - - mutex_unlock(&data->thermal_lock); } static int hisi_thermal_get_temp(void *__data, int *temp) @@ -344,7 +339,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) if (!data) return -ENOMEM; - mutex_init(&data->thermal_lock); data->pdev = pdev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); From patchwork Thu Oct 19 17:05:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116424 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp723578qgn; Thu, 19 Oct 2017 10:10:35 -0700 (PDT) X-Received: by 10.84.252.141 with SMTP id y13mr1957615pll.295.1508433035056; Thu, 19 Oct 2017 10:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508433035; cv=none; d=google.com; s=arc-20160816; b=qrhf8VdHSHTEdr2/UOIU1eOp6oTy3GxfqkupzcryW3+Sn4D6UI/3x41zDFrTQtTuMG FslgRYn9aqVD9zaeXTlADUyhIU/VWxXT16nK2AfX3/SSt9C+0IIe+ep0fSnTLaCOt1Jo PX/d33CkU/6jvmW8il6Iv/nFoqGpaA8Ac03mHCe9tdoah3SPTo6PZlbIBmNUz/xHGf+9 2bYrBnIjM2WlD6GcGBu8V6CiUTwaWv3ltLQxafTVgnkwrnUQGWqFDZ3YkYTJDsclbERz q5iJsnDCwKdohhTHrcp7nA+YNVfHYn5rTW+YaP/Ce9Mg0bP6MjI8kgZi0BUg9ZDAzeBK N9UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dAFGnwUGcIyW+JyCLCRVbyCM5D5yhc3ufakQ1nujlr4=; b=hk7U299DtdcNYbIsCq8uMc0ipsmyO2rl3dPhi40msuTHUfM91ind/bq3Z4IgX82+bX IcJv2X8Itoz/Ycz7+04peQkgGMnYXNoikJiHjtY70EHeg/XjV3Cmf3v5foIWpE4//KbK /14eridHRdWraSwHduP2srl3oqXgKa6B8WNF7QJFGtcBVk40Nrc5jzrv+gu/a38iVvF4 TGBkg47BRtDIdoZ7RvhD6S7L+V1ZyJ/0eRSpJ4dV5/OPI+cPJiFCZVPsjnZ6uwCttuFE a7F57KX1vOu/f8RZC+gvK9gYzzXkuUPLJECzRTEG1ZWLQQIFzmOCVjgRoN4mCkAnE/Fe mdVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vqs3glde; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 30si6518071plf.786.2017.10.19.10.10.34; Thu, 19 Oct 2017 10:10:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vqs3glde; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932082AbdJSRKc (ORCPT + 27 others); Thu, 19 Oct 2017 13:10:32 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:43414 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755106AbdJSRIu (ORCPT ); Thu, 19 Oct 2017 13:08:50 -0400 Received: by mail-wm0-f67.google.com with SMTP id m72so16806035wmc.0 for ; Thu, 19 Oct 2017 10:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dAFGnwUGcIyW+JyCLCRVbyCM5D5yhc3ufakQ1nujlr4=; b=Vqs3gldeUAr94j0LZ44Y4FHSNbGXhIn35Fw96jYtC11uQydGodG8t99K9S+iM5epWh i3RzzA17i9/TF1cr2Fo+VFCy96WtxxQ6yMDvVNEgjUMfbRoX2/XcMpOX7Be3xICYnx0+ x48OY7mi3v/wggkXkmFoSC2a4vzS7P3c+B/nE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dAFGnwUGcIyW+JyCLCRVbyCM5D5yhc3ufakQ1nujlr4=; b=alGJouKLMyMCCBsttGrIEELpyGYClvuLFEP+VbCed23CUake07ipU3LvIm7//ehFny +cQsDaMFZmmREJ5OrVCp6pgVX8cr6TbPsizlg1RxFLvsUxsTw3l//BquytekCnmIzVol fBVL7sefCTYbrrM6CAKCb3AP5WqogjORU1xT/NXMfRSLMrl5tqbeHbSUYDGgU/wM0PCg rn3OZBZ0sNLqfKHMOklIzB5ydPdzzAXNlVIJHNeM4tQhzmsRFj3yc1CGaHXcMH8NT9Ly BpifoUn4TNQUssO+XDiohsRzfFb1qduhlI0ntaPfoHvKsYyv0DnRRGvPgVQAsOnD4KnJ fglQ== X-Gm-Message-State: AMCzsaXy0uksAZqciXYisW+ugnhdRehVMBQaCrNAyRRjwmYzPQKujtI/ ZH8UZtkl1Kqs6xfGs7kOK2STag== X-Google-Smtp-Source: ABhQp+QAanU5irQD+1sHieJPvXJH5tJy42fpI0luIwoCYLzzTTQlExOU74Hfl34KtpO5FeWvM+2mmQ== X-Received: by 10.28.107.17 with SMTP id g17mr2471563wmc.58.1508432929322; Thu, 19 Oct 2017 10:08:49 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:48 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, Kevin Wangtao Subject: [PATCH 14/18] thermal/drivers/hisi: Move the clk setup in the corresponding functions Date: Thu, 19 Oct 2017 19:05:56 +0200 Message-Id: <1508432760-17847-14-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kevin Wangtao The sensor's clock is enabled and disabled outside of the probe and disable function. Moving the corresponding action in the hisi_thermal_setup() and hisi_thermal_disable_sensor(), factors out some lines of code and makes the code more symmetric. Signed-off-by: Kevin Wangtao Tested-by: Daniel Lezcano # hikey6220 Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 8d1a8be..b9e4a9a 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -203,6 +203,8 @@ static void hisi_thermal_disable_sensor(struct hisi_thermal_data *data) hisi_thermal_enable(data->regs, 0); hisi_thermal_alarm_enable(data->regs, 0); hisi_thermal_reset_enable(data->regs, 0); + + clk_disable_unprepare(data->clk); } static int hisi_thermal_get_temp(void *__data, int *temp) @@ -297,9 +299,13 @@ static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, static int hisi_thermal_setup(struct hisi_thermal_data *data) { - struct hisi_thermal_sensor *sensor; + struct hisi_thermal_sensor *sensor = &data->sensor; + int ret; - sensor = &data->sensor; + /* enable clock for tsensor */ + ret = clk_prepare_enable(data->clk); + if (ret) + return ret; /* disable module firstly */ hisi_thermal_reset_enable(data->regs, 0); @@ -363,13 +369,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) return ret; } - /* enable clock for thermal */ - ret = clk_prepare_enable(data->clk); - if (ret) { - dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret); - return ret; - } - ret = hisi_thermal_register_sensor(pdev, data, &data->sensor, HISI_DEFAULT_SENSOR); @@ -405,7 +404,6 @@ static int hisi_thermal_remove(struct platform_device *pdev) hisi_thermal_toggle_sensor(sensor, false); hisi_thermal_disable_sensor(data); - clk_disable_unprepare(data->clk); return 0; } @@ -417,23 +415,14 @@ static int hisi_thermal_suspend(struct device *dev) hisi_thermal_disable_sensor(data); - clk_disable_unprepare(data->clk); - return 0; } static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - int ret; - ret = clk_prepare_enable(data->clk); - if (ret) - return ret; - - hisi_thermal_setup(data); - - return 0; + return hisi_thermal_setup(data); } #endif From patchwork Thu Oct 19 17:05:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116420 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp722010qgn; Thu, 19 Oct 2017 10:08:58 -0700 (PDT) X-Received: by 10.159.218.135 with SMTP id w7mr2031809plp.229.1508432938735; Thu, 19 Oct 2017 10:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508432938; cv=none; d=google.com; s=arc-20160816; b=ZKXzkFpGgzBvOdyEc9YocybGyTJxVqbJJKFOpuEjbRDoiJ0cBtZe9Xb7ifgPUGIEON Wd2K8VpbMFEh2TV2bD59QXpOiFPXwyRCOBzwp9K91Qkurb5ToqEyCbGQemf8OzFAW083 24WBq0scNtaatCz3TMvCZ6Z2WxSk29/TDf2g0u6dsO8c3KTS8N7V1nMUwZuzPJ8gI2wy RFptyl8vMcNpmmf34Y6rVcZIMptUy5M6Iu0ZPRofEQ8yxaso5Bn9WrfVqHc1dzzAvj/i +JYo/T+IWDhh5fVKqyahmBHj4wVN/bpiTtNuIrigv4rrEKT6GlMrDcEFIgWORFu78M2y BB6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=GXkHr9S270dLkhuUiQbappPpev4Lnh5qNTan11darjg=; b=R19yhpY/ghULkJ6zWoXYW3HoStSnscNaPiMSX3IyAmvG/Sb1n8ARSo57FRpfo08qhK qJ0CMq0/rXt8+19OeQ8jkw39Pe1c5bh+bbhTD6DCUc9pQek6d6tHMi4COTBNKruciKxR jnaqi0dV2m3RIaiWJlpKxUdk3oWKqhzBB5hxd5FqrCSlThgTp3kleeLWhOIRGgusJ4eG +Y4/iYw8heJh4Jm2xCbMfB7WD1vHDY7KvYg4kPPI/ZueMK1Ckqs5+0yLFwyueBqBNmY1 vOYX1zU5oooSBaNEU77aWvhv2ERiVlFi/gG/PvtOf4yJ/Y1dfStw8Wb8USUIYEZzWiYW eoxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ia654xIC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si4409160pgq.28.2017.10.19.10.08.58; Thu, 19 Oct 2017 10:08:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ia654xIC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755153AbdJSRI4 (ORCPT + 27 others); Thu, 19 Oct 2017 13:08:56 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:46606 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755116AbdJSRIw (ORCPT ); Thu, 19 Oct 2017 13:08:52 -0400 Received: by mail-wr0-f193.google.com with SMTP id l1so9047364wrc.3 for ; Thu, 19 Oct 2017 10:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GXkHr9S270dLkhuUiQbappPpev4Lnh5qNTan11darjg=; b=Ia654xICXE8HzrLX1/kp6jzYSQr2IpLOwwKziBGuqftSx5GFpY5Ip9aB2z4shxUhPa U8ll8AFx8x0HjC9Ff4V2UvgbzYIF6tr1qrF4xkrmWbJiITvjoi6RQTGVW2JfsSUVHg6x C0ay8/ZWeK3DJBDAEyL9DRg2JuAEJXX98Byuk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GXkHr9S270dLkhuUiQbappPpev4Lnh5qNTan11darjg=; b=GXkZ63KhYUluviA6j+zGYDDoCx1do1bvWRm6kfkV5fgMxl4/c/mOkO722iBSdSmSPB gXjhChWsypMRIr8ga5ZlMqGiY6iGRgte+ppt/L9Lv7LmwBajhzPJpsV62Ic3z0Z2gpK5 FtvrHIDS5lrhY3UVhctBMuxNe5w0FMkQW2fr3iHwn8T5oWQ4z/e+qYSwMntaTmeSz943 pPg1cJ2jcZZLB80s8ZqMIyRyVH6L1CWnu1w9nzKROL2bgjK471WZh8fIgZhwKIB1W4De VMaBqG78FSn0h9JvgCv38QQoR8kq50MMyY6ceJZc4O2SPEcG+cRaQVcfe4ODykgvMIOl G79A== X-Gm-Message-State: AMCzsaVGABCqQkf3iDgtgLJ5ztQ80LbnNX9EyEZ0jA3NNTdruyDybKlx iamCCQAbveOfwR1DMQ/UA1XsDQ== X-Google-Smtp-Source: ABhQp+RuUsknBGGYmcCrhUleBaFE0r8uRCXP65bO8tnd/Da4z0pDxlIXiKSCKmynLryt84MMEZQzkA== X-Received: by 10.223.185.78 with SMTP id b14mr2271703wrg.197.1508432930916; Thu, 19 Oct 2017 10:08:50 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:50 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, Kevin Wangtao Subject: [PATCH 15/18] thermal/drivers/hisi: Use round up step value Date: Thu, 19 Oct 2017 19:05:57 +0200 Message-Id: <1508432760-17847-15-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kevin Wangtao Use round up division to ensure the programmed value of threshold and the lag are not less than what we set, and in order to keep the accuracy while using round up division, the step value should be a rounded up value. There is no need to use hisi_thermal_round_temp. Signed-off-by: Kevin Wangtao Tested-by: Daniel Lezcano # hikey6220 Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index b9e4a9a..b48e47e 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -40,7 +40,7 @@ #define HISI_TEMP_BASE (-60000) #define HISI_TEMP_RESET (100000) -#define HISI_TEMP_STEP (784) +#define HISI_TEMP_STEP (785) #define HISI_TEMP_LAG (3500) #define HISI_MAX_SENSORS 4 @@ -63,19 +63,19 @@ struct hisi_thermal_data { /* * The temperature computation on the tsensor is as follow: * Unit: millidegree Celsius - * Step: 255/200 (0.7843) + * Step: 200/255 (0.7843) * Temperature base: -60°C * - * The register is programmed in temperature steps, every step is 784 + * The register is programmed in temperature steps, every step is 785 * millidegree and begins at -60 000 m°C * * The temperature from the steps: * - * Temp = TempBase + (steps x 784) + * Temp = TempBase + (steps x 785) * * and the steps from the temperature: * - * steps = (Temp - TempBase) / 784 + * steps = (Temp - TempBase) / 785 * */ static inline int hisi_thermal_step_to_temp(int step) @@ -85,13 +85,7 @@ static inline int hisi_thermal_step_to_temp(int step) static inline int hisi_thermal_temp_to_step(int temp) { - return (temp - HISI_TEMP_BASE) / HISI_TEMP_STEP; -} - -static inline int hisi_thermal_round_temp(int temp) -{ - return hisi_thermal_step_to_temp( - hisi_thermal_temp_to_step(temp)); + return DIV_ROUND_UP(temp - HISI_TEMP_BASE, HISI_TEMP_STEP); } /* @@ -127,7 +121,7 @@ static inline int hisi_thermal_round_temp(int temp) */ static inline void hisi_thermal_set_lag(void __iomem *addr, int value) { - writel((value / HISI_TEMP_STEP) & 0x1F, addr + TEMP0_LAG); + writel(DIV_ROUND_UP(value, HISI_TEMP_STEP) & 0x1F, addr + TEMP0_LAG); } static inline void hisi_thermal_alarm_clear(void __iomem *addr, int value) @@ -274,7 +268,7 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, for (i = 0; i < of_thermal_get_ntrips(sensor->tzd); i++) { if (trip[i].type == THERMAL_TRIP_PASSIVE) { - sensor->thres_temp = hisi_thermal_round_temp(trip[i].temperature); + sensor->thres_temp = trip[i].temperature; break; } } From patchwork Thu Oct 19 17:05:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116423 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp722768qgn; Thu, 19 Oct 2017 10:09:44 -0700 (PDT) X-Received: by 10.84.247.129 with SMTP id o1mr1949497pll.6.1508432984357; Thu, 19 Oct 2017 10:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508432984; cv=none; d=google.com; s=arc-20160816; b=e7wb0OoVi7fbVwIyTkjgjriwdqyDtn5qLdrvZCIr9bd+zsqinVZiLLRvvCPq8m0hNI 1JzNgHNeSH4r1RuLqHeAUuEJfJ4uXjSYOT89XAJClZJotgeTwXU9XOvqKcI0fXlVlSHQ LxapO0QalcLSzY5ngS1oS+rH34oVmDvofGqJphWTGIXRfbQBMAhZ6C1KCRh9Af2JU5a/ xjrQsJggzlrNiIdt1DrDhGUyy7IADNSReL+EYkGuTuUen/zFrCFCpgJLLq/cx2hN48X3 JyjnAg8YoggDZiQnUwpUEHysjTCAfR/JbzKxQGX2jm08CtG8yQhZsUhQF8w5kSyDIbej NQoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=YBGegqm2fHrZCHEZt7W/w8X5F/h/bUD75IbXg0MUAC8=; b=b8ZrrepI5XanDYbGD85r0RiaOhnx2Nu0+RDwtOiqDJJ13eJkpOZycouNRib2AMVAco 6sfhB4JCOvajhToZT+PfBSzUrtCIUUcdfwWf1Hie/ulP57FhQEZr4ljCUwOV2zyqP0ie EOzqjQtNIrzyuAaEr4ckXDd7Pm7mnDxtzmYUh5bj6JuEv5wmFY/2yq0G904BMxI48kfR RT1n4KMTXqsl2EhmK1q2JtwW34XiH9bolX8Ei8937G0ZoMb1u3Na6dx31KPDy0zlk0P/ v6BUWjuI+1RXzvcFxb1bKx20xtAQnLA5GJbnFNG9PjKaz89WXYA4Rc9btCdNCnlEYJNo 9oPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DINGSdIx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z100si10012351plh.362.2017.10.19.10.09.44; Thu, 19 Oct 2017 10:09:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DINGSdIx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755182AbdJSRJ2 (ORCPT + 27 others); Thu, 19 Oct 2017 13:09:28 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:47576 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755134AbdJSRIz (ORCPT ); Thu, 19 Oct 2017 13:08:55 -0400 Received: by mail-wr0-f196.google.com with SMTP id y39so9050015wrd.4 for ; Thu, 19 Oct 2017 10:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YBGegqm2fHrZCHEZt7W/w8X5F/h/bUD75IbXg0MUAC8=; b=DINGSdIxFJKyvaYda0xywaVbgykideaBsUOsxVZMsHjhAEw/5iMiRD5XBKFXWpOAZk QGYbBtHSBxohjt7eTsBoU/aX+Hxs7V4MWblfHYYNI9sFP230uPBXtRL19vskJk++WqDu EPrtXi3TXq4eYTh5oDPUHYbB5ZJCBZuRNrcbo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YBGegqm2fHrZCHEZt7W/w8X5F/h/bUD75IbXg0MUAC8=; b=n2lGN30TSSoHHaeFZ8IE8hc0wmIiJtdafYg1ZKcb2o1G0kA/E2OVeZ81IuyAgDATpc v/nSvRJAJRJs7PM+1GGtiHfEPd9GpFMcu43SMSpbut90HnwOodn9dnNClZippwKRtiKK FW6bYHUntnDjT7ZpBIhvPEQgiT2TJpe1BbTOLB+V9GwG2fh/EylOO9BaKf+itiWQ+XuV R3XHWYv85d4wcxySyaP1ClI61xLMzW7cN3kSOR7ZTVRPfLGkq3SB4j5WfX19hIVfClDS +RzTQa9G4CKFalsPVCi2gghuL61jOckN5KL7nYgmYeYwa9irFJ/HJx44+3rtuPYwUh6N HG4Q== X-Gm-Message-State: AMCzsaXLnxuoZsRDvorWBHzECDaoiAZ93z1lDxmibICGKnKJuI8ch7PJ c759EBE39R25AkQMIo8A49ME4g== X-Google-Smtp-Source: ABhQp+RZgv3Ds0J2OaMIM18TJHXRgkC3hftWqSQ1O1l8dgwr06As88QHEap3zolI7E/YMcQWMrWfIw== X-Received: by 10.223.150.76 with SMTP id c12mr2336095wra.10.1508432933831; Thu, 19 Oct 2017 10:08:53 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:53 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, Laxman Dewangan Subject: [PATCH 17/18] thermal/drivers/generic-iio-adc: Switch tz request to devm version Date: Thu, 19 Oct 2017 19:05:59 +0200 Message-Id: <1508432760-17847-17-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Everything mentionned here: https://lkml.org/lkml/2016/4/20/850 This driver was added before the devm_iio_channel_get() function version was merged. The sensor should be released before the iio channel, thus we had to use the non-devm version of thermal_zone_of_sensor_register(). Now the devm_iio_channel_get() is available, do the corresponding change in this driver and remove gadc_thermal_remove(). [Compiled tested only] Acked-by: Laxman Dewangan Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal-generic-adc.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c index 73f55d6..46d3005 100644 --- a/drivers/thermal/thermal-generic-adc.c +++ b/drivers/thermal/thermal-generic-adc.c @@ -126,38 +126,23 @@ static int gadc_thermal_probe(struct platform_device *pdev) gti->dev = &pdev->dev; platform_set_drvdata(pdev, gti); - gti->channel = iio_channel_get(&pdev->dev, "sensor-channel"); + gti->channel = devm_iio_channel_get(&pdev->dev, "sensor-channel"); if (IS_ERR(gti->channel)) { ret = PTR_ERR(gti->channel); dev_err(&pdev->dev, "IIO channel not found: %d\n", ret); return ret; } - gti->tz_dev = thermal_zone_of_sensor_register(&pdev->dev, 0, - gti, &gadc_thermal_ops); + gti->tz_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, gti, + &gadc_thermal_ops); if (IS_ERR(gti->tz_dev)) { ret = PTR_ERR(gti->tz_dev); dev_err(&pdev->dev, "Thermal zone sensor register failed: %d\n", ret); - goto sensor_fail; + return ret; } return 0; - -sensor_fail: - iio_channel_release(gti->channel); - - return ret; -} - -static int gadc_thermal_remove(struct platform_device *pdev) -{ - struct gadc_thermal_info *gti = platform_get_drvdata(pdev); - - thermal_zone_of_sensor_unregister(&pdev->dev, gti->tz_dev); - iio_channel_release(gti->channel); - - return 0; } static const struct of_device_id of_adc_thermal_match[] = { @@ -172,7 +157,6 @@ static struct platform_driver gadc_thermal_driver = { .of_match_table = of_adc_thermal_match, }, .probe = gadc_thermal_probe, - .remove = gadc_thermal_remove, }; module_platform_driver(gadc_thermal_driver); From patchwork Thu Oct 19 17:06:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 116421 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp722147qgn; Thu, 19 Oct 2017 10:09:05 -0700 (PDT) X-Received: by 10.84.210.105 with SMTP id z96mr2002387plh.325.1508432945578; Thu, 19 Oct 2017 10:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508432945; cv=none; d=google.com; s=arc-20160816; b=Y3L1aEXiWCsGTsXpXNHRGvtnMMjvHTCo4vYgVem0CEeB9wr6MEQ3D1gz8tOZz1gsgi kwVvAMCSzxyC6ubgeQkurAcIP9MuiSLQi7/GumegGdIFhf3/Kqs8bXKAyenWmfC7SecT eUCBmhhn/eiscOq3etqF1ywvLrDuvtymxLaDDSStnKPcvpxqjn0RUfdAowTmsmtJ6yxK Mi0ixCcWdhwnJKi2FAIxRsZQZl+3xp74PBaubRzs5+Mu5K1LCv2coauJIFdvn/Buucza T1CVutKBtrS4ey+Gk4pjwYjKy6kA1vm0FiGA69pEc7svrTUWeITZNoTerlNw+9eaO3UK LSrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dohuYtmbBQqt09ape1TFhBpj7e534EG+iGnCtAT4Av4=; b=xTJ+d1cAsk4Se0ihlbmKi6HWUcl7pxxwJLYnh4/1GMTwwb5zywlxZW3hQkimC61nRM 3ckbrVqDlV6GzATzezMhPEhOU3qD727H9ZEYX132H7w5yRzHjRNVuSOqzocL5yz1ojYW GIg8WTzm4aYRlhCy/o5UDZnpmoSPKtCyEH+mHx1cvgBRNtJbe/cEQ/GrVNHwmhMDlIYw 5eccRkVKgeSy1I1L7mtDqldSVSIYF37BWW5Oc/wr2pK/hV35KjwWMmVL7RBhdA9cC/Iq /tOGXACiP6Vh1yo061/0kw+/BX7lbfjmRnTpKd/fdVBtRIMVKdl9wXdJS0ZP2Z2LDT0Z NL0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esKQCEuQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w65si9601645pfk.197.2017.10.19.10.09.05; Thu, 19 Oct 2017 10:09:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esKQCEuQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755161AbdJSRJC (ORCPT + 27 others); Thu, 19 Oct 2017 13:09:02 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:57330 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755137AbdJSRI4 (ORCPT ); Thu, 19 Oct 2017 13:08:56 -0400 Received: by mail-wr0-f196.google.com with SMTP id r79so9047793wrb.13 for ; Thu, 19 Oct 2017 10:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dohuYtmbBQqt09ape1TFhBpj7e534EG+iGnCtAT4Av4=; b=esKQCEuQkqKEyEmF/eNmSVCnZ9S1XgTJ+/HBC+KL6t4XTTCqSus681IhFPqMaXFhng Vk7wW39xXRhiWK4KJmx8EMR/WJzMnRZz7POmHvxfm0qtNq4Pt5qne9pTuk26j1cxUvkl ZtwNn0lr7A5W0uxO6p2q4SjTsdRW9dJKp+sDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dohuYtmbBQqt09ape1TFhBpj7e534EG+iGnCtAT4Av4=; b=DuxMwxT96KYiV+aXhQec3c4Npo7G+IYp4lRG6zUXggpnfdRSPFyeKCVgZqyFuLXRm0 gBsfRCKEvq/6W0KWF6/KdVE3ekSk204i4IxP5uXGXnzuxks+nuAB/54Ns73I1/v3c9SZ vq9+86qil2A+JWFvpaZMEiN13Msbxk1EncB3BWMzwOqs9Pg6AOJCZDmvA0vxM3LPpamm +/BTzjofehuMB3Dq/KBBCJCy2V2hUrtr+Y+sA0nu2TpXT+EVfpXAz3f5EHrR8CY5IgRT +OVTT01ls+GwDhlZFTRP6IIMezsqtI1BFAC5wNd6vtmeYP2NXEzDgVClij5VN15/OEXW QT3w== X-Gm-Message-State: AMCzsaVSSxl7l+RndfxVi6hwSbIauz29Qm6myIS330CXUXXbgKglOYjJ mV5Zdsdj96c/QS8g+OIj80TlrA== X-Google-Smtp-Source: ABhQp+RmrvBcvjVSDvFXAROAr8cpS2srEEbHzwmFzyAFXXy/9tBuGAZdfnDlPkH2ruvdXvl1HAa71A== X-Received: by 10.223.177.143 with SMTP id q15mr2419344wra.269.1508432935285; Thu, 19 Oct 2017 10:08:55 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:51c7:d9b7:e14b:6840]) by smtp.gmail.com with ESMTPSA id g16sm14277394wrd.72.2017.10.19.10.08.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 10:08:54 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/18] thermal/drivers/qcom-spmi: Use devm_iio_channel_get Date: Thu, 19 Oct 2017 19:06:00 +0200 Message-Id: <1508432760-17847-18-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> References: <6ac48f08-7fe6-92e9-0801-6ed3bcd05ff1@linaro.org> <1508432760-17847-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The iio_channel_get() function has now its devm_ version. Use it and remove all the rollback code for iio_channel_release() as well as the .remove ops. [Compiled tested only] Signed-off-by: Daniel Lezcano --- drivers/thermal/qcom-spmi-temp-alarm.c | 43 +++++++++++----------------------- 1 file changed, 14 insertions(+), 29 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/qcom-spmi-temp-alarm.c b/drivers/thermal/qcom-spmi-temp-alarm.c index f502419..95f987d 100644 --- a/drivers/thermal/qcom-spmi-temp-alarm.c +++ b/drivers/thermal/qcom-spmi-temp-alarm.c @@ -125,7 +125,7 @@ static int qpnp_tm_get_temp(void *data, int *temp) if (!temp) return -EINVAL; - if (IS_ERR(chip->adc)) { + if (!chip->adc) { ret = qpnp_tm_update_temp_no_adc(chip); if (ret < 0) return ret; @@ -224,67 +224,53 @@ static int qpnp_tm_probe(struct platform_device *pdev) return irq; /* ADC based measurements are optional */ - chip->adc = iio_channel_get(&pdev->dev, "thermal"); - if (PTR_ERR(chip->adc) == -EPROBE_DEFER) - return PTR_ERR(chip->adc); + chip->adc = devm_iio_channel_get(&pdev->dev, "thermal"); + if (IS_ERR(chip->adc)) { + ret = PTR_ERR(chip->adc); + chip->adc = NULL; + if (ret == -EPROBE_DEFER) + return ret; + } chip->base = res; ret = qpnp_tm_read(chip, QPNP_TM_REG_TYPE, &type); if (ret < 0) { dev_err(&pdev->dev, "could not read type\n"); - goto fail; + return ret; } ret = qpnp_tm_read(chip, QPNP_TM_REG_SUBTYPE, &subtype); if (ret < 0) { dev_err(&pdev->dev, "could not read subtype\n"); - goto fail; + return ret; } if (type != QPNP_TM_TYPE || subtype != QPNP_TM_SUBTYPE) { dev_err(&pdev->dev, "invalid type 0x%02x or subtype 0x%02x\n", type, subtype); - ret = -ENODEV; - goto fail; + return -ENODEV; } ret = qpnp_tm_init(chip); if (ret < 0) { dev_err(&pdev->dev, "init failed\n"); - goto fail; + return ret; } ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, qpnp_tm_isr, IRQF_ONESHOT, node->name, chip); if (ret < 0) - goto fail; + return ret; chip->tz_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, chip, &qpnp_tm_sensor_ops); if (IS_ERR(chip->tz_dev)) { dev_err(&pdev->dev, "failed to register sensor\n"); - ret = PTR_ERR(chip->tz_dev); - goto fail; + return PTR_ERR(chip->tz_dev); } return 0; - -fail: - if (!IS_ERR(chip->adc)) - iio_channel_release(chip->adc); - - return ret; -} - -static int qpnp_tm_remove(struct platform_device *pdev) -{ - struct qpnp_tm_chip *chip = dev_get_drvdata(&pdev->dev); - - if (!IS_ERR(chip->adc)) - iio_channel_release(chip->adc); - - return 0; } static const struct of_device_id qpnp_tm_match_table[] = { @@ -299,7 +285,6 @@ static struct platform_driver qpnp_tm_driver = { .of_match_table = qpnp_tm_match_table, }, .probe = qpnp_tm_probe, - .remove = qpnp_tm_remove, }; module_platform_driver(qpnp_tm_driver);