From patchwork Thu Aug 14 10:55:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 4723681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E9434C0338 for ; Thu, 14 Aug 2014 10:57:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C68052017D for ; Thu, 14 Aug 2014 10:57:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1ABA20148 for ; Thu, 14 Aug 2014 10:57:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XHsgx-0001cr-3Z; Thu, 14 Aug 2014 10:55:35 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XHsgt-0001av-Qo for linux-arm-kernel@lists.infradead.org; Thu, 14 Aug 2014 10:55:33 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NAA000R4MBVEL40@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 14 Aug 2014 19:55:07 +0900 (KST) X-AuditID: cbfee61b-f79f86d00000144c-c6-53ec958bcfd5 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id C2.C4.05196.B859CE35; Thu, 14 Aug 2014 19:55:07 +0900 (KST) Received: from amdc1032.localnet ([106.116.147.136]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NAA00EVQMBSMB80@mmp1.samsung.com>; Thu, 14 Aug 2014 19:55:07 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Daniel Lezcano Subject: Re: [PATCH] Exynos4: cpuidle: support dual CPUs with AFTR state Date: Thu, 14 Aug 2014 12:55:03 +0200 Message-id: <1929175.yd8jnLbgsd@amdc1032> User-Agent: KMail/4.8.4 (Linux/3.2.0-54-generic-pae; KDE/4.8.5; i686; ; ) In-reply-to: <53CCF438.8000805@linaro.org> References: <1396604925-18383-1-git-send-email-daniel.lezcano@linaro.org> <2337363.gvYnZM7kuD@amdc1032> <53CCF438.8000805@linaro.org> MIME-version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrELMWRmVeSWpSXmKPExsVy+t9jAd3uqW+CDW6t4LRYMKOd2WLeZ1mL 1y8MLXoXXGWzeH/oGbPFpsfXWC0+9x5htJhxfh+TxfoZr1ksVu36w+jA5bFz1l12jwWbSj3u XNvD5rF5Sb3H7X+PmT36tqxi9Pi8SS6APYrLJiU1J7MstUjfLoErY/fqZ0wF75wr3k7/xdbA uMq0i5GTQ0LAROLrlRfMELaYxIV769m6GLk4hAQWMUpcfXmPEcJpYZJ4034KrIpNwEpiYvsq RhBbREBPovF9GxOIzSwwlUni5sdYEFtYwEPi9PW17CA2i4CqxOcpjWwgNq+ApsTCw5PB5ogK eErs2L4SLM4poCVx48pJFohl7YwSZ1Z9Z4VoEJT4MfkeC8QCeYl9+6eyQtjqEpPmLWKewCgw C0nZLCRls5CULWBkXsUomlqQXFCclJ5rpFecmFtcmpeul5yfu4kRHBPPpHcwrmqwOMQowMGo xMPrEfU6WIg1say4MvcQowQHs5II76reN8FCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeQ+2WgcK CaQnlqRmp6YWpBbBZJk4OKUaGL2+rvsbzyf1PGSrclD0iY+WZicPulptFNRjvdivUvOZ+YJi NuOcbS+dH3UIM/1SYXwZy/zIZ3u4jI/q6itXvjwt4FXy+Cw15YfkjCmiPRWdNns4O9mlJ5/r 36ExZ8arWdJcGqcdX3/Lncmh8XSt972MK7cm3hPtXcje+fZWjvzlKhErmdMiP5RYijMSDbWY i4oTAQzxbx2FAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140814_035532_028960_70C572D5 X-CRM114-Status: GOOD ( 38.53 ) X-Spam-Score: -5.7 (-----) Cc: k.kozlowski@samsung.com, linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, Tomasz Figa , Tomasz Figa , ccross@google.com, kgene.kim@samsung.com, linaro-kernel@lists.linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On Monday, July 21, 2014 01:06:32 PM Daniel Lezcano wrote: > On 07/16/2014 07:34 PM, Bartlomiej Zolnierkiewicz wrote: > > > > Hi, > > > > On Friday, May 30, 2014 03:53:09 PM Bartlomiej Zolnierkiewicz wrote: > >> > >> Hi, > >> > >> On Friday, May 30, 2014 01:34:45 PM Tomasz Figa wrote: > >>> Hi Daniel, > >>> > >>> On 30.05.2014 11:30, Daniel Lezcano wrote: > >>>> On 04/24/2014 07:42 PM, Tomasz Figa wrote: > >>>>> Hi Daniel, > >>>>> > >>>>> Please see my comments inline. > >>>>> > >>>>> Btw. Please fix your e-mail composer to properly wrap your messages > >>>>> around 7xth column, as otherwise they're hard to read. > >>>>> > >>>>> On 04.04.2014 11:48, Daniel Lezcano wrote: > >>>>>> The following driver is for exynos4210. I did not yet finished the > >>>>>> other boards, so > >>>>>> I created a specific driver for 4210 which could be merged later. > >>>>>> > >>>>>> The driver is based on Colin Cross's driver found at: > >>>>>> > >>>>>> https://android.googlesource.com/kernel/exynos/+/e686b1ec67423c40b4fdf811f9a4dfa3b393a010%5E%5E!/ > >>>>>> > >>>>>> > >>>>>> > >>>>>> This one was based on a 3.4 kernel and an old API. > >>>>>> > >>>>>> It has been refreshed, simplified and based on the recent code cleanup > >>>>>> I sent > >>>>>> today. > >>>>>> > >>>>>> The AFTR could be entered when all the cpus (except cpu0) are down. In > >>>>>> order to > >>>>>> reach this situation, the couple idle states are used. > >>>>>> > >>>>>> There is a sync barrier at the entry and the exit of the low power > >>>>>> function. So > >>>>>> all cpus will enter and exit the function at the same time. > >>>>>> > >>>>>> At this point, CPU0 knows the other cpu will power down itself. CPU0 > >>>>>> waits for > >>>>>> the CPU1 to be powered down and then initiate the AFTR power down > >>>>>> sequence. > >>>>>> > >>>>>> No interrupts are handled by CPU1, this is why we switch to the timer > >>>>>> broadcast > >>>>>> even if the local timer is not impacted by the idle state. > >>>>>> > >>>>>> When CPU0 wakes up, it powers up CPU1 and waits for it to boot. Then > >>>>>> they both > >>>>>> exit the idle function. > >>>>>> > >>>>>> This driver allows the exynos4210 to have the same power consumption > >>>>>> at idle > >>>>>> time than the one when we have to unplug CPU1 in order to let CPU0 to > >>>>>> reach > >>>>>> the AFTR state. > >>>>>> > >>>>>> This patch is a RFC because, we have to find a way to remove the macros > >>>>>> definitions and cpu powerdown function without pulling the arch > >>>>>> dependent > >>>>>> headers. > >>>>>> > >>>>>> Signed-off-by: Daniel Lezcano > >>>>>> --- > >>>>>> arch/arm/mach-exynos/common.c | 11 +- > >>>>>> drivers/cpuidle/Kconfig.arm | 8 ++ > >>>>>> drivers/cpuidle/Makefile | 1 + > >>>>>> drivers/cpuidle/cpuidle-exynos4210.c | 226 > >>>>>> ++++++++++++++++++++++++++++++++++ > >>>> > >>>> [ ... ] > >>>> > >>>> > >>>>> Otherwise, I quite like the whole idea. I need to play a bit with CPU > >>>>> hotplug and PMU to verify that things couldn't really be simplified a > >>>>> bit, but in general this looks reasonably. > >>>> > >>>> Hi Tomasz, > >>>> > >>>> did you have time to look at this simplification ? > >>> > >>> Unfortunately I got preempted with other things to do and now I'm on > >>> vacation. I worked a bit with Bart (added on CC) on this and generally > >>> the conclusion was that all the things are necessary. He was also > >>> working to extend the driver to support Exynos4x12. > >>> > >>> Bart, has anything interesting showed up since we talked about this last > >>> time? > >> > >> Since we last looked into this I have fixed the "standard" AFTR support > >> for Exynos3250 and started to work on adding Exynos3250 support to this > >> driver (as Exynos3250 support has bigger priority than Exynos4x12 one). > >> Unfortunately I also got preempted with other things so it is still > >> unfinished and doesn't work yet. Moreover I had no possibility to test > >> the new driver on Exynos4210 based Origen yet (I hope to do this next > >> week). > > > > I have tested this patch on Origen board (Exynos4210 rev 1.1) and it > > causes system lockup (it seems that the code gets stuck on waiting for > > CPU1 to wake up). > > > > The kernels I have tried: > > * current -next + this patch + few fixes to bring it up to date > > * commit cd245f5 + this patch + some fixes > > * next-20140403 + your Exynos cpuidle patch series + this patch > > > > I have also tried with S5P_VA_SYSRAM replaced by S5P_INFORM5 to > > match Exynos 4210 rev 1.1 but it didn't help. > > > > U-Boot version used is: > > U-Boot 2012.07 (Sep 22 2012 - 05:12:41) for ORIGEN > > > > Could you please tell me which hardware/bootloader/kernel exactly > > have you used to test this patch? > > When I used it, it was on top of 3.15-rc1: > > https://git.linaro.org/people/daniel.lezcano/linux.git/shortlog/refs/heads/cpuidle/samsung-next > > The hardware was a exynos-4210 origen board ver A. I need the following patch to make this driver work on my hardware. [ Unfortunately even with this patch the driver doesn't work reliably. After 30-40 minutes of stress testing it lockups the system (I can send you testing app+script if needed). ] Best regards, --- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics From: Bartlomiej Zolnierkiewicz Subject: [PATCH] cpuidle: Exynos4210: make coupled driver work on Revision 1.1 * Add static inline helper cpu_boot_reg_base() and use it instead of BOOT_VECTOR macro. * Use S5P_INFORM register instead of S5P_VA_SYSRAM one on Revison 1.1 (this matches platform code in arch/arm/mach-exynos/platsmp.c). * Retry poking CPU1 out of the BOOT ROM if necessary (this matches platform code in arch/arm/mach-exynos/platsmp.c). Signed-off-by: Bartlomiej Zolnierkiewicz Acked-by: Kyungmin Park --- drivers/cpuidle/cpuidle-exynos4210.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) Index: b/drivers/cpuidle/cpuidle-exynos4210.c =================================================================== --- a/drivers/cpuidle/cpuidle-exynos4210.c 2014-07-22 15:42:11.580365939 +0200 +++ b/drivers/cpuidle/cpuidle-exynos4210.c 2014-07-22 16:11:01.112369130 +0200 @@ -29,12 +29,19 @@ static atomic_t exynos_idle_barrier; static atomic_t cpu1_wakeup = ATOMIC_INIT(0); -#define BOOT_VECTOR S5P_VA_SYSRAM #define S5P_VA_PMU S3C_ADDR(0x02180000) #define S5P_PMUREG(x) (S5P_VA_PMU + (x)) +#define S5P_INFORM5 S5P_PMUREG(0x0814) #define S5P_ARM_CORE1_CONFIGURATION S5P_PMUREG(0x2080) #define S5P_ARM_CORE1_STATUS S5P_PMUREG(0x2084) +static inline void __iomem *cpu_boot_reg_base(void) +{ + if (samsung_rev() == EXYNOS4210_REV_1_1) + return S5P_INFORM5; + return S5P_VA_SYSRAM; +} + static void (*exynos_aftr)(void); extern void exynos_cpu_resume(void); static int cpu_suspend_finish(unsigned long flags) @@ -76,7 +83,7 @@ static int exynos_cpu0_enter_aftr(void) * boot back up again, getting stuck in the * boot rom code */ - if (__raw_readl(BOOT_VECTOR) == 0) + if (__raw_readl(cpu_boot_reg_base()) == 0) goto abort; cpu_relax(); @@ -95,7 +102,7 @@ abort: * Set the boot vector to something non-zero */ __raw_writel(virt_to_phys(exynos_cpu_resume), - BOOT_VECTOR); + cpu_boot_reg_base()); dsb(); /* @@ -108,24 +115,18 @@ abort: /* * Wait for cpu1 to get stuck in the boot rom */ - while ((__raw_readl(BOOT_VECTOR) != 0) && + while ((__raw_readl(cpu_boot_reg_base()) != 0) && !atomic_read(&cpu1_wakeup)) cpu_relax(); - if (!atomic_read(&cpu1_wakeup)) { + while (!atomic_read(&cpu1_wakeup)) { /* * Poke cpu1 out of the boot rom */ __raw_writel(virt_to_phys(exynos_cpu_resume), - BOOT_VECTOR); + cpu_boot_reg_base()); dsb_sev(); } - - /* - * Wait for cpu1 to finish booting - */ - while (!atomic_read(&cpu1_wakeup)) - cpu_relax(); } return ret; @@ -165,7 +166,7 @@ static int exynos_enter_aftr(struct cpui { int ret; - __raw_writel(virt_to_phys(exynos_cpu_resume), BOOT_VECTOR); + __raw_writel(virt_to_phys(exynos_cpu_resume), cpu_boot_reg_base()); /* * Waiting all cpus to reach this point at the same moment