All of lore.kernel.org
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated clocksource read value
Date: Wed, 16 Dec 2015 09:33:40 +0000	[thread overview]
Message-ID: <20151216093340.GD8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <56712D33.5080009@linaro.org>

On Wed, Dec 16, 2015 at 10:21:55AM +0100, Daniel Lezcano wrote:
> On 12/16/2015 08:36 AM, Jisheng Zhang wrote:
> >And in fact, clocksource_mmio_readw_down() also has similar issue, but it masks
> >with c->mask before return, the c->mask is less than 32 bit (because the
> >clocksource_mmio_init think number of valid bits > 32 or < 16 is invalid.)
> >the higher 32 bits are masked off, so we never saw such issue. But we'd better
> >to fix that, what's your opinion?
> 
> I think we should have a look to this portion closely.

There is no need to return more bits than are specified.  If you have
a N-bit counter, then the high (64-N)-bits can be any value, because:

static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask)
{
        return (now - last) & mask;
}

where 'now' is the current value returned from the clock source read
function, 'last' is a previously returned value, and 'mask' is the
bit mask.  This has the effect of ignoring the high order bits.

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

WARNING: multiple messages have this Message-ID (diff)
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Jisheng Zhang <jszhang@marvell.com>,
	tglx@linutronix.de, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated clocksource read value
Date: Wed, 16 Dec 2015 09:33:40 +0000	[thread overview]
Message-ID: <20151216093340.GD8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <56712D33.5080009@linaro.org>

On Wed, Dec 16, 2015 at 10:21:55AM +0100, Daniel Lezcano wrote:
> On 12/16/2015 08:36 AM, Jisheng Zhang wrote:
> >And in fact, clocksource_mmio_readw_down() also has similar issue, but it masks
> >with c->mask before return, the c->mask is less than 32 bit (because the
> >clocksource_mmio_init think number of valid bits > 32 or < 16 is invalid.)
> >the higher 32 bits are masked off, so we never saw such issue. But we'd better
> >to fix that, what's your opinion?
> 
> I think we should have a look to this portion closely.

There is no need to return more bits than are specified.  If you have
a N-bit counter, then the high (64-N)-bits can be any value, because:

static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask)
{
        return (now - last) & mask;
}

where 'now' is the current value returned from the clock source read
function, 'last' is a previously returned value, and 'mask' is the
bit mask.  This has the effect of ignoring the high order bits.

-- 
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

  reply	other threads:[~2015-12-16  9:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 15:42 [PATCH] clocksource/drivers/pistachio: Fix wrong calculated clocksource read value Jisheng Zhang
2015-11-25 15:42 ` Jisheng Zhang
2015-12-15 20:59 ` Daniel Lezcano
2015-12-15 20:59   ` Daniel Lezcano
2015-12-16  7:11   ` Jisheng Zhang
2015-12-16  7:11     ` Jisheng Zhang
2015-12-16  7:28     ` Jisheng Zhang
2015-12-16  7:28       ` Jisheng Zhang
2015-12-16  7:36       ` Jisheng Zhang
2015-12-16  7:36         ` Jisheng Zhang
2015-12-16  7:49         ` Jisheng Zhang
2015-12-16  7:49           ` Jisheng Zhang
2015-12-16  9:21         ` Daniel Lezcano
2015-12-16  9:21           ` Daniel Lezcano
2015-12-16  9:33           ` Russell King - ARM Linux [this message]
2015-12-16  9:33             ` Russell King - ARM Linux
2015-12-16 10:32             ` Daniel Lezcano
2015-12-16 10:32               ` Daniel Lezcano
2015-12-16 10:38               ` Russell King - ARM Linux
2015-12-16 10:38                 ` Russell King - ARM Linux
2015-12-16 16:23                 ` Daniel Lezcano
2015-12-16 16:23                   ` Daniel Lezcano
2015-12-17  9:07                 ` Jisheng Zhang
2015-12-17  9:07                   ` Jisheng Zhang
2015-12-16  9:01       ` Daniel Lezcano
2015-12-16  9:01         ` Daniel Lezcano
2015-12-16  9:02     ` Daniel Lezcano
2015-12-16  9:02       ` Daniel Lezcano

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=20151216093340.GD8644@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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 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.