Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3226195yba; Mon, 22 Apr 2019 23:18:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYnRgPDTNd+BpwmnVKHFcqxpqRK+bAT1LJhlqBo7UoWHhZ2C93wyr476PFASsPzYRBkim2 X-Received: by 2002:a63:2b03:: with SMTP id r3mr22476982pgr.105.1556000288769; Mon, 22 Apr 2019 23:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556000288; cv=none; d=google.com; s=arc-20160816; b=MwmcbVjd8SqS7ruKle6Zjz5VaPZHsa3LHuEMhVJ7cfEiIZ+FVOpXNNHdlwGeowabuD Uv0OzqUMY0gXQ52uYGzXwAra/V4yxJN/j5ORktgCVuxvNH+Bez1JpJmYmaQcO37BjUsx NsOn3gGGII+WvLW3pGbw4lFfbBbAuGsqQ58Wdwx2cC9P9BAXXeW9z3T2+7e8XoTBAKwF 8h+LGOAvHP29IEeo9Aamzfai8nR/DZtK8T+Elj9i5XuJ4SfmJ1t4rCrEiAJC/S6GZS0R Q/i6yZGOoCVfhAHtfKncGUQA8Jo6dgu1xZmN4O5DY/lWJWbuBJkSCTloviCSukORyHkI Lkww== 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; bh=Y88oAn1iSd4+Se0xUGJEvU+QxPDIHvx9vbdAk7Qmx9w=; b=zoqvNu7TfqcNqowc84KJxIEV1/hMhEJKlC9PFUDK4SsAiUa2q9ANIHYrITcFoUsvRv QplesScxyh4IHCrNh5rX2hEC5QFC+ebI6tc+o4juB+tHDKtQvcOcam5KrcH56REUay/a +d8A2NpGmcmVAtSCLXnLmhBA3ojEnTJ/RqH0Mo/9Sjcj+Dl1qYW4B7TeK5vegpIqUS40 rTsc5HTKwNzMe6gseee9Q+O7LcrJk69MqRaSr7en6oV+l1rU1JQbIvgas8Yt7M2zr5if 3QU6SvcwAYdq9CnNJgHs3vuJWbbWMJvceCZn4ST0D6SocZRIfMG5EtPdXZAXYSBholnA Oekw== 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 127si16304499pfz.28.2019.04.22.23.17.52; Mon, 22 Apr 2019 23:18:08 -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 S1726157AbfDWGPf (ORCPT + 99 others); Tue, 23 Apr 2019 02:15:35 -0400 Received: from mga14.intel.com ([192.55.52.115]:19207 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725888AbfDWGPf (ORCPT ); Tue, 23 Apr 2019 02:15:35 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Apr 2019 23:15:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,384,1549958400"; d="scan'208";a="318152017" Received: from rzhang-dell-9360.sh.intel.com ([10.239.161.125]) by orsmga005.jf.intel.com with ESMTP; 22 Apr 2019 23:15:32 -0700 Message-ID: <1556000129.26198.50.camel@intel.com> Subject: Re: [PATCH] thermal: core: skip update disabled thermal zones after suspend From: Zhang Rui To: Wei Wang Cc: Wei Wang , Eduardo Valentin , Daniel Lezcano , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 23 Apr 2019 14:15:29 +0800 In-Reply-To: References: <20190416170701.50333-1-wvw@google.com> <1555923800.26198.30.camel@intel.com> 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 一, 2019-04-22 at 09:44 -0700, Wei Wang wrote: > On Mon, Apr 22, 2019 at 2:03 AM Zhang Rui > wrote: > > > > > > On 二, 2019-04-16 at 10:07 -0700, Wei Wang wrote: > > > > > > It is unnecessary to update disabled thermal zones post suspend > > > and > > > sometimes leads error/warning in bad behaved thermal drivers. > > > > > a good catch, and in fact, there are more issues about thermal > > handling > > for disabled thermal zones, like we're able to read the temperature > > of > > disabled thermal zones, either via sysfs or via function calls like > > thermal_zone_device_update. > Thanks Rui for following up. Yes, we noticed the same behavior. Right > now, individual thermal driver can still respect set_mode and present > value meaningful or return error when thermal zone disabled, and > that's what we do locally. > Currently, sysfs-api documents "Preventing kernel thermal zone driver > actions upon trip points so that user application can take full > charge > of the thermal management.", so is it intended for some other agents > in kernel or user land polling temperature with function call or > sysfs > respectively? hmmm, here we have three cases, 1). we can read the temperature and we can take cooling actions. 2). we can read the temperature only 3). we can not read the temperature we do have a case for 3), e.g. the wifi device, which registers a thermal zone, but it does not work if wifi firmware is unloaded. And IMO, we should set the thermal zone mode to disable for this case. I'm not sure if there is any case for 2), but if we do, it seems to me that we should set its governor to nop, rather then the way we're describing in the sys-abi file. we should fix the code and doc to use "mode" attribute to handle case 3) instead. thanks, rui > > Thanks! > -Wei > > > > For this patch, I will take it as it fixes one of the problem. > > > > thanks, > > rui > > > > > > > > Signed-off-by: Wei Wang > > > --- > > >  drivers/thermal/thermal_core.c | 8 ++++++++ > > >  1 file changed, 8 insertions(+) > > > > > > diff --git a/drivers/thermal/thermal_core.c > > > b/drivers/thermal/thermal_core.c > > > index 6590bb5cb688..5baf5cfab999 100644 > > > --- a/drivers/thermal/thermal_core.c > > > +++ b/drivers/thermal/thermal_core.c > > > @@ -1494,6 +1494,7 @@ static int thermal_pm_notify(struct > > > notifier_block *nb, > > >                            unsigned long mode, void *_unused) > > >  { > > >       struct thermal_zone_device *tz; > > > +     enum thermal_device_mode tz_mode; > > > > > >       switch (mode) { > > >       case PM_HIBERNATION_PREPARE: > > > @@ -1506,6 +1507,13 @@ static int thermal_pm_notify(struct > > > notifier_block *nb, > > >       case PM_POST_SUSPEND: > > >               atomic_set(&in_suspend, 0); > > >               list_for_each_entry(tz, &thermal_tz_list, node) { > > > +                     tz_mode = THERMAL_DEVICE_ENABLED; > > > +                     if (tz->ops->get_mode) > > > +                             tz->ops->get_mode(tz, &tz_mode); > > > + > > > +                     if (tz_mode == THERMAL_DEVICE_DISABLED) > > > +                             continue; > > > + > > >                       thermal_zone_device_init(tz); > > >                       thermal_zone_device_update(tz, > > >                                                  THERMAL_EVENT_UN > > > S > > > PECIFIED);