All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [Resend RFC PATCH v2 0/1] MIPS64 timer bug
Date: Tue, 14 Jul 2015 22:54:40 +1200	[thread overview]
Message-ID: <1436871282-5602-1-git-send-email-judge.packham@gmail.com> (raw)

We found this on a custom MIPS64 based board. Basically we were seeing
udelay and friends do odd things occasionally. The problem appears to be
when we read the c0 32-bit counter sometimes we get unexpected values
when this is returned as an unsigned long on a 64-bit system. I've
written a little test program (below) that demonstrates the what I think
is problem, it'll work on a x86_64 desktop. I don't know the ins and
outs of the C specifications to comment on if this is a compiler bug but
I still think we should be treating the c0 registers as unsigned
regardless.

 $ cat test.c
 #include <stdio.h>

 int main(int argc, char *argv[])
 {
         int a;
         unsigned long b;

         a = 0x80000000;
         b = a;

         printf("sizeof(int) = %zu\n", sizeof(int));
         printf("sizeof(unsigned long) = %zu\n", sizeof(unsigned long));
         printf("a = %d\n", a);
         printf("a = %x\n", a);
         printf("b = %lu\n", b);
         printf("b = %lx\n", b);

         return 0;
 }

Which yields the following output

 $ ./test
 sizeof(int) = 4
 sizeof(unsigned long) = 8
 a = -2147483648
 a = 80000000
 b = 18446744071562067968
 b = ffffffff80000000

And for completeness
  $ gcc --version
  gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
  Copyright (C) 2013 Free Software Foundation, Inc.

Our embedded target is using
 $ mips64-octeon-linux-gnu-gcc --version
 mips64-octeon-linux-gnu-gcc (GCC) 4.7.0
 Copyright (C) 2012 Free Software Foundation, Inc.


Changes in v2:
- Use Rob's current email address

Chris Packham (1):
  mips: Use unsigned int when reading c0 registers

 arch/mips/include/asm/mipsregs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.5.0.rc0

             reply	other threads:[~2015-07-14 10:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14 10:54 Chris Packham [this message]
2015-07-14 10:54 ` [U-Boot] [Resend RFC PATCH v2] mips: Use unsigned int when reading c0 registers Chris Packham
2015-07-14 19:01   ` Daniel Schwierzeck
2015-07-14 21:12     ` Chris Packham
2015-07-16  0:14       ` Chris Packham
2015-07-18  9:29   ` Daniel Schwierzeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436871282-5602-1-git-send-email-judge.packham@gmail.com \
    --to=judge.packham@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.