Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3647185ybi; Mon, 29 Jul 2019 10:04:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQfZw7KWQTcpwxfU2I0spb0p3jN1mYvKc1P9dFrSbr7rtoCuDSQLTS8DCoxmPwexBEB5nU X-Received: by 2002:a63:ec03:: with SMTP id j3mr3072732pgh.325.1564419877501; Mon, 29 Jul 2019 10:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564419877; cv=none; d=google.com; s=arc-20160816; b=gUbt8SGP/JpsKnK4AwgTzHToFx8fvuXEb/2s7OAYlWFlYE5YBDqscaZ69MJ+m83+C3 PawU0YAAkLFXO67h5efZQsJPfXqozsj94LwqeloFlg/Ki2q+gF9sd2wrbIwx/SKnLrL1 /Pyz+BjhNDoMhlQ7n+JsBNOhdMJC95en6lI27b7PEfrZppxGlx5fRtbMV5UiVZQAX3bY 4EOCnMwXmDKS8wzbN+yjshGl/cQu5uTyj2wVnTREq/rnJMuD98+7bp9jD0PIuR8tg/p6 Mr6KKQ0pL/xDbWdaN9issxi9hf+Qz9+wxrfPd+/egTYXgfb1fuE1XxeDOg9RY0K0Lsz7 whZw== 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=1rG5B+o2VjO9RrL+xsfmgF+x6faimyKuyYbtOh0syfs=; b=tjpPhZ+77/swEmes/ih2/aT7xDwxnGIBqdxAWzCioQct5qRDckGRTcaAZgTlPY1xmH soEUk/imDIuhaH/17as67t4tSVc9GlShhBBjci35q9K9CdZzmBNJROdRD/u62XKcVOL5 uToWQf7kdIITTBuSL6Ec8E8KVUoEOb0m8Y6RzYcBHGEQEpOBsOjmvuAZiSTR1FYD+W3n MTFXlu+Ml5Ds+PdOwrRD5nieeEVi7TtY4zg2kyAIMwKKrkltw/f/nQnV6hO48q06TH8u UaR6h8izXtEDAymh35pUl2b+mN/mciQsALDgfcKTy9GUDXIaFz25GJpOFyEF+NMlKR7+ sLUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iMJBO7Cz; 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 b24si11813680pfi.180.2019.07.29.10.04.22; Mon, 29 Jul 2019 10:04:37 -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=iMJBO7Cz; 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 S1728957AbfG2QvL (ORCPT + 99 others); Mon, 29 Jul 2019 12:51:11 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:41067 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728291AbfG2QvI (ORCPT ); Mon, 29 Jul 2019 12:51:08 -0400 Received: by mail-io1-f68.google.com with SMTP id j5so117392752ioj.8 for ; Mon, 29 Jul 2019 09:51:07 -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=1rG5B+o2VjO9RrL+xsfmgF+x6faimyKuyYbtOh0syfs=; b=iMJBO7CzFDXrKhFARbuDHHMTaO9XVZ8Ne4nthG6sBNughIMiW/tIyaCEt/UWLV4snj c5Wz8IRuJq5/HBOtvn0tdicUlfabqLSnYTuauXbU0NHzKZxTplbqTcMojnU6W7MO+4Id RNB3zlnATDGznsQemONTue4F1yoPEjfvkANdUR246NFIFKZGUuEZ4uoB6BvRwcq0r6Wd uIy98cksW9s+alA+MGQ3XTuLQsdIaWUOTb5OFjJ7Gd8OnerwB4SXx2luTuhjyjMxdEnk AwmYFVWGDEaXkcW4D5MQ2cvV+IpMvDhwyREZt/uI72HEqxFHqN0RN/77lG8qQi9Pomyk zWAA== 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=1rG5B+o2VjO9RrL+xsfmgF+x6faimyKuyYbtOh0syfs=; b=hn57vTZIRvbkqJMq+NPeMKGKwwN49tYS3YvPuDHp5HTf8QD7MA5FAjZnbANN6w4Xrj lVApXEAFxDySbnq+HAkE3XSkO54sWgyOeKNmSjPeoPF7EgYNA+XT/YpitIqHieoNDlYr /ys2kvUYPhiDdRvHJqfxhsEERKLjw82iiOHXyK+aSA5CT+kEvd9cKANRvXqL58e1GtHs 8OnCAOvBhQ8pmgJC9kS1i7sIa7I3PT1bhXgh2OcQ9OPwmCDd0AF5BHOnJyKVPSFxWQix pfgqlusy2s7PLM67Th7IhNqsz5z/k3ZAcZ1XLQunbT7nvDKvoF9UUamnwFmZKwhu2zSC mBIg== X-Gm-Message-State: APjAAAUkNZxNk++fD1gZV4TTJ+lU7r3Z2LEk6ni6EBHU2ZtEzMQf5u3Z ubx1tLqi190qbALL83ysHMxexEz/dcwgCzPugxOZ X-Received: by 2002:a02:cd83:: with SMTP id l3mr78290994jap.66.1564419067206; Mon, 29 Jul 2019 09:51:07 -0700 (PDT) MIME-Version: 1.0 References: <20190729164307.200716-1-avifishman70@gmail.com> In-Reply-To: <20190729164307.200716-1-avifishman70@gmail.com> From: Avi Fishman Date: Mon, 29 Jul 2019 19:50:17 +0300 Message-ID: Subject: [PATCH] [v4] 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 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