Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2169157pxu; Fri, 18 Dec 2020 07:07:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAMxa/8g9suoIOFa+uFwi/ZlzfWBN4lzzGu4JclagxRBCuIDG6HX1fo9O3rONxwnbcyMeg X-Received: by 2002:a17:906:6d0b:: with SMTP id m11mr4346252ejr.230.1608304024546; Fri, 18 Dec 2020 07:07:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608304024; cv=none; d=google.com; s=arc-20160816; b=dpicqUtrh6feCY8NaC2mX/0DJ7+DCxgk/+iZNREns1qVnM213TYfi22MYSXqdxMZOJ 3Anuq5aXCKvS0hrlnFd+IFIIQBa2E0LaFOtAETDtJH9yNf07Iv77jnJP6Sp9jaRz3LTP W7bQ9Qrjt47YcinqzY9WSWaPeQ3tV/dLUm1Wll4aPWHW3D1ylNlbSI4Nyi7pGRahb359 2OxXNgKfVzzilOmBxp9blECG+bwJSKv8KcTS/WEZ4u4EBPoyQye7pnhYqEcAZw6+TcbK isc45aRLwWIP9eJCcRcpi8xNcF3bkfdCXsZTGntxYe4c7J9gFSIi96L6XD/FpXCdbx/l lOig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=oNg9fsqgN01iZDjFmGDppzyqEcee51C5C07Q60xgAD8=; b=DQ96+Yu0F0gqjvLCGGghP4E5NEGodLsV4I3616RzkubUEpnIjwSXlhqQY+ae0sPxFq nvI/zneBkWu7DfCM0kjzkSKR81IIljlqNwzLTqPv4A6rriMx8BTIGQkmRXWzlyxAo4jU MnnVySTId42jlCp5D9bjVLCCLwZV36w7xZmVkH6ydPfXSQKzMO8bnML6+HGJutMEpt7I JJRX0GpGWasbft7pj5ifH704yJgZc9ADC2ugjANNskqE3Xf/WSFoExbxkyMRkChAfV/O UgxKe1jsa7zEa2BK43cA0YHcgL4rKstHk4hdQKwJ7T9EoIpL/DhTgvjqghD/rmq014vu p4Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GOxEeLjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id t26si4691831eji.212.2020.12.18.07.06.42; Fri, 18 Dec 2020 07:07:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GOxEeLjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727531AbgLRPG2 (ORCPT + 99 others); Fri, 18 Dec 2020 10:06:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726677AbgLRPG1 (ORCPT ); Fri, 18 Dec 2020 10:06:27 -0500 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FD60C0617A7 for ; Fri, 18 Dec 2020 07:05:47 -0800 (PST) Received: by mail-qk1-x733.google.com with SMTP id c7so2246106qke.1 for ; Fri, 18 Dec 2020 07:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=oNg9fsqgN01iZDjFmGDppzyqEcee51C5C07Q60xgAD8=; b=GOxEeLjpPQyQV9lrjpq19FcBzloQtCxYDK8Znr7NnsLOS3t9R9HEFQc9ArER8I97P4 WQ9cA5VURzeXEeM5EcTOk1uwhrcpj4Z371c0d3DCceg7oRSw8YTufT1AzM+XplyTez58 1wJW28vMdE/Ya4pZ4ExLHg+pVilmRqDnq/S2W9ULGb2JSsHJJLTs4BVd9Vc2Mzz5nCOF 3HJOqZ3ufTUybpavulfzR46IOt91JBQLNBhUFAyIWS3i7ZZUJ3hs5JoG/B052KY7Dudv G7q4Pnyn8RUXQLKr6gc3HX0vdDp4/UnmlhwEEI2Rc5rpR/hL2GehXlIAtOsxx0YgNvQo sIhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=oNg9fsqgN01iZDjFmGDppzyqEcee51C5C07Q60xgAD8=; b=g/uK08TeicT/mNCB+5Zrp2ZP46Gu/c7v5OM3g1+S67nFSUYSaA+3/1jFUrmfX71b4s miEGodBu1Dny4q14gZ0+Zf3I8mOI3sGYnRAGSlxXzQw10mLF5d0uf01yGZMjpoQEyYAH 88xfNEIdnxMYOeB83U3CHY7b+6dYxjK+LCzcYu2xJ49VVwzzxca4Y7jgHtk5/YhzOnXm EmdD20C+BuH0RlvZoXVJFRPMpCKgUKtrKXelhoy7w1MF+HYjW+2KMn6fwRPSwXP3QN8V xrKHUgvS94t24XAXrhVmqyIyBiClGtbTCWYC0xFKw5WcfCBhhzr/rUevO7NxrwyLQNfI oFog== X-Gm-Message-State: AOAM531D+r/Kf/b+k6xNYNVSgMZ5mabD63hG/wGxxJlbtNts0Scnux0v qJwuakP0csS9QKnvyJu2m6yCIbexLc+MjA== X-Received: by 2002:a37:a64b:: with SMTP id p72mr5312567qke.304.1608303946528; Fri, 18 Dec 2020 07:05:46 -0800 (PST) Received: from [192.168.1.93] (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.gmail.com with ESMTPSA id s21sm5377130qtn.13.2020.12.18.07.05.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Dec 2020 07:05:45 -0800 (PST) Subject: Re: [PATCH v2 1/3] thermal/core: Precompute the delays from msecs to jiffies To: Daniel Lezcano , rui.zhang@intel.com Cc: amitk@kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Lukasz Luba References: <20201216220337.839878-1-daniel.lezcano@linaro.org> From: Thara Gopinath Message-ID: <6a57bf9a-c4f4-2350-8bd2-01717d966611@linaro.org> Date: Fri, 18 Dec 2020 10:05:44 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201216220337.839878-1-daniel.lezcano@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/16/20 5:03 PM, Daniel Lezcano wrote: > The delays are stored in ms units and when the polling function is > called this delay is converted into jiffies at each call. > > Instead of doing the conversion again and again, compute the jiffies > at init time and use the value directly when setting the polling. > > Cc: Thara Gopinath > Signed-off-by: Daniel Lezcano > Reviewed-by: Lukasz Luba > --- > drivers/thermal/thermal_core.c | 3 +++ > drivers/thermal/thermal_core.h | 1 + > drivers/thermal/thermal_helpers.c | 7 +++++++ > include/linux/thermal.h | 7 +++++++ > 4 files changed, 18 insertions(+) Reviewed-by: Thara Gopinath > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index bcc2ea4f5482..2c41d4a0923f 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -1315,6 +1315,9 @@ thermal_zone_device_register(const char *type, int trips, int mask, > tz->passive_delay = passive_delay; > tz->polling_delay = polling_delay; > > + thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); > + thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); > + > /* sys I/F */ > /* Add nodes that are always present via .groups */ > result = thermal_zone_create_device_groups(tz, mask); > diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h > index e50c6b2909fe..90f9a80c8b23 100644 > --- a/drivers/thermal/thermal_core.h > +++ b/drivers/thermal/thermal_core.h > @@ -123,6 +123,7 @@ int thermal_build_list_of_policies(char *buf); > > /* Helpers */ > void thermal_zone_set_trips(struct thermal_zone_device *tz); > +void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms); > > /* sysfs I/F */ > int thermal_zone_create_device_groups(struct thermal_zone_device *, int); > diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c > index c94bc824e5d3..7f50f412e02a 100644 > --- a/drivers/thermal/thermal_helpers.c > +++ b/drivers/thermal/thermal_helpers.c > @@ -175,6 +175,13 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz) > mutex_unlock(&tz->lock); > } > > +void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) > +{ > + *delay_jiffies = msecs_to_jiffies(delay_ms); > + if (delay_ms > 1000) > + *delay_jiffies = round_jiffies(*delay_jiffies); > +} > + > static void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, > int target) > { > diff --git a/include/linux/thermal.h b/include/linux/thermal.h > index 060a2160add4..d1b82c70de69 100644 > --- a/include/linux/thermal.h > +++ b/include/linux/thermal.h > @@ -117,9 +117,14 @@ struct thermal_cooling_device { > * @trips_disabled; bitmap for disabled trips > * @passive_delay: number of milliseconds to wait between polls when > * performing passive cooling. > + * @passive_delay_jiffies: number of jiffies to wait between polls when > + * performing passive cooling. > * @polling_delay: number of milliseconds to wait between polls when > * checking whether trip points have been crossed (0 for > * interrupt driven systems) > + * @polling_delay_jiffies: number of jiffies to wait between polls when > + * checking whether trip points have been crossed (0 for > + * interrupt driven systems) > * @temperature: current temperature. This is only for core code, > * drivers should use thermal_zone_get_temp() to get the > * current temperature > @@ -155,6 +160,8 @@ struct thermal_zone_device { > void *devdata; > int trips; > unsigned long trips_disabled; /* bitmap for disabled trips */ > + unsigned long passive_delay_jiffies; > + unsigned long polling_delay_jiffies; > int passive_delay; > int polling_delay; > int temperature; > -- Warm Regards Thara