Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4419187ybi; Mon, 15 Jul 2019 08:38:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3ksp6xNyiC8BZH97Ium2KQWUOcqc3qt5be+YAqV6CRYPtECs0ARWHdLjDo4vmoEJUljIG X-Received: by 2002:a63:2ad5:: with SMTP id q204mr14723252pgq.140.1563205122434; Mon, 15 Jul 2019 08:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563205122; cv=none; d=google.com; s=arc-20160816; b=kMLRGb+fOLSQumFctYqPQR+iKAhC3K6qdpV3uY9Y85Ocb9YC5gcbkQP5dcUpOWQ3kO wqiLrCSY7KIuJcaAnmEne5MVxlJTWijrL/ObN/YCiqRnyKvrfe/hmyouW/W7fF/AMus9 N/vqztEpnO5cSbb4Yi5s24ufMxM9QdOWTr7VIY1HyoTeZ0e/NemA+75u509W2jjqgEZD P/7FzYDftNmTsuV45oSdMA1Q6L8GBAa36AR1tTMSz9Gelq9QzoEC4kJrKNv4iBspeKLi YPpqi9ZFXgy3E8pEUrX5FXy3VOFZTFPwwy2d2Wx2bu60GGWBY5hFU2I8u9FicfDb1jt/ 3IEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=VccW3XX4r4vZwLd27xpBqZ7B292zYtdpx1q0EUABLHg=; b=SQFJRCSipsaDdU6CagqYx308Zya8FyLMrryMroeKbABcHivGnIZF0cHfRvNhu6hSh3 +CSMdBvlygkte5WApGFVa0ey48n11fZF5cO8Z6f8x4MuD1jtEXrykPSmtU68E3Jy5XK0 rIj3QXMhvuEhpW1sfFGAEvQN9kpY5I/ZmNw9jamgJmp0iTk/lWagz5qfjmwL71eQYsRg pV12+VbUaTQgc8VkY1Aym3UajZ1hKVEMHxK3M09DsQo6DPFEwOBDmpiCglhj0+TAeWnX hi/MSH97ZJpiRcPF8GbVcai+tfIrevWf6Bztd6ZWl1PFWehzFLlsWX7WO/s14HSCZ26V sEBg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f59si16537680plf.220.2019.07.15.08.38.25; Mon, 15 Jul 2019 08:38:42 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730886AbfGOPZH (ORCPT + 99 others); Mon, 15 Jul 2019 11:25:07 -0400 Received: from smtprelay0161.hostedemail.com ([216.40.44.161]:38097 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730785AbfGOPZH (ORCPT ); Mon, 15 Jul 2019 11:25:07 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 329608368EF8; Mon, 15 Jul 2019 15:25:05 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::,RULES_HIT:41:355:379:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:1801:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3873:4250:4321:4605:5007:7514:9121:10004:10400:10848:11026:11232:11233:11473:11658:11914:12043:12048:12296:12297:12438:12555:12740:12760:12895:13439:13972:14181:14659:14721:21080:21451:21627:30054:30060:30091,0,RBL:23.242.196.136:@perches.com:.lbl8.mailshell.net-62.14.0.180 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: boat47_2c25f66738a4c X-Filterd-Recvd-Size: 3683 Received: from XPS-9350 (cpe-23-242-196-136.socal.res.rr.com [23.242.196.136]) (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA; Mon, 15 Jul 2019 15:25:03 +0000 (UTC) Message-ID: Subject: Re: [PATCH] [v2] clocksource/drivers/npcm: fix GENMASK and timer operation From: Joe Perches To: Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Daniel Lezcano , Thomas Gleixner Cc: OpenBMC Maillist , Linux Kernel Mailing List Date: Mon, 15 Jul 2019 08:25:01 -0700 In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.5-0ubuntu0.18.10.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-07-15 at 18:19 +0300, Avi Fishman wrote: > 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. You might mention how the original use of GENMASK(3, 27) was defective or correct without effect. > 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; >