From: Maxim Uvarov <maxim.uvarov@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Shashi Mallela" <shashi.mallela@linaro.org>,
"Leif Lindholm" <leif@nuviainc.com>,
"QEMU Developers" <qemu-devel@nongnu.org>,
qemu-arm <qemu-arm@nongnu.org>,
"Radosław Biernacki" <rad@semihalf.com>
Subject: Re: [PATCH v3 1/2] hw/watchdog: Implement SBSA watchdog device
Date: Thu, 8 Oct 2020 13:43:35 +0300 [thread overview]
Message-ID: <CAD8XO3YaavVfz6yaAx2N95B8a87tkp=-GKt814Zou4e7B+cVvg@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA9QRJhorL1XtWBCQk9uo21OtMHUrH7ipG3tiFbOBGizPQ@mail.gmail.com>
On Thu, 8 Oct 2020 at 13:27, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Thu, 8 Oct 2020 at 11:21, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
> >
> > On Thu, 8 Oct 2020 at 05:43, Shashi Mallela <shashi.mallela@linaro.org> wrote:
> > > +static void sbsa_gwdt_update_timer(SBSA_GWDTState *s)
> > > +{
> > > + uint64_t timeout = 0;
> > > +
> > > + if (s->enabled) {
> > > + /*
> > > + * Extract the upper 16 bits from woru & 32 bits from worl
> > > + * registers to construct the 48 bit offset value
> > > + */
> > > + timeout = s->woru & SBSA_GWDT_WOR_MASK;
> > > + timeout <<= 32;
> > > + timeout |= s->worl;
> > > + timeout = muldiv64(timeout, NANOSECONDS_PER_SECOND, SBSA_TIMER_FREQ);
> >
> > static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
> > {
> > return (__int128_t)a * b / c;
> > }
> >
> > #define NANOSECONDS_PER_SECOND 1000000000LL
> >
> > Interesting why gcc does not warn on 64bit signed to 32bit unsigned
> > truncation here. Looks like it's too smart to understand
> > that value fits in 32 bits.
>
> What truncation? 1000000000 in decimal is 0x3B9ACA00 in hex:
> the number fits in an 32 bit integer without truncation.
>
> (ns = muldiv64(ticks, NANOSECONDS_PER_SECOND, frequency) is a pretty
> common pattern in our timer devices for converting a number of
> ticks to a duration in nanoseconds, as is the reverse
> conversion of ticks = muldiv64(ns, NANOSECONDS_PER_SECOND, frequency).)
>
> thanks
> -- PMM
I meant that LL is an long long int which is 64 bit size type. And
then you pass it to uint32_t.
next prev parent reply other threads:[~2020-10-08 10:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 2:42 [PATCH v3 0/2] Add watchdog support for SbsaQemu Shashi Mallela
2020-10-08 2:42 ` [PATCH v3 1/2] hw/watchdog: Implement SBSA watchdog device Shashi Mallela
2020-10-08 10:21 ` Maxim Uvarov
2020-10-08 10:27 ` Peter Maydell
2020-10-08 10:43 ` Maxim Uvarov [this message]
2020-10-08 14:08 ` Peter Maydell
2020-10-09 9:35 ` Maxim Uvarov
2020-10-08 2:42 ` [PATCH v3 2/2] hw/arm/sbsa-ref: add " Shashi Mallela
2020-10-08 9:29 ` Maxim Uvarov
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='CAD8XO3YaavVfz6yaAx2N95B8a87tkp=-GKt814Zou4e7B+cVvg@mail.gmail.com' \
--to=maxim.uvarov@linaro.org \
--cc=leif@nuviainc.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rad@semihalf.com \
--cc=shashi.mallela@linaro.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).