All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Breathitt Gray <vilhelm.gray@gmail.com>
To: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de,
	a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com,
	gwendal@chromium.org, alexandre.belloni@bootlin.com,
	david@lechnology.com, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	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,
	o.rempel@pengutronix.de, jarkko.nikula@linux.intel.com,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH v16 07/14] counter: Add character device interface
Date: Mon, 27 Sep 2021 20:33:00 +0900	[thread overview]
Message-ID: <YVGr7PQQThADPNSW@shinobu> (raw)
In-Reply-To: <20210927122000.00007d65@Huawei.com>

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

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@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@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@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@lechnology.com>
> > > > > > Cc: Gwendal Grignou <gwendal@chromium.org>
> > > > > > Cc: Dan Carpenter <dan.carpenter@oracle.com>
> > > > > > Cc: Oleksij Rempel <o.rempel@pengutronix.de>
> > > > > > Signed-off-by: William Breathitt Gray <vilhelm.gray@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

[-- 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: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de,
	a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com,
	gwendal@chromium.org, alexandre.belloni@bootlin.com,
	david@lechnology.com, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	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,
	o.rempel@pengutronix.de, jarkko.nikula@linux.intel.com,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH v16 07/14] counter: Add character device interface
Date: Mon, 27 Sep 2021 20:33:00 +0900	[thread overview]
Message-ID: <YVGr7PQQThADPNSW@shinobu> (raw)
In-Reply-To: <20210927122000.00007d65@Huawei.com>


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

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@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@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@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@lechnology.com>
> > > > > > Cc: Gwendal Grignou <gwendal@chromium.org>
> > > > > > Cc: Dan Carpenter <dan.carpenter@oracle.com>
> > > > > > Cc: Oleksij Rempel <o.rempel@pengutronix.de>
> > > > > > Signed-off-by: William Breathitt Gray <vilhelm.gray@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

[-- 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:[~2021-09-27 11:33 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27  3:47 [PATCH v16 00/14] Introduce the Counter character device interface William Breathitt Gray
2021-08-27  3:47 ` William Breathitt Gray
2021-08-27  3:47 ` [PATCH v16 01/14] counter: stm32-lptimer-cnt: Provide defines for clock polarities William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-08-31 13:38   ` Fabrice Gasnier
2021-08-31 13:38     ` Fabrice Gasnier
2021-09-08 17:31     ` Jonathan Cameron
2021-09-08 17:31       ` Jonathan Cameron
2021-08-27  3:47 ` [PATCH v16 02/14] counter: stm32-timer-cnt: Provide defines for slave mode selection William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-08-31 13:40   ` Fabrice Gasnier
2021-08-31 13:40     ` Fabrice Gasnier
2021-09-08 17:31     ` Jonathan Cameron
2021-09-08 17:31       ` Jonathan Cameron
2021-08-27  3:47 ` [PATCH v16 03/14] counter: Internalize sysfs interface code William Breathitt Gray
2021-08-27 14:09   ` kernel test robot
2021-08-28  4:56   ` kernel test robot
2021-08-31 13:44   ` [Linux-stm32] " Fabrice Gasnier
2021-08-31 14:16     ` William Breathitt Gray
2021-08-31 14:16       ` William Breathitt Gray
2021-08-31 14:55       ` William Breathitt Gray
2021-08-31 14:55         ` William Breathitt Gray
2021-09-08 17:44     ` Jonathan Cameron
2021-08-27  3:47 ` [PATCH v16 04/14] counter: Update counter.h comments to reflect sysfs internalization William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-09-08 17:46   ` Jonathan Cameron
2021-09-08 17:46     ` Jonathan Cameron
2021-08-27  3:47 ` [PATCH v16 05/14] docs: counter: Update " William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-09-08 17:48   ` Jonathan Cameron
2021-09-08 17:48     ` Jonathan Cameron
2021-08-27  3:47 ` [PATCH v16 06/14] counter: Move counter enums to uapi header William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-08-27  3:47 ` [PATCH v16 07/14] counter: Add character device interface William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-09-12 16:18   ` Jonathan Cameron
2021-09-12 16:18     ` Jonathan Cameron
2021-09-20 10:09     ` William Breathitt Gray
2021-09-20 10:09       ` William Breathitt Gray
2021-09-26 15:15       ` Jonathan Cameron
2021-09-26 15:15         ` Jonathan Cameron
2021-09-27 10:21         ` William Breathitt Gray
2021-09-27 10:21           ` William Breathitt Gray
2021-09-27 11:20           ` Jonathan Cameron
2021-09-27 11:20             ` Jonathan Cameron
2021-09-27 11:33             ` William Breathitt Gray [this message]
2021-09-27 11:33               ` William Breathitt Gray
2021-08-27  3:47 ` [PATCH v16 08/14] docs: counter: Document " William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-09-12 16:18   ` Jonathan Cameron
2021-09-12 16:18     ` Jonathan Cameron
2021-08-27  3:47 ` [PATCH v16 09/14] tools/counter: Create Counter tools William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-09-12 16:26   ` Jonathan Cameron
2021-09-12 16:26     ` Jonathan Cameron
2021-08-27  3:47 ` [PATCH v16 10/14] counter: Implement signalZ_action_component_id sysfs attribute William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-08-27  3:47 ` [PATCH v16 11/14] counter: Implement *_component_id sysfs attributes William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-08-27  3:47 ` [PATCH v16 12/14] counter: Implement events_queue_size sysfs attribute William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-08-27  3:47 ` [PATCH v16 13/14] counter: 104-quad-8: Replace mutex with spinlock William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-08-27  3:47 ` [PATCH v16 14/14] counter: 104-quad-8: Add IRQ support for the ACCES 104-QUAD-8 William Breathitt Gray
2021-08-27  3:47   ` William Breathitt Gray
2021-08-30 17:17 ` [PATCH v16 00/14] Introduce the Counter character device interface Jonathan Cameron
2021-08-30 17:17   ` Jonathan Cameron
2021-09-12 16:36   ` Jonathan Cameron
2021-09-12 16:36     ` Jonathan Cameron

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=YVGr7PQQThADPNSW@shinobu \
    --to=vilhelm.gray@gmail.com \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandre.torgue@st.com \
    --cc=dan.carpenter@oracle.com \
    --cc=david@lechnology.com \
    --cc=fabrice.gasnier@st.com \
    --cc=gwendal@chromium.org \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=jic23@kernel.org \
    --cc=kamel.bouhara@bootlin.com \
    --cc=kernel@pengutronix.de \
    --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=o.rempel@pengutronix.de \
    --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.