All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, mingo@kernel.org,
	Jisheng Zhang <jszhang@marvell.com>
Subject: [PATCH 62/69] clocksource/drivers/pistachio: Fix wrong calculated clocksource read value
Date: Fri, 18 Dec 2015 15:18:15 +0100	[thread overview]
Message-ID: <1450448302-27429-62-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1450448302-27429-1-git-send-email-daniel.lezcano@linaro.org>

From: Jisheng Zhang <jszhang@marvell.com>

Let's assume the counter value is 0xf0000000, the pistachio clocksource
read cycles function should return ~0x0fffffff but actually it returns
0xffffffff0fffffff.

That occurs because:

	~(cycle_t)value is different from (cycle_t)~value.

unsigned long val = ~(unsigned long)0xf0000000;
40049a:       48 b8 ff ff ff 0f ff    movabs $0xffffffff0fffffff,%rax

unsigned long val = (unsigned long)~0xf0000000;
40049a:       48 c7 45 f8 ff ff ff    movq   $0xfffffff,-0x8(%rbp)

We fix this issue by calculating bitwise-not counter, then cast to
cycle_t.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/time-pistachio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/time-pistachio.c b/drivers/clocksource/time-pistachio.c
index bba6799..3269d9e 100644
--- a/drivers/clocksource/time-pistachio.c
+++ b/drivers/clocksource/time-pistachio.c
@@ -84,7 +84,7 @@ pistachio_clocksource_read_cycles(struct clocksource *cs)
 	counter = gpt_readl(pcs->base, TIMER_CURRENT_VALUE, 0);
 	raw_spin_unlock_irqrestore(&pcs->lock, flags);
 
-	return ~(cycle_t)counter;
+	return (cycle_t)~counter;
 }
 
 static u64 notrace pistachio_read_sched_clock(void)
-- 
1.9.1


WARNING: multiple messages have this Message-ID (diff)
From: daniel.lezcano@linaro.org (Daniel Lezcano)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 62/69] clocksource/drivers/pistachio: Fix wrong calculated clocksource read value
Date: Fri, 18 Dec 2015 15:18:15 +0100	[thread overview]
Message-ID: <1450448302-27429-62-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1450448302-27429-1-git-send-email-daniel.lezcano@linaro.org>

From: Jisheng Zhang <jszhang@marvell.com>

Let's assume the counter value is 0xf0000000, the pistachio clocksource
read cycles function should return ~0x0fffffff but actually it returns
0xffffffff0fffffff.

That occurs because:

	~(cycle_t)value is different from (cycle_t)~value.

unsigned long val = ~(unsigned long)0xf0000000;
40049a:       48 b8 ff ff ff 0f ff    movabs $0xffffffff0fffffff,%rax

unsigned long val = (unsigned long)~0xf0000000;
40049a:       48 c7 45 f8 ff ff ff    movq   $0xfffffff,-0x8(%rbp)

We fix this issue by calculating bitwise-not counter, then cast to
cycle_t.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/time-pistachio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/time-pistachio.c b/drivers/clocksource/time-pistachio.c
index bba6799..3269d9e 100644
--- a/drivers/clocksource/time-pistachio.c
+++ b/drivers/clocksource/time-pistachio.c
@@ -84,7 +84,7 @@ pistachio_clocksource_read_cycles(struct clocksource *cs)
 	counter = gpt_readl(pcs->base, TIMER_CURRENT_VALUE, 0);
 	raw_spin_unlock_irqrestore(&pcs->lock, flags);
 
-	return ~(cycle_t)counter;
+	return (cycle_t)~counter;
 }
 
 static u64 notrace pistachio_read_sched_clock(void)
-- 
1.9.1

  parent reply	other threads:[~2015-12-18 14:23 UTC|newest]

Thread overview: 154+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-17 14:50 [GIT PULL] clockevents for 4.5 Daniel Lezcano
2015-12-17 14:50 ` Daniel Lezcano
2015-12-18 14:17 ` [PATCH 01/69] clocksource/drivers/mtk_timer: Add pr_fmt define Daniel Lezcano
2015-12-18 14:17   ` Daniel Lezcano
2015-12-18 14:17   ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 02/69] clocksource/drivers/mtk_timer: Fix pr_warn() messages in mtk_timer_init Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-30 18:15     ` Matthias Brugger
2015-12-30 18:15       ` Matthias Brugger
2015-12-30 18:15       ` Matthias Brugger
2015-12-18 14:17   ` [PATCH 03/69] clocksource/drivers/mtk_timer: Fix memleak in mtk_timer_init() Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 04/69] clocksource/drivers/tegra: Allow timer irq affinity change Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 05/69] clocksource/drivers/rockchip: Make the driver more readable Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 06/69] time: Define dummy functions for the generic sched clock Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 07/69] clocksource/drivers/rockchip: Remove dsb() usage Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 08/69] clocksource/drivers/qcom: Make COMPILE_TEST enabled for ARM architecture Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 09/69] clocksource/drivers/st_lpc: Fix Kconfig dependency Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 10/69] clocksource/drivers/st_lpc: Add the COMPILE_TEST option Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 11/69] clocksource/drivers/pxa_timer: Move the Kconfig rule Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 12/69] clocksource/drivers/pxa_timer: Add the COMPILE_TEST option Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 13/69] clocksource/drivers/tango: Add " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 14/69] clocksource/drivers/pistachio: Add the " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 15/69] clocksource/drivers/mediatek: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-30 18:16     ` Matthias Brugger
2015-12-30 18:16       ` Matthias Brugger
2015-12-30 18:16       ` Matthias Brugger
2015-12-18 14:17   ` [PATCH 16/69] clocksource/drivers/rockchip: Add " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 17/69] clocksource/drivers/armada-370-xp: Add the " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 18/69] clocksource/drivers/meson6: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 19/69] clocksource/drivers/orion: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 20/69] clocksource/drivers/digicolor: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 21/69] clocksource/drivers/dw_apb: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 22/69] clocksource/drivers/sun4i: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 23/69] clocksource/drivers/sun5i: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 24/69] clocksource/drivers/tegra2: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 25/69] clocksource/drivers/vt8500: Remove unneeded header Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 26/69] clocksource/drivers/vt8500: Add the COMPILE_TEST option Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 27/69] clocksource/drivers/cadence_ttc: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 28/69] clocksource/drivers/asm9260: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 29/69] clocksource/drivers/lpc32xx: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 30/69] clocksource/drivers/nomadik_mtu: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 31/69] clocksource/drivers/prcmu: Fix Kconfig and add " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 32/69] clocksource/drivers/exynos_mct: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 33/69] clocksource/drivers/samsung-pwm: Add the " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 34/69] clocksource/drivers/fsl-ftm: " Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 35/69] clocksource/drivers/Kconfig: Add missing GENERIC_CLOCKEVENTS dependency Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 36/69] clocksource/drivers/dw_apb_timer_of: Implement ARM delay timer Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 37/69] clocksource/drivers/h8300: Cleanup startup and remove module code Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 38/69] clocksource/drivers/h8300_timer8: Fix compilation error with dev_warn Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 39/69] clocksource/drivers/h8300_tpu: Remove unused macros Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 40/69] clocksource/drivers/h8300_tpu: Remove pointless headers for TPU Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 41/69] clocksource/drivers/h8300_timer8: Remove unused headers Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 42/69] clocksource/drivers/h8300_timer8: Remove unused macros Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 43/69] clocksource/drivers/h8300_timer8: Remove PERIODIC and ONESHOT macro Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 44/69] clocksource/drivers/h8300_timer8: Fix irq return value check Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 45/69] clocksource/drivers/h8300_timer8: Remove pointless irq re-entrant safe code Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:17   ` [PATCH 46/69] clocksource/drivers/h8300_timer8: Remove irq and lock legacy code Daniel Lezcano
2015-12-18 14:17     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 47/69] clocksource/drivers/h8300_timer8: Retrieve the clock rate at init time Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 48/69] clocksource/drivers/h8300_timer16: Remove pointless headers Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 49/69] clocksource/drivers/h8300_timer16: Remove unused macros Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 50/69] clocksource/drivers/h8300_timer16: Remove unused fields in timer16_priv Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 51/69] clocksource/drivers/h8300_timer16: Fix irq return value check Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 52/69] clocksource/drivers/h8300_timer16: Remove pointless lock Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 53/69] clocksource/drivers/timer_sun5i: Replace code by clocksource_mmio_init Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 54/69] clocksource/drivers/h8300_timer8: Separate the Kconfig option from the arch Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 55/69] h8300: Rename ctlr_out/in[bwl] to raw_read/write[bwl] Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 56/69] clocksource/drivers/h8300: Increase the compilation test coverage Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 57/69] clocksource/drivers/tango-xtal: Replace code by clocksource_mmio_init Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 58/69] clocksource/drivers/dw_apb_timer: Fix apbt_readl return types Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 59/69] clocksource/drivers/dw_apb_timer: Use {readl|writel}_relaxed in critical path Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 60/69] clocksource/drivers/dw_apb_timer: Inline apbt_readl and apbt_writel Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 61/69] clockevents/drivers/arm_global_timer: Use writel_relaxed in gt_compare_set Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` Daniel Lezcano [this message]
2015-12-18 14:18     ` [PATCH 62/69] clocksource/drivers/pistachio: Fix wrong calculated clocksource read value Daniel Lezcano
2015-12-18 14:18   ` [PATCH 63/69] clocksource/drivers/arm_global_timer: Fix suspend resume Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 64/69] clocksource/drivers/lpc32: Correct pr_err() output format Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 65/69] clocksource/drivers/h8300: Change to overflow interrupt Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 66/69] clocksource/drivers/h8300: Fix timer not overflow case Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 67/69] clocksource/drivers/h8300: Simplify delta handling Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 68/69] clocksource/drivers/h8300: Initializer cleanup Daniel Lezcano
2015-12-18 14:18     ` Daniel Lezcano
2015-12-18 14:18   ` [PATCH 69/69] clocksource/drivers/h8300: Use ioread / iowrite Daniel Lezcano
2015-12-18 14:18     ` 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=1450448302-27429-62-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=jszhang@marvell.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.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.