Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp204763imm; Thu, 26 Jul 2018 01:56:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdOw2HH+sIgQhXec8qCJHUZ1zqNe3XbeM5oBMeFRYKmYCjoTOlI8Y5rm+CsCQgipVQJ16DH X-Received: by 2002:a63:91c8:: with SMTP id l191-v6mr1094506pge.180.1532595385914; Thu, 26 Jul 2018 01:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532595385; cv=none; d=google.com; s=arc-20160816; b=SzuHsdswKPQGU3WvTytWN/pCa+2IW5cRBMbF6Pyi8/055mB5AV1cg6HSoyJV4zU1wD xVy1VnvvfagZWxwEZhPpXILcz2ca7CcJzKvTykzRC94pS/HJOjhQqA6WZHbH5NpWc2hA wyBm7LlFivAazrc2qav5bZmokhEgMYw/R/FDF4YI5LXG3iNnulfpZ4IDntBME+Z8+Zma le4tE9keWfucofQ7iFEZs2s6N5zi1spePyPn6bpQNgRqwFemWJZLGncJcTBggx+QC/Re TuOxCtKoS6MhCfaTo9pCuztCm2VHblJOr4BgHtZsFBhns76LBZyQ5x6k7fR+vmKZO404 v1hw== 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:date:cc:to:from:subject:message-id :arc-authentication-results; bh=GNb+wx0quT8epibSXXEIH1JvJ27Aid6txg9V+B8cUA0=; b=c7/TI/kEnCFuywG10hKhImUELkL+Gz5iUh6cL5nSteKqPJAgDPJnpAdcI2Bbv1hp8j at0FW851UadJp6w+3j4PHAHOWNpBquRUUDGmc7RQkOGiWfMF6IACkhEreDk35oS0lXnj EYFDXNUgSFMt/FlHe+zpARZHuaomvr3xCma51NIGhtX0BYep/rP/wi+dLGjLYNry7SsF cCF9UPC6ao7wJBEusMx1cl01d5G2opGC93Q2iG+WSBdEWPc9DZz/4h34oSPYyXUD6XyO TRwrY+ppV7O0JwAI4pX8c+bzwdIke37aAiaJxSsF3sdxPb8EU5FKBiJSDbJMhcYO2NyN UQmw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e93-v6si803091plb.135.2018.07.26.01.56.10; Thu, 26 Jul 2018 01:56:25 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729111AbeGZKLM (ORCPT + 99 others); Thu, 26 Jul 2018 06:11:12 -0400 Received: from mga12.intel.com ([192.55.52.136]:52026 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728968AbeGZKLM (ORCPT ); Thu, 26 Jul 2018 06:11:12 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2018 01:55:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,404,1526367600"; d="scan'208";a="74658209" Received: from taolv-mobl.ccr.corp.intel.com ([10.249.169.42]) by fmsmga004.fm.intel.com with ESMTP; 26 Jul 2018 01:55:10 -0700 Message-ID: <1532595308.2358.45.camel@intel.com> Subject: Re: [PATCH] drivers: thermal: do not clobber cooling dev state from userspace From: Zhang Rui To: Lina Iyer , edubezval@gmail.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Date: Thu, 26 Jul 2018 16:55:08 +0800 In-Reply-To: <20180507175505.2389-1-ilina@codeaurora.org> References: <20180507175505.2389-1-ilina@codeaurora.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 一, 2018-05-07 at 11:55 -0600, Lina Iyer wrote: > 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. > hmmm, I don't understand this. If the governor does not work well, we should either improve the governor or use userspace governor instead. do you have any examples that the kernel governor chooses improper cooling state? thanks, rui > 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 {