From patchwork Wed Aug 31 12:36:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 1115772 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7VCaYHB016840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 31 Aug 2011 12:36:55 GMT Received: from canuck.infradead.org ([134.117.69.58]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qyk1i-0006G4-Je; Wed, 31 Aug 2011 12:36:21 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qyk1i-00044x-4h; Wed, 31 Aug 2011 12:36:18 +0000 Received: from mail-ww0-f49.google.com ([74.125.82.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qyk1e-00044f-Qb for linux-arm-kernel@lists.infradead.org; Wed, 31 Aug 2011 12:36:15 +0000 Received: by wwf10 with SMTP id 10so478305wwf.18 for ; Wed, 31 Aug 2011 05:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding:content-type; bh=bQ+lVsh96AcmSORRb1p5uWD0ccUktvhlO01q5YvadPE=; b=W4KC+eTSVb7ovLk1qhWCySgD7SYbeo6H5qxYwp1o4wSY7X8/DwWPFizKHgo5gBKwB3 fIPxbUuTQ6WBFa4xxQYhpbNBdqhCZ1YGzg4tYsD1+YnAcNqQKoexWru8hZ7j8eZUlqrY DZwGAzE5QcSTKqd9PkJb15SBVPjMpxddy0D80= Received: by 10.216.212.34 with SMTP id x34mr364826weo.41.1314794173723; Wed, 31 Aug 2011 05:36:13 -0700 (PDT) Received: from flatron.localnet (178-73-0-134.home.aster.pl [178.73.0.134]) by mx.google.com with ESMTPS id y61sm4259445wec.6.2011.08.31.05.36.07 (version=SSLv3 cipher=OTHER); Wed, 31 Aug 2011 05:36:12 -0700 (PDT) From: Tomasz Figa To: linux-arm-kernel Subject: [PATCH 5/5] ARM: s3c64xx: Add optional local sched_clock implementation. Date: Wed, 31 Aug 2011 14:36:05 +0200 Message-ID: <1592368.OPFfVHzi2n@flatron> User-Agent: KMail/4.7.0 (Linux/3.0.3-gentoo; KDE/4.7.0; x86_64; ; ) In-Reply-To: <1731819.jJi37IsjvJ@flatron> References: <1731819.jJi37IsjvJ@flatron> MIME-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110831_083615_111316_35DAF1EA X-CRM114-Status: GOOD ( 16.28 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tomasz.figa[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Kukjin Kim , Ben Dooks X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 31 Aug 2011 12:36:55 +0000 (UTC) From 3927708d26986ec42cce92e74b19dbdbbc3dae4b Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Sun, 28 Aug 2011 02:49:58 +0200 Subject: [PATCH 5/5] ARM: s3c64xx: Add optional local sched_clock implementation. This patch adds local sched_clock implementation using the PWM timer used for generic clock source and a Kconfig option to enable/disable it. Signed-off-by: Tomasz Figa --- arch/arm/mach-s3c64xx/Kconfig | 8 ++++++++ arch/arm/mach-s3c64xx/time.c | 28 +++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletions(-) diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig index 2db76fd..e11dd9b 100644 --- a/arch/arm/mach-s3c64xx/Kconfig +++ b/arch/arm/mach-s3c64xx/Kconfig @@ -33,6 +33,14 @@ config S3C64XX_GENERIC_CLOCKEVENTS on S3C6400/S3C6410 SoCs using PWM timers 3 and 4 instead of standard periodic tick using PWM timer 4. +config S3C64XX_SCHED_CLOCK + bool "Use PWM clock source for scheduler clock" + depends on S3C64XX_GENERIC_CLOCKEVENTS + select HAVE_SCHED_CLOCK + help + This option enables local scheduler clock implementation + using PWM clock source. + config S3C64XX_ARCH_USES_GETTIMEOFFSET def_bool y if !S3C64XX_GENERIC_CLOCKEVENTS select ARCH_USES_GETTIMEOFFSET diff --git a/arch/arm/mach-s3c64xx/time.c b/arch/arm/mach-s3c64xx/time.c index 4fa57f0..4a78844 100644 --- a/arch/arm/mach-s3c64xx/time.c +++ b/arch/arm/mach-s3c64xx/time.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -241,6 +242,29 @@ static void s3c64xx_clocksource_resume(struct clocksource *cs) s3c64xx_pwm_start(PWM_SOURCE, PERIODIC); } +#ifdef CONFIG_S3C64XX_SCHED_CLOCK +/* + * Override the global weak sched_clock symbol with this + * local implementation which uses the clocksource to get some + * better resolution when scheduling the kernel. We accept that + * this wraps around for now, since it is just a relative time + * stamp. (Inspired by U300 implementation.) + */ +static DEFINE_CLOCK_DATA(cd); + +unsigned long long notrace sched_clock(void) +{ + return cyc_to_sched_clock(&cd, + ~__raw_readl(S3C2410_TCNTO(PWM_SOURCE)), TCNT_MAX); +} + +static void notrace s3c64xx_update_sched_clock(void) +{ + update_sched_clock(&cd, + ~__raw_readl(S3C2410_TCNTO(PWM_SOURCE)), (u32)~0); +} +#endif /* CONFIG_S3C64XX_SCHED_CLOCK */ + static struct clocksource pwm_clocksource = { .name = "s3c64xx_clksrc", .rating = 250, @@ -258,7 +282,9 @@ static void __init s3c64xx_clocksource_init(void) s3c64xx_pwm_init(PWM_SOURCE, TCNT_MAX); s3c64xx_pwm_start(PWM_SOURCE, PERIODIC); - +#ifdef CONFIG_S3C64XX_SCHED_CLOCK + init_sched_clock(&cd, s3c64xx_update_sched_clock, 32, clock_rate); +#endif /* CONFIG_S3C64XX_SCHED_CLOCK */ if (clocksource_register_hz(&pwm_clocksource, clock_rate)) panic("%s: can't register clocksource\n", pwm_clocksource.name); }