Received: by 10.213.65.68 with SMTP id h4csp528176imn; Tue, 27 Mar 2018 04:11:54 -0700 (PDT) X-Google-Smtp-Source: AG47ELuq05u5tinv34uzenl5PJiW2+7w8ckTdUHBJQsN4IAqaRTrnl6JB30dOHw2HAlTmjXsc19O X-Received: by 10.98.71.211 with SMTP id p80mr18764947pfi.136.1522149114381; Tue, 27 Mar 2018 04:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522149114; cv=none; d=google.com; s=arc-20160816; b=QyCQBbLTV3zAtjxdhoxaodmT/rSfwerbQPrVXhQWztWWWrhHTptk3XgC7G5IgvzjG7 vm/bwgdvMnkYgGNIJBXWuJlBtEzu/5+psk7woIh4FXjyjjuF/Sx1YXPrneXpf6uVAR8B slaLz9oq7XI0mkgdjUvAnLhwf6eeafrahRTanEaLziK5uEgeubuTV08LQCFHuW6ryU7c HW+ZQDqsutcClsI+jiaMJwQepVy0vVpMKK5urrpt22g+NCXiGisMSu1j0e/fi8UrdzsK ZHVTbWoYGNIjA8hO2DrRSRmJxGQqab+ikUG+CqVIk1hIkk3FsFABkjhEmkKqDHWBO8ca LDWw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=YXbw2703AWdKDHxaZ8lagAYeWvW60MCVffXdxGWmnOM=; b=FwfH5JC76w/SGlBeduChPz2E2qYG1gdWkKpzIiDvgFh/pZOgxJd9KBB8Bg/SZQu1lS kPdu2kVufcS5wLl9OmQ/o/5IDqjiPw4wn34S/Nuq+lzourr3MHxX7t+10gALrL6nnxKY LPI3hBjfuGPUdEn+AnUIWxoJAXIYqikD3DjX7xjpw/SWS2mlOxWqMQLPN6sVM1ix/olk QS/oIYBHH9DzSg2bV4HaiuAUtJ6afvzB7jWVDGgtNj85Jg3UkBAeExIOGRHRveUVOP03 o1I+6xJt26q8cF595P+U/RPYJpMaqqHYyvct624hIytFgxQQC7VJZN+zNooKWIiUb288 OK2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SfHkZF8H; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z100-v6si1089228plh.77.2018.03.27.04.11.39; Tue, 27 Mar 2018 04:11:54 -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=@linaro.org header.s=google header.b=SfHkZF8H; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752128AbeC0LKM (ORCPT + 99 others); Tue, 27 Mar 2018 07:10:12 -0400 Received: from mail-wr0-f172.google.com ([209.85.128.172]:33803 "EHLO mail-wr0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbeC0LKK (ORCPT ); Tue, 27 Mar 2018 07:10:10 -0400 Received: by mail-wr0-f172.google.com with SMTP id o8so21982366wra.1 for ; Tue, 27 Mar 2018 04:10:10 -0700 (PDT) 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=YXbw2703AWdKDHxaZ8lagAYeWvW60MCVffXdxGWmnOM=; b=SfHkZF8Hztg8TXmju5bgqgOFX/smoWh1UQBvXlSoAuz3k69QZJ3xF6kTUiY/Dm9Hf1 qA9aWasLglli5jGgg4E1+u11afy9Ta4eS1wwUY9nn0YUdYnntMiGITIi5IlSdiMGodaW 8lZKDx8uJyWd/OCEeVLFjNuwJI8iX6BhBu3og= 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=YXbw2703AWdKDHxaZ8lagAYeWvW60MCVffXdxGWmnOM=; b=QSXrxbf6qCg4XLLhXe0tLW00ZlvMAiUgg/NbrjI7yfL2/PZKC6ledqTVD+QzgrVbcZ dMkMaKWkoUX1GXANLQw08rlUJSi2rH/Ygg7nMQQT6ImnitzPMx/mEQOI6IgrcuiU4QzR sAAOT7TdXwi3mBFDSaI3DziMapnu8AWFDCBE/kgA9z0lWu7qHjo2eB+Zoj+cywvG1zTI siF6/+7/Tnv4mtSg5Ti9ztKOjFZFWH3tlVKezbht+k3qfR5Z5NmMPdRCKYwXHVjAJPCu oQsuAewsHtkrKFwVBYAWPe9c+5Vn2+bsg3yhEhisLQkC1nMp92kQSwyCtcz62K1gSLfa OJVw== X-Gm-Message-State: AElRT7H6Bsn8eKWnVYzP1zMTu5sA+qXBic/KkasGg5KBNeniSnRo5D1+ nXVTqcoI32AdP7o4UAq6LA3IjQ== X-Received: by 10.223.168.7 with SMTP id l7mr14940093wrc.77.1522149009320; Tue, 27 Mar 2018 04:10:09 -0700 (PDT) Received: from ?IPv6:2001:41d0:fe90:b800:b0a9:da92:8c72:d9e2? ([2001:41d0:fe90:b800:b0a9:da92:8c72:d9e2]) by smtp.googlemail.com with ESMTPSA id q90sm2803216wrb.6.2018.03.27.04.10.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 04:10:08 -0700 (PDT) Subject: Re: [PATCH V2 6/7] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver To: Leo Yan Cc: Viresh Kumar , edubezval@gmail.com, kevin.wangtao@linaro.org, vincent.guittot@linaro.org, amit.kachhap@gmail.com, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org References: <1519226968-19821-1-git-send-email-daniel.lezcano@linaro.org> <1519226968-19821-7-git-send-email-daniel.lezcano@linaro.org> <20180223073432.GF26947@vireshk-i7> <20180327034344.GC21693@leoy-ThinkPad-X240s> From: Daniel Lezcano Message-ID: Date: Tue, 27 Mar 2018 13:10:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180327034344.GC21693@leoy-ThinkPad-X240s> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/03/2018 05:43, Leo Yan wrote: > On Fri, Feb 23, 2018 at 12:28:51PM +0100, Daniel Lezcano wrote: >> On 23/02/2018 08:34, Viresh Kumar wrote: >>> On 21-02-18, 16:29, Daniel Lezcano wrote: > >> [ ... ] >> >>>> +static s64 cpuidle_cooling_runtime(struct cpuidle_cooling_device *idle_cdev) >>>> +{ >>>> + s64 next_wakeup; >>>> + int state = idle_cdev->state; >>>> + >>>> + /* >>>> + * The function must never be called when there is no >>>> + * mitigation because: >>>> + * - that does not make sense >>>> + * - we end up with a division by zero >>>> + */ >>>> + BUG_ON(!state); >>> >>> As there is no locking in place, we can surely hit this case. What if >>> the state changed to 0 right before this routine was called ? >>> >>> I would suggest we should just return 0 in that case and get away with >>> the BUG_ON(). > > Here if 'state' equals to 0 and we return 0, then the return value will > be same with when 'state' = 100; this lets the return value confused. > > I think for 'state' = 0, should we return -1 so indicate the hrtimer > will not be set for this case? Yeah, I will look at how to make this smoother. Thanks -- Daniel -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog