linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: David Lechner <david@lechnology.com>
To: William Breathitt Gray <vilhelm.gray@gmail.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,
	fabrice.gasnier@st.com, syednwaris@gmail.com,
	linux-stm32@st-md-mailman.stormreply.com, jic23@kernel.org
Subject: Re: [PATCH v3 3/4] counter: Add character device interface
Date: Sat, 27 Jun 2020 14:20:52 -0500	[thread overview]
Message-ID: <cc1c347a-3363-c563-de81-06dbb464a29d@lechnology.com> (raw)
In-Reply-To: <20200627181748.GA8254@shinobu>

On 6/27/20 1:17 PM, William Breathitt Gray wrote:
> On Mon, Jun 22, 2020 at 09:08:48AM -0500, David Lechner wrote:
>> On 6/21/20 2:53 PM, William Breathitt Gray wrote:
>>> For example, in the dual-axes positioning table scenario, a user
>>> application would likely want to know the exact X and Y position at the
>>> time of a given event -- that means an event should provide two Count
>>> values (and possibly associated device flags) when it occurs. I'm not
>>> sure yet how the struct counter_event should be defined in order to
>>> support this; we will need to indicate the format of data as well as
>>> provide the data itself. Perhaps, we can handle this by providing an
>>> unique id field so that only a single datum (e.g. a single count value)
>>> is provided via the value field, but subsequent struct counter_event
>>> items share the same id so that the user knows that a particular datum
>>> is part of a larger group of data for a specific event.
>>
>> The timestamp could act as the "id" to correlate multiple values of a
>> single event.
> 
> Okay, I see how that can work. So the /dev/counterX character nodes
> would return a stream of data structures that look something like this:
> 
> struct counter_event {
> 	/**
> 	 * Best approximation of when event occurred in nanoseconds.
> 	 * Same timestamp value indicates data is part of same event.
> 	 */
> 	struct timeval time;
> 	/**
> 	 * Type of event that triggered. This would correlate with the
> 	 * IRQ set up for the device.
> 	 */
> 	__u16 type;
> 	/**
> 	 * Type of data represented by the value member. This enables
> 	 * the user to extract the right datatype from the value field.
> 	 */
> 	__u16 code;
> 	/** The value recorded when the event fired. */
> 	__u64 value;
> };
> 
> In fact, this data structure looks a lot like struct input_event; would
> it make sense to use that for this? I suppose we can't because we need
> to support 64-bit value for our use cases.

Yes, since counter is its own subsystem, it makes sense to have its own
data types.

> 
> Userspace also requires a way to enable the events and configure them to
> report the data it wants. So perhaps the following sysfs attributes
> would accomplish such:
> 
> * /sys/bus/devices/counterX/eventY_enable:
>    Users can enable/disable event Y.
> * /sys/bus/devices/counterX/eventY_config:
>    Data to get when event Y is triggered (e.g. Counts, extensions, etc.).

This is one of the questions I had too that I don't have a good answer to.

If we want to allow the use case of multiple "consumers" for a single
chardev where each consumer wants different events (e.g program X opens
/dev/counter0 and wants only events A and B while program Y opens the
same /dev/counter0 and wants only events A and C) then it would make
sense to use an ioctl for configuration of events so that each open
file descriptor could be configured differently.

But if we only want to allow one user of a counter, then configuring
via sysfs as you have suggested is probably fine.

I think I might make sense to us an ioctl in any case though if we are
going to use the same code values to configure the event.

> 
> Here's another concern for latency-sensitive applications: should we
> handle writing data to the devices? While we have real-life examples of
> latency-sensitive read operations, I'm not sure if a user will ever need
> to write to a counter device within some realtime critical deadline --
> I think write operations are primarily done for the purpose of
> configuring the device for operation rather than during it. So perhaps
> we don't need to worry about this use case because users can write data
> via the existing sysfs interface.

Agreed.

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

  reply	other threads:[~2020-06-27 19:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  1:39 [PATCH v3 0/4] Introduce the Counter character device interface William Breathitt Gray
2020-06-17  1:40 ` [PATCH v3 2/4] docs: counter: Update to reflect sysfs internalization William Breathitt Gray
2020-06-17  1:40 ` [PATCH v3 3/4] counter: Add character device interface William Breathitt Gray
2020-06-20 18:50   ` David Lechner
     [not found]     ` <20200621195347.GA59797@shinobu>
     [not found]       ` <47ad15e7-05ce-d463-b6af-406365b3c3b4@lechnology.com>
2020-06-27 18:17         ` William Breathitt Gray
2020-06-27 19:20           ` David Lechner [this message]
2020-06-17  1:40 ` [PATCH v3 4/4] docs: counter: Document " 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=cc1c347a-3363-c563-de81-06dbb464a29d@lechnology.com \
    --to=david@lechnology.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandre.torgue@st.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 \
    --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).