From patchwork Tue Dec 4 10:29:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10711473 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 DA2AE109C for ; Tue, 4 Dec 2018 10:45:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB6422AAD0 for ; Tue, 4 Dec 2018 10:45:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFBDC2AB18; Tue, 4 Dec 2018 10:45:56 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 BA05A2AAD0 for ; Tue, 4 Dec 2018 10:45:55 +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=RWUaEo/qktRcMkky5LhS+2z1SKS6sqSyUXpfthozUwA=; b=cID+rwtckGnJx83E/syqg8qFIC B3De0RXIa+w1KrzCKqYjzU4qjt0Q+VRJJg+di71kgusiNgb+V00S5WVyw/xYdpPgEd+etGCj/Vv0L j3HVnO8zFeOLP026RP2PYeakBGEkYM4ZUOTavPBR77CW/LdDNrpEOxfTwtRUSsoPF+rWUTs1P3Rrl 9ErPg0jyA3Vy7S1Fkeh0X6YMHltM1Ial6fKDu/TZdvq55IK9M6DPUXMKHIWzgyZe/fp6bFcwd3vIV taunCMGpJmYvwkOsn9aQ6JRuvMEPUvazMhrLSlEV1lnO2qj/zxYhZ6cUbKVf/+DKYApo9WFcASxDk 6ZnqKoPQ==; 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 1gU8DD-0004P0-1V; Tue, 04 Dec 2018 10:45:55 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU8D9-0004LQ-TR for linux-riscv@lists.infradead.org; Tue, 04 Dec 2018 10:45:53 +0000 Received: by mail-pf1-x444.google.com with SMTP id q1so8016912pfi.5 for ; Tue, 04 Dec 2018 02:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j4avgKxJ7er1mkSgLv64vmGkmY63IGVLkeRJB+3yExU=; b=WSU1xHpUmzmizOSvpN72KaeN2XZ8/7U+r8fWZAv3osZYg0oBPm9JBHzmo865sFHHo3 et6IlRcweK8Qru2TFutmmYeKd23IYfmk/lzVby6S1N4dBuK/XSwD84KF9Ui9UWxsagvU TVWTDHSmXv3NrUqvFOpV88V8o0rB6pRbLUDkGFI2d/FsNc9zh/tDfPfUXuI3NINHjbEu /HjjGJppSP6tA7zhwI0aHXUAQ6mfP4oX+D91BuH+BlkVccu8x/86dz4wDMR2aISYciDp VBtghfj32yA9LTdBgGoIAfvS8egJFJLup65dRMx2ZcGBfIl2wmy07VI5GRMtsVfRvi7v g6hg== 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=j4avgKxJ7er1mkSgLv64vmGkmY63IGVLkeRJB+3yExU=; b=GsCTDBAylCh0ccqXyNzZWpUkxHwKJL2NP38WNyk0yHjmFyrW9BpijALd8hr+UEKpVU CCXqQhmBaZ2CEbXZhCAkrx1V7LNUVMN7fmWpJqhB5xrEIRni3XQG8Nbavc6oaYGPEOZR Q0z2O8YBn9VoyiWbzJ4Q8JV5FiWQp0nLKCLlh9llNDxPUHGIv9O5HkYwKhWR+x6thHla DsSs/F9jx49P46boQJvhuDA+yrMXXc/onkna0suMZA9jcE2QexWt5ab/dg1zB37+g2um P2Q0pSMLrW4DsF+MG6uAlG2LZWY9Yi2FPPAHRK+5/fyMB71sslJNScP0z1R6PCJKzW9c ZSFw== X-Gm-Message-State: AA+aEWZFZygeXXvuL80yzbyFfSdRZ/KxFOCWEVOy18xvjP4IGGoSjRKD 4mBVK2AQ3qWXU0w12FELX6h19g== X-Google-Smtp-Source: AFSGD/Wtvji/X00CS395VNSz+1FZ95aC6LHfk23e/UOH/alPQ3I8LuRRnct+LM9YFxLP4/syqguAEA== X-Received: by 2002:a63:cd17:: with SMTP id i23mr16162337pgg.13.1543920340951; Tue, 04 Dec 2018 02:45:40 -0800 (PST) Received: from anup-ubuntu64.qualcomm.com ([106.51.23.39]) by smtp.googlemail.com with ESMTPSA id s37sm19034734pgm.19.2018.12.04.02.45.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 02:45:40 -0800 (PST) From: Anup Patel To: Daniel Lezcano , Thomas Gleixner , Palmer Dabbelt , Albert Ou Subject: [PATCH v2 1/2] RISC-V: Select GENERIC_SCHED_CLOCK for clocksource drivers Date: Tue, 4 Dec 2018 15:59:51 +0530 Message-Id: <20181204102952.21297-2-anup@brainfault.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181204102952.21297-1-anup@brainfault.org> References: <20181204102952.21297-1-anup@brainfault.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_024551_962810_6FCA4D8B X-CRM114-Status: UNSURE ( 9.99 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoph Hellwig , Atish Patra , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The riscv_timer driver can provide sched_clock using "rdtime" instruction but to achieve this we require generic sched_clock framework hence this patch selects GENERIC_SCHED_CLOCK for RISCV. Signed-off-by: Anup Patel Reviewed-by: Palmer Dabbelt --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 55da93f4e818..09a0f2582cad 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -24,6 +24,7 @@ config RISCV select GENERIC_CPU_DEVICES select GENERIC_IRQ_SHOW select GENERIC_PCI_IOMAP + select GENERIC_SCHED_CLOCK select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select GENERIC_SMP_IDLE_THREAD From patchwork Tue Dec 4 10:29:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10711475 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 4E12617D5 for ; Tue, 4 Dec 2018 10:45:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EFE02AAD0 for ; Tue, 4 Dec 2018 10:45:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 335742AB15; Tue, 4 Dec 2018 10:45:57 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 D8CD62AB1E for ; Tue, 4 Dec 2018 10:45:56 +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=kfBH4mimqmt9EKXnQKfBtwiSV/1tYddQzQj0cPr2oRU=; b=im2BqmJ7lBSTwGi7V+J+bHJBDT 3TBjAXb6+CmgwVuefnRG1BXkZlHwB8Q1x7fFYKMbkbyLUeuCNIoq6GILFqVAhq/oQ80w1i/sEL/Ej xkroSiolL5I+tuyM23ukAqHAM1P/H3eoHIVA4OmYSkHymbgl9poBdfvTJoERDLo4j8ZqQOiX2L9Qn SPE25DaI5atVmsFhxg+VdeqdtAGwJmoNbYzbUaj/dcoSQ/53PUh7XjuhpR4fRxbNDmzqIMyPiAQEI 0zU0PA/sRS7DT8ZgR1JCPE1ww2MMb3VDNjqKyNmuuefljU1Czxpl6/j6DCoFxvDeiFlkZaAN4MWbD LDS8arHw==; 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 1gU8DD-0004PJ-IU; Tue, 04 Dec 2018 10:45:55 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gU8D9-0004Lv-TU for linux-riscv@lists.infradead.org; Tue, 04 Dec 2018 10:45:53 +0000 Received: by mail-pf1-x444.google.com with SMTP id 64so8007435pfr.9 for ; Tue, 04 Dec 2018 02:45:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L4yb/wtuagw+sPGtsZIsDQ9oRwj4098XHksxUaA5GSM=; b=JhKZ8XBfpmf5oNPC5DsZRbP+06aecEB9EHz57ti9YKa8qDmAQnflfCNurq8ocVp3rk BFT459NWwejSu/+jAz7hXqd5sX40tOt8yFvRsv3iymTKQNHleups1SYUemKZruBGck+K fpxLKT3l9tdwmL6TiBfSR74ZmObeWavsE+OdLSeimwlbXiDwJE/LBNCn/n1Et8Z0nbdO aLHCdHP5axFGcCOawzUBv/6DUOx9WdEf8xplqkrqumjnUOtUD90+f9djKcexijrkVBue w7I5e/fVpFqlZrtNRbEWkR4p0+1exmaGrgihIGPI7yUIZvCNGhg7KldY532s3rxZeny/ Gf9g== 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=L4yb/wtuagw+sPGtsZIsDQ9oRwj4098XHksxUaA5GSM=; b=VL8Pzp7U863t8l3MIbQZfSCLmNWnUxmqwl+JfBqv7akxFPVEbtYXUY1bUfA56xZUBO vsC9XGnSr60drNqjbom1iBxkOAtiGx0qh5KpPPpBj6w0EPXtpAJWasriIZJluTh4yEKJ ZbeOZDlwsac/YfBoxiTwluPbtNkYOiIe8WxhzgkDDI6SAMgxPYxOHDSxU7XdKUJ1hskN 6cCIp1HajPSYNSWwgiwFEEzw0zjIEGfEJIc75UjLyLpcrSspJiUlCSv3+GbqU0mo4Zpy cVlNXSuv5TSlBvcrVhnS6xeuIeqlL0XeMdvPKFU4LS737vittAQwJY9ZCvRmeGTRI+Xq i3Ig== X-Gm-Message-State: AA+aEWbq63arkrpSfmkWLFbdfyRvIxFND3HfcNW43JhT3NQNHX9UwNdE c3m39kQ9Hc4pvH25kkTTrZ00+xvdZ3s= X-Google-Smtp-Source: AFSGD/XCMx2RUewUEkFdQyd/qO+zjuxGBrfBuTBAky+CysatspDpy4r+JH7O71zM+WZ9lhK+SWBwcQ== X-Received: by 2002:a63:7556:: with SMTP id f22mr15040408pgn.231.1543920347035; Tue, 04 Dec 2018 02:45:47 -0800 (PST) Received: from anup-ubuntu64.qualcomm.com ([106.51.23.39]) by smtp.googlemail.com with ESMTPSA id s37sm19034734pgm.19.2018.12.04.02.45.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 02:45:46 -0800 (PST) From: Anup Patel To: Daniel Lezcano , Thomas Gleixner , Palmer Dabbelt , Albert Ou Subject: [PATCH v2 2/2] clocksource: riscv_timer: Provide sched_clock Date: Tue, 4 Dec 2018 15:59:52 +0530 Message-Id: <20181204102952.21297-3-anup@brainfault.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181204102952.21297-1-anup@brainfault.org> References: <20181204102952.21297-1-anup@brainfault.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181204_024551_962631_C57DEE4E X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoph Hellwig , Atish Patra , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, we don't have a sched_clock registered for RISC-V systems. This means Linux time keeping will use jiffies (running at HZ) as the default sched_clock. To avoid this, we explicity provide sched_clock using RISC-V rdtime instruction (similar to riscv_timer clocksource). Signed-off-by: Anup Patel Reviewed-by: Palmer Dabbelt --- drivers/clocksource/Kconfig | 2 +- drivers/clocksource/riscv_timer.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 55c77e44bb2d..19649abd7c75 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -611,7 +611,7 @@ config ATCPIT100_TIMER config RISCV_TIMER bool "Timer for the RISC-V platform" - depends on RISCV + depends on GENERIC_SCHED_CLOCK && RISCV default y select TIMER_PROBE select TIMER_OF diff --git a/drivers/clocksource/riscv_timer.c b/drivers/clocksource/riscv_timer.c index 084e97dc10ed..431892200a08 100644 --- a/drivers/clocksource/riscv_timer.c +++ b/drivers/clocksource/riscv_timer.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,11 @@ static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs) return get_cycles64(); } +static u64 riscv_sched_clock(void) +{ + return get_cycles64(); +} + static DEFINE_PER_CPU(struct clocksource, riscv_clocksource) = { .name = "riscv_clocksource", .rating = 300, @@ -97,6 +103,9 @@ static int __init riscv_timer_init_dt(struct device_node *n) cs = per_cpu_ptr(&riscv_clocksource, cpuid); clocksource_register_hz(cs, riscv_timebase); + sched_clock_register(riscv_sched_clock, + BITS_PER_LONG, riscv_timebase); + error = cpuhp_setup_state(CPUHP_AP_RISCV_TIMER_STARTING, "clockevents/riscv/timer:starting", riscv_timer_starting_cpu, riscv_timer_dying_cpu);