From patchwork Thu Nov 15 13:32:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10684331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92FCE17EE for ; Thu, 15 Nov 2018 13:32:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 803922C66B for ; Thu, 15 Nov 2018 13:32:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71E692C678; Thu, 15 Nov 2018 13:32:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,SUSPICIOUS_RECIPS autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A62862C66B for ; Thu, 15 Nov 2018 13:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=YgPd/MP6GSyYBbM/M7tozpJP7RfwbnMF9FyjiwlvlO4=; b=QlZ BuU+U/u3G3B79n1NLhV4ejUJB0yksINWNh0vZFhKnaG0Ri34g7fapK4c7O10aQr0LivdZMUSgr36D LpTn4Z4ym7euk9RiWbyZlGy9m+KI6kL8tuQRJ+oBncOAjyUrrxvASvK3koGZrzSWVvDxEnCO9WgxM /UElgGbL1rMreBlrfNIX8BMZK40ZV0orwwa5HwyjldGAbdbDXeRuyQaTeKmAl8q8M+cBO34oV5d2E g3sajodmyUlzopUsXoBZGJ4DZX6EfC6OExKilu/miNjcE5r9LFUqQiI4Jn9RqM8DZwXNXgLs1lQGl fH9DUb+aiI/fSPfxRazq5G+iu67BThQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNHku-0003Vk-Iu; Thu, 15 Nov 2018 13:32:24 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNHkr-0003U7-8W for linux-arm-kernel@lists.infradead.org; Thu, 15 Nov 2018 13:32:22 +0000 Received: by mail-lf1-x142.google.com with SMTP id p6so14136915lfc.1 for ; Thu, 15 Nov 2018 05:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=KUan3OzAdZ8g7FaQ0bp8nq8b/qVWijqdlEjN9w8ObM4=; b=dDGCcTClUlsV9dWCLEtW5f0S8V5MhLLsNnQeQ45ZkG6zEUFn7nh8Wc3U6lV0BJ8ZUj 6f17EtFTgR49AnhKEhiB1frnjfZw5mmwUxN183kE2UXFkcD8qvRL3Zi3OpWwgMpUol1H neG6lF5wDuCU9pyxjUI8G1fi4cBlmUhi0ZYVE= 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; bh=KUan3OzAdZ8g7FaQ0bp8nq8b/qVWijqdlEjN9w8ObM4=; b=pAahK8+FrEVNrCr+HuviVdzIaRJ3u06qmO1vLqjtvH2G9uMUQQWg3RF6usmhSEn+s4 DYiVCQri10NG9I9BxXr45q/NuY1wfxdps0/PKX2EYuJFlzTW1Bj4gxvObXHssSLH4UaZ EIRmFuAP4mV7cOGcBO/KxUda0uXOCycfgsCFmIUff415M4VakP6Xq6jQ0dojf/SEAiFF 1tdH6BpAsFHz3X1yuiNqMUjm43a+/IqOr1EnR20tlk5jZd3oPCAA3ze2uBhDR0Wm0aSm khUue3m1cKCPhRZ8XCCQxrUUZXVz3SX4eHKqFU0lFuoUXRIBrVAf8nG2TjUI48PCNH9Q vJpg== X-Gm-Message-State: AGRZ1gLkovaTidbJrsea9TySsmQV8jn2axh4nZKPjkcwLV+UhyDnRrE7 tsIfrF0pz8O7vdC+tKWX5Rs1jw== X-Google-Smtp-Source: AJdET5chX+FoiEVNp1V7KzhzUoq2brPZi/s9YIrk+Q5wSn0yC+ff+S5nHu9xfi2dAEi/mfk2QMTDhg== X-Received: by 2002:a19:f813:: with SMTP id a19mr3325289lff.67.1542288728568; Thu, 15 Nov 2018 05:32:08 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id f76sm4291949lfl.74.2018.11.15.05.32.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 05:32:07 -0800 (PST) From: Linus Walleij To: linux-kernel@vger.kernel.org, Daniel Lezcano , Thomas Gleixner Subject: [PATCH 1/2] clocksource: Demote dbx500 PRCMU clocksource Date: Thu, 15 Nov 2018 14:32:02 +0100 Message-Id: <20181115133203.28567-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181115_053221_298049_3A1E50CA X-CRM114-Status: GOOD ( 14.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linus Walleij , linux-arm-kernel@lists.infradead.org, Baolin Wang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Demote the DBx500 PRCMU clocksource to quality 100 and mark it as NONSTOP so it will still be used for timekeeping across suspend/resume. The Nomadik MTU timer which has higher precision will be used when the system is up and running, thanks to the recent changes properly utilizing the suspend clocksources. This was discussed back in 2011 when the driver was written, but the infrastructure was not available upstream to use this timer properly. Now the infrastructure is there, so let's finalize the work. Cc: Baolin Wang Signed-off-by: Linus Walleij Reviewed-by: Baolin Wang --- drivers/clocksource/clksrc-dbx500-prcmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clocksource/clksrc-dbx500-prcmu.c b/drivers/clocksource/clksrc-dbx500-prcmu.c index c1b96dc5f444..4054539fe066 100644 --- a/drivers/clocksource/clksrc-dbx500-prcmu.c +++ b/drivers/clocksource/clksrc-dbx500-prcmu.c @@ -46,10 +46,10 @@ static u64 notrace clksrc_dbx500_prcmu_read(struct clocksource *cs) static struct clocksource clocksource_dbx500_prcmu = { .name = "dbx500-prcmu-timer", - .rating = 300, + .rating = 100, .read = clksrc_dbx500_prcmu_read, .mask = CLOCKSOURCE_MASK(32), - .flags = CLOCK_SOURCE_IS_CONTINUOUS, + .flags = CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP, }; #ifdef CONFIG_CLKSRC_DBX500_PRCMU_SCHED_CLOCK From patchwork Thu Nov 15 13:32:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10684333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABDA914D6 for ; Thu, 15 Nov 2018 13:32:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97A482C669 for ; Thu, 15 Nov 2018 13:32:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C1662C678; Thu, 15 Nov 2018 13:32:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,SUSPICIOUS_RECIPS autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 25BF62C680 for ; Thu, 15 Nov 2018 13:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rFgGCadm7JWx7d/nNagP4iTtkEg4FKXi9tIf3oaECCQ=; b=Pmd47i0Lh/K2seWQqUcfyp+KOS sSyl9qTBYs4CA8cMlWigQpdpC69Py4mMXpztDTHEhL/ff0HQuz2cZmlxPAQGFGeVGUbXE3baIZNYg 6Z4s6DnGpeHhY1VtUs1Dkh0jlhyhHO5iZO6KdtV/0TKDygD5ta428OmaQ/m2c9XPH7NW2g8IFLMPU C2w3eUve3BXbovsAOZmqtOxqfSdvgVzbrY41JpH+rSYXMJYUqnRV38dG9HJkUQg1jMBoxa6lstNXO PNNowvN0WqV6o7VTrRiftnJ8DGTopV1ScCOqInm0PBhfrr88LadNSQx/wNGCzXWfEgOnD80YJnJZt 6MsKYiXA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNHl3-0003fq-39; Thu, 15 Nov 2018 13:32:33 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNHkt-0003U8-R7 for linux-arm-kernel@lists.infradead.org; Thu, 15 Nov 2018 13:32:25 +0000 Received: by mail-lf1-x143.google.com with SMTP id p17so14135360lfh.4 for ; Thu, 15 Nov 2018 05:32:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o7M9G96s4mn6gVHofvS0Iq+dG/9ayDwkuUKUrD30CTM=; b=eR0brWNVkbTbmDX1Uss1C6555F3RWGVEXK2PRUbhUeGJzOZ8IlZmIbq8cH66PSEJN6 AemtFqTTwI81Q3YbGLY5+aDS2YwNf1UL+9BpDWZ7bY0Hv1INwGBqfKEloikonPjY6mfu T4RTAGnCW/9EIt5bypacmzmf40zwcQgY5zX9U= 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:in-reply-to :references; bh=o7M9G96s4mn6gVHofvS0Iq+dG/9ayDwkuUKUrD30CTM=; b=gc3B2IPqDmswgGqloJkMgdXHuJOh3reNI71NxB4CcBoUQU3MtkRU69bdYJKHsCbLwc hquQ67PRmfIshoUp6M0AWLunTSOB5om0yehHbrRAnxF2zbtSt8Gu1Dpij1WQo4C4C7Z2 1TFU2mkG4jL8wBv6cKtYXofW3bBeU6IPrzSlWV77dWCiPFiUKX8rNuuUpWlk2xXBIWOA IX+oLP1gcXnQy8ch1lyJ5JyxcQi/CkSXVxsTvWRZo6loOPxo3DAfjr34FhdNnKjguKL2 JLSaxxnbO4EdoiR0jk+N0Ke2JIpBuexKbVNr5iR2wcBmx1gHKPGZN8KZ16uCXpHz2Kia 1klA== X-Gm-Message-State: AGRZ1gICkQ4IIXkqQE7FlNYHabF6Ct5Jivwhgkrl/fT76gQUttq/TEhE 35rp4DUc/dn847kK4YEysFkOvQ== X-Google-Smtp-Source: AJdET5dLNCV+1hWCBIRqnWrNWyLl5oVzGepT/9MyEGTO6jr16eOjV7SpsFmscxjNoRQ0rSwM6Ff1RA== X-Received: by 2002:a19:4f0c:: with SMTP id d12mr3298185lfb.121.1542288731296; Thu, 15 Nov 2018 05:32:11 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id f76sm4291949lfl.74.2018.11.15.05.32.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 05:32:10 -0800 (PST) From: Linus Walleij To: linux-kernel@vger.kernel.org, Daniel Lezcano , Thomas Gleixner Subject: [PATCH 2/2] clocksource: Drop Ux500 custom SCHED_CLOCK Date: Thu, 15 Nov 2018 14:32:03 +0100 Message-Id: <20181115133203.28567-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115133203.28567-1-linus.walleij@linaro.org> References: <20181115133203.28567-1-linus.walleij@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181115_053223_871636_17E4B89C X-CRM114-Status: GOOD ( 19.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linus Walleij , linux-arm-kernel@lists.infradead.org, Baolin Wang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The two drivers used for Ux500 sched_clock use two Kconfig symbols to select which of the two gets used as sched_clock. This isn't right: the workaround is trying to make sure that the NONSTOP timer is used for sched_clock in order to keep that clock ticking consistently over a suspend/resume cycle. (Otherwise sched_clock simply stops during suspend and continues after resume). This will notably affect any timetstamped debug prints, so that they show the absolute number of seconds since the system was booted and does not loose wall-clock time during suspend and resume as if time stood still. The real way to fix this problem is to make sched_clock take advantage of any NONSTOP clock source on the system and adjust accordingly, not to try to work around this by using a different sched_clock depending on what system we are compiling for. This can solve the problem for everyone instead of providing a local solution. Cc: Baolin Wang Signed-off-by: Linus Walleij --- Any suggestions on how to proceed to make sched_clock keep ticking using NONSTOP clocksource is welcome. --- drivers/clocksource/Kconfig | 13 ------------- drivers/clocksource/clksrc-dbx500-prcmu.c | 18 ------------------ drivers/clocksource/nomadik-mtu.c | 4 ---- 3 files changed, 35 deletions(-) diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 55c77e44bb2d..64d5759ddf0e 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -163,12 +163,6 @@ config CLKSRC_NOMADIK_MTU to multiple interrupt generating programmable 32-bit free running decrementing counters. -config CLKSRC_NOMADIK_MTU_SCHED_CLOCK - bool - depends on CLKSRC_NOMADIK_MTU - help - Use the Multi Timer Unit as the sched_clock. - config CLKSRC_DBX500_PRCMU bool "Clocksource PRCMU Timer" if COMPILE_TEST depends on HAS_IOMEM @@ -226,13 +220,6 @@ config INTEGRATOR_AP_TIMER help Enables support for the Integrator-ap timer. -config CLKSRC_DBX500_PRCMU_SCHED_CLOCK - bool "Clocksource PRCMU Timer sched_clock" - depends on (CLKSRC_DBX500_PRCMU && !CLKSRC_NOMADIK_MTU_SCHED_CLOCK) - default y - help - Use the always on PRCMU Timer as sched_clock - config CLKSRC_EFM32 bool "Clocksource for Energy Micro's EFM32 SoCs" if !ARCH_EFM32 depends on OF && ARM && (ARCH_EFM32 || COMPILE_TEST) diff --git a/drivers/clocksource/clksrc-dbx500-prcmu.c b/drivers/clocksource/clksrc-dbx500-prcmu.c index 4054539fe066..51d53c4e646f 100644 --- a/drivers/clocksource/clksrc-dbx500-prcmu.c +++ b/drivers/clocksource/clksrc-dbx500-prcmu.c @@ -15,7 +15,6 @@ #include #include #include -#include #define RATE_32K 32768 @@ -26,8 +25,6 @@ #define PRCMU_TIMER_DOWNCOUNT 0x4 #define PRCMU_TIMER_MODE 0x8 -#define SCHED_CLOCK_MIN_WRAP 131072 /* 2^32 / 32768 */ - static void __iomem *clksrc_dbx500_timer_base; static u64 notrace clksrc_dbx500_prcmu_read(struct clocksource *cs) @@ -52,18 +49,6 @@ static struct clocksource clocksource_dbx500_prcmu = { .flags = CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP, }; -#ifdef CONFIG_CLKSRC_DBX500_PRCMU_SCHED_CLOCK - -static u64 notrace dbx500_prcmu_sched_clock_read(void) -{ - if (unlikely(!clksrc_dbx500_timer_base)) - return 0; - - return clksrc_dbx500_prcmu_read(&clocksource_dbx500_prcmu); -} - -#endif - static int __init clksrc_dbx500_prcmu_init(struct device_node *node) { clksrc_dbx500_timer_base = of_iomap(node, 0); @@ -81,9 +66,6 @@ static int __init clksrc_dbx500_prcmu_init(struct device_node *node) writel(TIMER_DOWNCOUNT_VAL, clksrc_dbx500_timer_base + PRCMU_TIMER_REF); } -#ifdef CONFIG_CLKSRC_DBX500_PRCMU_SCHED_CLOCK - sched_clock_register(dbx500_prcmu_sched_clock_read, 32, RATE_32K); -#endif return clocksource_register_hz(&clocksource_dbx500_prcmu, RATE_32K); } TIMER_OF_DECLARE(dbx500_prcmu, "stericsson,db8500-prcmu-timer-4", diff --git a/drivers/clocksource/nomadik-mtu.c b/drivers/clocksource/nomadik-mtu.c index 8e4ddb9420c6..19b336c9b417 100644 --- a/drivers/clocksource/nomadik-mtu.c +++ b/drivers/clocksource/nomadik-mtu.c @@ -69,7 +69,6 @@ static u32 clk_prescale; static u32 nmdk_cycle; /* write-once */ static struct delay_timer mtu_delay_timer; -#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK /* * Override the global weak sched_clock symbol with this * local implementation which uses the clocksource to get some @@ -82,7 +81,6 @@ static u64 notrace nomadik_read_sched_clock(void) return -readl(mtu_base + MTU_VAL(0)); } -#endif static unsigned long nmdk_timer_read_current_timer(void) { @@ -234,9 +232,7 @@ static int __init nmdk_timer_init(void __iomem *base, int irq, return ret; } -#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK sched_clock_register(nomadik_read_sched_clock, 32, rate); -#endif /* Timer 1 is used for events, register irq and clockevents */ setup_irq(irq, &nmdk_timer_irq);