From: Peter Chubb <peter.chubb@nicta.com.au>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: davidm@ok-labs.com, Peter Chubb <peter.chubb@nicta.com.au>,
qemu-devel@nongnu.org, philipo@ok-labs.com,
Paul Brook <paul@codesourcery.com>
Subject: Re: [Qemu-devel] [PATCH] [ARM] Fix sp804 dual-timer
Date: Fri, 30 Sep 2011 19:23:45 +1000 [thread overview]
Message-ID: <w4ty7uxu1q.wl%peter@chubb.wattle.id.au> (raw)
In-Reply-To: <CAFEAcA9zB+Ud1DTpDPsHpL7tYHD1Up4FVMt68J4+YkAi16aNtg@mail.gmail.com>
>>>>> "Peter" == Peter Maydell <peter.maydell@linaro.org> writes:
Peter> On 30 September 2011 01:20, Peter Chubb
Peter> <peter.chubb@nicta.com.au> wrote:
>> Thanks Peter!
>>
>> Here's a reworked patch.
Peter> NB: when you resend patches it's better to send them as
Peter> completely fresh emails (via git-send-email or equivalent)
Peter> because otherwise they're more of a pain to apply (you end up
Peter> with random email chatter in the commit message, usually).
Thanks for the heads-up. I'll edit the patch in Quilt.
>> +/* + * sp804_id should be: + * union { + * struct { + * uint32_t
>> PartNumber:12; == 0x804 + * uint32_t DesignerID:8; == 'A' + *
>> uint32_t Revision:4; == 1 + * uint32_t Configurations:6; == 0 + *
>> }; + * uint8_t bytes[4]; + * }; + * but that gets into too many
>> byte-ordering and packing issues. + */ +static const uint8_t
>> sp804_id[] = {0x04, 0x18, 0x14, 0}; +static const uint8_t
>> sp804_PrimeCellID[] = {0xB1, 0x05, 0xF0, 0x0D};
Peter> I disagree with "should be" -- yes, semantically the ID
Peter> registers have a number of subfields but for practical purposes
Peter> they're just bytes; so I don't think that comment is necessary.
Peter> There's no need to split the two sets of ID registers into
Peter> different arrays, either -- it just complicates the code. Also
Peter> you have the primecell ID values in the wrong order (check the
Peter> 'register summary' table in the docs). You want:
OK, and thanks.
Peter> static const uint8_t sp804_id[] = { 0x04, 0x18, 0x14, 0, 0x0d,
Peter> 0xf0, 0x05, 0xb1 };
>> + /* + * Ids are packed into a word, then accessed one byte
>> per word. + */
Peter> No, they're just a set of byte registers.
At word offsets.
>> + /* TimerPeriphID */ + if (offset >= 0xfe0 && offset <=
>> 0xfec) + return sp804_id[(offset - 0xfe0) >> 2];
Peter> Coding style requires braces on if statements (plus your
Peter> indentation is wrong). If you run your patch through
Peter> scripts/checkpatch.pl it will catch this sort of thing.
Thanks.
>> + hw_error("sp804_read: Bad offset %x\n", (int)offset); +
>> return 0;
Peter> hw_error() is a fatal error -- don't use it for conditions that
Peter> can be triggered by a malicious guest. (And since it's noreturn
Peter> there's not much point putting any code after it...)
Is there a better `tell the programmer s/he's done something stupid'
error function? The plxxx.c files all used hw_error() for bad
offsets.
I shan't be able to get to this again until Tuesday my time. Expect
another patch then.
Peter C
--
Dr Peter Chubb http://www.gelato.unsw.edu.au peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au ERTOS within National ICT Australia
next prev parent reply other threads:[~2011-09-30 9:24 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-29 2:34 [Qemu-devel] [PATCH] [ARM] Fix sp804 dual-timer Peter Chubb
2011-09-29 9:58 ` Peter Maydell
2011-09-30 0:20 ` Peter Chubb
2011-09-30 9:04 ` Peter Maydell
2011-09-30 9:23 ` Peter Chubb [this message]
2011-09-30 10:07 ` Peter Maydell
[not found] ` <w4y5x6g8gk.wl%peter@chubb.wattle.id.au>
[not found] ` <CAFEAcA8-iByH0xgjkMUo3hvkrLc8NV-Lq4GbHU-d7UoF8GSX-Q@mail.gmail.com>
2011-11-21 21:58 ` [Qemu-devel] [PATCH] imx.31 and KZM board support Peter Chubb
2011-11-21 22:45 ` Andreas Färber
2011-11-21 23:04 ` Peter Chubb
2011-11-21 23:10 ` Peter Maydell
2011-11-21 23:41 ` Peter Maydell
2011-11-21 23:54 ` Peter Chubb
2011-11-22 0:12 ` Peter Maydell
2011-11-22 0:27 ` Peter Chubb
2011-11-22 0:32 ` Peter Maydell
2011-11-22 4:31 ` [Qemu-devel] [PATCH V2 0/4] " Peter Chubb
2011-11-22 4:32 ` [Qemu-devel] [PATCH V2 1/4] imx.31 and KZM board support: UART support Peter Chubb
2011-11-24 18:53 ` Peter Maydell
2011-11-24 22:18 ` Peter Chubb
2011-11-22 4:33 ` [Qemu-devel] [PATCH V2 2/4] imx.31 and KZM board support: Timer support Peter Chubb
2011-11-24 17:01 ` Peter Maydell
2011-11-24 19:06 ` Peter Maydell
2011-11-22 4:34 ` [Qemu-devel] [PATCH V2 3/4] imx.31 and KZM board support: interrupt controller Peter Chubb
2011-11-24 19:37 ` Peter Maydell
2011-11-22 4:34 ` [Qemu-devel] [PATCH V2 4/4] imx.31 and KZM board support: Makefile and board Peter Chubb
2011-11-24 19:41 ` Peter Maydell
2011-11-24 20:19 ` Andreas Färber
2011-11-24 21:31 ` Peter Maydell
2011-11-24 21:46 ` Andreas Färber
2011-11-24 21:52 ` Peter Maydell
2011-11-23 0:51 ` [Qemu-devel] [PATCH V2 0/4] imx.31 and KZM board support Peter Chubb
2011-11-24 19:07 ` Andreas Färber
2011-11-26 5:21 ` Peter Chubb
2011-11-26 19:35 ` Peter Maydell
2011-11-22 11:06 ` [Qemu-devel] [PATCH] " Juan Quintela
2011-11-22 11:14 ` Peter Maydell
2011-11-23 14:24 ` Juan Quintela
2011-11-23 0:48 ` Peter Chubb
2011-11-21 22:05 ` [Qemu-devel] [PATCH] [ARM] Fix sp804 dual-timer Peter Chubb
2011-11-21 23:01 ` Andreas Färber
2011-11-22 0:20 ` [Qemu-devel] [PATCH] [ARM] fix function names in error messages in arm_timer.c Peter Chubb
2011-11-22 3:20 ` [Qemu-devel] [PATCH] [ARM] Fix hw_error messages from arm_timer.c Peter Chubb
2011-12-05 19:53 ` andrzej zaborowski
2011-11-22 3:25 ` [Qemu-devel] [PATCH] [ARM] Fix sp804 dual-timer Peter Chubb
2011-11-24 17:46 ` Peter Maydell
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=w4ty7uxu1q.wl%peter@chubb.wattle.id.au \
--to=peter.chubb@nicta.com.au \
--cc=davidm@ok-labs.com \
--cc=paul@codesourcery.com \
--cc=peter.maydell@linaro.org \
--cc=philipo@ok-labs.com \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).