All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Breathitt Gray <vilhelm.gray@gmail.com>
To: David Lechner <david@lechnology.com>
Cc: jic23@kernel.org, kamel.bouhara@bootlin.com,
	gwendal@chromium.org, alexandre.belloni@bootlin.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com,
	patrick.havelange@essensium.com, fabrice.gasnier@st.com,
	mcoquelin.stm32@gmail.com, alexandre.torgue@st.com
Subject: Re: [PATCH v5 3/5] counter: Add character device interface
Date: Wed, 14 Oct 2020 15:05:26 -0400	[thread overview]
Message-ID: <20201014190526.GA13439@shinobu> (raw)
In-Reply-To: <67a0290e-731b-822a-5113-30b56bde6c88@lechnology.com>

[-- Attachment #1: Type: text/plain, Size: 3143 bytes --]

On Wed, Oct 14, 2020 at 12:43:08PM -0500, David Lechner wrote:
> On 9/26/20 9:18 PM, William Breathitt Gray wrote:
> > diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
> > new file mode 100644
> > index 000000000000..2be3846e4105
> > --- /dev/null
> > +++ b/drivers/counter/counter-chrdev.c
> 
> 
> > +/**
> > + * counter_push_event - queue event for userspace reading
> > + * @counter:	pointer to Counter structure
> > + * @event:	triggered event
> > + * @channel:	event channel
> > + *
> > + * Note: If no one is watching for the respective event, it is silently
> > + * discarded.
> > + *
> > + * RETURNS:
> > + * 0 on success, negative error number on failure.
> > + */
> > +int counter_push_event(struct counter_device *const counter, const u8 event,
> > +		       const u8 channel)
> > +{
> > +	struct counter_event ev = {0};
> > +	unsigned int copied = 0;
> > +	unsigned long flags;
> > +	struct counter_event_node *event_node;
> > +	struct counter_comp_node *comp_node;
> > +	int err;
> > +
> > +	ev.timestamp = ktime_get_ns();
> > +	ev.watch.event = event;
> > +	ev.watch.channel = channel;
> > +
> > +	raw_spin_lock_irqsave(&counter->events_lock, flags);
> > +
> > +	/* Search for event in the list */
> > +	list_for_each_entry(event_node, &counter->events_list, l)
> > +		if (event_node->event == event &&
> > +		    event_node->channel == channel)
> > +			break;
> > +
> > +	/* If event is not in the list */
> > +	if (&event_node->l == &counter->events_list)
> > +		goto exit_early;
> > +
> > +	/* Read and queue relevant comp for userspace */
> > +	list_for_each_entry(comp_node, &event_node->comp_list, l) {
> > +		err = counter_get_data(counter, comp_node, &ev.value_u8);
> 
> Currently all counter devices are memory mapped devices so calling
> counter_get_data() here with interrupts disabled is probably OK, but
> if any counter drivers are added that use I2C/SPI/etc. that will take
> a long time to read, it would cause problems leaving interrupts
> disabled here.
> 
> Brainstorming: Would it make sense to separate the event from the
> component value being read? As I mentioned in one of my previous
> reviews, I think there are some cases where we would just want to
> know when an event happened and not read any additional data anyway.
> In the case of a slow communication bus, this would also let us
> queue the event in the kfifo and notify poll right away and then
> defer the reads in a workqueue for later.

I don't see any problems with reporting just an event without any
component value attached (e.g. userspace could handle the component
reads via sysfs at a later point). We would just need a way to inform
userspace that the struct counter_component in the struct counter_watch
returned should be ignored.

Perhaps we can add an additional member to struct counter_watch
indicating whether it's an empty watch; or alternatively, add a new
component scope define to differentiate between an actual component and
an empty one (e.g. COUNTER_SCOPE_EVENT). What do you think?

William Breathitt Gray

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: William Breathitt Gray <vilhelm.gray@gmail.com>
To: David Lechner <david@lechnology.com>
Cc: kamel.bouhara@bootlin.com, gwendal@chromium.org,
	alexandre.torgue@st.com, linux-iio@vger.kernel.org,
	patrick.havelange@essensium.com, alexandre.belloni@bootlin.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, mcoquelin.stm32@gmail.com,
	syednwaris@gmail.com, linux-stm32@st-md-mailman.stormreply.com,
	jic23@kernel.org
Subject: Re: [PATCH v5 3/5] counter: Add character device interface
Date: Wed, 14 Oct 2020 15:05:26 -0400	[thread overview]
Message-ID: <20201014190526.GA13439@shinobu> (raw)
In-Reply-To: <67a0290e-731b-822a-5113-30b56bde6c88@lechnology.com>


[-- Attachment #1.1: Type: text/plain, Size: 3143 bytes --]

On Wed, Oct 14, 2020 at 12:43:08PM -0500, David Lechner wrote:
> On 9/26/20 9:18 PM, William Breathitt Gray wrote:
> > diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
> > new file mode 100644
> > index 000000000000..2be3846e4105
> > --- /dev/null
> > +++ b/drivers/counter/counter-chrdev.c
> 
> 
> > +/**
> > + * counter_push_event - queue event for userspace reading
> > + * @counter:	pointer to Counter structure
> > + * @event:	triggered event
> > + * @channel:	event channel
> > + *
> > + * Note: If no one is watching for the respective event, it is silently
> > + * discarded.
> > + *
> > + * RETURNS:
> > + * 0 on success, negative error number on failure.
> > + */
> > +int counter_push_event(struct counter_device *const counter, const u8 event,
> > +		       const u8 channel)
> > +{
> > +	struct counter_event ev = {0};
> > +	unsigned int copied = 0;
> > +	unsigned long flags;
> > +	struct counter_event_node *event_node;
> > +	struct counter_comp_node *comp_node;
> > +	int err;
> > +
> > +	ev.timestamp = ktime_get_ns();
> > +	ev.watch.event = event;
> > +	ev.watch.channel = channel;
> > +
> > +	raw_spin_lock_irqsave(&counter->events_lock, flags);
> > +
> > +	/* Search for event in the list */
> > +	list_for_each_entry(event_node, &counter->events_list, l)
> > +		if (event_node->event == event &&
> > +		    event_node->channel == channel)
> > +			break;
> > +
> > +	/* If event is not in the list */
> > +	if (&event_node->l == &counter->events_list)
> > +		goto exit_early;
> > +
> > +	/* Read and queue relevant comp for userspace */
> > +	list_for_each_entry(comp_node, &event_node->comp_list, l) {
> > +		err = counter_get_data(counter, comp_node, &ev.value_u8);
> 
> Currently all counter devices are memory mapped devices so calling
> counter_get_data() here with interrupts disabled is probably OK, but
> if any counter drivers are added that use I2C/SPI/etc. that will take
> a long time to read, it would cause problems leaving interrupts
> disabled here.
> 
> Brainstorming: Would it make sense to separate the event from the
> component value being read? As I mentioned in one of my previous
> reviews, I think there are some cases where we would just want to
> know when an event happened and not read any additional data anyway.
> In the case of a slow communication bus, this would also let us
> queue the event in the kfifo and notify poll right away and then
> defer the reads in a workqueue for later.

I don't see any problems with reporting just an event without any
component value attached (e.g. userspace could handle the component
reads via sysfs at a later point). We would just need a way to inform
userspace that the struct counter_component in the struct counter_watch
returned should be ignored.

Perhaps we can add an additional member to struct counter_watch
indicating whether it's an empty watch; or alternatively, add a new
component scope define to differentiate between an actual component and
an empty one (e.g. COUNTER_SCOPE_EVENT). What do you think?

William Breathitt Gray

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-10-14 19:05 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-27  2:18 [PATCH v5 0/5] Introduce the Counter character device interface William Breathitt Gray
2020-09-27  2:18 ` William Breathitt Gray
2020-09-27  2:18 ` [PATCH v5 1/5] counter: Internalize sysfs interface code William Breathitt Gray
2020-10-13  2:15   ` David Lechner
2020-10-13  2:15     ` David Lechner
2020-10-18 14:49     ` William Breathitt Gray
2020-10-18 14:49       ` William Breathitt Gray
2020-10-20 15:38       ` David Lechner
2020-10-20 15:38         ` David Lechner
2020-10-23 13:12         ` William Breathitt Gray
2020-10-23 13:12           ` William Breathitt Gray
2020-10-15  1:38   ` David Lechner
2020-10-15  1:38     ` David Lechner
2020-10-18 17:00     ` William Breathitt Gray
2020-10-18 17:00       ` William Breathitt Gray
2020-09-27  2:18 ` [PATCH v5 2/5] docs: counter: Update to reflect sysfs internalization William Breathitt Gray
2020-09-27  2:18   ` William Breathitt Gray
2020-09-27  2:18 ` [PATCH v5 3/5] counter: Add character device interface William Breathitt Gray
2020-09-27  2:18   ` William Breathitt Gray
2020-10-14  1:40   ` David Lechner
2020-10-14  1:40     ` David Lechner
2020-10-18 16:49     ` William Breathitt Gray
2020-10-18 16:49       ` William Breathitt Gray
2020-10-20 15:53       ` David Lechner
2020-10-20 15:53         ` David Lechner
2020-10-25 12:55         ` William Breathitt Gray
2020-10-25 12:55           ` William Breathitt Gray
2020-10-25 16:36           ` David Lechner
2020-10-25 16:36             ` David Lechner
2020-10-14 17:43   ` David Lechner
2020-10-14 17:43     ` David Lechner
2020-10-14 19:05     ` William Breathitt Gray [this message]
2020-10-14 19:05       ` William Breathitt Gray
2020-10-14 22:32       ` David Lechner
2020-10-14 22:32         ` David Lechner
2020-10-14 22:40   ` David Lechner
2020-10-14 22:40     ` David Lechner
2020-10-18 16:58     ` William Breathitt Gray
2020-10-18 16:58       ` William Breathitt Gray
2020-10-20 16:06       ` David Lechner
2020-10-20 16:06         ` David Lechner
2020-10-25 13:18         ` William Breathitt Gray
2020-10-25 13:18           ` William Breathitt Gray
2020-10-25 16:34           ` David Lechner
2020-10-25 16:34             ` David Lechner
2020-10-25 17:53             ` William Breathitt Gray
2020-10-25 17:53               ` William Breathitt Gray
2020-09-27  2:18 ` [PATCH v5 4/5] docs: counter: Document " William Breathitt Gray
2020-09-27  2:18   ` William Breathitt Gray
2020-10-08  8:09   ` Pavel Machek
2020-10-08  8:09     ` Pavel Machek
2020-10-08 12:28     ` William Breathitt Gray
2020-10-08 12:28       ` William Breathitt Gray
2020-10-12 17:04       ` David Lechner
2020-10-12 17:04         ` David Lechner
2020-10-13 18:58         ` William Breathitt Gray
2020-10-13 18:58           ` William Breathitt Gray
2020-10-13 19:08           ` David Lechner
2020-10-13 19:08             ` David Lechner
2020-10-13 19:27             ` William Breathitt Gray
2020-10-13 19:27               ` William Breathitt Gray
2020-09-27  2:18 ` [PATCH v5 5/5] counter: 104-quad-8: Add IRQ support for the ACCES 104-QUAD-8 William Breathitt Gray
2020-09-27  2:18   ` William Breathitt Gray
2020-10-14  0:13   ` David Lechner
2020-10-14  0:13     ` David Lechner
2020-10-18 14:50     ` William Breathitt Gray
2020-10-18 14:50       ` William Breathitt Gray
2020-10-13  0:35 ` [PATCH v5 0/5] Introduce the Counter character device interface David Lechner
2020-10-13  0:35   ` David Lechner
2020-10-18 14:14   ` William Breathitt Gray
2020-10-18 14:14     ` 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=20201014190526.GA13439@shinobu \
    --to=vilhelm.gray@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandre.torgue@st.com \
    --cc=david@lechnology.com \
    --cc=fabrice.gasnier@st.com \
    --cc=gwendal@chromium.org \
    --cc=jic23@kernel.org \
    --cc=kamel.bouhara@bootlin.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=patrick.havelange@essensium.com \
    --cc=syednwaris@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.