linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2]  Use complete() instead of complete_all()
@ 2016-08-04 13:07 Daniel Wagner
  2016-08-04 13:07 ` [PATCH 1/2] iio: adc: " Daniel Wagner
  2016-08-04 13:07 ` [PATCH 2/2] iio: sx9500: " Daniel Wagner
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Wagner @ 2016-08-04 13:07 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

Hi,

Using complete_all() is not wrong per se but it suggest that there
might be more than one reader. For -rt I am reviewing all
complete_all() users and would like to leave only the real ones in the
tree. The main problem for -rt about complete_all() is that it can be
uses inside IRQ context and that can lead to unbounded amount work
inside the interrupt handler. That is a no no for -rt.

The patches grouped per subsystem and in small batches to allow
reviewing. Unfortanatly I am not so good in coming up with unique
commit message, so please bear with me in that regard. I could also
squash them together, although each patch containts a very short
reasoning why there is only one waiter. Let me know what you rather
prefer. One patch which updates all complete_all() users or those 2
patches with some reasoning.

It is only test compiled because I don't have the all the hardware.

cheers,
daniel

Daniel Wagner (2):
  iio: adc: Use complete() instead of complete_all()
  iio: sx9500: Use complete() instead of complete_all()

 drivers/iio/adc/nau7802.c      | 2 +-
 drivers/iio/proximity/sx9500.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] iio: adc: Use complete() instead of complete_all()
  2016-08-04 13:07 [PATCH 0/2] Use complete() instead of complete_all() Daniel Wagner
@ 2016-08-04 13:07 ` Daniel Wagner
  2016-08-15 17:02   ` Jonathan Cameron
  2016-08-04 13:07 ` [PATCH 2/2] iio: sx9500: " Daniel Wagner
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Wagner @ 2016-08-04 13:07 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

There is only one waiter for the completion, therefore there
is no need to use complete_all(). Let's make that clear by
using complete() instead of complete_all().

The usage pattern of the completion is:

waiter context                          waker context

nau7802_read_irq()
  reinit_completion()
  nau7802_read_conversion()
  wait_for_completion_interruptible_timeout()

                                        nau7802_eoc_trigger()
                                          complete()

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
 drivers/iio/adc/nau7802.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
index db9b829..08f4466 100644
--- a/drivers/iio/adc/nau7802.c
+++ b/drivers/iio/adc/nau7802.c
@@ -197,7 +197,7 @@ static irqreturn_t nau7802_eoc_trigger(int irq, void *private)
 	if (st->conversion_count < NAU7802_MIN_CONVERSIONS)
 		st->conversion_count++;
 	if (st->conversion_count >= NAU7802_MIN_CONVERSIONS)
-		complete_all(&st->value_ok);
+		complete(&st->value_ok);
 
 	return IRQ_HANDLED;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] iio: sx9500: Use complete() instead of complete_all()
  2016-08-04 13:07 [PATCH 0/2] Use complete() instead of complete_all() Daniel Wagner
  2016-08-04 13:07 ` [PATCH 1/2] iio: adc: " Daniel Wagner
@ 2016-08-04 13:07 ` Daniel Wagner
  2016-08-15 17:02   ` Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Wagner @ 2016-08-04 13:07 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, Daniel Wagner

From: Daniel Wagner <daniel.wagner@bmw-carit.de>

There is only one waiter for the completion, therefore there
is no need to use complete_all(). Let's make that clear by
using complete() instead of complete_all().

The usage pattern of the completion is:

waiter context                          waker context

sx9500_read_proximity()
  sx9500_inc_chan_users()
  sx9500_inc_data_rdy_users()
  wait_for_completion_interruptible()

                                        s9500_irq_thread_handler()
                                          complete()

  reinit_completion()

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
 drivers/iio/proximity/sx9500.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 1d74b3a..6f84f53 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -516,7 +516,7 @@ static irqreturn_t sx9500_irq_thread_handler(int irq, void *private)
 		sx9500_push_events(indio_dev);
 
 	if (val & SX9500_CONVDONE_IRQ)
-		complete_all(&data->completion);
+		complete(&data->completion);
 
 out:
 	mutex_unlock(&data->mutex);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] iio: adc: Use complete() instead of complete_all()
  2016-08-04 13:07 ` [PATCH 1/2] iio: adc: " Daniel Wagner
@ 2016-08-15 17:02   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2016-08-15 17:02 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-iio, linux-kernel, Daniel Wagner

On 04/08/16 14:07, Daniel Wagner wrote:
> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
> 
> There is only one waiter for the completion, therefore there
> is no need to use complete_all(). Let's make that clear by
> using complete() instead of complete_all().
> 
> The usage pattern of the completion is:
> 
> waiter context                          waker context
> 
> nau7802_read_irq()
>   reinit_completion()
>   nau7802_read_conversion()
>   wait_for_completion_interruptible_timeout()
> 
>                                         nau7802_eoc_trigger()
>                                           complete()
> 
> Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Applied to the togreg branch of iio.git - initially pushed
out as testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/nau7802.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c
> index db9b829..08f4466 100644
> --- a/drivers/iio/adc/nau7802.c
> +++ b/drivers/iio/adc/nau7802.c
> @@ -197,7 +197,7 @@ static irqreturn_t nau7802_eoc_trigger(int irq, void *private)
>  	if (st->conversion_count < NAU7802_MIN_CONVERSIONS)
>  		st->conversion_count++;
>  	if (st->conversion_count >= NAU7802_MIN_CONVERSIONS)
> -		complete_all(&st->value_ok);
> +		complete(&st->value_ok);
>  
>  	return IRQ_HANDLED;
>  }
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] iio: sx9500: Use complete() instead of complete_all()
  2016-08-04 13:07 ` [PATCH 2/2] iio: sx9500: " Daniel Wagner
@ 2016-08-15 17:02   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2016-08-15 17:02 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-iio, linux-kernel, Daniel Wagner

On 04/08/16 14:07, Daniel Wagner wrote:
> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
> 
> There is only one waiter for the completion, therefore there
> is no need to use complete_all(). Let's make that clear by
> using complete() instead of complete_all().
> 
> The usage pattern of the completion is:
> 
> waiter context                          waker context
> 
> sx9500_read_proximity()
>   sx9500_inc_chan_users()
>   sx9500_inc_data_rdy_users()
>   wait_for_completion_interruptible()
> 
>                                         s9500_irq_thread_handler()
>                                           complete()
> 
>   reinit_completion()
> 
> Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Applied to the togreg branch of iio.git - initially pushed
out as testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/proximity/sx9500.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index 1d74b3a..6f84f53 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -516,7 +516,7 @@ static irqreturn_t sx9500_irq_thread_handler(int irq, void *private)
>  		sx9500_push_events(indio_dev);
>  
>  	if (val & SX9500_CONVDONE_IRQ)
> -		complete_all(&data->completion);
> +		complete(&data->completion);
>  
>  out:
>  	mutex_unlock(&data->mutex);
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-15 17:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-04 13:07 [PATCH 0/2] Use complete() instead of complete_all() Daniel Wagner
2016-08-04 13:07 ` [PATCH 1/2] iio: adc: " Daniel Wagner
2016-08-15 17:02   ` Jonathan Cameron
2016-08-04 13:07 ` [PATCH 2/2] iio: sx9500: " Daniel Wagner
2016-08-15 17:02   ` Jonathan Cameron

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).