Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp386236pxk; Thu, 17 Sep 2020 05:56:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3KEnJLxk1T8V56yq1uvKlXBBCDDJBrrp/p5F5e82jpWIjkj8ymrEfcZHn53Bs9yfdq6Pf X-Received: by 2002:aa7:d981:: with SMTP id u1mr32028910eds.250.1600347401706; Thu, 17 Sep 2020 05:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600347401; cv=none; d=google.com; s=arc-20160816; b=gdPravzHTfbbC3VLj5VwO7JE7u5v0Jgc2gKne+ZaPL4F4b3ob6rwtYu7hKY8qjdNxk QU3tm4Hv4CG+wcJORoWpRd0zIFQ2DkGTmcwHn/LDT30qGena+7mB5khNVARtmkmgpCCX QTepWqjz2n5VIyBP4lE55n9wUPa3X4+zAhK+Qt9rFnPaBRHIQAlY4xQ2R4Kd6+KAe1sx xmLQNMrzO/n5pZf7/nT9dYSWjTOdPWYhjzebAhUX52H3MmzAZYGk3w6VMLbJFMVf0Gc4 Mhjgg2fnYI8AkbMCsEM94yt8T3KIVWf7gPMRYHl9vREdwWFkYUaqmF2287RrTVPiQfn1 yBSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:thread-index:content-language :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=LJ1NxJzh7pPV5ppYGpR1Y1syCcZxD49FHb5l6H+MhPU=; b=hS1h87pzFXmQ/ooWQXMUbOxqJejALuSQyxDb/IroMm8+Q3wFnecuf/ycj0WBRjSJ1L X+jxqCp/BaSvhOba6HxwKuOTvwqEbwwp4NKFnIddn7cJklW+o+hLvKWOacz4hPOKqb4B u2FwBkqu6yknD6JbNQcHtqPfkoTUhjvPxCJbwP0xhP//8lo0pcM2Of25RpbjvNzPh6DF WdCh6Cw9droW3G1dGa3HLXO69Gu37w7J7lf1bRfxY5RVsptouv3IYihs2zY/hYaJKTvu GtlMjoPECAN+n3Y8ysX2NSVMUCT2jXeJF/OMflhIhZYnRUuHO4ZnByJVpde8RW3UkeFO WBmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hDTDG7nn; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q14si13128947ejc.297.2020.09.17.05.56.16; Thu, 17 Sep 2020 05:56:41 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=hDTDG7nn; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727125AbgIQMzL (ORCPT + 99 others); Thu, 17 Sep 2020 08:55:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727043AbgIQMwp (ORCPT ); Thu, 17 Sep 2020 08:52:45 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 246C6C06174A; Thu, 17 Sep 2020 05:52:45 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id q12so1059289plr.12; Thu, 17 Sep 2020 05:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-language:thread-index; bh=LJ1NxJzh7pPV5ppYGpR1Y1syCcZxD49FHb5l6H+MhPU=; b=hDTDG7nnoPUCNmV9yhFnJDJLfQZvHx5zHmmLc17yRun9mZcMCZUryHVH1ARyK0ybeE Qgb75+UkBcoHh0EVZpeTdogQYWrUJ+HikFKDTbCUFUuqtTi/v9xAGRv7udbvcle071J5 77lzfDY022qJZLaaUeFMX54pio3JciwYo2LiGH4mAbU3EhkQBzReGN8Uq0vdzvFw1Gk7 7YQBMFpLPK805bfuNwSikisQhy599ucwa3yg4dhBVrRWUE7W/k6az/weWc/nxw0QioC8 63IB7Wvjne300BL8gPFaReWm9EYOV3KTFSZwmI+nOytr+Nh2rdwr+uEGZt7607m7OXwd WYfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-language:thread-index; bh=LJ1NxJzh7pPV5ppYGpR1Y1syCcZxD49FHb5l6H+MhPU=; b=pGbaMNeGD7FqYbz9bKJNd3LJ16kijsIsU81XHMp6DW85rXT9qo0YsaU87XZa+FNtPT /ZjIt8HsW5q1YvZSplzHd34NA9zFcQ3DzFr2nbmWGkigPtAiZWzoLOzOMJv9sC7EIe8W sQ+NMECsJa1ySHKAN4WmD524af+PXzptd4x9lY1wbv+ZUs9GMrpc0DT16vHmtsZGB3XL LGyrG/Ovz4bRay+Df7Ikci7TZWqv8peZ5eq3u67ZUOXKqjWEj5VFwYRPWKOwwSTIDRt7 rEOcTahf4hDtq4ZUtzUIEIKIgvSCVoN2yHtA8aWelua7UEWBGB+VdhC/opjpFdpNwViW IfUQ== X-Gm-Message-State: AOAM5334su9J8rkZ5SOq78DziNM7NEwJvlz+X4eIJVM4v8I4ybx/1Xod zskRlK2YPrdLJUvdIoEPh5Y= X-Received: by 2002:a17:90b:d89:: with SMTP id bg9mr7928146pjb.26.1600347164644; Thu, 17 Sep 2020 05:52:44 -0700 (PDT) Received: from DESKTOPIUKEMQD ([209.9.72.212]) by smtp.gmail.com with ESMTPSA id g7sm21032792pfr.150.2020.09.17.05.52.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 05:52:44 -0700 (PDT) From: "zhuguangqing83" To: "'Daniel Lezcano'" , , , , , , Cc: , Subject: Re: [PATCH] thermal/drivers/cpuidle_cooling: Change the set_cur_state function Date: Thu, 17 Sep 2020 20:52:37 +0800 Message-ID: <1a8601d68cf1$6ea7dc70$4bf79550$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Content-Language: zh-cn Thread-Index: AdaM8RxDFDW73nb5TsGgR07Fcyc++Q== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >=20 > On 17/09/2020 13:15, zhuguangqing83 wrote: > > > >>> From: zhuguangqing > >>> > >>> In the function cpuidle_cooling_set_cur_state(), if current_state = is > >>> not equal to state and both current_state and state are greater = than > >>> 0(scene 4 as follows), then maybe it should stop->start or restart > >>> idle_inject. > >> > >> Sorry, I don't get it. > >> > >> It is an update of the state, why do we need to restart the idle > >> injection ? The state change will be automatically take into = account by > >> the idle injection code at the new injection cycle. > >> > > > > Thanks for your comments. > > > > For example, we call cpuidle_cooling_set_cur_state() twice, first = time > > the input parameter state is 20, second time the input parameter = state > > is 30. > > > > In current code, in the second call of = cpuidle_cooling_set_cur_state(), > > current_state =3D=3D 20, state =3D=3D 30, then "if (current_state = =3D=3D 0 && > > state > 0)" is not satisfied, "else if (current_state > 0 && = !state)" > > is not satisfied either, so we just update idle_cdev->state to 30 = and > > idle_inject_set_duration to new injection cycle=EF=BC=8Cbut we do = not call > > idle injection code. >=20 > Ok, I think understand your question. >=20 > When the idle injection is started, a timer is periodically calling = the > function play_idle_precise() with the idle duration. This one is = updated > by idle_inject_set_duration(). >=20 > So when the state is changed, that changes the idle duration. At the > next timer expiration, a few Milli seconds after, play_idle_precise() > will be called with the new idle duration which was updated by > idle_inject_set_duration(). >=20 > There is no need to stop and start the idle injection at each update. >=20 > The new value is take into account automatically for the next cycle. >=20 > It does not really matter if the update is delayed. Restarting the = idle > injection at each update will be worth in the cooling context than > waiting an idle cycle. >=20 Ok, got it. Thanks. > > In the example mentioned above, we should call idle injection code. = If > > idle_inject_start() takes into account by the idle injection code at > > the new injection cycle, then just calling idle_inject_start() is = ok. > > Otherwise, we need a restart or stop->start process to execute idle > > injection code at the new state 30. > > > >>> The scenes changed is as follows, > >>> > >>> scene current_state state action > >>> 1 0 >0 start > >>> 2 0 0 do nothing > >>> 3 >0 0 stop > >>> 4 >0 && !=3Dstate >0 stop->start or restart > >>> 5 >0 && =3D=3Dstate >0 do nothing > >>> > >>> Signed-off-by: zhuguangqing > >>> --- > >>> drivers/thermal/cpuidle_cooling.c | 10 ++++++++-- > >>> 1 file changed, 8 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/thermal/cpuidle_cooling.c > >> b/drivers/thermal/cpuidle_cooling.c > >>> index 78e3e8238116..868919ad3dda 100644 > >>> --- a/drivers/thermal/cpuidle_cooling.c > >>> +++ b/drivers/thermal/cpuidle_cooling.c > >>> @@ -113,7 +113,7 @@ static int = cpuidle_cooling_get_cur_state(struct > >>> thermal_cooling_device *cdev, > >>> /** > >>> * cpuidle_cooling_set_cur_state - Set the current cooling state > >>> * @cdev: the thermal cooling device > >>> - * @state: the target state > >>> + * @state: the target state, max value is 100 > >>> * > >>> * The function checks first if we are initiating the mitigation = which > >>> * in turn wakes up all the idle injection tasks belonging to the = idle > >>> @@ -130,6 +130,9 @@ static int = cpuidle_cooling_set_cur_state(struct > >>> thermal_cooling_device *cdev, > >>> unsigned long current_state =3D idle_cdev->state; > >>> unsigned int runtime_us, idle_duration_us; > >>> > >>> + if (state > 100 || current_state =3D=3D state) > >>> + return 0; > >>> + > >>> idle_cdev->state =3D state; > >>> > >>> idle_inject_get_duration(ii_dev, &runtime_us, = &idle_duration_us); > >>> @@ -140,8 +143,11 @@ static int = cpuidle_cooling_set_cur_state(struct > >>> thermal_cooling_device *cdev, > >>> > >>> if (current_state =3D=3D 0 && state > 0) { > >>> idle_inject_start(ii_dev); > >>> - } else if (current_state > 0 && !state) { > >>> + } else if (current_state > 0 && !state) { > >>> idle_inject_stop(ii_dev); > >>> + } else { > >>> + idle_inject_stop(ii_dev); > >>> + idle_inject_start(ii_dev); > >>> } > >>> > >>> return 0; > >>> > >> > >> > >> -- > >> Linaro.org =E2=94=82 Open source software = for ARM SoCs > >> > >> Follow Linaro: Facebook | > >> Twitter | > >> Blog > > >=20 >=20 > -- > Linaro.org =E2=94=82 Open source software for = ARM SoCs >=20 > Follow Linaro: Facebook | > Twitter | > Blog