Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3640132ybv; Mon, 10 Feb 2020 03:49:43 -0800 (PST) X-Google-Smtp-Source: APXvYqxy4p7qAGtYemfzbeEWG0PJbDxmePLOOac7zgPXg6q12FfIyuBGKqOgYrKprfKnvvLuqQiT X-Received: by 2002:a05:6830:16d0:: with SMTP id l16mr767194otr.83.1581335383723; Mon, 10 Feb 2020 03:49:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581335383; cv=none; d=google.com; s=arc-20160816; b=R69z2QKw9dnNnUjXiwE7dUYet6LbUGw6R61JJFTcQTDup6p+PE3SqD7LI3fqHA6YKo jI3VkM+QMHlk676db8WrgoqUP+Z2SyL4NXOdXxyWz0FdjCUir0w4TQGcPdmCHUzZ4MKl 24YTRvUVDRvKX4eYAwqbG5EffRLm8RG6kDM79bBO9nB+P0zUdNLBY3abL2XiDnEmQYH+ E81DWgFzfYJuwM01ar5RzDS3Hf9GMRpGTzWsMQoiv9sq6V/RZeaNzGVboQfgcAY+c7y4 edm0x5c0tggIi10SDpnNRoPnycD6IOQcSGshmjSMPPY1u7Ju+/B6mJsF9sAx6KZIt2DN i4wg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=1aQqSSjewIOk+NSQDYZdBuMf/MgfILJe523/C8XJcy8=; b=jLeyy5zGxwMAmeR8QQIMTtHhnyQi9aCV1Kff7g01Boz0v1M1sv62RPDrQtD29gJzfm GtobQOhWV5UnTLHSFJkIe3GSCyTIkrPyOlNGU9oWoUgHitD7NxM6t9ivq/C9L5paA18l fxF32JHgrP4rVyagDe9qE7BC4TvaYyUgWZwHqYusjVREqBwTl8fODC3n7qBx7GOGisHR gepAEou9ZE5EiPPBQgqJF5jTkcdrSc6Dzi2ZhlcFe952/quUoGCH+R9CnAkrrYr/KQwA Xl/Ug39Ef2jOgRnn6PIyeZQ+CfbTXrrr37+pXoWzUipbbyYvs4tCbyWPdkgpAyH2PqCb oeaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@monstr-eu.20150623.gappssmtp.com header.s=20150623 header.b=FaZcVpT5; 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 d2si62206oth.267.2020.02.10.03.49.32; Mon, 10 Feb 2020 03:49:43 -0800 (PST) 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=@monstr-eu.20150623.gappssmtp.com header.s=20150623 header.b=FaZcVpT5; 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 S1727369AbgBJLs2 (ORCPT + 99 others); Mon, 10 Feb 2020 06:48:28 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38556 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726950AbgBJLs1 (ORCPT ); Mon, 10 Feb 2020 06:48:27 -0500 Received: by mail-wm1-f68.google.com with SMTP id a9so10230953wmj.3 for ; Mon, 10 Feb 2020 03:48:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1aQqSSjewIOk+NSQDYZdBuMf/MgfILJe523/C8XJcy8=; b=FaZcVpT5JDHcbUCWe+ralMxFLwrZvkzrej68mEa1ypXrQBM08yXsExEj1fzIr+Ddq0 /mCpv9nLEwmfxxtAPis0PuMAJAsun0WHWQ/UjZvJukQmj4idIQ5QrGpC2m/oCnp5ekRt RMSIdIofZYVa7bnSKRFMuGsiLFDWSxcekBzTUbXJQF8c4cZIlXF6DGqHRyAbZRZ4k6ps R0zCvMErCqMI9GPaQ0dCKcg/KA5LCCN27O/pVE7am24L0i8KjWByplOrt5w4H/mL+/3f 1b80zYLcG1FaS3R8hD30XXkeo0KEtQwLErR26kO9xMP38IEV/BK0kvAPRNf//7GK6kkj G/eQ== 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:content-transfer-encoding; bh=1aQqSSjewIOk+NSQDYZdBuMf/MgfILJe523/C8XJcy8=; b=acNQ4yZFEPBR+4/Jc0SB9powPpSzW9wtX9gaZ7tZ774UmkD+Lr0TwwCH/RrK/3Q9wj UmfpUl5MTtQIondS03FhOkXdIa0lBO0wCG8/M/qugyNtsWzMgGtkeHKdGlaIgNIM5D+b gZ/5gXZiyd2W31wwvrQqM7sXnaaVmaV7qSeplwscCZEG6+fWSRExts2PKHIwF2MtXjnH SBeQS2y4gI8vlyIyvROSZLKBHf2J0mmQ3/3xrYx49/iHYeagAv8KSlaXqGnZFfN+IXUg WH3LvpH+bgjwZh2Wt8aFQbEM+GeuJohxmNffCcQNXjj1gSNk3gXKrX/3zAJ81IJLlpXd 2kKA== X-Gm-Message-State: APjAAAWES3gQEZ3paaZx1cLR9RqRBMiMAevAoPF6zkG81hcLB/v8dFPZ dQ+uUyTX9N5r5YvifiBQ/dJA9+nymMMRrWz4yKMnCw== X-Received: by 2002:a7b:ce98:: with SMTP id q24mr14757971wmj.41.1581335305184; Mon, 10 Feb 2020 03:48:25 -0800 (PST) MIME-Version: 1.0 References: <1576155618-7933-1-git-send-email-srinivas.neeli@xilinx.com> In-Reply-To: <1576155618-7933-1-git-send-email-srinivas.neeli@xilinx.com> From: Michal Simek Date: Mon, 10 Feb 2020 12:48:14 +0100 Message-ID: Subject: Re: [PATCH] rtc: zynqmp: Clear alarm interrupt status before interrupt enable To: Srinivas Neeli Cc: Alessandro Zummo , Alexandre Belloni , Srinivas Goud , Shubhrajyoti Datta , linux-rtc@vger.kernel.org, LKML , linux-arm , git Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, =C4=8Dt 12. 12. 2019 v 14:01 odes=C3=ADlatel Srinivas Neeli napsal: > > Fix multiple occurring interrupts for alarm interrupt. RTC module doesn't > clear the alarm interrupt status bit immediately after the interrupt is > triggered.This is due to the sticky nature of the alarm interrupt status > register. The alarm interrupt status register can be cleared only after > the second counter outruns the set alarm value. To fix multiple spurious > interrupts, disable alarm interrupt in the handler and clear the status > bit before enabling the alarm interrupt. > > Fixes: 11143c19eb57 ("rtc: add xilinx zynqmp rtc driver") > Signed-off-by: Srinivas Neeli > --- > drivers/rtc/rtc-zynqmp.c | 29 ++++++++++++++++++++++++----- > 1 file changed, 24 insertions(+), 5 deletions(-) > > diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c > index 5786866c09e9..d311e3ef1f21 100644 > --- a/drivers/rtc/rtc-zynqmp.c > +++ b/drivers/rtc/rtc-zynqmp.c > @@ -38,6 +38,8 @@ > > #define RTC_CALIB_DEF 0x198233 > #define RTC_CALIB_MASK 0x1FFFFF > +#define RTC_ALRM_MASK BIT(1) > +#define RTC_MSEC 1000 > > struct xlnx_rtc_dev { > struct rtc_device *rtc; > @@ -124,11 +126,28 @@ static int xlnx_rtc_alarm_irq_enable(struct device = *dev, u32 enabled) > { > struct xlnx_rtc_dev *xrtcdev =3D dev_get_drvdata(dev); > here shouldn't be empty line. > - if (enabled) > + unsigned int status; > + ulong timeout; > + > + timeout =3D jiffies + msecs_to_jiffies(RTC_MSEC); > + > + if (enabled) { > + while (1) { > + status =3D readl(xrtcdev->reg_base + RTC_INT_STS)= ; > + if (!((status & RTC_ALRM_MASK) =3D=3D RTC_ALRM_MA= SK)) > + break; > + > + if (time_after_eq(jiffies, timeout)) { > + dev_err(dev, "Time out occur, while clear= ing alarm status bit\n"); > + return -ETIMEDOUT; > + } > + writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_= STS); > + } > + > writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_EN); > - else > + } else { > writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_DIS); > - > + } And here it was good to have empty line. > return 0; > } > > @@ -183,8 +202,8 @@ static irqreturn_t xlnx_rtc_interrupt(int irq, void *= id) > if (!(status & (RTC_INT_SEC | RTC_INT_ALRM))) > return IRQ_NONE; > > - /* Clear RTC_INT_ALRM interrupt only */ > - writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_STS); > + /* Disable RTC_INT_ALRM interrupt only */ > + writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_DIS); > > if (status & RTC_INT_ALRM) > rtc_update_irq(xrtcdev->rtc, 1, RTC_IRQF | RTC_AF); > -- > 2.7.4 Other then these two above things look good. Alexandre: Any issue with this patch? Thanks, Michal --=20 Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs