Received: by 10.192.165.148 with SMTP id m20csp3361391imm; Mon, 7 May 2018 10:55:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpRzoVifjXja8CGsalELKBhBdTMaP/Oww+qgPJ7EhMt6UhLJjZpmluba0oEGOfhGp6HN3QL X-Received: by 2002:a9d:8a3:: with SMTP id 32-v6mr7491764otf.208.1525715747370; Mon, 07 May 2018 10:55:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525715747; cv=none; d=google.com; s=arc-20160816; b=gv7cO5ebX4BM59mUJr9TFFgH/YXfKONjEsGUirSl/w44a51U85cUqQYg8+jLUr2jQn hKqPrCD9WY0GfyPcobMrS2vLRtantz1tMf8PX/vLxh1f9DcSVQOeqdePM07IDmgxCPNH HDyw6cTwN5TkB+sCaKcyr+TztyI2WULdbMDx5/CO1hnJzbsPV1YHyPhz2wvc0HqKjmwt mEocTBurZkjnuNydumScQsjjbLKK4bHMtpfGqPDkfcoDRbZEVvZ8m1LiaO8AtxBeVUsY D3bBrKQm0CiVMEF6vq3sbiJeCGfnTTWDqHUkX0NalpWpHdNZSzTst2t9wtKLnd1Zg6nc NFBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=t69HqHe/+Tx3AWKm196x7FIsZ3u7BPu3D6uFguzQFaw=; b=uaSZdoVtEq0dGMpZwm5KEh1wfWWhdFBZLvUy0x3ivJLg08StWTHKo7+3/rmjM8pHW7 IMv8BNa6yf6pYG/ad5Bqb7sRTVd8GZa7Z+v8XAPiHjTWGRp7vhXt1Te9H9isEmETxHoI TfrAQGmTDsS7OeCzpK8mM1DKwU0ZmzzAEu/JZEbft3oTtOcr0CsUCRfWfxfszn7DygJs yHY9NxFrWkxuD7devnJPICN2w9XuI9Xhr4lauf7KduAWMXQuaPnC4zxFC1/PBLTWbhnJ 3SEW5u3Sbc4Os68NdUlY2joDGQ4ryCUm6jAELp3ZVndMcE6IN879g2Egq81tJT6mPE8K rDbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=ZtfWdppf; dkim=pass header.i=@codeaurora.org header.s=default header.b=nLFV1Sbb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j76-v6si7731835oih.101.2018.05.07.10.55.33; Mon, 07 May 2018 10:55:47 -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=@codeaurora.org header.s=default header.b=ZtfWdppf; dkim=pass header.i=@codeaurora.org header.s=default header.b=nLFV1Sbb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752797AbeEGRzN (ORCPT + 99 others); Mon, 7 May 2018 13:55:13 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:50166 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbeEGRzL (ORCPT ); Mon, 7 May 2018 13:55:11 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 37E2E60115; Mon, 7 May 2018 17:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525715711; bh=3EzRdOZ2+X3WhEolivtIfeevTyNlMt8WVwQ5HpEWeZg=; h=From:To:Cc:Subject:Date:From; b=ZtfWdppfrOG0v1kXo9t8DmqQWFQgkts7aPSECkgeSvnnI6ERINZ9yYL808n3PIQLW uO5dbC9rbVifo42IMJhxxcgtwnP8fVbLagEu2J0iYeBvhjXNdY9WgdoIol7Z3wkRvg ZHz6KvTsYp4A28l1IrCF7QIvttnYOQ5662azLGaY= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from codeaurora.org (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ilina@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id EFFA26022C; Mon, 7 May 2018 17:55:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525715710; bh=3EzRdOZ2+X3WhEolivtIfeevTyNlMt8WVwQ5HpEWeZg=; h=From:To:Cc:Subject:Date:From; b=nLFV1SbbzHjEv4YtRhEGTzOt45sVOAPHXmeUyO4yuCVzQiKE0t2jMAvfc6/x5IjxK BAe9DHJ7c6QFa/0n5ZnQwrGQqSLrvjex7BM0d8doVQpwfeKYkJxhMTmKHizpquNd9q /IYrb5bKrhagE/WC4xoWQuIPbSFZGEcSRUDf1cTM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org EFFA26022C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=ilina@codeaurora.org From: Lina Iyer To: edubezval@gmail.com, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Lina Iyer Subject: [PATCH] drivers: thermal: do not clobber cooling dev state from userspace Date: Mon, 7 May 2018 11:55:05 -0600 Message-Id: <20180507175505.2389-1-ilina@codeaurora.org> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ram Chandrasekar Let userspace be another voter for cooling device state instead of the overriding authority. It is possible that the thermal governor may find a higher cooling state desirable than what is recommended by the userspace. Separate out the current cooling device state from the userspace request and aggregate the userspace request with the governors' recommendation. Signed-off-by: Lina Iyer --- drivers/thermal/thermal_core.c | 1 + drivers/thermal/thermal_helpers.c | 2 +- drivers/thermal/thermal_sysfs.c | 8 +++++++- include/linux/thermal.h | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 589925ac0994..c2e13e122934 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -970,6 +970,7 @@ __thermal_cooling_device_register(struct device_node *np, cdev->updated = false; cdev->device.class = &thermal_class; cdev->devdata = devdata; + cdev->sysfs_req = 0; thermal_cooling_device_setup_sysfs(cdev); dev_set_name(&cdev->device, "cooling_device%d", cdev->id); result = device_register(&cdev->device); diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c index 2ba756af76b7..f550fdee0f9b 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -166,7 +166,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_set_trips); void thermal_cdev_update(struct thermal_cooling_device *cdev) { struct thermal_instance *instance; - unsigned long target = 0; + unsigned long target = cdev->sysfs_req; mutex_lock(&cdev->lock); /* cooling device is updated*/ diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 275ffee292bf..eddada715ad2 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -719,7 +719,13 @@ thermal_cooling_device_cur_state_store(struct device *dev, result = cdev->ops->set_cur_state(cdev, state); if (result) return result; - thermal_cooling_device_stats_update(cdev, state); + + cdev->sysfs_req = state; + mutex_lock(&cdev->lock); + cdev->updated = false; + mutex_unlock(&cdev->lock); + thermal_cdev_update(cdev); + return count; } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 5f4705f46c2f..7a133bd6ff86 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -139,6 +139,7 @@ struct thermal_cooling_device { struct mutex lock; /* protect thermal_instances list */ struct list_head thermal_instances; struct list_head node; + unsigned long sysfs_req; }; struct thermal_attr { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project