Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4399857ybi; Mon, 15 Jul 2019 08:21:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuGTLO+pAt+NwvJ9xXiWA7tu638g25ZPdFTPKLg7mW8D0lkowiB7sdunnsyoX9PeOvOxQX X-Received: by 2002:a63:d755:: with SMTP id w21mr27756783pgi.311.1563204098928; Mon, 15 Jul 2019 08:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563204098; cv=none; d=google.com; s=arc-20160816; b=bJCuoZzBnjENfDlKj5FEMC+9r4PYnU+uBgoY+BKJiVA+C9rTAawR6t9la29ZS6wgL1 R2HTlcwrEnPaTWyRDzmQwC8R4P8F56R+QEekf2+M3lNv2NUVjbCzgehVQqdIMQ09VOa2 6o98XoS/3kCtkpNIjA4oOT/c5yUf/8PlXazQlumXTdrpX2zR748bG64NoV8vZzbi+f/k 1ZGiJX0sU1Jzc0NG6nt79cOOfUpolvj9WzVzfxG7Y9EMQ0MGfKptLXODucZHDujCQQgb AYRapmxoy4NPzKrr8gKT6iOjJAzkyKnQAm6wyU63JYCB5r9lPrU+m2HjbS1sMZVsxGHA Gaww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=jDhyWC5m7v6jwYwWBJCZO8vmmCQJIMiVT+1lgsXb/hQ=; b=evs9HsfF5a7/n+kz6hu7Gb/z+CvvJOe/dxy1Fz/c5MQ6N+eG7pbgVWqp9ElfBLAyYw JDuOVLZcEcC9ETFyh8i1poFVTn0HjVwK33glFmmFKeXRFwndyfYoHOAdXjPgAZ4yhrNg dxXkZsEL4LOOEKdzk3R2S3BOru3QlkSz2cyokQrgRXYJ5Sp9iLvTz0Sntu9aljo1ivh0 ndW4+/w7eUQVcDF1KK2a5U6GsWrX0hklBBnypp+uXwjqV1ne/hqT/8VY4WF7Zj5EJQ9X yJQlRPB+47EXD+P2PPhXjv+GFZO0Kfn04hcomW++/uZzf7vQO4Wr1g3n/GrtQ3qlqcT9 rXyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A4DV6iqs; 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=pass (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 j18si16942691pgb.60.2019.07.15.08.21.21; Mon, 15 Jul 2019 08:21:38 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A4DV6iqs; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731041AbfGOPUm (ORCPT + 99 others); Mon, 15 Jul 2019 11:20:42 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:34402 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730548AbfGOPUl (ORCPT ); Mon, 15 Jul 2019 11:20:41 -0400 Received: by mail-io1-f65.google.com with SMTP id k8so34762011iot.1 for ; Mon, 15 Jul 2019 08:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jDhyWC5m7v6jwYwWBJCZO8vmmCQJIMiVT+1lgsXb/hQ=; b=A4DV6iqs0VowpYFUQPzk7PIRlj/q0buwiqqVo5Tnn2W1bYwZH3LZjdymyVpEyNHb58 ANeMlc1dL7qmCH+KPGrrtDM3c4VaZ3v98djrhl92Tr3wXo9b3nheYpu/PTxXo7M1IIGS BttFTY/OlGhHbhqsh3A5BUs/9QBZa0xTD5rhO355ySRzpmzoU6sn9bBF+E4Dr+uSKbt2 lH/sq1QunSO29z5EuknVg6nZx7sqzSiIUeXHiDm+wFNqB01HXxLqzDs3YZ2gOR0rkBi4 c/dpw0kqhkkwDH7emRIRSNvrD1YNfFAcsy5QjXERSpI/2Vvc3276b+ud4LPtojDdWAO1 4UBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jDhyWC5m7v6jwYwWBJCZO8vmmCQJIMiVT+1lgsXb/hQ=; b=WF8cICYJypdQZ6ZBXI26klahogch2ZwwgDmMV0Q0lc9JprFxrCPHkyCLbI5/PeSKg7 0vqbzrbllPjIMkzSY/XxbdqL/cj96x1AuP4OnWIwuVwJNveeDjULf5BV1ZZK61H5QANu m1Qm6v8yem8qx0oIlVv36pzELKksjzukeyoVtu4QNINmrS39Ol0GhqEt+Pd79h3YuhFW sXGOBLMrTxD35hzk/ziGY1m9enxbsXUu/tqAHbxYbmUnaH987dyKDaKeok36vCihYGdZ NH9rpnsXgdQHEcEAGwV6qgSJAkXsaKxWw/uwEeoHH8fuBRUKLp3K11WnX9pHNNywu+cn uM/Q== X-Gm-Message-State: APjAAAX55ElshSuGsP8LyFyEHWNfV3qqiiTQqHmHa/2rNGwbUOx4yRQq EzCjib4KOto7jaqAxUVsqLMoh/oZOPY86KCO7A== X-Received: by 2002:a02:cd83:: with SMTP id l3mr28157334jap.66.1563204041005; Mon, 15 Jul 2019 08:20:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Avi Fishman Date: Mon, 15 Jul 2019 18:19:54 +0300 Message-ID: Subject: [PATCH] [v2] clocksource/drivers/npcm: fix GENMASK and timer operation To: Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Daniel Lezcano , Thomas Gleixner , Avi Fishman Cc: OpenBMC Maillist , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org clocksource/drivers/npcm: fix GENMASK and timer operation NPCM7XX_Tx_OPER GENMASK() changed from (27, 3) to (28, 27) 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. 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