Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3652013ybi; Mon, 29 Jul 2019 10:09:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSuNuXd1YXqedw2YloF88k0Xuci7tFIJ2jVN9ejVb8FVISJBVAe36HmPqxoaIKa8/mSY4A X-Received: by 2002:a17:902:9896:: with SMTP id s22mr106169836plp.4.1564420143084; Mon, 29 Jul 2019 10:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564420143; cv=none; d=google.com; s=arc-20160816; b=MfetrPr35565NmJgJY6j4nIe8MuVio1NaoikkE+jAZ1dxwVkFX4E25MY8fDvPXIVxh gVjXYbOwCVuzlNMxpEzeskedj0ZzMlICj2ucJE804TGI30dA/yw28HXPrj0m4W6YmXFR Ieo8rIwFjKlR42rjWeL6bnG16Cd4L7TVr0h/IsIOT+/Y5adjkJzMwtrmfvP4SdQ9xD+m RSpTO+r/Ba0BkHe/bxxzZPIOSSFmoX0QzBncz+H+sJPXI68o1CJY4zy/2GoZP6pMupBD sZIfiJ+FPMk/JpgNjq00V+AF934swLi9zDEG28mEfWys37ljRQoOVT8aT/04fmPz0trI mnRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=I4Xrf2HcNax3hit7aGozPoAjb6V05O9bDUBT9woTsVw=; b=qjkO19kOaYLwm16Wco2dmOOH88RJfphnwnFp9qspcSSpE0uiUTeropQR7bhA9ZifO+ hAuqPzEN4E5a3tAhkt9v7c5T/r1g52j3qeiAOyBWecOiWN20+T46NcSrWmM/LwFyLZ3V wsgALmK+PHGEYRyy1bR1LDu6riXg2J2TDgkzCho0Ywdsetc0ndFMGwrJG6eNHFoznRJw GmXsWTEJ09bij+REwVS3zM+twWozciGepqxTAG5mlAo2FrDVqPlYGm/ezKZG/uEZoqhM wOYvq02s6z42YcTBkNgcPHhUQ8+S3BEfNLodVuAii6Gk73Rly2M2531fefc1d8AW3yQD 2Caw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z142si27722707pfc.128.2019.07.29.10.08.47; Mon, 29 Jul 2019 10:09:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727651AbfG2RFE (ORCPT + 99 others); Mon, 29 Jul 2019 13:05:04 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:40125 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727487AbfG2RFE (ORCPT ); Mon, 29 Jul 2019 13:05:04 -0400 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id x6TH3wlC028965; Mon, 29 Jul 2019 20:03:58 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 8441) id BD76B62A2E; Mon, 29 Jul 2019 20:03:58 +0300 (IDT) From: Avi Fishman To: tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, daniel.lezcano@linaro.org, tglx@linutronix.de, avifishman70@gmail.com Cc: openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v5] clocksource/drivers/npcm: fix GENMASK and timer operation Date: Mon, 29 Jul 2019 20:03:54 +0300 Message-Id: <20190729170354.202374-1-avifishman70@gmail.com> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org NPCM7XX_Tx_OPER GENMASK bits where wrong, Since NPCM7XX_REG_TICR0 register reset value of those bits was 0, it did not cause an issue. in npcm7xx_timer_oneshot() the original NPCM7XX_REG_TCSR0 register was read again after masking it with ~NPCM7XX_Tx_OPER so the masking didn't take effect. npcm7xx_timer_periodic() was not wrong but it wrote to NPCM7XX_REG_TICR0 in a middle of read modify write to NPCM7XX_REG_TCSR0 which is confusing. npcm7xx_timer_oneshot() did wrong calculation Signed-off-by: Avi Fishman --- drivers/clocksource/timer-npcm7xx.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/clocksource/timer-npcm7xx.c b/drivers/clocksource/timer-npcm7xx.c index 8a30da7f083b..9780ffd8010e 100644 --- a/drivers/clocksource/timer-npcm7xx.c +++ b/drivers/clocksource/timer-npcm7xx.c @@ -32,7 +32,7 @@ #define NPCM7XX_Tx_INTEN BIT(29) #define NPCM7XX_Tx_COUNTEN BIT(30) #define NPCM7XX_Tx_ONESHOT 0x0 -#define NPCM7XX_Tx_OPER GENMASK(27, 3) +#define NPCM7XX_Tx_OPER GENMASK(28, 27) #define NPCM7XX_Tx_MIN_PRESCALE 0x1 #define NPCM7XX_Tx_TDR_MASK_BITS 24 #define NPCM7XX_Tx_MAX_CNT 0xFFFFFF @@ -84,8 +84,6 @@ static int npcm7xx_timer_oneshot(struct clock_event_device *evt) val = readl(timer_of_base(to) + NPCM7XX_REG_TCSR0); val &= ~NPCM7XX_Tx_OPER; - - val = readl(timer_of_base(to) + NPCM7XX_REG_TCSR0); val |= NPCM7XX_START_ONESHOT_Tx; writel(val, timer_of_base(to) + NPCM7XX_REG_TCSR0); @@ -97,12 +95,11 @@ static int npcm7xx_timer_periodic(struct clock_event_device *evt) struct timer_of *to = to_timer_of(evt); u32 val; + writel(timer_of_period(to), timer_of_base(to) + NPCM7XX_REG_TICR0); + val = readl(timer_of_base(to) + NPCM7XX_REG_TCSR0); val &= ~NPCM7XX_Tx_OPER; - - writel(timer_of_period(to), timer_of_base(to) + NPCM7XX_REG_TICR0); val |= NPCM7XX_START_PERIODIC_Tx; - writel(val, timer_of_base(to) + NPCM7XX_REG_TCSR0); return 0; -- 2.18.0