Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750955AbdL3OKk (ORCPT ); Sat, 30 Dec 2017 09:10:40 -0500 Received: from mail-eopbgr00046.outbound.protection.outlook.com ([40.107.0.46]:43466 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750806AbdL3OKi (ORCPT ); Sat, 30 Dec 2017 09:10:38 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; From: Peng Fan To: shawnguo@kernel.org, kernel@pengutronix.de, fabio.estevam@nxp.com Cc: aisheng.dong@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, van.freenix@gmail.com, Peng Fan Subject: [PATCH 2/2] ARM: imx: cpuidle-imx6q: configure CCM to RUN mode when CPU is active Date: Sat, 30 Dec 2017 21:53:19 +0800 Message-Id: <1514641999-20521-2-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1514641999-20521-1-git-send-email-peng.fan@nxp.com> References: <1514641999-20521-1-git-send-email-peng.fan@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [123.151.195.1] X-ClientProxiedBy: HK2PR04CA0090.apcprd04.prod.outlook.com (2603:1096:202:15::34) To VI1PR04MB3231.eurprd04.prod.outlook.com (2603:10a6:802:6::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: dddc6cf7-2baa-4ac4-753d-08d54f8f189e X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060);SRVR:VI1PR04MB3231; X-Microsoft-Exchange-Diagnostics: 1;VI1PR04MB3231;3:dSeAryXxexI7xoQ3jRm8ig7mG+LTaWOTIhqikxkYylXSG9/Anz2L/gezGtZNgKB9mM/6sCrROz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/vlOYJ22r/MKYNkVXly0HgPdgYsJS/GxGfielnRFsLxBHuksiyeKa+YA+ZOE6cw+AC1KiZZozIwPyPt/T9/aZ5mRCDXyym9s7agjsRLPQ4HCR8NvV4du5CxQH0BwRJQzTTWtiknvWUUFfe0mo5I8x2YSfiMGNFnL09pyQaR3KWF0YFlAgVZ0OTN2I0MgdXnLIJzau7dFjOL3C3Ucfch9rK1Hii9Tw+UQwYpNwzn8/jYsPcK3Y3rws8mCUoFGJUE4nZQ3+ir1akNW8f7hL;4:S9uqVFcHJlah1F0jhyaKPYDuJ7iOWigz6w5uEDwZUgAkNkIQL2z5yKyVLX9YbAW2xsP24zPkvsRb8SQNDyE3y4qxG5xM9SVlZJhZP876UJIcWNU4oukwSPtC+3++Vdxwf44S1PGoHvG2sHq/Q6/ZEsr2ERD/Q1Y35rLPTILv2wmS431YrK6PdNC2GV90++iAmrPVtnFeHB5A+/3EZwvkrj3VyDnsowdnkgb+fXEVgPmj2q5CWNfzmx2exbgWyKxKD0PbE2Bcw+Yp5rJLEGPW3km57CjJntIzeJFdpSU2nA6yfWXB2TDJGHLA5UpMzbb7/s92nrigPrxyhLAi09ENHhSsIyACe7kGQ+9z6rHAnlE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(3231023)(944501075)(93006095)(93001095)(10201501046)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:VI1PR04MB3231;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:VI1PR04MB3231; X-Forefront-PRVS: 05373A0663 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39380400002)(376002)(346002)(366004)(39860400002)(396003)(199004)(189003)(52116002)(51416003)(76176011)(6506007)(105586002)(36756003)(106356001)(81156014)(2906002)(59450400001)(386003)(8676002)(305945005)(7736002)(68736007)(5660300001)(2950100002)(6636002)(6666003)(6306002)(6486002)(97736004)(50466002)(6512007)(48376002)(966005)(478600001)(316002)(66066001)(6116002)(3846002)(16526018)(16586007)(4326008)(39060400002)(8936002)(81166006)(86362001)(47776003)(50226002)(25786009)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB3231;H:shlinux2.ap.freescale.net;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR04MB3231;23:kG0WdY9gq+dWjlvdjg7ew3SP9NB5vnFv+jmFrGEGP?= =?us-ascii?Q?3pUPzSOiAC+j2oaRDMN6+lmLQiU9+jUOsFVVmmZU9I8PrG3mQXfe6wz4P2IL?= =?us-ascii?Q?SOkvzESv+4ZKedWY0E1aK00vXFOo/IDPmMBDpzzgyJv7TMmVCECu7ZnfWMAB?= =?us-ascii?Q?s/gn9o5Oo8EfLvMb3BZSnNFrEkvdd1ZT3fo0j9CGGXV/r64/yYj/K8VgYfFL?= =?us-ascii?Q?hU/i4n7rO6Fir6Hg5CEmJt4zgoTaThuch4dr3P8hCTjUK8VFXj2IdcuNLiXg?= =?us-ascii?Q?PmHOAh3tM10zC3xTidZDyHI5OCG8RnZhGPnQl00TAucHw07DMj9vvBpBVwhV?= =?us-ascii?Q?/u5YvDEVav3meaQWoWGEWCOvKHear5IuG5y9QeYMgpyxLqr83sCbdYAeTPtt?= =?us-ascii?Q?osvFiFUp/Rjq9kDHEs/8IyTU/ThD7pGKnr1YUqI1EW+akBP5s0aC1Hq2kKs0?= =?us-ascii?Q?SbX66HIG/5P7H9GFUtMTJA/V1gV3q1NCMdFJGJQh1GBN8byml1yPMesoc867?= =?us-ascii?Q?Psd9ZkJc2jpjV4UYncka8wYPxcEyHdkSuspbPLujhUe8mQv6rKSdWVppzimZ?= =?us-ascii?Q?xWbL1oSwj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ZZY+gK9KqD/YgbAG8upJOWw3heZUM=;5:bD8Mk1vBM2aof3CBCz4nQzWmP4t7gOLvYKRiokxLe7HnRv9oDOoy9hUY7BDjEQ3o9lqy5opYOrdVe59GbxivbimYTqpSqGi5TVdOe9J79yaeluZzcEH8VAjollcowXYtUb6Sh+X13EH9P3dSTDHWvjPZ2yTjdrC5ZHnqhdXDrac=;24:wIYoI6RQPQIYI8Sp2YePrP9gqeekoDa+TjiOmUEtfwtQu5RsynxFHZFsOvOAEMxKYPL3GecbEq5oFMpUDBOCbQJRy1VEKWkiFhiKYQP0XM4=;7:9xaOZAxYYxaQ0TFFr+v96yKB4BuXgIpabI12xe/n+qVkQtVsfiFzK5AhetxvpcD1W7sq5Jul/UDXMwRTdBtwLm6BL4zp8N7hA7AyQbrW9Rf/CLGYVzOQvfoeX5/Hgqd8aUKIhZTOvgVdD2QfdQBfIjQtxxP/LMc2BfOTh29c92qYewIb8nRSSlcYgrZSD8Kfh1S1qghkY2bZNpw1KP2JHZ4+jkX7QTNvr5gfZAaKK672Uk/Ebdt97rzxm0+NvGl4 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Dec 2017 14:10:32.3499 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dddc6cf7-2baa-4ac4-753d-08d54f8f189e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3231 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2095 Lines: 60 There are two states in i.MX6Q cpuidle driver. state[1]: ARM WFI mode state[2]: i.MX6Q WAIT mode Take i.MX6DL as example, think out such a case: 1. CPU0/1 both run at normal mode 2. On CPU0, `sleep 1` is executed. And there are no workload on CPU1. 3. CPU0 first runs into state[2] and 'wfi' instruction. Switched to use GPT broadcast. 4. CPU1 runs into state[2] and configure CCM to WAIT MODE, then 'wfi' instruction. Now arm_clk and local timer clock are shutdown. Switched to use GPT broadcast 5. GPT broadcast timer interrupt comes to GPC/GIC, then CPU0 wakes up. CPU0 switched to use arm local timer. CPU1 is still sleeping. 6. No workload on CPU0, CPU0 runs into state[1]. But CCM register is still not restored to Normal RUN mode. 'wfi' + CCM WAIT will cause arm_clk and arm core clk. Now CPU0 stops, which is not correct. So, need to make sure CCM configured to RUN mode when any cpu exit state[2]. In this patch, When CPU exits state[2], it configures CCM to RUN mode. When all CPUs enters state[2], the last CPU needs to check whether it's ok to configure CCM to WAIT mode or not. Signed-off-by: Peng Fan --- V1: This is to upstream patch: http://git.freescale.com/git/cgit.cgi/imx/linux-imx.git/commit/?h=imx_4.9.11_1.0.0_ga&id=0d980646ee068b92db71fd5e4e4efcbc33749cbd arch/arm/mach-imx/cpuidle-imx6q.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c index bfeb25aaf9a2..4d342e2fdfe6 100644 --- a/arch/arm/mach-imx/cpuidle-imx6q.c +++ b/arch/arm/mach-imx/cpuidle-imx6q.c @@ -30,6 +30,8 @@ static int imx6q_enter_wait(struct cpuidle_device *dev, if (!spin_trylock(&master_lock)) goto idle; imx6_set_lpm(WAIT_UNCLOCKED); + if (atomic_read(&master) != num_online_cpus()) + imx6_set_lpm(WAIT_CLOCKED); cpu_do_idle(); imx6_set_lpm(WAIT_CLOCKED); spin_unlock(&master_lock); @@ -41,6 +43,7 @@ static int imx6q_enter_wait(struct cpuidle_device *dev, done: atomic_dec(&master); + imx6_set_lpm(WAIT_CLOCKED); return index; } -- 2.14.1