Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4126812yba; Tue, 23 Apr 2019 15:53:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVHeMtx7F1LivPPiLdkQ9gsGMw4kJqr0stePleunm0mmDhKW5GS+9rkL56B2baAgOCeG0S X-Received: by 2002:a65:5181:: with SMTP id h1mr5411196pgq.167.1556060006843; Tue, 23 Apr 2019 15:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556060006; cv=none; d=google.com; s=arc-20160816; b=Y/y4m7AL2KVj/m5YklgIGde+7i6I4GmOrtekSomPM8S39m+zRQfrPBvW9mHLodHIzV CdJccrRfB++Wg8QNYeczaw4lHhTmmyfIamgVCYGRAp811Hlxg/PVmRVWelPo0rfhremE htL3GSlRwslxohGsmhJaYLKupmLOi1ebuoFNvZhiNJ0giqkt+rmatz+lRQ5oMwL/3v0X AaOGivEpOsjfwjrEnVNxCqWXLfovMqbGVr/YWKeyOZ048DIMGysW4Hkdmc0FaAabCbh0 kjJ62rQxEJMY17fnDvezTj7r/s+M/narsF5caGFB+b7Hm6rjDH9m61WAgzFIK95t2713 l1Zg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Azihi0+y+0A9GqQQKlVvEfb9wIg0Y4clL04ZCREwPkY=; b=xY4rGp7sthIl0vt0/fyRSnSoEf7HIkXRKmbwOeG8yD/Vzbb4S6Ew4UKPvNSnHEs986 QTBAkqGEl3/wNhFOEfgfiYs+35wP+0GTrszJ4YwlID942kbTCCc0wGQDuuXGhaGBDomd bg7iU3GkNbeABNqLb3dgYrB4OYz+olesWaslyBRoL7kA7CK0/HN4qFBfFLMpvF8rpnSv n7/oZTrLeS2ijca46iUIlPqw10cy5/eLnT+BjQUFajIFp5wRXq1zVfnYZZhhRmG9EJ4c RiTU3EKtpteLLsoY1TwEEpbT3EOzbdq57UcAZx3I5sikvX31oGzTVtLMUhKUGSnz5Ok4 7/yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DBJgJ3JF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si16989434pff.3.2019.04.23.15.53.11; Tue, 23 Apr 2019 15:53:26 -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=@google.com header.s=20161025 header.b=DBJgJ3JF; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728576AbfDWWvK (ORCPT + 99 others); Tue, 23 Apr 2019 18:51:10 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:33557 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbfDWWvK (ORCPT ); Tue, 23 Apr 2019 18:51:10 -0400 Received: by mail-ed1-f65.google.com with SMTP id d55so14189036ede.0 for ; Tue, 23 Apr 2019 15:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Azihi0+y+0A9GqQQKlVvEfb9wIg0Y4clL04ZCREwPkY=; b=DBJgJ3JFtWrhy6k9uAuDJH1eTtTuqdpkfE62I2fdCmymaSazbsb9HkLkhe+94dUSHL dPdG0lEPRDlK9G005sQJCiSAlaDdUS9TGpd731NTC/aKLaDjl4W6ulM+cRg9wbJd27PK bsXEsFTcqn8gNGHcaS78nfgzY4dw5UjEvmrvpRsUiVTL5+CAogclUPigxD8sO1ehHi/d fBESRTO6Ts73/CXNm7xcFe5t/NHJg7ew8COCVnivHCbOlZQJKBw/w1bpi1B5Dt7aWcQt Uu1F7Fs2caWVvLGN9CCf7Ii+nbQmpir9ZzZQc5SUEWG+v9mPFZkj8ba5ibmYYydO1STg /3kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Azihi0+y+0A9GqQQKlVvEfb9wIg0Y4clL04ZCREwPkY=; b=dJhwPW7Iq16r4IK2hj0ClgflwPsDKXmTdXJzCUCb5dnISV8VMfSHdegxOkd9+ntnAb lS8VyBPX83ltfnqqpIvL0Iy8EHpfoSzVy+5cgBoLAQpLgl5QKp0TZlU1wmxNom/RKrho Eihs45cnYJU1x/tAyn147j9SfMQsBWihNbpI8JEfJxNrMd2jYA4hCA5Sagt6dH1oR1nH sNlZjMCKGa9P6GxLdFQFShTGlTNPq78XHKONAcYdPGv1lLDgqthUYLhiWmGSwnycZZ2n gEMuUrZIW49dQ65p5yNE36/jPuLqiFlLtFzwE5Bgymj6kVrCY3BUDRc6TlFnu5eyTjzt tcXA== X-Gm-Message-State: APjAAAUmr4snBeAuop63RJ+vueetFES98jdcKwtk0H+A2kSSMIEl086N BoKWXtn9ajGWpeVbLAsNLUInymKJEskV8vCKOtFLUQ== X-Received: by 2002:a50:b265:: with SMTP id o92mr18010685edd.221.1556059867217; Tue, 23 Apr 2019 15:51:07 -0700 (PDT) MIME-Version: 1.0 References: <20190416170701.50333-1-wvw@google.com> <1555923800.26198.30.camel@intel.com> <1556000129.26198.50.camel@intel.com> In-Reply-To: <1556000129.26198.50.camel@intel.com> From: Wei Wang Date: Tue, 23 Apr 2019 15:50:53 -0700 Message-ID: Subject: Re: [PATCH] thermal: core: skip update disabled thermal zones after suspend To: Zhang Rui Cc: Wei Wang , Eduardo Valentin , Daniel Lezcano , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 22, 2019 at 11:15 PM Zhang Rui wrote: > > On =E4=B8=80, 2019-04-22 at 09:44 -0700, Wei Wang wrote: > > On Mon, Apr 22, 2019 at 2:03 AM Zhang Rui > > wrote: > > > > > > > > > On =E4=BA=8C, 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. Agree. Another thought of suspend/resume case is in mobile world, most of the thermal zone sensors are interrupt capable and the linked cooling devices are platform cooling devices whose states won't be affected during suspend. So resetting each thermal zone during suspend/resume just wasted cycles/power on mobile due to re-setting trip threshold again and again and also delays in device resume. I am proposing that we have a flag in device tree per thermal zone to let thermal core not reset during suspend/resume. > 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. +1 noop sounds good. Do you have plan to change it? > > 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 =3D THERMAL_DEVICE_ENABLED; > > > > + if (tz->ops->get_mode) > > > > + tz->ops->get_mode(tz, &tz_mode); > > > > + > > > > + if (tz_mode =3D=3D THERMAL_DEVICE_DISABLED) > > > > + continue; > > > > + > > > > thermal_zone_device_init(tz); > > > > thermal_zone_device_update(tz, > > > > THERMAL_EVENT_UN > > > > S > > > > PECIFIED);