Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3649058ybi; Mon, 29 Jul 2019 10:06:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+V1xMMAKX6LWxHCvyvjH/hJ1dxE0YtUv6Zn9sHcLUWfKx2ka/US/bgBpTcayU/8ZQsjs1 X-Received: by 2002:a17:90a:d14b:: with SMTP id t11mr112963663pjw.79.1564419976370; Mon, 29 Jul 2019 10:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564419976; cv=none; d=google.com; s=arc-20160816; b=hBzgMe3O64naMplpX1Q/XnI4nc9o334ias52SHGy64Y9tneLr7vboJy0YsmdPeFqR4 D6YmgiODGxRFFF+NJkKoAjE8OXHVRFEBI9ANAJ5O0r/+yk5P/AUwKQ0wrUw2IPER7w82 uf80L75NhsDnpIw/WEKSooBKYiTOlW6PC9B1JyVkx4MDuMp/h2Mj/qwwWL2d59aWsglL am1qEIeD5BGdaicaKCfjbYo9HWmVjsIc07NEfd5v0qg7837uuGVb1NgIvoQhET5or/VT Nz0+QrxU5DtoLGUGUxKS/2f0W2W7eLmbobVQ7GfZh0bbCZDbKa7D+sul3yxxAZEPYE26 +/bQ== 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=iCFQqYIsIHUuEI1zjQL1qrOWxSUO9qXF3sIVxAvbwSY=; b=gCUkobTBRfr4MVnu0RoXYfJ9tlekHyiN00TJt6SGpmZRSP31ZI+soZYNnixY1RRV4s JkbcpkOK3xEdlVKriKI2sy5/rCzCUeb58WJjOrwgIEaknKf/5PZQNhTRGT9W9/0iUyUt NFBWklqKnh7bIhyw18UzXOp4dnDFkQguME4ZO97+k1gWaEBhpHpxFtz+kCxZx7Juxcyp sa4qeCDQEkTxJlk8M+Ham5cqPU64Kk+mvYU7oHGowmBkQr7Hi0rM9K0Y7WkzcorF/xte LdUCLhcAhAL+ewMFxamO9rJLf0vXReWVQjfX1D1ido5noJObco3C0uQE+zhC9YtS1suo 8/jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UhM52LN5; 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 c3si27429820pje.1.2019.07.29.10.06.00; Mon, 29 Jul 2019 10:06:16 -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=UhM52LN5; 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 S1728970AbfG2Qx3 (ORCPT + 99 others); Mon, 29 Jul 2019 12:53:29 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:37346 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726601AbfG2Qx3 (ORCPT ); Mon, 29 Jul 2019 12:53:29 -0400 Received: by mail-io1-f65.google.com with SMTP id q22so1753863iog.4 for ; Mon, 29 Jul 2019 09:53:29 -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=iCFQqYIsIHUuEI1zjQL1qrOWxSUO9qXF3sIVxAvbwSY=; b=UhM52LN5XGqZ/4g08xPziW3KDRUTEYB3xh9AsB6YP6onaqTgFL+t8JnUilZJPBphTf VOiFZ1mKxTZzB+w9GRMUJCcDgmVAkmgzg/fqacrvgcKw1pxSZI/ASWGFKY+JsovGG5aZ anR/x+yLweATOEOOXXqqan6a12Bl7TQmZUv20cb9ngMA0dQbIAIuURSuG2XxXZO8Fpf0 7EXQVrPRBNrHaujN/NOSoT7yQIgaBEGpHNOCKA0kDeAs5y+MQg0/dUjIinn0pXB5Z6yY 4wmMGaK7Hw7p8HsangTL0+vFadK5zWNpK1K7zzT3lEgPTemNiHCajcKlPd5Ykb2EmzNo EVSg== 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=iCFQqYIsIHUuEI1zjQL1qrOWxSUO9qXF3sIVxAvbwSY=; b=kBNy+tVbRykKerKauJqlRLtmzyWO/e9dVR0IwGzdnmlZjsawPUfbuQPkoNO2HtdHw3 YBeVb0uxA8+fGw1iga3bB6Olp8OOXgA6avS1sA6IYnqUDW+IuFVKM5lz6osFjzrY2oCS hz7moyBT4FQygNQPm09+rvtfRcZObDPHoPyvm4lvPm+XnpTaP8NxqoRvzKW9ALXYUKIH 8r/A229iohBGi7M3TNzBWmgHBJOaUnX6pCM9w7n8XYG4A5oMaLD6JCHpokjYTXzxYQP2 NiaVM9Zfz6LG2024vNf/G9uIQlEJ2BuCfu/RcjTtMnh9XmMgTi8wKr2wqoAK4AwyK0e8 k+VQ== X-Gm-Message-State: APjAAAXSTjh2sLGvGyiDlzUPyVfEvMJvC795vpGlH4Rgyf82oWZm0P+M BQwqHrFTH7Ae7V7kX5wR0WVlO0TV/h6CZvGoyA== X-Received: by 2002:a6b:f80e:: with SMTP id o14mr32870690ioh.1.1564419208818; Mon, 29 Jul 2019 09:53:28 -0700 (PDT) MIME-Version: 1.0 References: <20190729164307.200716-1-avifishman70@gmail.com> In-Reply-To: From: Avi Fishman Date: Mon, 29 Jul 2019 19:52:39 +0300 Message-ID: Subject: Re: [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 Please discard this. my mail tool corruppted it again. On Mon, Jul 29, 2019 at 7:50 PM Avi Fishman wrote: > > 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 -- Regards, Avi