[PATCH v16 07/14] counter: Add character device interface
William Breathitt Gray
vilhelm.gray at gmail.com
Mon Sep 27 04:33:00 PDT 2021
On Mon, Sep 27, 2021 at 12:20:00PM +0100, Jonathan Cameron wrote:
> On Mon, 27 Sep 2021 19:21:17 +0900
> William Breathitt Gray <vilhelm.gray at gmail.com> wrote:
>
> > On Sun, Sep 26, 2021 at 04:15:42PM +0100, Jonathan Cameron wrote:
> > > On Mon, 20 Sep 2021 19:09:13 +0900
> > > William Breathitt Gray <vilhelm.gray at gmail.com> wrote:
> > >
> > > > On Sun, Sep 12, 2021 at 05:18:42PM +0100, Jonathan Cameron wrote:
> > > > > On Fri, 27 Aug 2021 12:47:51 +0900
> > > > > William Breathitt Gray <vilhelm.gray at gmail.com> wrote:
> > > > >
> > > > > > This patch introduces a character device interface for the Counter
> > > > > > subsystem. Device data is exposed through standard character device read
> > > > > > operations. Device data is gathered when a Counter event is pushed by
> > > > > > the respective Counter device driver. Configuration is handled via ioctl
> > > > > > operations on the respective Counter character device node.
> > > > > >
> > > > > > Cc: David Lechner <david at lechnology.com>
> > > > > > Cc: Gwendal Grignou <gwendal at chromium.org>
> > > > > > Cc: Dan Carpenter <dan.carpenter at oracle.com>
> > > > > > Cc: Oleksij Rempel <o.rempel at pengutronix.de>
> > > > > > Signed-off-by: William Breathitt Gray <vilhelm.gray at gmail.com>
> > > > >
> > > > > Hi William,
> > > > >
> > > > > Why the bit based lock? It feels like a mutex_trylock() type approach or
> > > > > spinlock_trylock() would be a more common solution to this problem.
> > > > > There is precedence for doing what you have here though so I'm not that
> > > > > worried about it.
> > > >
> > > > Hi Jonathan,
> > > >
> > > > We originally used a mutex for this, but Jarkko discovered that this
> > > > produced a warning because chrdev_lock would be held when returning to
> > > > user space:
> > > > https://lore.kernel.org/linux-arm-kernel/YOq19zTsOzKA8v7c@shinobu/T/#m6072133d418d598a5f368bb942c945e46cfab9a5
> > > >
> > > > Following David Lechner's suggestion, I decided to reimplement
> > > > chrdev_lock as a bitmap using an atomic flag.
> > >
> > > Ok. I'm not sure bit lock was quite what was intended (as there is only one of them)
> > > but I suppose it doesn't greatly matter.
> >
> > It didn't cross my mind before, but would declaring chrdev_lock as an
> > atomic_t be a more appropriate solution here because we have only one
> > flag?
> >
> > William Breathitt Gray
> >
>
> It would be less esoteric. This was the first time I've ever come across the bitlock stuff
> whereas atomics are an every day thing.
>
> Thanks,
>
> Jonathan
I agree. I'll try that out then and reimplement this using
atomic_inc_and_test() instead of test_and_set_bit_lock().
William Breathitt Gray
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20210927/6e05b642/attachment-0001.sig>
More information about the linux-arm-kernel
mailing list