From: Oleksij Rempel <o.rempel@pengutronix.de>
To: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>,
Ahmad Fatoum <a.fatoum@pengutronix.de>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Pengutronix Kernel Team <kernel@pengutronix.de>,
David Jander <david@protonic.nl>,
Robin van der Gracht <robin@protonic.nl>,
linux-iio@vger.kernel.org,
Linus Walleij <linus.walleij@linaro.org>,
Jonathan Cameron <jic23@kernel.org>
Subject: Re: [PATCH v5 2/2] counter: add IRQ or GPIO based event counter
Date: Tue, 23 Feb 2021 11:06:56 +0100 [thread overview]
Message-ID: <20210223100656.efbshsh5bz66uhj5@pengutronix.de> (raw)
In-Reply-To: <YDMMJJ985Zq9oEOv@shinobu>
On Mon, Feb 22, 2021 at 10:43:00AM +0900, William Breathitt Gray wrote:
> On Mon, Feb 15, 2021 at 10:17:37AM +0100, Oleksij Rempel wrote:
> > > > +static irqreturn_t event_cnt_isr(int irq, void *dev_id)
> > > > +{
> > > > + struct event_cnt_priv *priv = dev_id;
> > > > +
> > > > + atomic_inc(&priv->count);
> > >
> > > This is just used to count the number of interrupts right? I wonder if
> > > we can do this smarter. For example, the kernel already keeps track of
> > > number of interrupts that has occurred for any particular IRQ line on a
> > > CPU (see the 'kstat_irqs' member of struct irq_desc, and the
> > > show_interrupts() function in kernel/irq/proc.c). Would it make sense to
> > > simply store the initial interrupt count on driver load or enablement,
> > > and then return the difference during a count_read() callback?
> >
> > This driver do not makes a lot of sense without your chardev patches. As
> > soon as this patches go mainline, this driver will be able to send
> > event with a timestamp and counter state to the user space.
> >
> > With other words, we will need an irq handler anyway. In this case we
> > can't save more RAM or CPU cycles by using system irq counters.
>
> It's true that this driver will need an IRQ handler when the timestamp
> functionality is added, but deriving the count value is different matter
> regardless. There's already code in the kernel to retrieve the number of
> interrupts, so it makes sense that we use that rather than rolling our
> own -- at the very least to ensure the value we provide to users is
> consistent with the ones already provided by other areas of the kernel.
We are talking about one or two code lines. If we will take some
duplication search engine, it will find that major part of the kernel
is matching against it.
Newer the less, this driver provides a way to reset the counter. Why
should we drop this functionality no advantage?
> To that end, I'd like to see your cnt_isr() function removed for this
> patchset (you can bring it back once timestamp support is added).
Are you suggesting to enable IRQ without interrupt handler? May be i'm
missing some thing.. I do not understand it.
> Reimplement your cnt_read/cnt_write() functions to instead use
> kstat_irqs_usr() from <linux/kernel_stat.h> to get the current number of
> interrupts the IRQ line and use it to derive your count value for this
> driver.
I can follow the counter read way, but overwriting system wide counter
for local use is bad idea.
> > > > +static struct counter_signal event_cnt_signals[] = {
> > > > + {
> > > > + .id = 0,
> > > > + .name = "Channel 0 signal",
> > >
> > > You should choose a more description name for this Signal;
> > > "Channel 0 signal" isn't very useful information for the user. Is this
> > > signal the respective GPIO line state?
> >
> > Sounds plausible. How about "Channel 0, GPIO line state"?
>
> Ideally, this would match the GPIO name (or I suppose the IRQ number if
> not a GPIO line). So in your probe() function you can do something like
> this I believe:
>
> cnt_signals[0].name = priv->gpio->name;
to make this possible, i would need hack gpiolib framework and add
name/label exporter. But after endless rounds of pingponging me for
renaming the driver and removing interrupt handler, i feel like we are
not having serious discussion for mainlining this driver.
Is it some expensive way to prepare me for 1. April joke?
> Of course, you should first check whether this is a GPIO line or IRQ
> line and set the name accordingly.
Please, let's stop bike-shed for now. This driver has no limitless
budget. If there are serious problem, I would love to fix it, but if we
still discussing name of the driver or how to misuse kernel interrupt
handling, then it makes no sense to continue.
Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2021-02-23 10:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-08 13:53 [PATCH v5 0/2] add support for GPIO or IRQ based evemt counter Oleksij Rempel
2021-02-08 13:53 ` [PATCH v5 1/2] dt-bindings: counter: add event-counter binding Oleksij Rempel
2021-02-10 18:41 ` Rob Herring
2021-02-12 9:22 ` Linus Walleij
2021-02-12 9:29 ` Linus Walleij
2021-02-08 13:53 ` [PATCH v5 2/2] counter: add IRQ or GPIO based event counter Oleksij Rempel
2021-02-08 14:14 ` William Breathitt Gray
2021-02-12 9:26 ` Linus Walleij
2021-02-15 7:58 ` Oleksij Rempel
2021-02-14 8:54 ` William Breathitt Gray
2021-02-15 9:17 ` Oleksij Rempel
2021-02-22 1:43 ` William Breathitt Gray
2021-02-23 10:06 ` Oleksij Rempel [this message]
2021-02-23 17:45 ` Oleksij Rempel
2021-02-24 2:34 ` William Breathitt Gray
2021-02-24 7:35 ` Oleksij Rempel
2021-02-24 8:11 ` William Breathitt Gray
2021-02-24 8:20 ` William Breathitt Gray
2021-02-26 6:46 ` Oleksij Rempel
2021-02-26 6:58 ` William Breathitt Gray
2021-03-02 15:37 ` Linus Walleij
2021-02-14 7:43 ` [PATCH v5 0/2] add support for GPIO or IRQ based evemt counter William Breathitt Gray
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=20210223100656.efbshsh5bz66uhj5@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=david@protonic.nl \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=robin@protonic.nl \
--cc=vilhelm.gray@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).