Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1292883

Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated clocksource read value

From Daniel Lezcano <daniel.lezcano@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated clocksource read value
Date 2015-12-16 11:40 +0100
Message-ID <qGhF0-zW-15@gated-at.bofh.it> (permalink)
References (2 earlier) <qGexr-78d-5@gated-at.bofh.it> <qGeQN-7gA-5@gated-at.bofh.it> <qGf0u-7kj-7@gated-at.bofh.it> <qGgzg-8nq-1@gated-at.bofh.it> <qGgIV-8qr-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 12/16/2015 10:33 AM, Russell King - ARM Linux wrote:
> 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.

I think this approach is perfectly sane. When I said we should look at 
this portion closely, I meant we should double check the bitwise-nor 
order regarding the explicit cast. The clocksource's mask makes sense 
and must stay untouched.



-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-12-15 22:00 +0100
  Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Jisheng Zhang <jszhang@marvell.com> - 2015-12-16 08:20 +0100
    Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Jisheng Zhang <jszhang@marvell.com> - 2015-12-16 08:40 +0100
      Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Jisheng Zhang <jszhang@marvell.com> - 2015-12-16 08:50 +0100
        Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Jisheng Zhang <jszhang@marvell.com> - 2015-12-16 09:00 +0100
        Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-12-16 10:30 +0100
          Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-12-16 10:40 +0100
            Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-12-16 11:40 +0100
              Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-12-16 17:30 +0100
              Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Jisheng Zhang <jszhang@marvell.com> - 2015-12-17 10:20 +0100
            Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-12-16 11:40 +0100
      Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-12-16 10:10 +0100
    Re: [PATCH] clocksource/drivers/pistachio: Fix wrong calculated  clocksource read value Daniel Lezcano <daniel.lezcano@linaro.org> - 2015-12-16 10:10 +0100

csiph-web