Linux IIO development
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Masahiro Honda <honda@mechatrax.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Jonathan Cameron <jic23@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag
Date: Mon, 27 Mar 2023 14:28:02 +0200	[thread overview]
Message-ID: <2a108acdd79682f47e3ac923fe005b943a4a00c0.camel@gmail.com> (raw)
In-Reply-To: <CA+Tz-SFbt2RAz3POMRoTHqz+tNyQOn3UsssZV9EvHUhhR+XJbQ@mail.gmail.com>

On Mon, 2023-03-27 at 18:01 +0900, Masahiro Honda wrote:

Hi Masahiro,

Thanks for looking in more detail into this...

> Hi, Nuno
> 
> > On Mon, Mar 6, 2023 at 10:30 PM Nuno Sá <noname.nuno@gmail.com>
> > wrote:
> > > Another thing that came to my mind is if the data is totally
> > > garbage/wrong or is it just some outstanding sample?
> 
> I'm sorry for not answering your question. The data is the same as
> the previous conversion even if the input voltage is changed. At this
> time, a logic analyzer shows that the read operation is performed
> immediately after the conversion is performed. The read operation
> returns the previous conversion result because it is performed before
> the completion of the conversion.
> 

So, my suspicion was right... We are getting stalled data (which is
obviously not good). AFAIU, when disabling the IRQ, we don't
immediately mask the IRQ and we only do it in the next time an
interrupt (sample) comes which means (I think) we'll process (right
away) that outstanding interrupt next time we enable the IRQ.

> > > Some research on this also seems to point that we should (need?)
> > > call
> > > irq_clear_status_flags(irq, IRQ_DISABLE_UNLAZY) when freeing the
> > > IRQ.
> 
> I have understood that I need to call irq_clear_status_flags.
> However,
> I cannot find a code to free the IRQ in ad_sigma_delta.c and other
> Sigma-Delta ADC driver source files. So, I would like to implement
> only irq_set_status_flags.

Well, that's because we are using devm_request_irq() which is a device
managed API. So, I can see two options in here... 

1) You do not use devm_request_irq() and use request_irq() +
devm_add_action_or_reset() and in your release() function you would
call irq_clear_status_flags() + free_irq().

2) You add a devm_add_action_or_reset() after devm_request_irq() and
your release() function would only clear the flag. But in here we would
likely also have to be careful in the case where devm_request_irq()
fails. So option 2) seems a bit more "ugly".

I would likely go to option 1) but maybe Jonathan or others have better
ideas.

- Nuno Sá

  reply	other threads:[~2023-03-27 12:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06  4:47 [PATCH] Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag Masahiro Honda
2023-03-06 13:32 ` Nuno Sá
2023-03-07 10:54   ` Masahiro Honda
2023-03-27  9:01     ` Masahiro Honda
2023-03-27 12:28       ` Nuno Sá [this message]
2023-03-28 10:55         ` Masahiro Honda

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=2a108acdd79682f47e3ac923fe005b943a4a00c0.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=honda@mechatrax.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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