* [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree @ 2014-11-07 0:21 Anatol Pomozov 2014-11-07 0:25 ` Anatol Pomozov 0 siblings, 1 reply; 10+ messages in thread From: Anatol Pomozov @ 2014-11-07 0:21 UTC (permalink / raw) To: marc.zyngier, mark.rutland Cc: lorenzo.pieralisi, linux-kernel, Anatol Pomozov This allows to port code that needs register_persistent_clock() to arm64 Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> --- arch/arm64/include/asm/time.h | 17 +++++++++++++++++ arch/arm64/kernel/time.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 arch/arm64/include/asm/time.h diff --git a/arch/arm64/include/asm/time.h b/arch/arm64/include/asm/time.h new file mode 100644 index 0000000..28015b8 --- /dev/null +++ b/arch/arm64/include/asm/time.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2004 MontaVista Software, Inc. + * Copyright (C) 2014 The Chromium OS Authors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_TIME_H +#define __ASM_TIME_H + +struct timespec; +typedef void (*clock_access_fn)(struct timespec *); +extern int register_persistent_clock(clock_access_fn read_boot, + clock_access_fn read_persistent); + +#endif diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c index 1a7125c..71a907e 100644 --- a/arch/arm64/kernel/time.c +++ b/arch/arm64/kernel/time.c @@ -40,6 +40,7 @@ #include <asm/thread_info.h> #include <asm/stacktrace.h> +#include <asm/time.h> #ifdef CONFIG_SMP unsigned long profile_pc(struct pt_regs *regs) @@ -79,3 +80,39 @@ void __init time_init(void) /* Calibrate the delay loop directly */ lpj_fine = arch_timer_rate / HZ; } + +static void dummy_clock_access(struct timespec *ts) +{ + ts->tv_sec = 0; + ts->tv_nsec = 0; +} + +static clock_access_fn __read_persistent_clock = dummy_clock_access; +static clock_access_fn __read_boot_clock = dummy_clock_access; + +void read_persistent_clock(struct timespec *ts) +{ + __read_persistent_clock(ts); +} + +void read_boot_clock(struct timespec *ts) +{ + __read_boot_clock(ts); +} + +int __init register_persistent_clock(clock_access_fn read_boot, + clock_access_fn read_persistent) +{ + /* Only allow the clockaccess functions to be registered once */ + if (__read_persistent_clock == dummy_clock_access && + __read_boot_clock == dummy_clock_access) { + if (read_boot) + __read_boot_clock = read_boot; + if (read_persistent) + __read_persistent_clock = read_persistent; + + return 0; + } + + return -EINVAL; +} -- 2.1.0.rc2.206.gedb03e5 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree 2014-11-07 0:21 [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree Anatol Pomozov @ 2014-11-07 0:25 ` Anatol Pomozov [not found] ` <CAOMFOmXDqhwCk1pRf_9yGycboMqt-ZE33y=kZrhbqXOjVcrxYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Anatol Pomozov @ 2014-11-07 0:25 UTC (permalink / raw) To: Marc Zyngier, mark.rutland, Stephen Warren Cc: Lorenzo Pieralisi, LKML, Anatol Pomozov +Stephen This patch is for tegra20_timer that uses register_persistent_clock(). I did not find any way to share the same arch code for arm/arm64. Actually this register_persistent_clock() does not look arm specific at all. Would it be better to move it somewhere outside of arch/? On Thu, Nov 6, 2014 at 4:21 PM, Anatol Pomozov <anatol.pomozov@gmail.com> wrote: > This allows to port code that needs register_persistent_clock() to arm64 > > Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> > --- > arch/arm64/include/asm/time.h | 17 +++++++++++++++++ > arch/arm64/kernel/time.c | 37 +++++++++++++++++++++++++++++++++++++ > 2 files changed, 54 insertions(+) > create mode 100644 arch/arm64/include/asm/time.h > > diff --git a/arch/arm64/include/asm/time.h b/arch/arm64/include/asm/time.h > new file mode 100644 > index 0000000..28015b8 > --- /dev/null > +++ b/arch/arm64/include/asm/time.h > @@ -0,0 +1,17 @@ > +/* > + * Copyright (C) 2004 MontaVista Software, Inc. > + * Copyright (C) 2014 The Chromium OS Authors. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + */ > +#ifndef __ASM_TIME_H > +#define __ASM_TIME_H > + > +struct timespec; > +typedef void (*clock_access_fn)(struct timespec *); > +extern int register_persistent_clock(clock_access_fn read_boot, > + clock_access_fn read_persistent); > + > +#endif > diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c > index 1a7125c..71a907e 100644 > --- a/arch/arm64/kernel/time.c > +++ b/arch/arm64/kernel/time.c > @@ -40,6 +40,7 @@ > > #include <asm/thread_info.h> > #include <asm/stacktrace.h> > +#include <asm/time.h> > > #ifdef CONFIG_SMP > unsigned long profile_pc(struct pt_regs *regs) > @@ -79,3 +80,39 @@ void __init time_init(void) > /* Calibrate the delay loop directly */ > lpj_fine = arch_timer_rate / HZ; > } > + > +static void dummy_clock_access(struct timespec *ts) > +{ > + ts->tv_sec = 0; > + ts->tv_nsec = 0; > +} > + > +static clock_access_fn __read_persistent_clock = dummy_clock_access; > +static clock_access_fn __read_boot_clock = dummy_clock_access; > + > +void read_persistent_clock(struct timespec *ts) > +{ > + __read_persistent_clock(ts); > +} > + > +void read_boot_clock(struct timespec *ts) > +{ > + __read_boot_clock(ts); > +} > + > +int __init register_persistent_clock(clock_access_fn read_boot, > + clock_access_fn read_persistent) > +{ > + /* Only allow the clockaccess functions to be registered once */ > + if (__read_persistent_clock == dummy_clock_access && > + __read_boot_clock == dummy_clock_access) { > + if (read_boot) > + __read_boot_clock = read_boot; > + if (read_persistent) > + __read_persistent_clock = read_persistent; > + > + return 0; > + } > + > + return -EINVAL; > +} > -- > 2.1.0.rc2.206.gedb03e5 > ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <CAOMFOmXDqhwCk1pRf_9yGycboMqt-ZE33y=kZrhbqXOjVcrxYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree 2014-11-07 0:25 ` Anatol Pomozov @ 2014-11-07 4:16 ` Stephen Warren 0 siblings, 0 replies; 10+ messages in thread From: Stephen Warren @ 2014-11-07 4:16 UTC (permalink / raw) To: Anatol Pomozov Cc: Marc Zyngier, mark.rutland-5wv7dgnIgG8, Lorenzo Pieralisi, LKML, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On 11/06/2014 05:25 PM, Anatol Pomozov wrote: > +Stephen > > This patch is for tegra20_timer that uses register_persistent_clock(). > I did not find any way to share the same arch code for arm/arm64. > > Actually this register_persistent_clock() does not look arm specific > at all. Would it be better to move it somewhere outside of arch/? No CC to linux-tegra@ or the other Tegra maintainers? Yes, I think it'd be best not to have arch-specific APIs, or cut/paste the same code into multiple places. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree @ 2014-11-07 4:16 ` Stephen Warren 0 siblings, 0 replies; 10+ messages in thread From: Stephen Warren @ 2014-11-07 4:16 UTC (permalink / raw) To: Anatol Pomozov Cc: Marc Zyngier, mark.rutland, Lorenzo Pieralisi, LKML, linux-tegra@vger.kernel.org On 11/06/2014 05:25 PM, Anatol Pomozov wrote: > +Stephen > > This patch is for tegra20_timer that uses register_persistent_clock(). > I did not find any way to share the same arch code for arm/arm64. > > Actually this register_persistent_clock() does not look arm specific > at all. Would it be better to move it somewhere outside of arch/? No CC to linux-tegra@ or the other Tegra maintainers? Yes, I think it'd be best not to have arch-specific APIs, or cut/paste the same code into multiple places. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <545C4783.8070506-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree 2014-11-07 4:16 ` Stephen Warren @ 2014-11-07 10:40 ` Mark Rutland -1 siblings, 0 replies; 10+ messages in thread From: Mark Rutland @ 2014-11-07 10:40 UTC (permalink / raw) To: Stephen Warren Cc: Anatol Pomozov, Marc Zyngier, Lorenzo Pieralisi, LKML, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Fri, Nov 07, 2014 at 04:16:03AM +0000, Stephen Warren wrote: > On 11/06/2014 05:25 PM, Anatol Pomozov wrote: > > +Stephen > > > > This patch is for tegra20_timer that uses register_persistent_clock(). > > I did not find any way to share the same arch code for arm/arm64. > > > > Actually this register_persistent_clock() does not look arm specific > > at all. Would it be better to move it somewhere outside of arch/? > > No CC to linux-tegra@ or the other Tegra maintainers? > > Yes, I think it'd be best not to have arch-specific APIs, or cut/paste > the same code into multiple places. Agreed. This looks in no way architecture specific, and having this in common code would be preferable to copying. Mark. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree @ 2014-11-07 10:40 ` Mark Rutland 0 siblings, 0 replies; 10+ messages in thread From: Mark Rutland @ 2014-11-07 10:40 UTC (permalink / raw) To: Stephen Warren Cc: Anatol Pomozov, Marc Zyngier, Lorenzo Pieralisi, LKML, linux-tegra@vger.kernel.org On Fri, Nov 07, 2014 at 04:16:03AM +0000, Stephen Warren wrote: > On 11/06/2014 05:25 PM, Anatol Pomozov wrote: > > +Stephen > > > > This patch is for tegra20_timer that uses register_persistent_clock(). > > I did not find any way to share the same arch code for arm/arm64. > > > > Actually this register_persistent_clock() does not look arm specific > > at all. Would it be better to move it somewhere outside of arch/? > > No CC to linux-tegra@ or the other Tegra maintainers? > > Yes, I think it'd be best not to have arch-specific APIs, or cut/paste > the same code into multiple places. Agreed. This looks in no way architecture specific, and having this in common code would be preferable to copying. Mark. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree 2014-11-07 10:40 ` Mark Rutland @ 2014-11-07 16:24 ` Anatol Pomozov -1 siblings, 0 replies; 10+ messages in thread From: Anatol Pomozov @ 2014-11-07 16:24 UTC (permalink / raw) To: Mark Rutland Cc: Stephen Warren, Marc Zyngier, Lorenzo Pieralisi, LKML, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Hi On Fri, Nov 7, 2014 at 2:40 AM, Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> wrote: > On Fri, Nov 07, 2014 at 04:16:03AM +0000, Stephen Warren wrote: >> On 11/06/2014 05:25 PM, Anatol Pomozov wrote: >> > +Stephen >> > >> > This patch is for tegra20_timer that uses register_persistent_clock(). >> > I did not find any way to share the same arch code for arm/arm64. >> > >> > Actually this register_persistent_clock() does not look arm specific >> > at all. Would it be better to move it somewhere outside of arch/? >> >> No CC to linux-tegra@ or the other Tegra maintainers? >> >> Yes, I think it'd be best not to have arch-specific APIs, or cut/paste >> the same code into multiple places. > > Agreed. This looks in no way architecture specific, and having this in > common code would be preferable to copying. Where the code common for arm and arm64 should go? drivers/???/arm_timekeeping.c ? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree @ 2014-11-07 16:24 ` Anatol Pomozov 0 siblings, 0 replies; 10+ messages in thread From: Anatol Pomozov @ 2014-11-07 16:24 UTC (permalink / raw) To: Mark Rutland Cc: Stephen Warren, Marc Zyngier, Lorenzo Pieralisi, LKML, linux-tegra@vger.kernel.org Hi On Fri, Nov 7, 2014 at 2:40 AM, Mark Rutland <mark.rutland@arm.com> wrote: > On Fri, Nov 07, 2014 at 04:16:03AM +0000, Stephen Warren wrote: >> On 11/06/2014 05:25 PM, Anatol Pomozov wrote: >> > +Stephen >> > >> > This patch is for tegra20_timer that uses register_persistent_clock(). >> > I did not find any way to share the same arch code for arm/arm64. >> > >> > Actually this register_persistent_clock() does not look arm specific >> > at all. Would it be better to move it somewhere outside of arch/? >> >> No CC to linux-tegra@ or the other Tegra maintainers? >> >> Yes, I think it'd be best not to have arch-specific APIs, or cut/paste >> the same code into multiple places. > > Agreed. This looks in no way architecture specific, and having this in > common code would be preferable to copying. Where the code common for arm and arm64 should go? drivers/???/arm_timekeeping.c ? ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <CAOMFOmWfgtN+Q-sbQUS8-90pTrtk5Du8xkDVXaed=teVPb8sbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree 2014-11-07 16:24 ` Anatol Pomozov @ 2014-11-07 16:38 ` Mark Rutland -1 siblings, 0 replies; 10+ messages in thread From: Mark Rutland @ 2014-11-07 16:38 UTC (permalink / raw) To: Anatol Pomozov Cc: Stephen Warren, Marc Zyngier, Lorenzo Pieralisi, LKML, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Fri, Nov 07, 2014 at 04:24:19PM +0000, Anatol Pomozov wrote: > Hi > > On Fri, Nov 7, 2014 at 2:40 AM, Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> wrote: > > On Fri, Nov 07, 2014 at 04:16:03AM +0000, Stephen Warren wrote: > >> On 11/06/2014 05:25 PM, Anatol Pomozov wrote: > >> > +Stephen > >> > > >> > This patch is for tegra20_timer that uses register_persistent_clock(). > >> > I did not find any way to share the same arch code for arm/arm64. > >> > > >> > Actually this register_persistent_clock() does not look arm specific > >> > at all. Would it be better to move it somewhere outside of arch/? > >> > >> No CC to linux-tegra@ or the other Tegra maintainers? > >> > >> Yes, I think it'd be best not to have arch-specific APIs, or cut/paste > >> the same code into multiple places. > > > > Agreed. This looks in no way architecture specific, and having this in > > common code would be preferable to copying. > > Where the code common for arm and arm64 should go? > drivers/???/arm_timekeeping.c ? I'd argue that this is in no way specific to ARM, and the current weak functions live in kernel/time/timekeeping.c, so this should too. Thanks, Mark. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree @ 2014-11-07 16:38 ` Mark Rutland 0 siblings, 0 replies; 10+ messages in thread From: Mark Rutland @ 2014-11-07 16:38 UTC (permalink / raw) To: Anatol Pomozov Cc: Stephen Warren, Marc Zyngier, Lorenzo Pieralisi, LKML, linux-tegra@vger.kernel.org On Fri, Nov 07, 2014 at 04:24:19PM +0000, Anatol Pomozov wrote: > Hi > > On Fri, Nov 7, 2014 at 2:40 AM, Mark Rutland <mark.rutland@arm.com> wrote: > > On Fri, Nov 07, 2014 at 04:16:03AM +0000, Stephen Warren wrote: > >> On 11/06/2014 05:25 PM, Anatol Pomozov wrote: > >> > +Stephen > >> > > >> > This patch is for tegra20_timer that uses register_persistent_clock(). > >> > I did not find any way to share the same arch code for arm/arm64. > >> > > >> > Actually this register_persistent_clock() does not look arm specific > >> > at all. Would it be better to move it somewhere outside of arch/? > >> > >> No CC to linux-tegra@ or the other Tegra maintainers? > >> > >> Yes, I think it'd be best not to have arch-specific APIs, or cut/paste > >> the same code into multiple places. > > > > Agreed. This looks in no way architecture specific, and having this in > > common code would be preferable to copying. > > Where the code common for arm and arm64 should go? > drivers/???/arm_timekeeping.c ? I'd argue that this is in no way specific to ARM, and the current weak functions live in kernel/time/timekeeping.c, so this should too. Thanks, Mark. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-11-07 16:38 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07 0:21 [PATCH] arm64: kernel: Copy register_persistent_clock() to arm64 source subtree Anatol Pomozov
2014-11-07 0:25 ` Anatol Pomozov
[not found] ` <CAOMFOmXDqhwCk1pRf_9yGycboMqt-ZE33y=kZrhbqXOjVcrxYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-07 4:16 ` Stephen Warren
2014-11-07 4:16 ` Stephen Warren
[not found] ` <545C4783.8070506-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-11-07 10:40 ` Mark Rutland
2014-11-07 10:40 ` Mark Rutland
2014-11-07 16:24 ` Anatol Pomozov
2014-11-07 16:24 ` Anatol Pomozov
[not found] ` <CAOMFOmWfgtN+Q-sbQUS8-90pTrtk5Du8xkDVXaed=teVPb8sbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-07 16:38 ` Mark Rutland
2014-11-07 16:38 ` Mark Rutland
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.