{"id":813792,"url":"http://patchwork.ozlabs.org/api/patches/813792/?format=json","web_url":"http://patchwork.ozlabs.org/project/skiboot/patch/20170914111346.11970-4-npiggin@gmail.com/","project":{"id":44,"url":"http://patchwork.ozlabs.org/api/projects/44/?format=json","name":"skiboot firmware development","link_name":"skiboot","list_id":"skiboot.lists.ozlabs.org","list_email":"skiboot@lists.ozlabs.org","web_url":"http://github.com/open-power/skiboot","scm_url":"http://github.com/open-power/skiboot","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170914111346.11970-4-npiggin@gmail.com>","list_archive_url":null,"date":"2017-09-14T11:13:44","name":"[3/5] cpu: idle notice if pm state changes","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8bd92c8e569b6073c2aa8c3a81f9fc4b5bd9c2a9","submitter":{"id":69518,"url":"http://patchwork.ozlabs.org/api/people/69518/?format=json","name":"Nicholas Piggin","email":"npiggin@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/skiboot/patch/20170914111346.11970-4-npiggin@gmail.com/mbox/","series":[{"id":3075,"url":"http://patchwork.ozlabs.org/api/series/3075/?format=json","web_url":"http://patchwork.ozlabs.org/project/skiboot/list/?series=3075","date":"2017-09-14T11:13:41","name":"POWER9 idle pm support","version":1,"mbox":"http://patchwork.ozlabs.org/series/3075/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/813792/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/813792/checks/","tags":{},"related":[],"headers":{"Return-Path":"<skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","skiboot@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","skiboot@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xtGCc5gqXz9s7v\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 21:15:08 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xtGCc4NKtzDrb6\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 21:15:08 +1000 (AEST)","from mail-pg0-x243.google.com (mail-pg0-x243.google.com\n\t[IPv6:2607:f8b0:400e:c05::243])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xtGBf2lkkzDrSM\n\tfor <skiboot@lists.ozlabs.org>; Thu, 14 Sep 2017 21:14:18 +1000 (AEST)","by mail-pg0-x243.google.com with SMTP id d8so1531660pgt.3\n\tfor <skiboot@lists.ozlabs.org>; Thu, 14 Sep 2017 04:14:18 -0700 (PDT)","from roar.au.ibm.com (203-219-56-202.tpgi.com.au. [203.219.56.202])\n\tby smtp.gmail.com with ESMTPSA id\n\tc2sm29289224pgq.61.2017.09.14.04.14.12\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 14 Sep 2017 04:14:14 -0700 (PDT)"],"Authentication-Results":["ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"MyhESPYR\"; dkim-atps=neutral","lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"MyhESPYR\"; dkim-atps=neutral","ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gmail.com\n\t(client-ip=2607:f8b0:400e:c05::243; helo=mail-pg0-x243.google.com;\n\tenvelope-from=npiggin@gmail.com; receiver=<UNKNOWN>)","lists.ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"MyhESPYR\"; dkim-atps=neutral"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=by/XV8l9oSeOXpgDPvJxf/x0aIEev6WOLGyZR7OPpm8=;\n\tb=MyhESPYR1AglsuwsJbk8iFMXELQlnmBx91nES2k9ZpceAvkm8Ubsx6kVsnaULd7H4y\n\t1ihufZZpvtDb/V0vWFHdZ2mRE2Chc7LN0q7A6el9iTPft7CH2MqKhRsGkia+pEqNk6qa\n\tqao0WfgNSLj6bqsMolG3A2QPrzGI40GKpGXjLEaO9aC5pep9fmym6LP+OB2rz/dAvKkj\n\toJEYWRz2s5e+5cVSu5WUIaay2oHRyO3VrZ0IbEG/UVMZv6KdGwGHTiZU63r7awSekvER\n\tvcs1fSEzOPpfCCoiGTueVprHz28q3Vvtb14ZD1fDEhmJmDD4mkulUpx9E1S/Htp8gclm\n\tLCpA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=by/XV8l9oSeOXpgDPvJxf/x0aIEev6WOLGyZR7OPpm8=;\n\tb=mZ4n6rt+CxRYji4nkSsslWrynPkfreDpGkLC81HhOxuAcyoR9m9eDcVNBW7bGB87nU\n\tsoIfohp/mtzTrMUQPElc5eocqC4CoEBAnxxu87t8lLKlsMOBcMW9A2286flhCKYq6VIg\n\tXC1mos705LiAWPk9B69z7HOVmLRU6CUHaetTcinLajAGEP9s7+kwJcykzezGapGVOcc2\n\t4A+TFsX8rBhQQRqfrQaqczCJL0QCT2OI61l1pXyhiy0TdQA/l0jQJNpVRc1RSw6QIPHQ\n\t/T3Y6vn3WnDs8RVcDQtLdwocdCVGiWjxlEGrHsSOKr5ObgAUFxLtBuOQVkR5seKqZpns\n\t3wXg==","X-Gm-Message-State":"AHPjjUh4Miwq4nzbkPFRG8BMiP5CdF9eL/936XGDtXoNgDvWUpm1UR0M\n\tECaBJ9UhQGWs8AEH","X-Google-Smtp-Source":"ADKCNb7EwTYDnMKUAl1xiDIMfdZqo1lQFF6Hv+kHT9Ai1HboEl7cN7YsPdYghyxMfbLRjJ8ko1B50g==","X-Received":"by 10.99.123.79 with SMTP id k15mr20819121pgn.33.1505387655550; \n\tThu, 14 Sep 2017 04:14:15 -0700 (PDT)","From":"Nicholas Piggin <npiggin@gmail.com>","To":"skiboot@lists.ozlabs.org","Date":"Thu, 14 Sep 2017 21:13:44 +1000","Message-Id":"<20170914111346.11970-4-npiggin@gmail.com>","X-Mailer":"git-send-email 2.13.3","In-Reply-To":"<20170914111346.11970-1-npiggin@gmail.com>","References":"<20170914111346.11970-1-npiggin@gmail.com>","Subject":"[Skiboot] [PATCH 3/5] cpu: idle notice if pm state changes","X-BeenThere":"skiboot@lists.ozlabs.org","X-Mailman-Version":"2.1.24","Precedence":"list","List-Id":"Mailing list for skiboot development <skiboot.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/skiboot>,\n\t<mailto:skiboot-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/skiboot/>","List-Post":"<mailto:skiboot@lists.ozlabs.org>","List-Help":"<mailto:skiboot-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/skiboot>,\n\t<mailto:skiboot-request@lists.ozlabs.org?subject=subscribe>","Cc":"\"Gautham R . Shenoy\" <ego@linux.vnet.ibm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org","Sender":"\"Skiboot\"\n\t<skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>"},"content":"The idle code checks pm_enabled once at entry, then not again\nuntil the idle exit condition is met. Change this to check\neach opportunity and change idle type if necessary.\n\nSigned-off-by: Nicholas Piggin <npiggin@gmail.com>\n---\n core/cpu.c | 22 ++++++++++++++++++----\n 1 file changed, 18 insertions(+), 4 deletions(-)","diff":"diff --git a/core/cpu.c b/core/cpu.c\nindex 2a95dff6..01001861 100644\n--- a/core/cpu.c\n+++ b/core/cpu.c\n@@ -396,8 +396,11 @@ void cpu_idle_job(void)\n \n \t\tsmt_lowest();\n \t\t/* Check for jobs again */\n-\t\twhile (!cpu_check_jobs(cpu))\n+\t\twhile (!cpu_check_jobs(cpu)) {\n+\t\t\tif (pm_enabled)\n+\t\t\t\tbreak;\n \t\t\tbarrier();\n+\t\t}\n \t\tsmt_medium();\n \t}\n }\n@@ -409,6 +412,7 @@ void cpu_idle_delay(unsigned long delay)\n \tunsigned long min_pm = usecs_to_tb(10);\n \n \tif (pm_enabled && delay > min_pm) {\n+pm:\n \t\tfor (;;) {\n \t\t\tif (delay >= 0x7fffffff)\n \t\t\t\tdelay = 0x7fffffff;\n@@ -419,13 +423,23 @@ void cpu_idle_delay(unsigned long delay)\n \t\t\tnow = mftb();\n \t\t\tif (tb_compare(now, end) == TB_AAFTERB)\n \t\t\t\tbreak;\n-\n \t\t\tdelay = end - now;\n+\t\t\tif (!(pm_enabled && delay > min_pm))\n+\t\t\t\tgoto no_pm;\n \t\t}\n \t} else {\n+no_pm:\n \t\tsmt_lowest();\n-\t\twhile (tb_compare(mftb(), end) != TB_AAFTERB)\n-\t\t\tbarrier();\n+\t\tfor (;;) {\n+\t\t\tnow = mftb();\n+\t\t\tif (tb_compare(now, end) == TB_AAFTERB)\n+\t\t\t\tbreak;\n+\t\t\tdelay = end - now;\n+\t\t\tif (pm_enabled && delay > min_pm) {\n+\t\t\t\tsmt_medium();\n+\t\t\t\tgoto pm;\n+\t\t\t}\n+\t\t}\n \t\tsmt_medium();\n \t}\n }\n","prefixes":["3/5"]}