From: Jonathan Cameron <jic23@kernel.org>
To: "O'Griofa, Conall" <conall.ogriofa@amd.com>
Cc: "Sean Anderson" <sean.anderson@linux.dev>,
"Anand Ashok Dumbre" <anand.ashok.dumbre@xilinx.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"Simek, Michal" <michal.simek@amd.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Manish Narani" <manish.narani@xilinx.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: xilinx-ams: Unmask interrupts after updating alarms
Date: Mon, 25 Aug 2025 12:23:19 +0100 [thread overview]
Message-ID: <20250825122319.6faf8782@jic23-huawei> (raw)
In-Reply-To: <MN2PR12MB42237EC0AA00D05DE52F8C988B33A@MN2PR12MB4223.namprd12.prod.outlook.com>
On Wed, 20 Aug 2025 11:28:27 +0000
"O'Griofa, Conall" <conall.ogriofa@amd.com> wrote:
> Hi,
>
> Looks good, thank you for taking the time to submit this patch.
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
>
> Cheers,
> Conall.
>
> > -----Original Message-----
> > From: Sean Anderson <sean.anderson@linux.dev>
> > Sent: 15 July 2025 01:29
> > To: Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>; Jonathan Cameron
> > <jic23@kernel.org>; linux-iio@vger.kernel.org
> > Cc: David Lechner <dlechner@baylibre.com>; Nuno Sá <nuno.sa@analog.com>;
> > linux-arm-kernel@lists.infradead.org; Simek, Michal <michal.simek@amd.com>;
> > Andy Shevchenko <andy@kernel.org>; Manish Narani
> > <manish.narani@xilinx.com>; linux-kernel@vger.kernel.org; Sean Anderson
> > <sean.anderson@linux.dev>
> > Subject: [PATCH] iio: xilinx-ams: Unmask interrupts after updating alarms
> >
> > To convert level-triggered alarms into edge-triggered IIO events, alarms are masked
> > when they are triggered. To ensure we catch subsequent alarms, we then
> > periodically poll to see if the alarm is still active.
> > If it isn't, we unmask it. Active but masked alarms are stored in
> > current_masked_alarm.
> >
> > If an active alarm is disabled, it will remain set in current_masked_alarm until
> > ams_unmask_worker clears it. If the alarm is re-enabled before
> > ams_unmask_worker runs, then it will never be cleared from
> > current_masked_alarm. This will prevent the alarm event from being pushed even if
> > the alarm is still active.
> >
> > Fix this by recalculating current_masked_alarm immediately when enabling or
> > disabling alarms.
> >
> > Fixes: d5c70627a794 ("iio: adc: Add Xilinx AMS driver")
> > Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
> > ---
> >
> > drivers/iio/adc/xilinx-ams.c | 45 ++++++++++++++++++++----------------
> > 1 file changed, 25 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c index
> > 76dd0343f5f7..180d4140993d 100644
> > --- a/drivers/iio/adc/xilinx-ams.c
> > +++ b/drivers/iio/adc/xilinx-ams.c
> > @@ -389,6 +389,29 @@ static void ams_update_pl_alarm(struct ams *ams,
> > unsigned long alarm_mask)
> > ams_pl_update_reg(ams, AMS_REG_CONFIG3,
> > AMS_REGCFG3_ALARM_MASK, cfg); }
> >
> > +static void ams_unmask(struct ams *ams) {
> > + unsigned int status, unmask;
> > +
> > + status = readl(ams->base + AMS_ISR_0);
> > +
> > + /* Clear those bits which are not active anymore */
> > + unmask = (ams->current_masked_alarm ^ status) &
> > +ams->current_masked_alarm;
> > +
> > + /* Clear status of disabled alarm */
> > + unmask |= ams->intr_mask;
> > +
> > + ams->current_masked_alarm &= status;
> > +
> > + /* Also clear those which are masked out anyway */
> > + ams->current_masked_alarm &= ~ams->intr_mask;
> > +
> > + /* Clear the interrupts before we unmask them */
> > + writel(unmask, ams->base + AMS_ISR_0);
> > +
> > + ams_update_intrmask(ams, ~AMS_ALARM_MASK,
> > ~AMS_ALARM_MASK); }
> > +
> > static void ams_update_alarm(struct ams *ams, unsigned long alarm_mask) {
> > unsigned long flags;
> > @@ -401,6 +424,7 @@ static void ams_update_alarm(struct ams *ams, unsigned
> > long alarm_mask)
> >
> > spin_lock_irqsave(&ams->intr_lock, flags);
> > ams_update_intrmask(ams, AMS_ISR0_ALARM_MASK, ~alarm_mask);
> > + ams_unmask(ams);
> > spin_unlock_irqrestore(&ams->intr_lock, flags); }
> >
> > @@ -1035,28 +1059,9 @@ static void ams_handle_events(struct iio_dev
> > *indio_dev, unsigned long events) static void ams_unmask_worker(struct
> > work_struct *work) {
> > struct ams *ams = container_of(work, struct ams, ams_unmask_work.work);
> > - unsigned int status, unmask;
> >
> > spin_lock_irq(&ams->intr_lock);
> > -
> > - status = readl(ams->base + AMS_ISR_0);
> > -
> > - /* Clear those bits which are not active anymore */
> > - unmask = (ams->current_masked_alarm ^ status) & ams-
> > >current_masked_alarm;
> > -
> > - /* Clear status of disabled alarm */
> > - unmask |= ams->intr_mask;
> > -
> > - ams->current_masked_alarm &= status;
> > -
> > - /* Also clear those which are masked out anyway */
> > - ams->current_masked_alarm &= ~ams->intr_mask;
> > -
> > - /* Clear the interrupts before we unmask them */
> > - writel(unmask, ams->base + AMS_ISR_0);
> > -
> > - ams_update_intrmask(ams, ~AMS_ALARM_MASK,
> > ~AMS_ALARM_MASK);
> > -
> > + ams_unmask(ams);
> > spin_unlock_irq(&ams->intr_lock);
> >
> > /* If still pending some alarm re-trigger the timer */
> > --
> > 2.35.1.1320.gc452695387.dirty
>
> Reviewed-by: O'Griofa, Conall <conall.ogriofa@amd.com>
prev parent reply other threads:[~2025-08-25 12:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 0:28 [PATCH] iio: xilinx-ams: Unmask interrupts after updating alarms Sean Anderson
2025-07-24 15:32 ` Jonathan Cameron
2025-07-25 4:47 ` Michal Simek
2025-07-27 15:43 ` Jonathan Cameron
2025-07-28 5:54 ` Michal Simek
2025-07-30 10:55 ` Erim, Salih
2025-08-20 11:23 ` Erim, Salih
2025-08-20 11:28 ` O'Griofa, Conall
2025-08-25 11:23 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250825122319.6faf8782@jic23-huawei \
--to=jic23@kernel.org \
--cc=anand.ashok.dumbre@xilinx.com \
--cc=andy@kernel.org \
--cc=conall.ogriofa@amd.com \
--cc=dlechner@baylibre.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manish.narani@xilinx.com \
--cc=michal.simek@amd.com \
--cc=nuno.sa@analog.com \
--cc=sean.anderson@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox