Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH 24/56] microblaze_v2: time support

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


monstr at seznam

May 4, 2008, 4:41 AM

Post #1 of 12 (2272 views)
Permalink
[PATCH 24/56] microblaze_v2: time support

From: Michal Simek <monstr [at] monstr>


Signed-off-by: Michal Simek <monstr [at] monstr>
---
arch/microblaze/kernel/time.c | 90 ++++++++++++++++++++++++++++++++++++++++
include/asm-microblaze/delay.h | 33 +++++++++++++++
include/asm-microblaze/timex.h | 20 +++++++++
3 files changed, 143 insertions(+), 0 deletions(-)
create mode 100644 arch/microblaze/kernel/time.c
create mode 100644 include/asm-microblaze/delay.h
create mode 100644 include/asm-microblaze/timex.h

diff --git a/arch/microblaze/kernel/time.c b/arch/microblaze/kernel/time.c
new file mode 100644
index 0000000..d5ebdff
--- /dev/null
+++ b/arch/microblaze/kernel/time.c
@@ -0,0 +1,90 @@
+/*
+ * arch/microblaze/kernel/time.c
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2006 Atmark Techno, Inc.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/param.h>
+#include <linux/jiffies.h>
+#include <linux/time.h>
+#include <linux/hrtimer.h>
+#include <asm/bug.h>
+#include <asm/setup.h>
+
+void time_init(void)
+{
+ system_timer_init();
+}
+
+int do_settimeofday(struct timespec *tv)
+{
+ if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
+ return -EINVAL;
+
+ write_seqlock_irq(&xtime_lock);
+
+ /* This is revolting. We need to set the xtime.tv_nsec
+ * correctly. However, the value in this location is
+ * is value at the last tick.
+ * Discover what correction gettimeofday
+ * would have done, and then undo it!
+ */
+#if 0
+ tv->tv_nsec -= mach_gettimeoffset() * 1000;
+#endif
+
+ while (tv->tv_nsec < 0) {
+ tv->tv_nsec += NSEC_PER_SEC;
+ tv->tv_sec--;
+ }
+
+ xtime.tv_sec = tv->tv_sec;
+ xtime.tv_nsec = tv->tv_nsec;
+
+ time_adjust = 0;
+ time_status |= STA_UNSYNC;
+ time_maxerror = NTP_PHASE_LIMIT;
+ time_esterror = NTP_PHASE_LIMIT;
+
+ write_sequnlock_irq(&xtime_lock);
+ clock_was_set();
+ return 0;
+}
+EXPORT_SYMBOL(do_settimeofday);
+
+/*
+ * This version of gettimeofday has near microsecond resolution.
+ */
+void do_gettimeofday(struct timeval *tv)
+{
+ unsigned long seq;
+ unsigned long usec, sec;
+ /* unsigned long max_ntp_tick = tick_usec - tickadj; */
+
+ do {
+ seq = read_seqbegin(&xtime_lock);
+ usec = do_gettimeoffset();
+ sec = xtime.tv_sec;
+ usec += (xtime.tv_nsec / 1000);
+ } while (read_seqretry(&xtime_lock, seq));
+
+ while (usec >= 1000000) {
+ usec -= 1000000;
+ sec++;
+ }
+
+ tv->tv_sec = sec;
+ tv->tv_usec = usec;
+}
+EXPORT_SYMBOL(do_gettimeofday);
+
+unsigned long long sched_clock(void)
+{
+ return (unsigned long long)jiffies * (1000000000 / HZ);
+}
diff --git a/include/asm-microblaze/delay.h b/include/asm-microblaze/delay.h
new file mode 100644
index 0000000..481359c
--- /dev/null
+++ b/include/asm-microblaze/delay.h
@@ -0,0 +1,33 @@
+/*
+ * include/asm-microblaze/delay.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2006 Atmark Techno, Inc.
+ */
+
+#ifndef _ASM_MICROBLAZE_DELAY_H
+#define _ASM_MICROBLAZE_DELAY_H
+
+#include <asm/param.h>
+
+static inline void __delay(unsigned long loops)
+{
+ asm volatile ("# __delay \n\t" \
+ "1: addi %0, %0, -1 \t\n" \
+ "bneid %0, 1b \t\n" \
+ "nop \t\n"
+ : "=r" (loops)
+ : "0" (loops));
+}
+
+static inline void udelay(unsigned long usec)
+{
+ unsigned long long tmp = usec;
+ unsigned long loops = (tmp * 4295 * HZ * loops_per_jiffy) >> 32;
+ __delay(loops);
+}
+
+#endif /* _ASM_MICROBLAZE_DELAY_H */
diff --git a/include/asm-microblaze/timex.h b/include/asm-microblaze/timex.h
new file mode 100644
index 0000000..b3e77ef
--- /dev/null
+++ b/include/asm-microblaze/timex.h
@@ -0,0 +1,20 @@
+/*
+ * include/asm-microblaze/timex.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2006 Atmark Techno, Inc.
+ */
+
+#ifndef _ASM_MICROBLAZE_TIMEX_H
+#define _ASM_MICROBLAZE_TIMEX_H
+
+#define CLOCK_TICK_RATE 1000 /* Timer input freq. */
+
+typedef unsigned long cycles_t;
+
+#define get_cycles() (0)
+
+#endif /* _ASM_TIMEX_H */
--
1.5.4.GIT

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


john.williams at petalogix

May 4, 2008, 7:19 PM

Post #2 of 12 (2202 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

> +static inline void udelay(unsigned long usec)
> +{
> + unsigned long long tmp = usec;
> + unsigned long loops = (tmp * 4295 * HZ * loops_per_jiffy) >> 32;
> + __delay(loops);
> +}

Let's hope like hell the CPU has HW multipler and shifter for this
one! :)

> +++ b/include/asm-microblaze/timex.h
> @@ -0,0 +1,20 @@
> +
> +#define CLOCK_TICK_RATE 1000 /* Timer input freq. */

What's this? Is it used anywhere?



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


monstr at seznam

May 5, 2008, 7:22 AM

Post #3 of 12 (2192 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

Hi John,

you wrote me you have smarter implementation that xilinx did. Can you find it
and send me it?

Thanks,
M


>> +static inline void udelay(unsigned long usec)
>> +{
>> + unsigned long long tmp = usec;
>> + unsigned long loops = (tmp * 4295 * HZ * loops_per_jiffy) >> 32;
>> + __delay(loops);
>> +}
>
> Let's hope like hell the CPU has HW multipler and shifter for this
> one! :)
>
>> +++ b/include/asm-microblaze/timex.h
>> @@ -0,0 +1,20 @@
>> +
>> +#define CLOCK_TICK_RATE 1000 /* Timer input freq. */
>
> What's this? Is it used anywhere?
>
>
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


john.williams at petalogix

May 5, 2008, 5:30 PM

Post #4 of 12 (2196 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

Hi Michal,

On Mon, 2008-05-05 at 16:22 +0200, Michal Simek wrote:
> Hi John,
>
> you wrote me you have smarter implementation that xilinx did. Can you find it
> and send me it?

It's not much (any?) better? One less multiply I think? Attached
anyway - feel free to discard for now.

We could do a nice asm implementation with the optional mulhi
instruction, but that can wait.

Cheers,

John
Attachments: delay-improvement.patch (2.84 KB)


monstr at seznam

May 6, 2008, 2:56 AM

Post #5 of 12 (2180 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

Hi John,

> Hi Michal,
>
> On Mon, 2008-05-05 at 16:22 +0200, Michal Simek wrote:
>> Hi John,
>>
>> you wrote me you have smarter implementation that xilinx did. Can you find it
>> and send me it?
>
> It's not much (any?) better? One less multiply I think? Attached
> anyway - feel free to discard for now.
>
> We could do a nice asm implementation with the optional mulhi
> instruction, but that can wait.
>
> Cheers,
>
> John

+extern __inline__ void __udelay(unsigned int x)
{
- unsigned long long tmp = usec;
- unsigned long loops = (tmp * 4295 * HZ * loops_per_jiffy) >> 32;
+ unsigned long long tmp=(unsigned long long)x*(unsigned long
long)loops_per_jiffy*226LL;
+ unsigned loops=tmp>>32;
+
__delay(loops);
}

-#endif /* _ASM_MICROBLAZE_DELAY_H */
+extern __inline__ void __ndelay(unsigned int x)
+{
+ unsigned long long tmp=(unsigned long long)x*(unsigned long
long)loops_per_jiffy*226LL;
+ unsigned loops=tmp>>32;
+
+ __delay(loops);
+}

Why is __ndelay implementation the same with __udelay? This is weird for me.

+
+extern void __bad_udelay(void); /* deliberately undefined */
+extern void __bad_ndelay(void); /* deliberately undefined */

Are these function used anywhere?

+#define udelay(n) (__builtin_constant_p(n)? \
+ ((n) > __MAX_UDELAY? __bad_udelay(): __udelay((n) * (19 * HZ))) : \
+ __udelay((n) * (19 * HZ)))
+
+#define ndelay(n) (__builtin_constant_p(n)? \
+ ((n) > __MAX_NDELAY? __bad_ndelay(): __ndelay((n) * HZ)) : \
+ __ndelay((n) * HZ))

+#define muldiv(a, b, c) (((a)*(b))/(c))

muldiv: Where is this use?

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


monstr at seznam

May 6, 2008, 3:02 AM

Post #6 of 12 (2195 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

Hi All,

I saw a lot of comments about files but I have never seen any comments that
any file is OK.
Does it mean everything is broken??? I don't think so.

I'll integrate reported bugs and send microblaze_v3 version.

Thanks,
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


arnd at arndb

May 6, 2008, 4:38 AM

Post #7 of 12 (2197 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

On Tuesday 06 May 2008, Michal Simek wrote:
> I saw a lot of comments about files but I have never seen any comments that
> any file is OK.
> Does it mean everything is broken??? I don't think so.

I've commented mostly on the header files defining the ABI. Since my aim
is to have the ABI definition entirely in asm-generic/*.h, every exported
file that has more than one line in it should be changed.

The files that implement the architecture support itself all look good
to me, but since I'm not familiar with the architecture, I'm not trying
to comment on them.

I think you're doing a great job on this. Any patch set of this size that
has been maintained for a long time outside of the kernel goes through this
phase where everyone tells you what to improve, based on their experience,
while everything you do right about the patches is just taken for granted.

Don't let yourself get discouraged by the negative comments, we're really
all just trying to help you do the right thing!

> I'll integrate reported bugs and send microblaze_v3 version.

Ok, thanks!

Arnd <><
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


monstr at seznam

May 6, 2008, 6:26 AM

Post #8 of 12 (2185 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

Hi Arnd,

I am not discouraged from negative comments. I got school from Wolfgang Denk on
U-BOOT project. (Thanks Wolfgang :-))

I only want to direct this to right way. That's all. And positive ACK to some
files give me better view what's wrong. :-)

Have a good day,
Michal


>> I saw a lot of comments about files but I have never seen any comments that
>> any file is OK.
>> Does it mean everything is broken??? I don't think so.
>
> I've commented mostly on the header files defining the ABI. Since my aim
> is to have the ABI definition entirely in asm-generic/*.h, every exported
> file that has more than one line in it should be changed.
>
> The files that implement the architecture support itself all look good
> to me, but since I'm not familiar with the architecture, I'm not trying
> to comment on them.
>
> I think you're doing a great job on this. Any patch set of this size that
> has been maintained for a long time outside of the kernel goes through this
> phase where everyone tells you what to improve, based on their experience,
> while everything you do right about the patches is just taken for granted.
>
> Don't let yourself get discouraged by the negative comments, we're really
> all just trying to help you do the right thing!
>
>> I'll integrate reported bugs and send microblaze_v3 version.
>
> Ok, thanks!
>
> Arnd <><
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


grant.likely at secretlab

May 6, 2008, 7:28 AM

Post #9 of 12 (2189 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

On Tue, May 6, 2008 at 5:38 AM, Arnd Bergmann <arnd [at] arndb> wrote:
> On Tuesday 06 May 2008, Michal Simek wrote:
> > I saw a lot of comments about files but I have never seen any comments that
> > any file is OK.
> > Does it mean everything is broken??? I don't think so.
>
<snip>
>
> I think you're doing a great job on this. Any patch set of this size that
> has been maintained for a long time outside of the kernel goes through this
> phase where everyone tells you what to improve, based on their experience,
> while everything you do right about the patches is just taken for granted.
>
> Don't let yourself get discouraged by the negative comments, we're really
> all just trying to help you do the right thing!

Let me add my voice to Arnd's. This is a *big* task and you're
handling it very well.

Cheers,
g.

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


stephen.neuendorffer at xilinx

May 6, 2008, 9:36 AM

Post #10 of 12 (2180 views)
Permalink
RE: [PATCH 24/56] microblaze_v2: time support [In reply to]

> I think you're doing a great job on this. Any patch set of this size
that
> has been maintained for a long time outside of the kernel goes through
this
> phase where everyone tells you what to improve, based on their
experience,
> while everything you do right about the patches is just taken for
granted.

I completely agree on this. I think you're making a huge amount of
progress and spending alot of time incorporating alot of comments from
alot of people.

My main priority is to get as many of the improvements that we've had at
in our git tree, so as to be able to switch to the mainline code as
quickly as possible. If I keep bringing up the same things it is
because they are barriers to that happening. I very much want to put a
big ACK on everything, but I'm uncomfortable doing that until I can at
least boot it, and that hasn't happened yet.

> Don't let yourself get discouraged by the negative comments, we're
really
> all just trying to help you do the right thing!

One of the key things that many people take a long time to learn is that
negative comments about code are not a reflection of negativity towards
the person who wrote the code.

Steve


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


john.williams at petalogix

May 6, 2008, 3:50 PM

Post #11 of 12 (2188 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

Hi Michal,

On Tue, 2008-05-06 at 15:26 +0200, Michal Simek wrote:

> I am not discouraged from negative comments. I got school from Wolfgang Denk on
> U-BOOT project. (Thanks Wolfgang :-))
>
> I only want to direct this to right way. That's all. And positive ACK to some
> files give me better view what's wrong. :-)

I'd like to echo the other comments so far -you are doing a great job.
I'd take silence on a patch as cautious agreement - like Steve I'm
waiting for the dust to settle to do a build and boot test (probably on
v3 of your patchset).

Most of this code has been running happily for >18 months in the
PetaLogix 2.6.20 kernel, and you tested your OF changes pretty well over
Oct-Jan. So, I'm happy enough with the underlying implementation, it's
really just a case of meeting the kernel.org gatekeeper's standards.

The syscall interface is the last prickly one, but we'll get there.

Cheers,

John


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


tglx at linutronix

May 7, 2008, 12:22 AM

Post #12 of 12 (2192 views)
Permalink
Re: [PATCH 24/56] microblaze_v2: time support [In reply to]

On Sun, 4 May 2008, monstr [at] seznam wrote:
> From: Michal Simek <monstr [at] monstr>

> +int do_settimeofday(struct timespec *tv)
> +void do_gettimeofday(struct timeval *tv)

Again, please convert the time code to clocksource and use the generic
functionality.

Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.